wiktionary_api 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d197bdd3a4ca0783154ddee36287d5bf96b63693fc1ceb7e2161771fe5281559
4
- data.tar.gz: 573bcc23d48203a941a4b8b5630409cb80271a97ec4b6d900dc6ae53d12553eb
3
+ metadata.gz: 319d3ed1a563b1611e76b47de385b213c39e55b3ce4ca9981ffec89994496ed2
4
+ data.tar.gz: 681e731b9f4592dd43c60be2ccc054314d7ba9e2ac7ad1652ed32e9b94987f24
5
5
  SHA512:
6
- metadata.gz: 2d37db76704da2f422f6d6e518696e94bacd437fe06bf9d2e2a87d10b77507bbe05ef201bdd44e1d761ccc3722613ecaa9ab5409a1666ea44a6d5d145d627c78
7
- data.tar.gz: d6c7ad9b8abdb654a4956e67d57588d9c86a7652d4d3b13a820dabc502e10b026baaafca265a481316e2765080880173ae10afdf44b0377e75249b110e3654e6
6
+ metadata.gz: 57789f038f86dfe20c15d35d68df17d54139fb6b30e130d8dbe7ba720274297ff0b16f1d28a5c67c68b9c3a39d6099b1068322d80ff61358485bc357111bc37d
7
+ data.tar.gz: a599c2f1fdb20f41dff320425e09c891b3d519846fa8a628dfe79903d384143ee69b0a5358292d469c9fe963b1774b4439700f5bcfb258d3fb12396851e5e306
@@ -1,3 +1,3 @@
1
1
  module WiktionaryAPI
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -1,19 +1,19 @@
1
1
  module WiktionaryAPI
2
2
  class Word
3
- attr_reader :part_of_speech, :language
3
+ attr_reader :part_of_speech, :language, :raw_definitions
4
4
 
5
5
  def initialize(data)
6
6
  @part_of_speech = data['partOfSpeech']
7
7
  @language = data['language']
8
- @definitions = data['definitions']
8
+ @raw_definitions = data['definitions']
9
9
  end
10
10
 
11
11
  def definitions
12
- @definitions.flat_map { |meaning| ::Nokogiri::HTML(meaning['definition']).text.strip }
12
+ @raw_definitions.flat_map { |meaning| ::Nokogiri::HTML(meaning['definition']).text.strip }
13
13
  end
14
14
 
15
15
  def examples
16
- @definitions.flat_map do |definition|
16
+ @raw_definitions.flat_map do |definition|
17
17
  definition["examples"].map do |e|
18
18
  ::Nokogiri::HTML(e).text.strip
19
19
  end
@@ -47,6 +47,9 @@ module WiktionaryAPI
47
47
  data = JSON.parse(body)
48
48
 
49
49
  lang_data = data[lang.to_s]
50
+
51
+ return nil if lang_data.nil?
52
+
50
53
  lang_data.map { |word_data| Word.new(word_data) }
51
54
  end
52
55
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wiktionary_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
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-12-20 00:00:00.000000000 Z
11
+ date: 2024-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri