wordniknik 1.0.0.pre.beta.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2fb440a0662f5612f8137956f1880bde5d0df786e57b641280984f702b31917a
4
- data.tar.gz: 48bde3e097cca779a32bb3ddd675ed1e400a8a674b82e94440f73c8e4d089ba1
3
+ metadata.gz: ba0f7f6d3bcee957c78f5e64d10a1dfece0eda19f1f9dc4833fddd7747b97d86
4
+ data.tar.gz: de70b9f33a67bb7dad8e52cbcea8fa491c2e4d4837b97969bd263175dfec4a85
5
5
  SHA512:
6
- metadata.gz: b9de81f28363c4138323228d2d2a81ed1aa3610c9f9a6c8e6e2cd3c2af022e2b31980bfbd888bfafef263414acebe7ccaa367fd3ef6548287cc44ec78f6a7091
7
- data.tar.gz: 2b5e1bd3feef16edcc701b4e1dda03066a6f19ec6336f1d19ed86cdd61403b04cab4186e647835be1a53d71b32210751047e8708855feb9f317f0c45c78821fd
6
+ metadata.gz: 739b4382d12c5bfa2178e240511d1a22fd30352f3c0d654d1402cc89d3cec47dbe7222a59265f28d02e1dc3790ea27135609796302a433381c0b2a66600c6aae
7
+ data.tar.gz: 1dc00749d44738c7e9e333ac2113178645cad22891a2e67a43a3ef4164aca40ca15e754862687e8b130ed688870e696810cc56bb0a972d7644d73d6781036561
@@ -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 @clean_up && is_404?(results)
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 @clean_up && results.is_a?(Hash)
227
- results
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 it in the environment variable WORDNIK_API_KEY or in a #{WORDNIK_CONFIG_FILE} file."
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
@@ -3,6 +3,7 @@
3
3
  # deep transform keys of a hash to symbols in snake case
4
4
  require 'time'
5
5
 
6
+ # Wordniknik module
6
7
  module Wordniknik
7
8
  module_function
8
9
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wordniknik
4
- VERSION = '1.0.0-beta.1'
4
+ VERSION = '1.0.0'
5
5
  end
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.pre.beta.1
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: 2024-09-13 00:00:00.000000000 Z
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.5.18
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: []