cambridge_dict 0.2.2 → 0.2.3

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: 8c7205facd81e402d36a810dc1b595547207b0f6e3168193fd4bcb56b5c2f9ee
4
- data.tar.gz: 29adecbe8c3d0f96e59f8b43ff1b34fc093291af9a2649568ad716104aa78792
3
+ metadata.gz: f6ced5f541aa52f47a68c54450b7763bbf904a6ddb61287b9c0fe9affbf1e5c9
4
+ data.tar.gz: 3f9e664f60ad00d6afc9ff97bbc674133fa4a7deb1294d2f3c48e41b1e035ccb
5
5
  SHA512:
6
- metadata.gz: 7dfa104d86a45b96b7dac3b7a97beb99c14f662ddc25b58b2e58e2e262d82f8730458b39e5e6ffb2aca9824188bb531e54bbcd38f0841e4777c561777269c13c
7
- data.tar.gz: 2e8f2f7f5ceac4f88568b7752d950add874c99472671b5ff04e86c3330042de34774462eb6a42a0833b1d252ed808619c455a5dc24d80dca82b42e324c629673
6
+ metadata.gz: 77dd6ddc26ec659636cfbc166acbea179be8cb80eeabebfbe4e125360d440cb7d97bd50ad04b6b4e943dd99bb318647112fa8d0019c132e4dd549d7d98dbaba9
7
+ data.tar.gz: 8b63b295e1dd76f3def1a961f0952b54ad831d46b79e65be92f5d0fd49573ae7f2ed8e962a27b4a5e72ce5ada3d1d99ebb24801b2b5cef8d95959fbcc87d0190
data/README.md CHANGED
@@ -12,13 +12,13 @@ gem install cambridge_dict
12
12
 
13
13
  ```
14
14
  # throws error
15
- client = CambridgeDictionary::Client.lookup! "hello", "en"
15
+ result = CambridgeDict::Client.lookup! "hello", language: "en"
16
16
 
17
17
  # returns nil if not found
18
- client = CambridgeDictionary::Client.lookup "hello", "en"
18
+ result = CambridgeDict::Client.lookup "hello", language: "en"
19
19
 
20
20
  # can also create instance
21
- client = CambridgeDictionary::Client.new
21
+ client = CambridgeDict::Client.new
22
22
  result = client.lookup("back", language: "en")
23
23
 
24
24
  return if result.nil?
@@ -1,3 +1,3 @@
1
1
  module CambridgeDict
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -147,13 +147,14 @@ module CambridgeDict
147
147
 
148
148
  pos = entry&.at_css('.pos.dpos')&.text
149
149
  headword = entry&.at_css('.headword .hw')&.text
150
+ text = clean_string block.at_css('.def.ddef_d.db')&.text&.strip
150
151
 
151
152
  definition = {
152
153
  id: index,
153
154
  headword: headword,
154
155
  pos: pos,
155
156
  source: source || nil,
156
- text: block.at_css('.def.ddef_d.db')&.text&.strip,
157
+ text: text,
157
158
  translation: block.at_css('.def-body.ddef_b > span.trans.dtrans')&.text&.strip,
158
159
  example: extract_examples(block)
159
160
  }
@@ -177,6 +178,10 @@ module CambridgeDict
177
178
 
178
179
  examples
179
180
  end
181
+
182
+ def clean_string(input)
183
+ input&.gsub(/\s+/, ' ')&.strip
184
+ end
180
185
  end
181
186
 
182
187
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cambridge_dict
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben D'Angelo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-23 00:00:00.000000000 Z
11
+ date: 2024-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri