Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LQDN Adminsys
amendments
Commits
94a6ab18
Commit
94a6ab18
authored
Apr 05, 2011
by
Michael Witrant
Browse files
essai differ
parent
f4a81181
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Amdts_spectre_3.txt
View file @
94a6ab18
Amendment <NumAm>1</NumAm>
<Amend>
Amendment <NumAm>1</NumAm>
<DocAmend>Proposal for a decision</DocAmend>
<Article>Recital 4</Article>
...
...
convert
View file @
94a6ab18
#!/usr/bin/env ruby
# Pour lancer le script il faut ruby, rubygems et l
a
gem nokogiri
# Pour lancer le script il faut ruby, rubygems et l
es
gem
s
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
...
...
result.mediawiki
View file @
94a6ab18
This diff is collapsed.
Click to expand it.
template.erb
View file @
94a6ab18
...
...
@@ -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:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment