onix 0.7.6 → 0.7.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/lib/onix.rb +1 -1
- data/lib/onix/normaliser.rb +14 -8
- metadata +2 -2
data/CHANGELOG
CHANGED
data/lib/onix.rb
CHANGED
data/lib/onix/normaliser.rb
CHANGED
@@ -71,12 +71,14 @@ module ONIX
|
|
71
71
|
@curfile = dest
|
72
72
|
|
73
73
|
# remove entities
|
74
|
-
|
74
|
+
dest = next_tempfile
|
75
|
+
replace_named_entities(@curfile, dest)
|
76
|
+
@curfile = dest
|
75
77
|
|
76
78
|
FileUtils.cp(@curfile, @newfile)
|
77
79
|
end
|
78
80
|
|
79
|
-
private
|
81
|
+
#private
|
80
82
|
|
81
83
|
# check the specified app is available on the system
|
82
84
|
#
|
@@ -133,7 +135,7 @@ module ONIX
|
|
133
135
|
FileUtils.cp(inpath, outpath)
|
134
136
|
else
|
135
137
|
FileUtils.cp(inpath, outpath)
|
136
|
-
`sed -i 's/<?xml.*?>/<?xml version=\"1.0\" encoding=\"UTF-8\"?>/' #{outpath}`
|
138
|
+
`sed -i 's/<?xml.*?>/<?xml version=\"1.0\" encoding=\"UTF-8\"?>/g' #{outpath}`
|
137
139
|
end
|
138
140
|
elsif src_enc
|
139
141
|
`iconv --from-code=#{src_enc} --to-code=UTF-8 #{inpath} > #{outpath}`
|
@@ -154,11 +156,15 @@ module ONIX
|
|
154
156
|
# replace all named entities in the specified file with
|
155
157
|
# numeric entities.
|
156
158
|
#
|
157
|
-
def replace_named_entities(
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
159
|
+
def replace_named_entities(src, dest)
|
160
|
+
inpath = File.expand_path(src)
|
161
|
+
outpath = File.expand_path(dest)
|
162
|
+
|
163
|
+
cmd = "sed " + entity_map.map do |named, numeric|
|
164
|
+
"-e 's/\\&#{named};/\\&#{numeric};/g'"
|
165
|
+
end.join(" ") + " #{inpath} > #{outpath}"
|
166
|
+
#raise cmd
|
167
|
+
`#{cmd}`
|
162
168
|
end
|
163
169
|
|
164
170
|
# return a named entity to numeric entity mapping, build by extracting
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Healy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-01 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|