koko_keywords 0.0.1 → 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: 5ce6aee9f3257cdc04c2f66d5c9f613c34ed87a963c9bf941ed507c52d4dbb7e
4
- data.tar.gz: 3e031c08ab38963a593b2d77a7f1a25d6d7e58c73b9b7b700975e61b6d7f51bd
3
+ metadata.gz: e6adf016d74f8bd31fef826d4c86fd5f060b262f8a8b038b12f785a1a3bd22eb
4
+ data.tar.gz: 70565ac34a07715655fd7e26b93fa43d98bd656b64f0b7197e0a6867407180aa
5
5
  SHA512:
6
- metadata.gz: fe3a1962ae2adb1ba181ee4e331caa0e4e7b18a04d5880258a69e3a76bb9994ccd511b86f00db4e9a5941fc0df8cf7bd1989088899b19fba0c60fcc25ef5a8a8
7
- data.tar.gz: 585366f7875451afb5a75e8c747852e8811d3befcd811898a3000d7431a466f41a856af0fdc43c358b6861aadb29accc2d9842fbfa0d4aad4c13098e53fbfe8e
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,8 +1,7 @@
1
- Koko Keyword Python Client
1
+ Koko Keyword Ruby Client
2
2
  ============
3
3
 
4
- A ruby client for the [Koko Keywords API](https://r.kokocares.org/koko_keywords/docs). The client handles caching to ensure very low latency.
5
-
4
+ A ruby client for the [Koko Keywords API](https://developers.kokocares.org). The client handles caching to ensure very low latency.
6
5
 
7
6
  ## Install
8
7
 
@@ -13,7 +12,7 @@ gem install koko_keywords
13
12
  ## Usage
14
13
 
15
14
  Set the `KOKO_KEYWORDS_AUTH` environment to the authentication string provided
16
- by Koko (contact us at api@kokocares.org if you would like one).
15
+ by Koko. To get an api key, complete our [sign up form](https://r.kokocares.org/api_signup).
17
16
 
18
17
  ```
19
18
  export KOKO_KEYWORDS_AUTH=username:password
@@ -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,17 +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
45
  ## Performance
54
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).
55
47
 
56
-
57
48
  ## Error Handling
58
49
  A RuntimeError will be raised with hints on how to resolve the issue. No exception handling should be necessary.
59
50
 
Binary file
Binary file
Binary file
Binary file
@@ -9,10 +9,17 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Kareem Kouddous"]
10
10
  spec.email = ["kkouddous@gmail.com"]
11
11
 
12
- spec.summary = "A python client for the Koko Keywords API. The client handles caching to ensure very low latency."
13
- spec.description = File.open('README.md').read
12
+ spec.summary = "A ruby client for the Koko Keywords API"
13
+ spec.description = "A ruby client for the Koko Keywords API. The client handles caching to ensure very low latency."
14
14
  spec.homepage = "https://api-docs.kokocares.org"
15
15
  spec.license = "MIT"
16
+ spec.metadata = {
17
+ 'bug_tracker_uri' => 'https://github.com/kokocares/keywords-client/issues',
18
+ 'changelog_uri' => 'https://api-docs.kokocares.org/docs/changelog',
19
+ 'documentation_uri' => 'https://api-docs.kokocares.org/docs/python',
20
+ 'homepage_uri' => 'https://api-docs.kokocares.org',
21
+ "source_code_uri" => "https://github.com/kokocares/keywords-client/tree/main/clients/ruby"
22
+ }
16
23
 
17
24
  # Specify which files should be added to the gem when it is released.
18
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -1,3 +1,3 @@
1
1
  module KokoKeywords
2
- VERSION = "0.0.1"
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.0.1
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-18 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
@@ -66,42 +66,8 @@ dependencies:
66
66
  - - "<"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.12'
69
- description: "Koko Keyword Python Client\n============\n\nA ruby client for the [Koko
70
- Keywords API](https://r.kokocares.org/koko_keywords/docs). The client handles caching
71
- to ensure very low latency.\n\n\n## Install\n\n```\ngem install koko_keywords\n```\n\n##
72
- Usage\n\nSet the `KOKO_KEYWORDS_AUTH` environment to the authentication string provided\nby
73
- Koko (contact us at api@kokocares.org if you would like one).\n\n```\nexport KOKO_KEYWORDS_AUTH=username:password\n```\n\nRequire
74
- the gem or add it to you Bundle\n\n```py\nrequire 'koko_keywords'\n```\n\nThen use
75
- the `match` function to check whether a query prompt matches a risky\nkeyword\n\n```py\nKokoKeywords.match(\"sewerslide\")\n```\n\nThere
76
- are two optional params, `filter` and `version`. \n\n### Filter\nFilter the keyword
77
- based on the taxonomy using a colon delimited list of “dimension=value” filters.
78
- Omitting a dimension does not filter by that dimension e.g.\n\n```py\nKokoKeywords.match(\"sewerslide\",
79
- filter: \"category=eating,parenting:confidence=1,2\")\n```\n\nThis matches \"sewerslide\"
80
- against eating eating and parenting, with a confidence of 1 and 2 and any intensity
81
- (as intensity was omitted).\n\n### Version\nUse this to pin to a specific version
82
- of the regex otherwise the endpoint returns the latest. e.g.\n\n```py\nKokoKeywords.match(\"sewerslide\",
83
- version: \"20220206\")\n```\n\n## Performance\nThe underlying library is written
84
- in Rust and cross-compiled to the four major CPU targets. Regexes are cached based
85
- on the cache expiration headers (currently set to an hour). This ensures very low
86
- latency and overhead (< 1μs/req).\n\n\n## Error Handling\nA RuntimeError will be
87
- raised with hints on how to resolve the issue. No exception handling should be necessary.\n\n##
88
- Logging\nMinimal log messages are logged to STDERR\n\n## License\n\n```\nWWWWWW||WWWWWW\n
89
- W W W||W W W\n ||\n ( OO )__________\n / | \\\n /o o|
90
- \ MIT \\\n \\___/||_||__||_|| *\n || || || ||\n _||_||
91
- _||_||\n (__|__|(__|__|\n```\n\n(The MIT License)\n\nCopyright (c) 2017 Koko
92
- AI Inc. <us@kokocares.org>\n\nPermission is hereby granted, free of charge, to any
93
- person obtaining a copy of this software and associated documentation files (the
94
- 'Software'), to deal in the Software without restriction, including without limitation
95
- the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
96
- sell copies of the Software, and to permit persons to whom the Software is furnished
97
- to do so, subject to the following conditions:\n\nThe above copyright notice and
98
- this permission notice shall be included in all copies or substantial portions of
99
- the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
100
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
101
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
102
- OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
103
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
104
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
69
+ description: A ruby client for the Koko Keywords API. The client handles caching to
70
+ ensure very low latency.
105
71
  email:
106
72
  - kkouddous@gmail.com
107
73
  executables: []
@@ -120,16 +86,22 @@ files:
120
86
  - bin/console
121
87
  - bin/setup
122
88
  - clib/libkoko_arm64.dylib
123
- - clib/libkoko_arm64.so
124
- - clib/libkoko_x86_64.dylib
125
- - 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
126
93
  - koko_keywords.gemspec
127
94
  - lib/koko_keywords.rb
128
95
  - lib/koko_keywords/version.rb
129
96
  homepage: https://api-docs.kokocares.org
130
97
  licenses:
131
98
  - MIT
132
- metadata: {}
99
+ metadata:
100
+ bug_tracker_uri: https://github.com/kokocares/keywords-client/issues
101
+ changelog_uri: https://api-docs.kokocares.org/docs/changelog
102
+ documentation_uri: https://api-docs.kokocares.org/docs/python
103
+ homepage_uri: https://api-docs.kokocares.org
104
+ source_code_uri: https://github.com/kokocares/keywords-client/tree/main/clients/ruby
133
105
  post_install_message:
134
106
  rdoc_options: []
135
107
  require_paths:
@@ -145,9 +117,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
117
  - !ruby/object:Gem::Version
146
118
  version: '0'
147
119
  requirements: []
148
- rubygems_version: 3.3.3
120
+ rubygems_version: 3.3.7
149
121
  signing_key:
150
122
  specification_version: 4
151
- summary: A python client for the Koko Keywords API. The client handles caching to
152
- ensure very low latency.
123
+ summary: A ruby client for the Koko Keywords API
153
124
  test_files: []
Binary file
Binary file
Binary file