cmess 0.0.9.276 → 0.1.0.281
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +4 -0
- data/README +1 -1
- data/bin/guess_encoding +11 -1
- data/lib/cmess/guess_encoding.rb +1 -1
- data/lib/cmess/guess_encoding/encoding.rb +18 -1
- data/lib/cmess/guess_encoding/manual.rb +6 -3
- data/lib/cmess/version.rb +2 -2
- metadata +8 -8
data/ChangeLog
CHANGED
data/README
CHANGED
data/bin/guess_encoding
CHANGED
|
@@ -111,7 +111,7 @@ OptionParser.new(nil, 40) { |opts|
|
|
|
111
111
|
|
|
112
112
|
opts.on('-e', '--encodings ENCODINGS...', "List of encodings to try >instead of< default (see below)") { |e|
|
|
113
113
|
options[:encodings] ||= []
|
|
114
|
-
options[:encodings] += e.split(
|
|
114
|
+
options[:encodings] += e.split(SPLIT_ARG_LIST_RE)
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
opts.on('-a', '--additional-encodings ENCODINGS...', "List of encodings to try >in addition to< default (see below)") { |e|
|
|
@@ -124,6 +124,13 @@ OptionParser.new(nil, 40) { |opts|
|
|
|
124
124
|
options[:target_encoding] = e
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
opts.separator ''
|
|
128
|
+
|
|
129
|
+
opts.on('--list-encodings', 'Print a list of all available encodings on your system and exit') {
|
|
130
|
+
puts CGE::Encoding.all_encodings
|
|
131
|
+
exit
|
|
132
|
+
}
|
|
133
|
+
|
|
127
134
|
opts.separator ''
|
|
128
135
|
opts.separator ' * Charcodes'
|
|
129
136
|
opts.separator ''
|
|
@@ -179,6 +186,9 @@ OptionParser.new(nil, 40) { |opts|
|
|
|
179
186
|
opts.separator l
|
|
180
187
|
}
|
|
181
188
|
|
|
189
|
+
opts.separator ''
|
|
190
|
+
opts.separator 'NOTE: To select all encodings available on your system, specify __ALL__.'
|
|
191
|
+
|
|
182
192
|
opts.separator ''
|
|
183
193
|
opts.separator "When FILE is -, STDIN is used."
|
|
184
194
|
}.parse!
|
data/lib/cmess/guess_encoding.rb
CHANGED
|
@@ -36,8 +36,21 @@ module CMess::GuessEncoding::Encoding
|
|
|
36
36
|
|
|
37
37
|
extend self
|
|
38
38
|
|
|
39
|
+
def all_encodings
|
|
40
|
+
const_defined?(:ALL_ENCODINGS) ? ALL_ENCODINGS :
|
|
41
|
+
const_set(:ALL_ENCODINGS, get_all_encodings)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def get_all_encodings
|
|
47
|
+
%x{iconv -l}.split("\n").map { |e|
|
|
48
|
+
get_or_set_encoding_const(e.sub(/\/*\z/, ''))
|
|
49
|
+
}
|
|
50
|
+
end
|
|
51
|
+
|
|
39
52
|
def const_name_for(encoding)
|
|
40
|
-
encoding.tr('-', '_').gsub(/\W/, '').upcase
|
|
53
|
+
encoding.tr('-', '_').gsub(/\W/, '').sub(/\A\d/, 'ENC_\&').upcase
|
|
41
54
|
end
|
|
42
55
|
|
|
43
56
|
def set_encoding_const(encoding, const = const_name_for(encoding))
|
|
@@ -58,4 +71,8 @@ module CMess::GuessEncoding::Encoding
|
|
|
58
71
|
ANSI_X3.4 EBCDIC-AT-DE EBCDIC-US EUC-JP KOI-8 MS-ANSI SHIFT-JIS
|
|
59
72
|
].each { |encoding| set_encoding_const(encoding) }
|
|
60
73
|
|
|
74
|
+
def included(base)
|
|
75
|
+
base.extend self
|
|
76
|
+
end
|
|
77
|
+
|
|
61
78
|
end
|
|
@@ -79,9 +79,12 @@ module CMess::GuessEncoding::Manual
|
|
|
79
79
|
target = target_encoding
|
|
80
80
|
|
|
81
81
|
encodings = (encodings || ENCODINGS) + additional_encodings
|
|
82
|
-
encodings = encodings.
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
encodings = encodings.include?('__ALL__') ? all_encodings :
|
|
83
|
+
encodings.reverse.uniq.reverse # uniq with additional encodings
|
|
84
|
+
# staying at the end
|
|
85
|
+
|
|
86
|
+
# move target encoding to front
|
|
87
|
+
encodings = [target] + (encodings - [target])
|
|
85
88
|
|
|
86
89
|
max_length = encodings.map { |encoding| encoding.length }.max
|
|
87
90
|
|
data/lib/cmess/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cmess
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.1.0.281
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jens Wille
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2008-
|
|
12
|
+
date: 2008-09-15 00:00:00 +02:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -98,15 +98,15 @@ has_rdoc: true
|
|
|
98
98
|
homepage: http://prometheus.rubyforge.org/cmess
|
|
99
99
|
post_install_message:
|
|
100
100
|
rdoc_options:
|
|
101
|
-
- --line-numbers
|
|
102
|
-
- --main
|
|
103
|
-
- README
|
|
104
101
|
- --inline-source
|
|
105
|
-
- --all
|
|
106
|
-
- --charset
|
|
107
|
-
- UTF-8
|
|
108
102
|
- --title
|
|
109
103
|
- cmess Application documentation
|
|
104
|
+
- --charset
|
|
105
|
+
- UTF-8
|
|
106
|
+
- --main
|
|
107
|
+
- README
|
|
108
|
+
- --all
|
|
109
|
+
- --line-numbers
|
|
110
110
|
require_paths:
|
|
111
111
|
- lib
|
|
112
112
|
required_ruby_version: !ruby/object:Gem::Requirement
|