Commit 94a6ab18 authored by Michael Witrant's avatar Michael Witrant

essai differ

parent f4a81181
Amendment <NumAm>1</NumAm>
<Amend>Amendment <NumAm>1</NumAm>
<DocAmend>Proposal for a decision</DocAmend>
<Article>Recital 4</Article>
......
#!/usr/bin/env ruby
# Pour lancer le script il faut ruby, rubygems et la gem nokogiri
# Pour lancer le script il faut ruby, rubygems et les gems nokogiri et differ
require 'rubygems'
require 'nokogiri'
require 'differ'
require 'erb'
data = %w(3 1 2).map { |i| File.read("Amdts_spectre_#{i}.txt") }.join
......@@ -11,7 +12,7 @@ sections = data.scan(%r(<Amend>.+?</Amend>)m)
Amendment = Struct.new :num, :note, :color, :commission_rows, :amendement_rows, :members, :article
Differ.format = :html
class Amendment
Template = ERB.new File.read('template.erb'), nil, '-'
......@@ -19,6 +20,10 @@ class Amendment
def format
Template.result(binding)
end
def rows
[commission_rows.size, amendement_rows.size].max
end
end
amendments = sections.map do |xml|
......@@ -51,13 +56,12 @@ amendments = sections.map do |xml|
commission_rows = []
amendement_rows = []
infos.each_slice(2) do |commission, amendement|
commission_rows << commission
amendement_rows << amendement
end
[commission_rows, amendement_rows].each do |rows|
rows.delete_if { |row| row.nil? or row.empty? }
infos.each_slice(2) do |commission, amendment|
commission = commission.to_s
amendment = amendment.to_s
#p [commission, amendment, Differ.diff_by_char(amendment, commission).to_s]
commission_rows << Differ.diff_by_char(commission, amendment).to_s
amendement_rows << Differ.diff_by_char(amendment, commission).to_s
end
members = doc.css('Members').text
......
This diff is collapsed.
......@@ -9,11 +9,13 @@ Amendement <%= num %>
<%= members %>
<br/>
<%= note %>
<% rows.times do |row| -%>
|-
|width="50%"|
<%= commission_rows.join("\n\n") %>
<%= commission_rows[row] %>
|width="50%"|
<%= amendement_rows.join("\n\n") %>
<%= amendement_rows[row] %>
<% end -%>
|-
| colspan="2" |
Comments:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment