mojibake 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,14 @@
1
- === 1.1.0 (2011-6-31)
1
+ === 1.1.1 (2013-5-28)
2
+ * Fix Ruby 2.0.0 compatibility (#3, Maciej Hitsu Kowalski)
3
+ * Drop EncodingSupport for jruby 1.7.x, as 1.7.4 continues to exhibit
4
+ Unicode conformance bugs vs MRI and Rubinius. Note that
5
+ table.json config backed recovery still works on jruby 1.7.x.
6
+ * Avoid warning by not using 'U' lang on 1.9 Regexp.new.
7
+ * Upgrade to tarpit ~> 2.0, bundler Gemfile, gemspec.
8
+ * Consolidate (j)ruby version checks to VersionSupport and mojibake.rb.
9
+ * Add Travis CI setup and add increased test findings to README.
10
+
11
+ === 1.1.0 (2011-10-30)
2
12
  * Add table.json output support as more convenient language
3
13
  independent format. Include default version (as well as table.txt)
4
14
  as part of gem.
@@ -2,6 +2,7 @@
2
2
  = MojiBake
3
3
 
4
4
  * http://github.com/dekellum/mojibake
5
+ * {<img src="https://travis-ci.org/dekellum/mojibake.png" />}[https://travis-ci.org/dekellum/mojibake]
5
6
 
6
7
  == Description
7
8
 
@@ -15,10 +16,16 @@ Windows-1252 is in the wild, should also benefit.
15
16
 
16
17
  == Dependencies
17
18
 
18
- Requires the String Encoding support in ruby 1.9 as provided by:
19
+ Mojibake mappings generation requires the String encoding support in
20
+ ruby 1.9 as provided by:
19
21
 
20
- * ruby 1.9.2+ (tested 1.9.2p180, Linux)
21
- * jruby 1.6.5+ (tested 1.6.5, Linux)
22
+ * ruby >= 1.9.2 (tested 1.9.2p290, 1.9.3p392, 2.0.0p0 Linux)
23
+ * jruby ~> 1.6.5 (tested 1.6.5, 1.6.8, Linux)
24
+ * rubinius >= 2.0.0 (tested via Travis CI)
25
+
26
+ Recovery of text with default settings is supported by using the
27
+ pre-generated table.json when in ruby 1.8 mode, or for jruby 1.7.x
28
+ (with contains bugs vs MRI ruby 1.9.x, 2.0.x behavior).
22
29
 
23
30
  == Synopsis
24
31
 
@@ -42,7 +49,7 @@ Recover from a text file:
42
49
 
43
50
  == License
44
51
 
45
- Copyright (c) 2011 David Kellum
52
+ Copyright (c) 2011-2013 David Kellum
46
53
 
47
54
  Licensed under the Apache License, Version 2.0 (the "License"); you
48
55
  may not use this file except in compliance with the License. You
data/Rakefile CHANGED
@@ -1,45 +1,16 @@
1
1
  # -*- ruby -*-
2
2
 
3
- $LOAD_PATH << './lib'
4
-
5
3
  require 'rubygems'
6
- gem 'rjack-tarpit', '~> 1.4'
4
+ require 'bundler/setup'
7
5
  require 'rjack-tarpit'
8
6
 
9
- require 'mojibake/base'
10
-
11
- t = RJack::TarPit.new( 'mojibake', MojiBake::VERSION )
12
-
13
- t.specify do |h|
14
- h.developer( 'David Kellum', 'dek-oss@gravitext.com' )
15
-
16
- h.testlib = :minitest
17
- h.extra_deps += [ [ 'json', '~> 1.6.1' ] ]
18
- h.extra_dev_deps += [ [ 'minitest', '~> 2.3' ] ]
19
-
20
- h.url = 'http://github.com/dekellum/mojibake'
21
- end
22
-
23
- # Version/date consistency checks:
24
-
25
- task :check_history_version do
26
- t.test_line_match( 'History.rdoc', /^==/, / #{ t.version } / )
27
- end
28
- task :check_history_date do
29
- t.test_line_match( 'History.rdoc', /^==/, /\([0-9\-]+\)$/ )
30
- end
31
-
32
- task :gem => [ :check_history_version ]
33
- task :tag => [ :check_history_version, :check_history_date ]
34
- task :push => [ :check_history_version, :check_history_date ]
35
-
36
- t.define_tasks
7
+ RJack::TarPit.new( 'mojibake' ).define_tasks
37
8
 
38
9
  desc "(Re-)generate config output files (requires 1.9)"
39
10
  task :generate_config do
40
- if ( RUBY_VERSION.split( '.' ).map { |d| d.to_i } <=> [ 1, 9 ] ) >= 0
41
- require 'mojibake'
42
- mapper = MojiBake::Mapper.new
11
+ require 'mojibake'
12
+ mapper = MojiBake::Mapper.new
13
+ if defined?( mapper.table )
43
14
  open( "config/table.txt", 'w' ) { |fout| fout.puts( mapper.table ) }
44
15
  open( "config/table.json", 'w' ) { |fout| fout.puts( mapper.json ) }
45
16
  else
@@ -3,7 +3,7 @@
3
3
  #.hashdot.profile += jruby-shortlived
4
4
 
5
5
  #--
6
- # Copyright (c) 2011 David Kellum
6
+ # Copyright (c) 2011-2013 David Kellum
7
7
  #
8
8
  # Licensed under the Apache License, Version 2.0 (the "License"); you
9
9
  # may not use this file except in compliance with the License. You
@@ -36,7 +36,7 @@ module Script
36
36
  exit 1
37
37
  end
38
38
 
39
- if ( RUBY_VERSION.split( '.' ).map { |d| d.to_i } <=> [ 1, 9 ] ) >= 0
39
+ if defined?( mapper.char_tree )
40
40
 
41
41
  opts.on( "--no-windows-1252",
42
42
  "Don't include miscodings from Windows-1252" ) do
@@ -1,5 +1,5 @@
1
1
  {
2
- "mojibake": "1.1.0",
2
+ "mojibake": "1.1.1",
3
3
  "url": "https://github.com/dekellum/mojibake",
4
4
  "regexp": "Â[\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ŒœŠšŸŽžƒˆ˜–—‘’‚“”„†‡•…‰‹›€™\uFFFD]|Ã[\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ŒœŠšŸŽžƒˆ˜–—‘’‚“”„†‡•…‰‹›€™\uFFFD]|Å[\u0092\u0093\u00A0¡¸½¾’“]|Æ[\u0092’]|Ë[\u0086\u009Cœ†]|â(\u0080[\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u0093\u0094\u0098\u0099\u009A\u009C\u009D\u009E\u00A0¡¢¦°¹º]|\u0081\u00A0|\u0082¬|\u0084¢|‚¬|„¢|€[\u0081\u009D\u00A0¡¢¦°¹ºœŠšžƒˆ˜‚“”„†‡…‰‹€™\uFFFD]|\uFFFD\u00A0)|ï(»¿|¿[½¾])",
5
5
  "moji": {
@@ -1,4 +1,4 @@
1
- # -*- coding: utf-8 -*- mojibake: 1.1.0
1
+ # -*- coding: utf-8 -*- mojibake: 1.1.1
2
2
  /Â[\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ŒœŠšŸŽžƒˆ˜–—‘’‚“”„†‡•…‰‹›€™\uFFFD]|Ã[\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ŒœŠšŸŽžƒˆ˜–—‘’‚“”„†‡•…‰‹›€™\uFFFD]|Å[\u0092\u0093\u00A0¡¸½¾’“]|Æ[\u0092’]|Ë[\u0086\u009Cœ†]|â(\u0080[\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u0093\u0094\u0098\u0099\u009A\u009C\u009D\u009E\u00A0¡¢¦°¹º]|\u0081\u00A0|\u0082¬|\u0084¢|‚¬|„¢|€[\u0081\u009D\u00A0¡¢¦°¹ºœŠšžƒˆ˜‚“”„†‡…‰‹€™\uFFFD]|\uFFFD\u00A0)|ï(»¿|¿[½¾])/
3
3
 
4
4
  Moji UNICODE Org CODE
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2011 David Kellum
2
+ # Copyright (c) 2011-2013 David Kellum
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you
5
5
  # may not use this file except in compliance with the License. You may
@@ -22,9 +22,13 @@ module MojiBake
22
22
 
23
23
  # Supports recovering Mojibake characters to the original text.
24
24
  class Mapper
25
+ extend VersionSupport
25
26
  include JSONSupport
26
27
 
27
- if ( RUBY_VERSION.split( '.' ).map { |d| d.to_i } <=> [ 1, 9 ] ) >= 0
28
+ if ( ruby_version_a <=> [1,9] ) >= 0 &&
29
+ ( !jruby_version_a ||
30
+ ( ( ( jruby_version_a <=> [1,6,5] ) >= 0 ) &&
31
+ ( ( jruby_version_a <=> [1,7] ) < 0 ) ) )
28
32
  require 'mojibake/encoding'
29
33
  include EncodingSupport
30
34
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2011 David Kellum
2
+ # Copyright (c) 2011-2013 David Kellum
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you
5
5
  # may not use this file except in compliance with the License. You may
@@ -15,5 +15,19 @@
15
15
  #++
16
16
 
17
17
  module MojiBake
18
- VERSION = "1.1.0"
18
+ VERSION = "1.1.1"
19
+
20
+ module VersionSupport
21
+ def ruby_version_a
22
+ ver_to_a( RUBY_VERSION )
23
+ end
24
+
25
+ def jruby_version_a
26
+ ver_to_a( JRUBY_VERSION ) if defined?( JRUBY_VERSION )
27
+ end
28
+
29
+ def ver_to_a( ver )
30
+ ver.split( '.' ).map { |d| d.to_i }
31
+ end
32
+ end
19
33
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2011 David Kellum
2
+ # Copyright (c) 2011-2013 David Kellum
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you
5
5
  # may not use this file except in compliance with the License. You may
@@ -161,7 +161,7 @@ module MojiBake
161
161
  end
162
162
 
163
163
  def regex_encode( c )
164
- i = c.codepoints.next #only one
164
+ i = c.each_codepoint.next #only one
165
165
  if INTEREST_CODEPOINTS.include?( i )
166
166
  sprintf( '\u%04X', i )
167
167
  else
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2011 David Kellum
2
+ # Copyright (c) 2011-2013 David Kellum
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you
5
5
  # may not use this file except in compliance with the License. You may
@@ -20,6 +20,7 @@ require 'json'
20
20
  module MojiBake
21
21
 
22
22
  module JSONSupport
23
+ include VersionSupport
23
24
 
24
25
  JSON_CONFIG = File.join( File.dirname( __FILE__ ),
25
26
  '..', '..', 'config', 'table.json' )
@@ -37,8 +38,13 @@ module MojiBake
37
38
  end
38
39
 
39
40
  def regexp
40
- # Note use of Unicode mode for ruby 1.8's
41
- @regexp ||= Regexp.new( config[ 'regexp' ], 0, 'U' )
41
+ @regexp ||= create_regexp
42
+ end
43
+
44
+ def create_regexp
45
+ # Use (U)nicode mode on ruby 1.8 only
46
+ lang = ( ruby_version_a <=> [1,9] ) >= 0 ? nil : 'U'
47
+ Regexp.new( config[ 'regexp' ], 0, lang )
42
48
  end
43
49
 
44
50
  # table as self contained json-ready Hash
@@ -1,10 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- coding: utf-8 -*-
3
- #.hashdot.args.pre = --1.9
4
3
  #.hashdot.profile += jruby-shortlived
5
4
 
6
5
  #--
7
- # Copyright (c) 2011 David Kellum
6
+ # Copyright (c) 2011-2013 David Kellum
8
7
  #
9
8
  # Licensed under the Apache License, Version 2.0 (the "License"); you
10
9
  # may not use this file except in compliance with the License. You
@@ -19,10 +18,9 @@
19
18
  # permissions and limitations under the License.
20
19
  #++
21
20
 
22
- ldir = File.join( File.dirname( __FILE__ ), "..", "lib" )
23
- $LOAD_PATH.unshift( ldir ) unless $LOAD_PATH.include?( ldir )
24
-
25
21
  require 'rubygems'
22
+ require 'bundler/setup'
23
+
26
24
  require 'minitest/unit'
27
25
  require 'minitest/autorun'
28
26
 
@@ -31,16 +29,14 @@ require 'mojibake'
31
29
  class TestEncoding < MiniTest::Unit::TestCase
32
30
  include MojiBake
33
31
 
34
- def setup
35
- @mapper = Mapper.new
36
- end
32
+ MAPPER = Mapper.new
37
33
 
38
34
  TEST_TREE = { "a" => { "b" => { "c" => {},
39
35
  "d" => {} } },
40
36
  "d" => { "b" => { "f" => {} } } }
41
37
 
42
38
  # These only test with Ruby 1.9 support
43
- if ( RUBY_VERSION.split( '.' ).map { |d| d.to_i } <=> [ 1, 9 ] ) >= 0
39
+ if defined?( MAPPER.char_tree )
44
40
 
45
41
  def test_init_options
46
42
  assert_equal( true, Mapper.new.map_iso_8859_1 )
@@ -50,16 +46,16 @@ class TestEncoding < MiniTest::Unit::TestCase
50
46
 
51
47
  def test_char_tree
52
48
  assert_equal( TEST_TREE,
53
- @mapper.char_tree( [ "abc", "abd", "dbf" ] ) )
49
+ MAPPER.char_tree( [ "abc", "abd", "dbf" ] ) )
54
50
  end
55
51
 
56
52
  def test_tree_flaten
57
53
  assert_equal( "ab[cd]|dbf",
58
- @mapper.tree_flatten( TEST_TREE ) )
54
+ MAPPER.tree_flatten( TEST_TREE ) )
59
55
  end
60
56
 
61
57
  def test_regexp
62
- re = Regexp.new( @mapper.tree_flatten( TEST_TREE ) )
58
+ re = Regexp.new( MAPPER.tree_flatten( TEST_TREE ) )
63
59
  assert_match( re, "abc" )
64
60
  assert_match( re, "abd" )
65
61
  assert_match( re, "dbf" )
@@ -1,10 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- coding: utf-8 -*-
3
- #.hashdot.args.pre = --1.9
4
3
  #.hashdot.profile += jruby-shortlived
5
4
 
6
5
  #--
7
- # Copyright (c) 2011 David Kellum
6
+ # Copyright (c) 2011-2013 David Kellum
8
7
  #
9
8
  # Licensed under the Apache License, Version 2.0 (the "License"); you
10
9
  # may not use this file except in compliance with the License. You
@@ -19,10 +18,9 @@
19
18
  # permissions and limitations under the License.
20
19
  #++
21
20
 
22
- ldir = File.join( File.dirname( __FILE__ ), "..", "lib" )
23
- $LOAD_PATH.unshift( ldir ) unless $LOAD_PATH.include?( ldir )
24
-
25
21
  require 'rubygems'
22
+ require 'bundler/setup'
23
+
26
24
  require 'minitest/unit'
27
25
  require 'minitest/autorun'
28
26
 
metadata CHANGED
@@ -1,68 +1,80 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mojibake
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.1.0
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.1.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - David Kellum
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-10-31 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2013-05-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: json
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ! '>='
19
+ - !ruby/object:Gem::Version
20
+ version: 1.7.5
21
+ - - <
22
+ - !ruby/object:Gem::Version
23
+ version: '1.9'
19
24
  none: false
20
- requirements:
21
- - - ~>
22
- - !ruby/object:Gem::Version
23
- version: 1.6.1
25
+ requirement: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.7.5
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: '1.9'
33
+ none: false
34
+ prerelease: false
24
35
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
36
+ - !ruby/object:Gem::Dependency
27
37
  name: minitest
28
- prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ version: '3.2'
30
43
  none: false
31
- requirements:
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
32
46
  - - ~>
33
- - !ruby/object:Gem::Version
34
- version: "2.3"
47
+ - !ruby/object:Gem::Version
48
+ version: '3.2'
49
+ none: false
50
+ prerelease: false
35
51
  type: :development
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
52
+ - !ruby/object:Gem::Dependency
38
53
  name: rjack-tarpit
39
- prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
54
+ version_requirements: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ version: '2.0'
41
59
  none: false
42
- requirements:
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
43
62
  - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 1.4.0
63
+ - !ruby/object:Gem::Version
64
+ version: '2.0'
65
+ none: false
66
+ prerelease: false
46
67
  type: :development
47
- version_requirements: *id003
48
- description: "Mojibake occurs in English most frequently due to misinterpreting and\n\
49
- bad-transcoding between Windows-1252, ISO-8859-1, and UTF-8. This\n\
50
- module provides a mojibake sequence to original character mapping\n\
51
- table, and utility to recover mojibake\xE2\x80\x99d text.\n\n\
52
- Testing has been with English but other Latin based languages, where\n\
53
- Windows-1252 is in the wild, should also benefit."
54
- email:
68
+ description: Mojibake occurs in English most frequently due to misinterpreting and bad-transcoding between Windows-1252, ISO-8859-1, and UTF-8. This module provides a mojibake sequence to original character mapping table, and utility to recover mojibake’d text.
69
+ email:
55
70
  - dek-oss@gravitext.com
56
- executables:
71
+ executables:
57
72
  - mojibake
58
73
  extensions: []
59
-
60
- extra_rdoc_files:
61
- - Manifest.txt
62
- - config/table.txt
74
+ extra_rdoc_files:
63
75
  - History.rdoc
64
76
  - README.rdoc
65
- files:
77
+ files:
66
78
  - History.rdoc
67
79
  - Manifest.txt
68
80
  - README.rdoc
@@ -77,35 +89,37 @@ files:
77
89
  - test/test.txt
78
90
  - test/test_encoding.rb
79
91
  - test/test_mapper.rb
80
- - .gemtest
81
92
  homepage: http://github.com/dekellum/mojibake
82
93
  licenses: []
83
-
84
- post_install_message:
85
- rdoc_options:
94
+ post_install_message:
95
+ rdoc_options:
86
96
  - --main
87
97
  - README.rdoc
88
- require_paths:
98
+ require_paths:
89
99
  - lib
90
- required_ruby_version: !ruby/object:Gem::Requirement
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ segments:
106
+ - 0
107
+ hash: 2
91
108
  none: false
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: "0"
96
- required_rubygems_version: !ruby/object:Gem::Requirement
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ segments:
115
+ - 0
116
+ hash: 2
97
117
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- version: "0"
102
118
  requirements: []
103
-
104
- rubyforge_project: mojibake
105
- rubygems_version: 1.8.11
106
- signing_key:
119
+ rubyforge_project:
120
+ rubygems_version: 1.8.24
121
+ signing_key:
107
122
  specification_version: 3
108
- summary: Mojibake occurs in English most frequently due to misinterpreting and bad-transcoding between Windows-1252, ISO-8859-1, and UTF-8
109
- test_files:
110
- - test/test_encoding.rb
111
- - test/test_mapper.rb
123
+ summary: Mojibake occurs in English most frequently due to misinterpreting and bad-transcoding between Windows-1252, ISO-8859-1, and UTF-8.
124
+ test_files: []
125
+ ...
data/.gemtest DELETED
File without changes