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 +4 -4
- data/README.md +3 -3
- data/lib/cambridge_dict/version.rb +1 -1
- data/lib/cambridge_dict.rb +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6ced5f541aa52f47a68c54450b7763bbf904a6ddb61287b9c0fe9affbf1e5c9
|
4
|
+
data.tar.gz: 3f9e664f60ad00d6afc9ff97bbc674133fa4a7deb1294d2f3c48e41b1e035ccb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
15
|
+
result = CambridgeDict::Client.lookup! "hello", language: "en"
|
16
16
|
|
17
17
|
# returns nil if not found
|
18
|
-
|
18
|
+
result = CambridgeDict::Client.lookup "hello", language: "en"
|
19
19
|
|
20
20
|
# can also create instance
|
21
|
-
client =
|
21
|
+
client = CambridgeDict::Client.new
|
22
22
|
result = client.lookup("back", language: "en")
|
23
23
|
|
24
24
|
return if result.nil?
|
data/lib/cambridge_dict.rb
CHANGED
@@ -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:
|
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.
|
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-
|
11
|
+
date: 2024-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|