koko_keywords 0.1.0 → 0.2.0

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: 6e62d0bc41570d8c6b5305979cfb128fe396c6c2fc1215d793fa664d40269823
4
- data.tar.gz: eda1f54501da576ca9ba75b1a44a5d1a6ca4b4ad14f4f42c2afc3bbde498870b
3
+ metadata.gz: e6adf016d74f8bd31fef826d4c86fd5f060b262f8a8b038b12f785a1a3bd22eb
4
+ data.tar.gz: 70565ac34a07715655fd7e26b93fa43d98bd656b64f0b7197e0a6867407180aa
5
5
  SHA512:
6
- metadata.gz: 1b5fd64a6f799415c392befeee91ec9da48ff19e9a73404d96990b864c871e8069bf25864a590c31a7fd2813d20989e487c50efa5ce515b46716cd36202c3a7e
7
- data.tar.gz: d25e6bc6dc5e5e36c3635bbadc467945b73ea3808bcc432caedf017a46e2eb817e643635d2584747bd86a87c89944cf734774857fbfa17eb267c70fe08bf4dd0
6
+ metadata.gz: d9398455e9b4152c94404f5acde8f14ddaa722e50f64d52e3d959761e13e72cf08e3c7f0ff8f7086dbe8d8f70ef8c0b126872a150061b427d0a3a16331dff46b
7
+ data.tar.gz: e400993968f25eae29896432fc1010ea62968c8407f4a180e190bd29696f68144567da39537d7930456193913847c1f5771b5390dc3743e45d1eccfda255e77f
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
@@ -1,3 +1,3 @@
1
1
  module KokoKeywords
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.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.2.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-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -86,9 +86,10 @@ files:
86
86
  - bin/console
87
87
  - bin/setup
88
88
  - clib/libkoko_arm64.dylib
89
- - clib/libkoko_arm64.so
90
- - clib/libkoko_x86_64.dylib
91
- - clib/libkoko_x86_64.so
89
+ - clib/libkoko_keywords_arm64.dylib
90
+ - clib/libkoko_keywords_arm64.so
91
+ - clib/libkoko_keywords_x86_64.dylib
92
+ - clib/libkoko_keywords_x86_64.so
92
93
  - koko_keywords.gemspec
93
94
  - lib/koko_keywords.rb
94
95
  - lib/koko_keywords/version.rb
@@ -116,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
117
  - !ruby/object:Gem::Version
117
118
  version: '0'
118
119
  requirements: []
119
- rubygems_version: 3.3.3
120
+ rubygems_version: 3.3.7
120
121
  signing_key:
121
122
  specification_version: 4
122
123
  summary: A ruby client for the Koko Keywords API
Binary file
Binary file
Binary file