charlock_holmes-jruby 0.1.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +4 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +29 -0
- data/LICENSE +20 -0
- data/README.md +65 -0
- data/Rakefile +17 -0
- data/charlock_holmes-jruby.gemspec +25 -0
- data/lib/charlock_holmes-jruby.rb +1 -0
- data/lib/charlock_holmes.rb +5 -0
- data/lib/charlock_holmes/charset_match_ext.rb +17 -0
- data/lib/charlock_holmes/converter.rb +12 -0
- data/lib/charlock_holmes/encoding_detector.rb +54 -0
- data/lib/charlock_holmes/string.rb +21 -0
- data/lib/charlock_holmes/version.rb +5 -0
- data/lib/charlock_holmes_jruby.rb +1 -0
- data/spec/converter_spec.rb +57 -0
- data/spec/encoding_detector_spec.rb +97 -0
- data/spec/fixtures/AnsiGraph.psm1 +0 -0
- data/spec/fixtures/TwigExtensionsDate.es.yml +8 -0
- data/spec/fixtures/cl-messagepack.lisp +264 -0
- data/spec/fixtures/core.rkt +254 -0
- data/spec/fixtures/laholator.py +131 -0
- data/spec/fixtures/mingpao.html +455 -0
- data/spec/fixtures/repl2.cljs +109 -0
- data/spec/fixtures/shift_jis.html +1244 -0
- data/spec/spec_helpers.rb +1 -0
- data/spec/string_spec.rb +39 -0
- metadata +144 -0
@@ -0,0 +1 @@
|
|
1
|
+
$LOAD_PATH << "lib"
|
data/spec/string_spec.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helpers'
|
4
|
+
require 'charlock_holmes/string'
|
5
|
+
|
6
|
+
describe CharlockHolmes::StringExt do
|
7
|
+
describe "#detect_encoding" do
|
8
|
+
it "should detect encoding of string" do
|
9
|
+
detected = "hello".detect_encoding
|
10
|
+
detected[:encoding].should == 'ISO-8859-1'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should accept encoding hint" do
|
14
|
+
detected = 'hello'.detect_encoding 'UTF-8'
|
15
|
+
detected[:encoding].should == 'ISO-8859-1'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#detect_encodings" do
|
20
|
+
it "should detect encoding of string" do
|
21
|
+
detected_list = "test".detect_encodings
|
22
|
+
encoding_list = detected_list.map {|d| d[:encoding] }.sort
|
23
|
+
encoding_list.should == ['ISO-8859-1', 'ISO-8859-2', 'UTF-8']
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should accept encoding hint" do
|
27
|
+
detected_list = 'test'.detect_encodings 'UTF-8'
|
28
|
+
encoding_list = detected_list.map {|d| d[:encoding] }.sort
|
29
|
+
encoding_list.should == ['ISO-8859-1', 'ISO-8859-2', 'UTF-8']
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#detect_encoding" do
|
34
|
+
it "should change encoding of string" do
|
35
|
+
str = "hello".detect_encoding!
|
36
|
+
str.encoding.to_s.should == 'ISO-8859-1'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: charlock_holmes-jruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: java
|
7
|
+
authors:
|
8
|
+
- Francis Chong
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake-compiler
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.7.5
|
21
|
+
none: false
|
22
|
+
requirement: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.7.5
|
27
|
+
none: false
|
28
|
+
prerelease: false
|
29
|
+
type: :development
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: !binary |-
|
37
|
+
MA==
|
38
|
+
none: false
|
39
|
+
requirement: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: !binary |-
|
44
|
+
MA==
|
45
|
+
none: false
|
46
|
+
prerelease: false
|
47
|
+
type: :development
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rake
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: !binary |-
|
55
|
+
MA==
|
56
|
+
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: !binary |-
|
62
|
+
MA==
|
63
|
+
none: false
|
64
|
+
prerelease: false
|
65
|
+
type: :development
|
66
|
+
description: JRuby compatible ICU encoding detection build on top of ICU4J.
|
67
|
+
email: francis@ignition.hk
|
68
|
+
executables: []
|
69
|
+
extensions: []
|
70
|
+
extra_rdoc_files: []
|
71
|
+
files:
|
72
|
+
- ".rspec"
|
73
|
+
- Gemfile
|
74
|
+
- Gemfile.lock
|
75
|
+
- LICENSE
|
76
|
+
- README.md
|
77
|
+
- Rakefile
|
78
|
+
- charlock_holmes-jruby.gemspec
|
79
|
+
- lib/charlock_holmes-jruby.rb
|
80
|
+
- lib/charlock_holmes.rb
|
81
|
+
- lib/charlock_holmes/charset_match_ext.rb
|
82
|
+
- lib/charlock_holmes/converter.rb
|
83
|
+
- lib/charlock_holmes/encoding_detector.rb
|
84
|
+
- lib/charlock_holmes/string.rb
|
85
|
+
- lib/charlock_holmes/version.rb
|
86
|
+
- lib/charlock_holmes_jruby.rb
|
87
|
+
- spec/converter_spec.rb
|
88
|
+
- spec/encoding_detector_spec.rb
|
89
|
+
- spec/fixtures/AnsiGraph.psm1
|
90
|
+
- spec/fixtures/TwigExtensionsDate.es.yml
|
91
|
+
- spec/fixtures/cl-messagepack.lisp
|
92
|
+
- spec/fixtures/core.rkt
|
93
|
+
- spec/fixtures/laholator.py
|
94
|
+
- spec/fixtures/mingpao.html
|
95
|
+
- spec/fixtures/repl2.cljs
|
96
|
+
- spec/fixtures/shift_jis.html
|
97
|
+
- spec/spec_helpers.rb
|
98
|
+
- spec/string_spec.rb
|
99
|
+
homepage: http://github.com/siuying/charlock_holmes-jruby
|
100
|
+
licenses: []
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options:
|
103
|
+
- "--charset=UTF-8"
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
segments:
|
111
|
+
- 0
|
112
|
+
hash: 2
|
113
|
+
version: !binary |-
|
114
|
+
MA==
|
115
|
+
none: false
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
hash: 2
|
123
|
+
version: !binary |-
|
124
|
+
MA==
|
125
|
+
none: false
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 1.8.24
|
129
|
+
signing_key:
|
130
|
+
specification_version: 3
|
131
|
+
summary: Character encoding detection, brought to you by ICU.
|
132
|
+
test_files:
|
133
|
+
- spec/converter_spec.rb
|
134
|
+
- spec/encoding_detector_spec.rb
|
135
|
+
- spec/fixtures/AnsiGraph.psm1
|
136
|
+
- spec/fixtures/TwigExtensionsDate.es.yml
|
137
|
+
- spec/fixtures/cl-messagepack.lisp
|
138
|
+
- spec/fixtures/core.rkt
|
139
|
+
- spec/fixtures/laholator.py
|
140
|
+
- spec/fixtures/mingpao.html
|
141
|
+
- spec/fixtures/repl2.cljs
|
142
|
+
- spec/fixtures/shift_jis.html
|
143
|
+
- spec/spec_helpers.rb
|
144
|
+
- spec/string_spec.rb
|