Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
amendments
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LQDN Adminsys
amendments
Commits
1dc02c07
Commit
1dc02c07
authored
Apr 04, 2011
by
Michael Witrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finition extraction
parent
8e2fbe9d
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3320 additions
and
63 deletions
+3320
-63
convert
convert
+45
-63
result.txt
result.txt
+3254
-0
template.erb
template.erb
+21
-0
No files found.
convert
View file @
1dc02c07
...
...
@@ -19,72 +19,54 @@ require 'rubygems'
require
'pp'
require
'nokogiri'
require
'unindent'
require
'erb'
sections
=
data
.
scan
(
%r(<Amend>.+?</Amend>)m
)
sections
.
each
do
|
xml
|
doc
=
Nokogiri
::
XML
(
xml
)
num
,
note
=
doc
.
css
(
'NumAm'
).
text
.
split
(
' '
,
2
)
note
.
gsub!
(
/\s/
,
''
)
if
note
color
=
case
note
.
to_s
.
gsub
(
/[^-+]/
,
''
)
when
"--"
"green"
when
"-"
"lightgreen"
when
"++"
"red"
when
"+"
"IndianRed"
when
""
"lightgrey"
else
raise
"Invalid note:
#{
note
.
inspect
}
"
end
infos
=
xml
.
scan
(
%r(Text proposed by the Commission
\n
Amendment
\n
(.+)
\n
Or.)m
).
first
raise
"No info found"
unless
infos
infos
=
infos
.
first
.
split
(
/\n/
)
template
=
ERB
.
new
File
.
read
(
'template.erb'
),
nil
,
'-'
commission_rows
=
[]
amendement_rows
=
[]
infos
.
each_slice
(
2
)
do
|
commission
,
amendement
|
commission_rows
<<
commission
amendement_rows
<<
amendement
end
commission_rows
,
amendement_rows
=
[
commission_rows
,
amendement_rows
].
map
do
|
rows
|
rows
.
delete_if
{
|
row
|
row
.
nil?
or
row
.
empty?
}
rows
.
join
(
"
\n
"
)
end
members
=
doc
.
css
(
'Members'
).
text
article
=
doc
.
css
(
'Article'
).
text
puts
<<-
TEXT
.
unindent
== Amendement
#{
num
}
==
{| border="1" style="border-spacing:0;" cellpadding="3"
|-
! colspan="2" style="background-color:
#{
color
}
;" |
Amendement
#{
num
}
<br/>
#{
article
}
<br/>
#{
members
}
<br/>
#{
note
}
|-
|
#{
commission_rows
}
||
#{
amendement_rows
}
|-
| colspan="2" |
<!-- Commentaires -->
|}
File
.
open
"result.txt"
,
"w"
do
|
f
|
sections
.
each
do
|
xml
|
doc
=
Nokogiri
::
XML
(
xml
)
TEXT
end
num
,
note
=
doc
.
css
(
'NumAm'
).
text
.
split
(
' '
,
2
)
note
.
gsub!
(
/\s/
,
''
)
if
note
color
=
case
note
.
to_s
.
gsub
(
/[^-+]/
,
''
)
when
"--"
"green"
when
"-"
"lightgreen"
when
"++"
"red"
when
"+"
"IndianRed"
when
""
"lightgrey"
else
raise
"Invalid note:
#{
note
.
inspect
}
"
end
infos
=
xml
.
scan
(
%r(Text proposed by the Commission
\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
,
amendement
|
commission_rows
<<
commission
amendement_rows
<<
amendement
end
[
commission_rows
,
amendement_rows
].
each
do
|
rows
|
rows
.
delete_if
{
|
row
|
row
.
nil?
or
row
.
empty?
}
end
members
=
doc
.
css
(
'Members'
).
text
article
=
doc
.
css
(
'Article'
).
text
f
.
puts
template
.
result
(
binding
)
end
end
result.txt
0 → 100644
View file @
1dc02c07
This diff is collapsed.
Click to expand it.
template.erb
0 → 100644
View file @
1dc02c07
== Amendement
<%=
num
%>
==
{| border="1" style="border-spacing:0;" cellpadding="3"
|-
! colspan="2" style="background-color:
<%=
color
%>
;" |
Amendement
<%=
num
%>
<br/>
<%=
article
%>
<br/>
<%=
members
%>
<br/>
<%=
note
%>
|-
|width="50%"|
<%=
commission_rows
.
join
(
"
\n\n
"
)
%>
|width="50%"|
<%=
amendement_rows
.
join
(
"
\n\n
"
)
%>
|-
| colspan="2" |
<!-- Commentaires -->
|}
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