whatlang 0.1.5 → 0.1.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f348df5e7f1c431fce809e42a475bde67a8af6a25e4a79cd1e1e1e4537c98c2
4
- data.tar.gz: 50f7297d38590e621eae72144cf2776f414a18fceb1496ca0c71b059eecdf49a
3
+ metadata.gz: 3fe408a4eb64c2503c40b8ab8aecdada6911921fe21f70b280666ac1a8e6caef
4
+ data.tar.gz: 97543a0ee08c9c4dbaedf432f13fae42e717277e175330b5a750dedac0a3eddb
5
5
  SHA512:
6
- metadata.gz: 8c3bd3c90a4736c8c2f2291decdaded53e759ef9990031c21d64cf2ddc18cb925567aa9646122e88d798f71fac34f0af5a4d66d4c3fe86cbafc16f2c61471ab6
7
- data.tar.gz: ebef27d4bbf696ccd8499efcc3125ca8077c1e6fba22b1506bb19b44528ba2a569967a122efb7c6363e533df6e26120c7b3a8fd85a80bae737a4105f14ddc8a1
6
+ metadata.gz: ed1d876556395802faad05ef54858d0ebfb2c8d4050a68fa2da806c9cfc870bde75d3716bab9e3ef30734913308c719b4dd5f87410cc84fbb2e6aca3a9f4f6d2
7
+ data.tar.gz: 3944216a4447a75408e0bc1ebb2e9d865be9ddc8739091cdf14cd4ac9a8e44942f89bedc6d8a54b254c5432813ab0dc937d2c78dc755a7a3fb889cdd5af39a24
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,16 @@
1
+ default:
2
+ image: ruby:3.2.2
3
+
4
+ before_script:
5
+ - apt-get update && apt-get install -y clang
6
+ - gem update --system '3.4.22'
7
+ - gem install bundler -v 2.4.22
8
+ - gem install tomlrb
9
+ - bundle install
10
+ - curl https://sh.rustup.rs -sSf | sh -s -- -y
11
+
12
+ test:
13
+ variables:
14
+ RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN: 'true'
15
+ script:
16
+ - source "$HOME/.cargo/env" && bundle exec rake test
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
+ 0.1.7
2
+ =====
3
+
4
+ * Stick Rust version to 1.77.2. See https://github.com/danielpclark/rutie/issues/185 for details
5
+
6
+ 0.1.6
7
+ =====
8
+
9
+ * Check argument and return value. Thanks [@bendangelo][] for filing a issue!
10
+ * Update Whatlang version to 0.16.4, which includes bug fix on Czech
11
+
1
12
  0.1.5
2
- ====
13
+ =====
3
14
 
4
15
  * Update Whatlang version to 0.16.0, which includes addition of Armenian
5
16
 
@@ -28,3 +39,5 @@
28
39
  =====
29
40
 
30
41
  * Initial release
42
+
43
+ [@bendangelo]: https://gitlab.com/bendangelo
data/Cargo.lock CHANGED
@@ -4,86 +4,112 @@ version = 3
4
4
 
5
5
  [[package]]
6
6
  name = "ahash"
7
- version = "0.7.6"
7
+ version = "0.8.11"
8
8
  source = "registry+https://github.com/rust-lang/crates.io-index"
9
- checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
9
+ checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
10
10
  dependencies = [
11
- "getrandom",
11
+ "cfg-if",
12
12
  "once_cell",
13
13
  "version_check",
14
+ "zerocopy",
14
15
  ]
15
16
 
16
17
  [[package]]
17
- name = "cfg-if"
18
- version = "1.0.0"
18
+ name = "allocator-api2"
19
+ version = "0.2.18"
19
20
  source = "registry+https://github.com/rust-lang/crates.io-index"
20
- checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
21
+ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
21
22
 
22
23
  [[package]]
23
- name = "getrandom"
24
- version = "0.2.6"
24
+ name = "cfg-if"
25
+ version = "1.0.0"
25
26
  source = "registry+https://github.com/rust-lang/crates.io-index"
26
- checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad"
27
- dependencies = [
28
- "cfg-if",
29
- "libc",
30
- "wasi",
31
- ]
27
+ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
32
28
 
33
29
  [[package]]
34
30
  name = "hashbrown"
35
- version = "0.12.1"
31
+ version = "0.14.5"
36
32
  source = "registry+https://github.com/rust-lang/crates.io-index"
37
- checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3"
33
+ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
38
34
  dependencies = [
39
35
  "ahash",
36
+ "allocator-api2",
40
37
  ]
41
38
 
42
39
  [[package]]
43
40
  name = "lazy_static"
44
- version = "1.4.0"
41
+ version = "1.5.0"
45
42
  source = "registry+https://github.com/rust-lang/crates.io-index"
46
- checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
43
+ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
47
44
 
48
45
  [[package]]
49
46
  name = "libc"
50
- version = "0.2.125"
47
+ version = "0.2.158"
51
48
  source = "registry+https://github.com/rust-lang/crates.io-index"
52
- checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b"
49
+ checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
53
50
 
54
51
  [[package]]
55
52
  name = "once_cell"
56
- version = "1.10.0"
53
+ version = "1.19.0"
54
+ source = "registry+https://github.com/rust-lang/crates.io-index"
55
+ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
56
+
57
+ [[package]]
58
+ name = "proc-macro2"
59
+ version = "1.0.86"
60
+ source = "registry+https://github.com/rust-lang/crates.io-index"
61
+ checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
62
+ dependencies = [
63
+ "unicode-ident",
64
+ ]
65
+
66
+ [[package]]
67
+ name = "quote"
68
+ version = "1.0.37"
57
69
  source = "registry+https://github.com/rust-lang/crates.io-index"
58
- checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
70
+ checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
71
+ dependencies = [
72
+ "proc-macro2",
73
+ ]
59
74
 
60
75
  [[package]]
61
76
  name = "rutie"
62
- version = "0.8.4"
77
+ version = "0.9.0"
63
78
  source = "registry+https://github.com/rust-lang/crates.io-index"
64
- checksum = "5d97db4cbb9739b48364c38cc9a6ebabdc07b42bd87b60ab448e1f29eaebb2ac"
79
+ checksum = "e5e8e4f6480c30609e3480adfab87b8d4792525225a1caf98b371fbc9a7b698a"
65
80
  dependencies = [
66
81
  "lazy_static",
67
82
  "libc",
68
83
  ]
69
84
 
70
85
  [[package]]
71
- name = "version_check"
72
- version = "0.9.4"
86
+ name = "syn"
87
+ version = "2.0.76"
88
+ source = "registry+https://github.com/rust-lang/crates.io-index"
89
+ checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525"
90
+ dependencies = [
91
+ "proc-macro2",
92
+ "quote",
93
+ "unicode-ident",
94
+ ]
95
+
96
+ [[package]]
97
+ name = "unicode-ident"
98
+ version = "1.0.12"
73
99
  source = "registry+https://github.com/rust-lang/crates.io-index"
74
- checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
100
+ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
75
101
 
76
102
  [[package]]
77
- name = "wasi"
78
- version = "0.10.2+wasi-snapshot-preview1"
103
+ name = "version_check"
104
+ version = "0.9.5"
79
105
  source = "registry+https://github.com/rust-lang/crates.io-index"
80
- checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
106
+ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
81
107
 
82
108
  [[package]]
83
109
  name = "whatlang"
84
- version = "0.16.0"
110
+ version = "0.16.4"
85
111
  source = "registry+https://github.com/rust-lang/crates.io-index"
86
- checksum = "2989d7e9d3cb96a76438e879144030b1be0931b944fbfed65e89e2ae536cd3b9"
112
+ checksum = "471d1c1645d361eb782a1650b1786a8fb58dd625e681a04c09f5ff7c8764a7b0"
87
113
  dependencies = [
88
114
  "hashbrown",
89
115
  "once_cell",
@@ -91,8 +117,28 @@ dependencies = [
91
117
 
92
118
  [[package]]
93
119
  name = "whatlang-rb"
94
- version = "0.1.5"
120
+ version = "0.1.6"
95
121
  dependencies = [
96
122
  "rutie",
97
123
  "whatlang",
98
124
  ]
125
+
126
+ [[package]]
127
+ name = "zerocopy"
128
+ version = "0.7.35"
129
+ source = "registry+https://github.com/rust-lang/crates.io-index"
130
+ checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
131
+ dependencies = [
132
+ "zerocopy-derive",
133
+ ]
134
+
135
+ [[package]]
136
+ name = "zerocopy-derive"
137
+ version = "0.7.35"
138
+ source = "registry+https://github.com/rust-lang/crates.io-index"
139
+ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
140
+ dependencies = [
141
+ "proc-macro2",
142
+ "quote",
143
+ "syn",
144
+ ]
data/Cargo.toml CHANGED
@@ -1,14 +1,14 @@
1
1
  [package]
2
2
  name = "whatlang-rb"
3
- version = "0.1.5"
3
+ version = "0.1.7"
4
4
  authors = ["Kitaiti Makoto <KitaitiMakoto@gmail.com>"]
5
5
  edition = "2018"
6
6
 
7
7
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8
8
 
9
9
  [dependencies]
10
- rutie = { version = "0.8.4", features = ["no-link"] }
11
- whatlang = "0.16.0"
10
+ rutie = { version = "0.9.0", features = ["no-link"] }
11
+ whatlang = "0.16.4"
12
12
 
13
13
  [lib]
14
14
  crate-type = ["cdylib"]
data/README.md CHANGED
@@ -8,7 +8,7 @@ Features
8
8
 
9
9
  Features are derived from original [Whatlang][] library, which includes:
10
10
 
11
- * Supports [87 languages](https://github.com/greyblake/whatlang-rs/blob/master/SUPPORTED_LANGUAGES.md)
11
+ * Supports [69 languages](https://github.com/greyblake/whatlang-rs/blob/master/SUPPORTED_LANGUAGES.md)
12
12
  * Lightweight, fast and simple
13
13
  * Recognizes not only a language, but also a script (Latin, Cyrillic, etc)
14
14
  * Provides reliability information
data/Rakefile CHANGED
@@ -5,12 +5,6 @@ require "rubygems/tasks"
5
5
  require "rake/testtask"
6
6
  require "yard"
7
7
 
8
- Rake::TestTask.new(:test) do |t|
9
- t.libs << "test"
10
- t.libs << "lib"
11
- t.test_files = FileList["test/**/*_test.rb"]
12
- end
13
-
14
8
  task default: :test
15
9
 
16
10
  Gem::Tasks.new
@@ -23,8 +17,9 @@ RUST_SRC.each do |path|
23
17
  file path
24
18
  end
25
19
 
26
- file RUST_TARGET => RUST_SRC do
20
+ file RUST_TARGET => RUST_SRC + ["Cargo.toml", "Cargo.lock"] do
27
21
  sh "cargo build --release"
28
22
  end
29
23
  CLEAN.include RUST_TARGET
30
- task test: RUST_TARGET
24
+
25
+ Rake::TestTask.new test: RUST_TARGET
data/lib/whatlang.rb CHANGED
@@ -9,6 +9,8 @@ module Whatlang
9
9
  raise ArgumentError, "Couldn't specify `allowlist' and `denylist' at a time. Choose one."
10
10
  end
11
11
 
12
+ text = text.to_s
13
+
12
14
  case
13
15
  when allowlist
14
16
  detect_with_allowlist(text, allowlist)
@@ -44,4 +46,12 @@ module Whatlang
44
46
  @eng_name = eng_name
45
47
  end
46
48
  end
49
+
50
+ private
51
+
52
+ # Class returnned by detect when no lang detected.
53
+ #
54
+ # Needed because Rutie cause segmentation fault when it returns NilClass.
55
+ # Should be removed after https://github.com/danielpclark/rutie/pull/180 is solved.
56
+ NO_INFO = nil
47
57
  end
@@ -0,0 +1,3 @@
1
+ [toolchain]
2
+ channel = "1.77.2"
3
+ profile = "minimal"
data/src/lib.rs CHANGED
@@ -1,5 +1,5 @@
1
1
  use rutie::{
2
- methods, module, AnyException, AnyObject, Array, Boolean, Float, Module, NilClass, Object,
2
+ methods, module, AnyException, AnyObject, Array, Boolean, Float, Module, Object,
3
3
  RString, VM,
4
4
  };
5
5
  use whatlang::{detect, detect_lang, detect_script, Detector, Info, Lang};
@@ -11,25 +11,25 @@ methods!(
11
11
  _rtself,
12
12
 
13
13
  fn wl_detect_without_options(text: RString) -> AnyObject {
14
- detect(rstring(text).to_str()).map_or(NilClass::new().into(), rinfo)
14
+ detect(rstring(text).to_str()).map_or(no_info(), rinfo)
15
15
  }
16
16
 
17
17
  fn wl_detect_with_allowlist(text: RString, list: Array) -> AnyObject {
18
18
  let detector = Detector::with_allowlist(rarray_to_lang_list(list));
19
- detector.detect(rstring(text).to_str()).map_or(NilClass::new().into(), rinfo)
19
+ detector.detect(rstring(text).to_str()).map_or(no_info(), rinfo)
20
20
  }
21
21
 
22
22
  fn wl_detect_with_denylist(text: RString, list: Array) -> AnyObject {
23
23
  let detector = Detector::with_denylist(rarray_to_lang_list(list));
24
- detector.detect(rstring(text).to_str()).map_or(NilClass::new().into(), rinfo)
24
+ detector.detect(rstring(text).to_str()).map_or(no_info(), rinfo)
25
25
  }
26
26
 
27
27
  fn wl_detect_lang(text: RString) -> AnyObject {
28
- detect_lang(rstring(text).to_str()).map_or(NilClass::new().into(), rlang)
28
+ detect_lang(rstring(text).to_str()).map_or(no_info(), rlang)
29
29
  }
30
30
 
31
31
  fn wl_detect_script(text: RString) -> AnyObject {
32
- detect_script(rstring(text).to_str()).map_or(NilClass::new().into(), |script| {
32
+ detect_script(rstring(text).to_str()).map_or(no_info(), |script| {
33
33
  RString::new_utf8(script.name()).into()
34
34
  })
35
35
  }
@@ -75,6 +75,13 @@ fn rlang(lang: Lang) -> AnyObject {
75
75
  ])
76
76
  }
77
77
 
78
+ // Needed because Rutie cause segmentation fault when it returns NilClass.
79
+ // Should be removed after https://github.com/danielpclark/rutie/pull/180 is solved.
80
+ fn no_info() -> AnyObject {
81
+ Module::from_existing("Whatlang")
82
+ .const_get("NO_INFO")
83
+ }
84
+
78
85
  #[allow(non_snake_case)]
79
86
  #[no_mangle]
80
87
  pub extern "C" fn Init_whatlang() {
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative "helper"
4
4
 
5
- class WhatlangTest < Test::Unit::TestCase
5
+ class TestWhatlang < Test::Unit::TestCase
6
6
  def test_detect
7
7
  text = "Ĉu vi ne volas eklerni Esperanton? Bonvolu!"
8
8
  list = ["eng", "ita"]
@@ -43,4 +43,22 @@ class WhatlangTest < Test::Unit::TestCase
43
43
  text = "Благодаря Эсперанто вы обрётете друзей по всему миру!"
44
44
  assert_equal "Cyrillic", Whatlang.detect_script(text)
45
45
  end
46
+
47
+ def test_detect_empty_string
48
+ assert_nil Whatlang.detect("")
49
+ end
50
+
51
+ def test_detect_nil
52
+ assert_nil Whatlang.detect(nil)
53
+ end
54
+
55
+ def test_inspect
56
+ assert_nothing_raised do
57
+ Whatlang.detect("こんにちは").inspect
58
+ end
59
+ end
60
+
61
+ def test_numeric
62
+ assert_nil Whatlang.detect(1234)
63
+ end
46
64
  end
data/whatlang.gemspec CHANGED
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "rake"
28
28
  spec.add_development_dependency "yard"
29
29
  spec.add_development_dependency "rubygems-tasks"
30
+ spec.add_runtime_dependency "racc"
30
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whatlang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kitaiti Makoto
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-10 00:00:00.000000000 Z
11
+ date: 2024-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rutie
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: racc
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: Ruby bindings for Whatlang, a natural language detection for Rust.
98
112
  email:
99
113
  - KitaitiMakoto@gmail.com
@@ -103,6 +117,7 @@ extensions:
103
117
  extra_rdoc_files: []
104
118
  files:
105
119
  - ".gitignore"
120
+ - ".gitlab-ci.yml"
106
121
  - ".yardopts"
107
122
  - BSDL
108
123
  - CHANGELOG.md
@@ -114,9 +129,10 @@ files:
114
129
  - Rakefile
115
130
  - ext/Rakefile
116
131
  - lib/whatlang.rb
132
+ - rust-toolchain.toml
117
133
  - src/lib.rs
118
134
  - test/helper.rb
119
- - test/whatlang_test.rb
135
+ - test/test_whatlang.rb
120
136
  - whatlang.gemspec
121
137
  homepage: https://gitlab.com/KitaitiMakoto/whatlang-rb
122
138
  licenses:
@@ -125,7 +141,7 @@ metadata:
125
141
  homepage_uri: https://gitlab.com/KitaitiMakoto/whatlang-rb
126
142
  source_code_uri: https://gitlab.com/KitaitiMakoto/whatlang-rb
127
143
  changelog_uri: https://gitlab.com/KitaitiMakoto/whatlang-rb/-/blob/master/CHANGELOG.md
128
- post_install_message:
144
+ post_install_message:
129
145
  rdoc_options: []
130
146
  require_paths:
131
147
  - lib
@@ -140,8 +156,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
156
  - !ruby/object:Gem::Version
141
157
  version: '0'
142
158
  requirements: []
143
- rubygems_version: 3.3.7
144
- signing_key:
159
+ rubygems_version: 3.5.18
160
+ signing_key:
145
161
  specification_version: 4
146
162
  summary: Fast natural language detection library.
147
163
  test_files: []