oxford_learners_dictionaries 0.1.3 → 0.1.5

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
  SHA1:
3
- metadata.gz: 5cef05ae63ffd879cfb1082725e9024d487aafa5
4
- data.tar.gz: d2204fc9220032645ee959436844cf123d682914
3
+ metadata.gz: 9b6233f3a7541d7f4ebe1d7de2f180f05ab761a0
4
+ data.tar.gz: 2f27bee6ae7dda6e424a96a47c75baaef5cebc95
5
5
  SHA512:
6
- metadata.gz: 65032da126bf0d459be8ad6c376e0d4c2c75c651dba27905999d0b480f855099ecaec1c9fd91a6d15abfada8b11f2a0476d64ad1cf2d13b1c40e0cbda7663850
7
- data.tar.gz: 25b69483e1f99939f86eb378b9df3663240e1126c439da8c468f08156ff43752b53dfd1b39515b853984d91cf71cf7e86dfde97b6acf7ab750311dee7e5a5376
6
+ metadata.gz: 9a9e4b18066688d67da05e242d42eb2c2588cd13ce766430806f6a707df7d0f82d2a90571d51cc977b2602791f1e5b84900edcc429219931e3bfc360b87ef44a
7
+ data.tar.gz: 8ffc47cf5be942a1d7096cbebc7d721bc870663c0980e07087a358052d3a3d3102dab617733512cbaa79f960d6e32067db75054edbd4bbeeb9a091c8e49b87f5
@@ -3,7 +3,7 @@ require 'open-uri'
3
3
 
4
4
  module OxfordLearnersDictionaries
5
5
  class English
6
- attr_reader :definition, :type, :urls, :word
6
+ attr_reader :definition, :type, :urls, :word, :examples
7
7
 
8
8
  def initialize word
9
9
  formatted_word = word.strip.gsub(' ', '-') rescue ''
@@ -13,6 +13,7 @@ module OxfordLearnersDictionaries
13
13
  @urls = [ main_url, main_url.gsub('?q=', '1?q=') ]
14
14
  @word = formatted_word
15
15
  @definition = Hash.new
16
+ @examples = Hash.new
16
17
  end
17
18
 
18
19
  def look_up
@@ -34,6 +35,7 @@ module OxfordLearnersDictionaries
34
35
  private
35
36
  def parse
36
37
  parse_type
38
+ parse_examples
37
39
  if @page.css('.num').count > 0
38
40
  parse_multiple_definitions
39
41
  else
@@ -53,12 +55,15 @@ module OxfordLearnersDictionaries
53
55
 
54
56
  def parse_multiple_definitions
55
57
  @page.css('.num').count.times do |index|
56
- @definition["definition_#{index}".to_sym] = @page.css('.def')[index].text
58
+ @definition[:"definition_#{index}"] = @page.css('.def')[index].text
59
+ end
60
+ end
61
+
62
+ def parse_examples
63
+ @page.css(".x-g").each_with_index do |example, index|
64
+ @examples[:"examples_#{index}"] = example.text.strip.capitalize
57
65
  end
58
66
  end
59
67
  end
60
68
  end
61
69
 
62
- # definition.css(".x-g").each do |examples|
63
- # puts "# #{examples.css(".x").text}"
64
- # end
@@ -1,3 +1,3 @@
1
1
  module OxfordLearnersDictionaries
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -24,7 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "simplecov", "~> 0.9.0"
25
25
  spec.add_development_dependency "rspec", "~> 3.0.0"
26
26
  spec.add_development_dependency "webmock", "~> 1.19"
27
- spec.add_development_dependency "pry", "~> 0.10.1"
28
27
  spec.add_development_dependency "vcr", "~> 2.9.3"
29
28
 
30
29
  spec.add_dependency "nokogiri", "~> 1.6.3"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oxford_learners_dictionaries
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felipe Pelizaro Gentil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-31 00:00:00.000000000 Z
11
+ date: 2015-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.19'
83
- - !ruby/object:Gem::Dependency
84
- name: pry
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 0.10.1
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 0.10.1
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: vcr
99
85
  requirement: !ruby/object:Gem::Requirement