wordniknik 1.0.0.pre.beta.2 → 1.0.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 +4 -4
- data/lib/wordniknik/client.rb +10 -3
- data/lib/wordniknik/configuration.rb +2 -1
- data/lib/wordniknik/utils.rb +1 -0
- data/lib/wordniknik/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba0f7f6d3bcee957c78f5e64d10a1dfece0eda19f1f9dc4833fddd7747b97d86
|
4
|
+
data.tar.gz: de70b9f33a67bb7dad8e52cbcea8fa491c2e4d4837b97969bd263175dfec4a85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 739b4382d12c5bfa2178e240511d1a22fd30352f3c0d654d1402cc89d3cec47dbe7222a59265f28d02e1dc3790ea27135609796302a433381c0b2a66600c6aae
|
7
|
+
data.tar.gz: 1dc00749d44738c7e9e333ac2113178645cad22891a2e67a43a3ef4164aca40ca15e754862687e8b130ed688870e696810cc56bb0a972d7644d73d6781036561
|
data/lib/wordniknik/client.rb
CHANGED
@@ -3,9 +3,14 @@
|
|
3
3
|
require 'json'
|
4
4
|
require 'net/http'
|
5
5
|
|
6
|
+
# Wornkiknik is a Ruby client for the Wordnik API.
|
6
7
|
module Wordniknik
|
8
|
+
# Error class for Wordniknik.
|
9
|
+
# This class is used to handle errors that occur during API calls.
|
7
10
|
class Error < StandardError; end
|
8
11
|
|
12
|
+
# Client class for Wordniknik.
|
13
|
+
# This class is used to interact with the Wordnik API.
|
9
14
|
class Client
|
10
15
|
attr_accessor :configuration
|
11
16
|
|
@@ -116,7 +121,7 @@ module Wordniknik
|
|
116
121
|
|
117
122
|
if @clean_up && is_404?(results)
|
118
123
|
[]
|
119
|
-
elsif
|
124
|
+
elsif is_404?(results)
|
120
125
|
results[:frequency]
|
121
126
|
else
|
122
127
|
results
|
@@ -223,8 +228,8 @@ module Wordniknik
|
|
223
228
|
|
224
229
|
if @clean_up && is_404?(results)
|
225
230
|
{}
|
226
|
-
elsif
|
227
|
-
|
231
|
+
elsif is_404?(results)
|
232
|
+
raise Wordniknik::Error, "No example found for word: #{word}"
|
228
233
|
else
|
229
234
|
results
|
230
235
|
end
|
@@ -420,8 +425,10 @@ module Wordniknik
|
|
420
425
|
result.is_a?(Hash) && result[:status_code] == 404
|
421
426
|
end
|
422
427
|
|
428
|
+
# rubocop:disable Naming/PredicateName
|
423
429
|
def is_error?(result)
|
424
430
|
result.is_a?(Hash) && result[:status_code] && result[:status_code] != 200 && result[:status_code] != 404
|
425
431
|
end
|
432
|
+
# rubocop:enable Naming/PredicateName
|
426
433
|
end
|
427
434
|
end
|
@@ -4,6 +4,7 @@ require 'yaml'
|
|
4
4
|
|
5
5
|
module Wordniknik
|
6
6
|
WORDNIK_CONFIG_FILE = '.wordnik.yml'
|
7
|
+
# Wordnik API configuration class
|
7
8
|
class Configuration
|
8
9
|
attr_accessor :api_key, :api_host, :api_port, :api_version, :connection
|
9
10
|
|
@@ -20,7 +21,7 @@ module Wordniknik
|
|
20
21
|
@api_version = loaded['api_version'] || defaults[:api_version]
|
21
22
|
return unless @api_key.nil?
|
22
23
|
|
23
|
-
raise "No API key found. Please set
|
24
|
+
raise "No API key found. Please set WORDNIK_API_KEY or in a #{WORDNIK_CONFIG_FILE} file."
|
24
25
|
end
|
25
26
|
|
26
27
|
def look_for_config_file
|
data/lib/wordniknik/utils.rb
CHANGED
data/lib/wordniknik/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wordniknik
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Fitzgerald
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-04-15 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: json
|
@@ -43,7 +42,6 @@ metadata:
|
|
43
42
|
source_code_uri: https://github.com/willf/wordniknik
|
44
43
|
changelog_uri: https://github.com/willf/wordniknik/blob/main/CHANGELOG.md
|
45
44
|
rubygems_mfa_required: 'true'
|
46
|
-
post_install_message:
|
47
45
|
rdoc_options: []
|
48
46
|
require_paths:
|
49
47
|
- lib
|
@@ -58,8 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
56
|
- !ruby/object:Gem::Version
|
59
57
|
version: '0'
|
60
58
|
requirements: []
|
61
|
-
rubygems_version: 3.
|
62
|
-
signing_key:
|
59
|
+
rubygems_version: 3.6.3
|
63
60
|
specification_version: 4
|
64
61
|
summary: A ruby wrapper for the Wordnik API
|
65
62
|
test_files: []
|