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
56d6eebf
Commit
56d6eebf
authored
Mar 27, 2013
by
Michael Witrant
Browse files
commited old files
parent
3fe64c78
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
LQDN_20120503_amendments_ITRE_ACTA_report/Gemfile
0 → 100644
View file @
56d6eebf
source
"http://rubygems.org"
gem
"nokogiri"
gem
'htmldiff'
LQDN_20120503_amendments_ITRE_ACTA_report/Gemfile.lock
0 → 100644
View file @
56d6eebf
GEM
remote: http://rubygems.org/
specs:
htmldiff (0.0.1)
nokogiri (1.5.2)
PLATFORMS
ruby
DEPENDENCIES
htmldiff
nokogiri
LQDN_20120503_amendments_ITRE_ACTA_report/LQDN_20120503_amendments_ITRE_ACTA_report.html
0 → 100644
View file @
56d6eebf
This diff is collapsed.
Click to expand it.
LQDN_20120503_amendments_ITRE_ACTA_report/LQDN_20120503_amendments_ITRE_ACTA_report.rtf
0 → 100644
View file @
56d6eebf
This diff is collapsed.
Click to expand it.
LQDN_20120503_amendments_ITRE_ACTA_report/LQDN_20120503_amendments_ITRE_ACTA_report.txt
0 → 100644
View file @
56d6eebf
This diff is collapsed.
Click to expand it.
LQDN_20120503_amendments_ITRE_ACTA_report/LQDN_20120503_amendments_ITRE_ACTA_report.xml
0 → 100644
View file @
56d6eebf
This diff is collapsed.
Click to expand it.
LQDN_20120503_amendments_ITRE_ACTA_report/convert
0 → 100755
View file @
56d6eebf
#!/usr/bin/env ruby
# encoding: utf-8
# Pour lancer le script il faut ruby, rubygems et les gems nokogiri et htmldiff
require
'rubygems'
require
"bundler/setup"
require
'nokogiri'
require
'htmldiff'
require
'erb'
data
=
File
.
read
(
"LQDN_20120503_amendments_ITRE_ACTA_report.txt"
)
sections
=
data
.
scan
(
%r(<Amend>.+?</Amend>)m
)
Amendment
=
Struct
.
new
:num
,
:note
,
:color
,
:commission_rows
,
:amendement_rows
,
:members
,
:article
include
HTMLDiff
class
Amendment
Template
=
ERB
.
new
File
.
read
(
'template.erb'
),
nil
,
'-'
def
format
Template
.
result
(
binding
)
end
def
rows
[
commission_rows
.
size
,
amendement_rows
.
size
].
max
end
end
amendments
=
sections
.
map
do
|
xml
|
doc
=
Nokogiri
::
XML
(
xml
)
num
,
note
=
doc
.
css
(
'NumAm'
).
text
.
split
(
' '
,
2
)
num
=
num
.
to_i
note
.
gsub!
(
/\s/
,
''
)
if
note
color
=
case
note
.
to_s
.
gsub
(
/[^-+]/
,
''
)
when
"--"
"red"
when
"-"
"IndianRed"
when
"++"
,
"+++"
"green"
when
"+"
"lightgreen"
when
""
"lightgrey"
else
raise
"Invalid note:
#{
note
.
inspect
}
"
end
infos
=
xml
.
scan
(
%r(Proposal for a decision
\n
Amendment
\n
(.+)
\n
Or.)m
).
first
raise
"No info found"
unless
infos
infos
=
infos
.
first
.
split
(
/\n/
)
commission_rows
=
[]
amendement_rows
=
[]
infos
.
each_slice
(
2
)
do
|
commission
,
amendment
|
commission
=
commission
.
to_s
amendment
=
amendment
.
to_s
commission_rows
<<
diff
(
commission
,
amendment
).
to_s
.
gsub
(
%r(<ins class=".+?">.+?</ins>)
,
""
).
gsub
(
%r(<del class=".+?">(.+?)</del>)
,
"'''
\\
1'''"
)
amendement_rows
<<
diff
(
commission
,
amendment
).
to_s
.
gsub
(
%r(<del class=".+?">.+?</del>)
,
""
).
gsub
(
%r(<ins class=".+?">(.+?)</ins>)
,
"'''
\\
1'''"
)
end
members
=
doc
.
css
(
'Members'
).
text
article
=
doc
.
css
(
'Article'
).
text
Amendment
.
new
num
,
note
,
color
,
commission_rows
,
amendement_rows
,
members
,
article
end
File
.
open
"result.mediawiki"
,
"w"
do
|
f
|
grouped
=
amendments
.
group_by
{
|
am
|
(
am
.
num
-
1
)
/
10
}
grouped
.
keys
.
sort
.
each
do
|
index
|
ams
=
grouped
[
index
].
sort_by
{
|
am
|
am
.
num
}
first
=
ams
.
first
.
num
last
=
ams
.
last
.
num
f
.
puts
"== Amendments
#{
first
}
–
#{
last
}
=="
ams
.
each
do
|
am
|
f
.
puts
am
.
format
end
f
.
puts
end
end
LQDN_20120503_amendments_ITRE_ACTA_report/result.mediawiki
0 → 100644
View file @
56d6eebf
This diff is collapsed.
Click to expand it.
LQDN_20120503_amendments_ITRE_ACTA_report/template.erb
0 → 100644
View file @
56d6eebf
=== Amendment
<%=
num
%><%=
" "
+
note
if
note
%>
===
{| border="1" style="border-spacing:0;" cellpadding="3"
|-
! colspan="2" style="background-color:
<%=
color
%>
;" |
Amendement
<%=
num
%>
<br/>
<%=
article
%>
<br/>
<%=
members
%>
<br/>
<%=
note
%>
<%
rows
.
times
do
|
row
|
-%>
|-
|width="50%"|
<%=
commission_rows
[
row
]
%>
|width="50%"|
<%=
amendement_rows
[
row
]
%>
<%
end
-%>
|-
| colspan="2" |
Comments:
|}
Write
Preview
Supports
Markdown
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