cmess 0.0.9.276 → 0.1.0.281

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,5 +1,9 @@
1
1
  = Revision history for cmess
2
2
 
3
+ == 0.1.0 [2008-09-15]
4
+
5
+ * Added ability to operate on all encodings available on a system
6
+
3
7
  == 0.0.9 [2008-08-15]
4
8
 
5
9
  * Reorganized file structure for guess_encoding
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to cmess version 0.0.9
5
+ This documentation refers to cmess version 0.1.0
6
6
 
7
7
 
8
8
  == DESCRIPTION
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(SPLIT_ENCODING_LIST_RE)
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!
@@ -39,7 +39,7 @@ require 'cmess'
39
39
  module CMess::GuessEncoding
40
40
 
41
41
  # our version ;-)
42
- VERSION = '0.0.7'
42
+ VERSION = '0.0.8'
43
43
 
44
44
  class << self
45
45
 
@@ -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.reverse.uniq.reverse # uniq with additional encodings
83
- # staying at the end
84
- encodings = [target] + (encodings - [target]) # move target encoding to front
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
@@ -29,8 +29,8 @@
29
29
  module CMess::Version
30
30
 
31
31
  MAJOR = 0
32
- MINOR = 0
33
- TINY = 9
32
+ MINOR = 1
33
+ TINY = 0
34
34
 
35
35
  class << self
36
36
 
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.9.276
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-08-15 00:00:00 +02:00
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