cmess 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README +2 -2
- data/bin/decode_entities +10 -7
- data/lib/cmess/decode_entities.rb +11 -3
- data/lib/cmess/version.rb +1 -1
- metadata +18 -9
data/README
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
== VERSION
|
4
4
|
|
5
|
-
This documentation refers to cmess version 0.2.
|
5
|
+
This documentation refers to cmess version 0.2.4
|
6
6
|
|
7
7
|
|
8
8
|
== DESCRIPTION
|
@@ -47,7 +47,7 @@ Rubyforge project:: <http://rubyforge.org/projects/prometheus>
|
|
47
47
|
|
48
48
|
== LICENSE AND COPYRIGHT
|
49
49
|
|
50
|
-
Copyright (C) 2007-
|
50
|
+
Copyright (C) 2007-2010 University of Cologne,
|
51
51
|
Albertus-Magnus-Platz, 50923 Cologne, Germany
|
52
52
|
|
53
53
|
cmess is free software: you can redistribute it and/or modify it under the
|
data/bin/decode_entities
CHANGED
@@ -44,7 +44,8 @@ options = {
|
|
44
44
|
:input => STDIN,
|
45
45
|
:output => STDOUT,
|
46
46
|
:source_encoding => CMess::DecodeEntities::INTERMEDIATE_ENCODING,
|
47
|
-
:target_encoding => nil
|
47
|
+
:target_encoding => nil,
|
48
|
+
:flavour => CMess::DecodeEntities::DEFAULT_FLAVOUR
|
48
49
|
}
|
49
50
|
|
50
51
|
OptionParser.new { |opts|
|
@@ -77,6 +78,13 @@ OptionParser.new { |opts|
|
|
77
78
|
options[:target_encoding] = e.downcase
|
78
79
|
}
|
79
80
|
|
81
|
+
opts.separator ''
|
82
|
+
|
83
|
+
opts.on('-f', '--flavour FLAVOUR', "Flavour to use for the HTMLEntities decoder [Default: #{options[:flavour]}]",
|
84
|
+
"(Available flavours are: #{HTMLEntities::FLAVORS.join(', ')})") { |f|
|
85
|
+
options[:flavour] = f
|
86
|
+
}
|
87
|
+
|
80
88
|
opts.separator ''
|
81
89
|
opts.separator 'Generic options:'
|
82
90
|
|
@@ -97,10 +105,5 @@ OptionParser.new { |opts|
|
|
97
105
|
cli do
|
98
106
|
trailing_args_as_input(options)
|
99
107
|
|
100
|
-
CMess::DecodeEntities.decode(
|
101
|
-
options[:input],
|
102
|
-
options[:output],
|
103
|
-
options[:source_encoding],
|
104
|
-
options[:target_encoding]
|
105
|
-
)
|
108
|
+
CMess::DecodeEntities.decode(*options.values_at(:input, :output, :source_encoding, :target_encoding, :flavour))
|
106
109
|
end
|
@@ -37,7 +37,7 @@ module CMess
|
|
37
37
|
extend self
|
38
38
|
|
39
39
|
# our version ;-)
|
40
|
-
VERSION = '0.0.
|
40
|
+
VERSION = '0.0.4'
|
41
41
|
|
42
42
|
# HTMLEntities requires UTF-8
|
43
43
|
INTERMEDIATE_ENCODING = 'utf-8'
|
@@ -52,7 +52,9 @@ module CMess
|
|
52
52
|
dummy
|
53
53
|
end
|
54
54
|
|
55
|
-
|
55
|
+
DEFAULT_FLAVOUR = 'xml-safe'
|
56
|
+
|
57
|
+
def decode(input, output, source_encoding, target_encoding = nil, flavour = nil)
|
56
58
|
target_encoding ||= source_encoding
|
57
59
|
|
58
60
|
iconv_in = source_encoding != INTERMEDIATE_ENCODING ?
|
@@ -61,7 +63,7 @@ module CMess
|
|
61
63
|
iconv_out = target_encoding != INTERMEDIATE_ENCODING ?
|
62
64
|
Iconv.new(target_encoding, INTERMEDIATE_ENCODING) : ICONV_DUMMY
|
63
65
|
|
64
|
-
html_entities = HTMLEntities.new
|
66
|
+
html_entities = HTMLEntities.new(flavour || DEFAULT_FLAVOUR)
|
65
67
|
|
66
68
|
input.each { |line|
|
67
69
|
output.puts iconv_out.iconv(html_entities.decode(iconv_in.iconv(line)))
|
@@ -70,3 +72,9 @@ module CMess
|
|
70
72
|
|
71
73
|
end
|
72
74
|
end
|
75
|
+
|
76
|
+
class HTMLEntities
|
77
|
+
FLAVORS << 'xml-safe'
|
78
|
+
MAPPINGS['xml-safe'] = MAPPINGS['xhtml1'].dup
|
79
|
+
%w[amp apos gt lt quot].each { |key| MAPPINGS['xml-safe'].delete(key) }
|
80
|
+
end
|
data/lib/cmess/version.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmess
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
9
|
+
- 4
|
10
|
+
version: 0.2.4
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Jens Wille
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-07-13 00:00:00 +02:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: ruby-nuggets
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 21
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
- 3
|
@@ -35,9 +38,11 @@ dependencies:
|
|
35
38
|
name: htmlentities
|
36
39
|
prerelease: false
|
37
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
38
42
|
requirements:
|
39
43
|
- - ">="
|
40
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
41
46
|
segments:
|
42
47
|
- 0
|
43
48
|
version: "0"
|
@@ -111,35 +116,39 @@ licenses: []
|
|
111
116
|
|
112
117
|
post_install_message:
|
113
118
|
rdoc_options:
|
114
|
-
- --
|
115
|
-
-
|
119
|
+
- --title
|
120
|
+
- cmess Application documentation
|
116
121
|
- --main
|
117
122
|
- README
|
123
|
+
- --line-numbers
|
124
|
+
- --inline-source
|
125
|
+
- --all
|
118
126
|
- --charset
|
119
127
|
- UTF-8
|
120
|
-
- --title
|
121
|
-
- cmess Application documentation
|
122
|
-
- --all
|
123
128
|
require_paths:
|
124
129
|
- lib
|
125
130
|
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
126
132
|
requirements:
|
127
133
|
- - ">="
|
128
134
|
- !ruby/object:Gem::Version
|
135
|
+
hash: 3
|
129
136
|
segments:
|
130
137
|
- 0
|
131
138
|
version: "0"
|
132
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
133
141
|
requirements:
|
134
142
|
- - ">="
|
135
143
|
- !ruby/object:Gem::Version
|
144
|
+
hash: 3
|
136
145
|
segments:
|
137
146
|
- 0
|
138
147
|
version: "0"
|
139
148
|
requirements: []
|
140
149
|
|
141
150
|
rubyforge_project: prometheus
|
142
|
-
rubygems_version: 1.3.
|
151
|
+
rubygems_version: 1.3.7
|
143
152
|
signing_key:
|
144
153
|
specification_version: 3
|
145
154
|
summary: "Assist with handling messed up encodings (Currently includes the following tools: bconv, cinderella, decode_entities, guess_encoding)"
|