koko_keywords 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e62d0bc41570d8c6b5305979cfb128fe396c6c2fc1215d793fa664d40269823
4
- data.tar.gz: eda1f54501da576ca9ba75b1a44a5d1a6ca4b4ad14f4f42c2afc3bbde498870b
3
+ metadata.gz: 3be8bce1f1c2e626b8694b3b8eece40131f49cfd29b4abe9aff7ea446f8a3b31
4
+ data.tar.gz: fe6594fca73d9f817cecfe3c2c0bcca2382f9f9b8f7fce821ed86c3d635bee17
5
5
  SHA512:
6
- metadata.gz: 1b5fd64a6f799415c392befeee91ec9da48ff19e9a73404d96990b864c871e8069bf25864a590c31a7fd2813d20989e487c50efa5ce515b46716cd36202c3a7e
7
- data.tar.gz: d25e6bc6dc5e5e36c3635bbadc467945b73ea3808bcc432caedf017a46e2eb817e643635d2584747bd86a87c89944cf734774857fbfa17eb267c70fe08bf4dd0
6
+ metadata.gz: db1e3bd803325c8637ee1c715024cda62bd218f96505f183809c54baf7614c6d03db2957e633d5a14b4655f262b436895d3173b1e72ac84daab6661cb3881597
7
+ data.tar.gz: bebb3ed5aa83ed810b866de08dc09d96938e90ca9b5445623ad2c3535ae7d9b29e4bee375adf7aeb24f0531e5bdc6fafa6f717cc2c9cf29a5a8939ef34b95d32
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.0
1
+ 3.1.1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- koko_keywords (0.0.1)
4
+ koko_keywords (0.1.0)
5
5
  ffi (~> 1.15)
6
6
 
7
7
  GEM
@@ -25,6 +25,7 @@ GEM
25
25
  rspec-support (3.11.0)
26
26
 
27
27
  PLATFORMS
28
+ arm64-darwin-20
28
29
  arm64-darwin-21
29
30
 
30
31
  DEPENDENCIES
@@ -34,4 +35,4 @@ DEPENDENCIES
34
35
  rspec (< 3.12)
35
36
 
36
37
  BUNDLED WITH
37
- 2.3.9
38
+ 2.3.11
data/README.md CHANGED
@@ -1,9 +1,8 @@
1
- Koko Keyword Python Client
1
+ Koko Keyword Ruby Client
2
2
  ============
3
3
 
4
4
  A ruby client for the [Koko Keywords API](https://developers.kokocares.org). The client handles caching to ensure very low latency.
5
5
 
6
-
7
6
  ## Install
8
7
 
9
8
  ```
@@ -32,7 +31,7 @@ keyword
32
31
  KokoKeywords.match("sewerslide")
33
32
  ```
34
33
 
35
- There are two optional params, `filter` and `version`.
34
+ There is one optional params, `filter`.
36
35
 
37
36
  ### Filter
38
37
  Filter the keyword based on the taxonomy using a colon delimited list of “dimension=value” filters. Omitting a dimension does not filter by that dimension e.g.
@@ -43,19 +42,9 @@ KokoKeywords.match("sewerslide", filter: "category=eating,parenting:confidence=1
43
42
 
44
43
  This matches "sewerslide" against eating eating and parenting, with a confidence of 1 and 2 and any intensity (as intensity was omitted).
45
44
 
46
- ### Version
47
- Use this to pin to a specific version of the regex otherwise the endpoint returns the latest. e.g.
48
-
49
- ```py
50
- KokoKeywords.match("sewerslide", version: "20220206")
51
- ```
52
-
53
- We do not recommend setting this as we frequently update keywords for better matching performance.
54
-
55
45
  ## Performance
56
46
  The underlying library is written in Rust and cross-compiled to the four major CPU targets. Regexes are cached based on the cache expiration headers (currently set to an hour). This ensures very low latency and overhead (< 1μs/req).
57
47
 
58
-
59
48
  ## Error Handling
60
49
  A RuntimeError will be raised with hints on how to resolve the issue. No exception handling should be necessary.
61
50
 
Binary file
Binary file
Binary file
Binary file
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  # Specify which files should be added to the gem when it is released.
25
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
26
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
27
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } + `ls ../clib`.split("\n").map { |s| "clib/#{s}" }
28
28
  end
29
29
  spec.require_paths = ["lib"]
30
30
 
@@ -1,3 +1,3 @@
1
1
  module KokoKeywords
2
- VERSION = "0.1.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/koko_keywords.rb CHANGED
@@ -7,16 +7,18 @@ module KokoKeywords
7
7
  def self.lib_path
8
8
  uname = Etc.uname
9
9
 
10
+ filename = 'libkoko_keywords'
11
+
10
12
  if ENV["KOKO_LIB_PATH"]
11
13
  return ENV["KOKO_LIB_PATH"]
12
14
  elsif uname[:sysname] == 'Darwin' and uname[:machine] == 'arm64'
13
- filename = 'libkoko_arm64.dylib'
15
+ filename = filename + '_arm64.dylib'
14
16
  elsif uname[:sysname] == 'Darwin' and uname[:machine] == 'x86_64'
15
- filename = 'libkoko_x86_64.dylib'
17
+ filename = filename + '_x86_64.dylib'
16
18
  elsif uname[:sysname] == 'Linux' and uname[:machine] == 'x86_64'
17
- filename = 'libkoko_x86_64.so'
19
+ filename = filename + '_x86_64.so'
18
20
  elsif uname[:sysname] == 'Linux' and uname[:machine] == 'arm64'
19
- filename = 'libkoko_arm64.so'
21
+ filename = filename + '_arm64.so'
20
22
  else
21
23
  raise RuntimeError("Unsupported platform #{uname[:sysname]}, #{uname[:machine]} contact api@kokocares.org for support")
22
24
  end
@@ -26,23 +28,16 @@ module KokoKeywords
26
28
 
27
29
  extend FFI::Library
28
30
  ffi_lib lib_path
29
- attach_function :c_koko_keywords_match, [:string, :string, :string], :int
31
+ attach_function :c_koko_keywords_match, [:string, :string], :int
32
+ attach_function :c_koko_keywords_error_description, [:int], :string
30
33
  end
31
34
 
32
35
 
33
- def self.match(text, filters: "", version: nil)
34
- match_value = NativeWrapper.c_koko_keywords_match(text, filters, version)
36
+ def self.match(text, filters: "")
37
+ match_value = NativeWrapper.c_koko_keywords_match(text, filters)
35
38
 
36
- if match_value == -1
37
- raise RuntimeError.new("KOKO_KEYWORDS_AUTH must be set before importing the library")
38
- elsif match_value == -2
39
- raise RuntimeError.new("Invalid credentials. Please confirm you are using valid credentials, contact us at api.kokocares.org if you need assistance.")
40
- elsif match_value == -3
41
- raise RuntimeError.new("Unable to refresh cache. Please try again or contact us at api.kokocares.org if this issue persists.")
42
- elsif match_value == -4
43
- raise RuntimeError.new("Unable to parse response from API. Please contact us at api.kokocares.org if this issue persists.")
44
- elsif match_value == -5
45
- raise RuntimeError.new("Invalid url. Please ensure the url used is valid.")
39
+ if match_value < 0
40
+ raise RuntimeError.new(NativeWrapper.c_koko_keywords_error_description(match_value))
46
41
  end
47
42
 
48
43
  !match_value.zero?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: koko_keywords
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kareem Kouddous
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-22 00:00:00.000000000 Z
11
+ date: 2022-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -85,10 +85,10 @@ files:
85
85
  - Rakefile
86
86
  - bin/console
87
87
  - bin/setup
88
- - clib/libkoko_arm64.dylib
89
- - clib/libkoko_arm64.so
90
- - clib/libkoko_x86_64.dylib
91
- - clib/libkoko_x86_64.so
88
+ - clib/libkoko_keywords_arm64.dylib
89
+ - clib/libkoko_keywords_arm64.so
90
+ - clib/libkoko_keywords_x86_64.dylib
91
+ - clib/libkoko_keywords_x86_64.so
92
92
  - koko_keywords.gemspec
93
93
  - lib/koko_keywords.rb
94
94
  - lib/koko_keywords/version.rb
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  requirements: []
119
- rubygems_version: 3.3.3
119
+ rubygems_version: 3.3.7
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: A ruby client for the Koko Keywords API
Binary file
Binary file
Binary file
Binary file