google_suggest 0.1.0 → 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
  SHA1:
3
- metadata.gz: 97a251c55415e7ecf907421034dd5a120c6cd9c7
4
- data.tar.gz: fb6b46af27920ff5da1770dba21925a23e5d37cf
3
+ metadata.gz: a3ead4838ea1a4c82772cb5c723e644b75b7a292
4
+ data.tar.gz: a378ffc7c5d3d521cd76dc15ccdb90592ac8ba73
5
5
  SHA512:
6
- metadata.gz: d802d3d3f7d3508c895f66b327c1f0817bbdcc94630e92ea1cd0a51e3314185aa9db748c26f3fe0650db130dbfa967ba16baedf597ddb5ddc8c41558b5a010d5
7
- data.tar.gz: 4517dc27d8908a516ae2214701432fc922cef2661c7afd5d23e082afafec3ff148db838dbcc247db4729b943db4f4c569a657a1a90dd3852f81539a97a4de080
6
+ metadata.gz: 342ab56bc62c168fd9ad5696b55d592b0f7cbf704539d33f42f9c2333c5c0adca8da92fc65530c243056a43d7997f668a6a45ba835033481247a5e02276a2474
7
+ data.tar.gz: 6579290639cc00c65eaaaf340df5997cf004c487726c14587f2573066c0de1b60780aa72a8a93bd0369a4f2c66e33c9e273bd3e5d1fc4c70f2c43562e9600e05
@@ -1,3 +1,9 @@
1
+ ## GoogleSuggest 1.0.0
2
+
3
+ * Removing the dependency on `nokogiri`, use REXML. [#10](https://github.com/satoryu/google_suggest/pull/10)
4
+ * Fix `NameError: uninitialized constant GoogleSuggest::Region::DEFAULT_GOOGLE_HOST`. [#11](https://github.com/satoryu/google_suggest/pull/11)
5
+ * Allows to get all supported region codes with `GoogleSuggest::Region.codes`. [#14](https://github.com/satoryu/google_suggest/pull/14)
6
+
1
7
  ## GoogleSuggest 0.1.0
2
8
 
3
9
  * `GoogleSuggest.suggest_for` supports `region` [#2](https://github.com/satoryu/google_suggest/issues/2)
@@ -1,16 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- google_suggest (0.1.0)
5
- nokogiri (~> 1.6.0)
4
+ google_suggest (1.0.0)
6
5
 
7
6
  GEM
8
7
  remote: https://rubygems.org/
9
8
  specs:
10
9
  diff-lcs (1.2.5)
11
- mini_portile2 (2.0.0)
12
- nokogiri (1.6.7.2)
13
- mini_portile2 (~> 2.0.0.rc2)
14
10
  rake (11.1.2)
15
11
  rspec (2.14.1)
16
12
  rspec-core (~> 2.14.0)
data/README.md CHANGED
@@ -26,17 +26,18 @@ Or install it yourself as:
26
26
 
27
27
  ```ruby
28
28
  GoogleSuggest.suggest_for 'google'
29
- => [{"suggestion"=>"google"}, {"suggestion"=>"google maps"}, {"suggestion"=>"google translate"}, {"suggestion"=>"google classroom"}, {"suggestion"=>"google docs"}, {"suggestion"=>"google drive"}, {"suggestion"=>"google earth"}, {"suggestion"=>"google play"}, {"suggestion"=>"google scholar"}, {"suggestion"=>"google slides"}]
30
-
29
+ => ["google", "google maps", "google translate", "google classroom", "google docs", "google drive", "google earth", "google play", "google scholar", "google slides"]
31
30
  ```
32
31
 
33
32
  and allows developers to switch the endpoint by specifying `region` option:
34
33
 
35
34
  ```ruby
36
- GoogleSuggest.suggest_for 'google'
37
- => [{"suggestion"=>"google maps"}, {"suggestion"=>"google"}, {"suggestion"=>"google translate"}, {"suggestion"=>"google drive"}, {"suggestion"=>"google scholar"}, {"suggestion"=>"google docs"}, {"suggestion"=>"google news"}, {"suggestion"=>"google flights"}, {"suggestion"=>"google play"}, {"suggestion"=>"google earth"}]
35
+ GoogleSuggest.suggest_for 'google', region: 'jp'
36
+ => ["google", "google maps", "google drive", "google translate", "google scholar", "google docs", "google flights", "google news", "google play", "google earth"]
38
37
  ```
39
38
 
39
+ You can get all available region codes by `GoogleSuggest::Region.codes`.
40
+
40
41
  ## Development
41
42
 
42
43
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -18,8 +18,6 @@ Gem::Specification.new do |spec|
18
18
  'spec/**/*'
19
19
  ]
20
20
 
21
- spec.add_runtime_dependency "nokogiri", '~> 1.6.0'
22
-
23
21
  spec.add_development_dependency 'rake'
24
22
  spec.add_development_dependency 'rspec', '~> 2.14.0'
25
23
  end
@@ -1,8 +1,6 @@
1
- # encoding: utf-8
2
-
3
1
  require 'uri'
4
- require 'nokogiri'
5
2
  require 'net/http'
3
+ require 'rexml/document'
6
4
  require 'google_suggest/configuration'
7
5
  require 'google_suggest/region'
8
6
 
@@ -35,20 +33,10 @@ class GoogleSuggest
35
33
  query = {:output => 'toolbar',
36
34
  :hl => self.home_language,
37
35
  :q => URI.encode(keyword)}
36
+
38
37
  res = http_get('/complete/search', query)
39
- xml = Nokogiri::XML(res.body.to_s)
40
- suggestions = []
41
- xml.css('toplevel CompleteSuggestion').each do |node|
42
- suggest = {}
43
- node.children.each do |child|
44
- suggest[child.name] = (child['data'] || child['int'].to_i)
45
- end
46
- if suggest['suggestion'] and not suggest['suggestion'].valid_encoding?
47
- suggest['suggestion'].force_encoding('Shift_JIS').encode!('UTF-8')
48
- end
49
- suggestions << suggest
50
- end
51
- return suggestions
38
+
39
+ return parse(res.body.to_s)
52
40
  end
53
41
 
54
42
  private
@@ -72,4 +60,17 @@ class GoogleSuggest
72
60
  def google_host
73
61
  Region.host_for(region)
74
62
  end
63
+
64
+ def parse(doc)
65
+ xml = REXML::Document.new(doc)
66
+ suggestions = REXML::XPath.match(xml, '/toplevel/CompleteSuggestion/suggestion').each_with_object([]) do |suggest, res|
67
+ data = suggest.attribute('data').value
68
+ if data and !data.valid_encoding?
69
+ data.force_encoding('Shift_JIS').encode!('UTF-8')
70
+ end
71
+ res << data
72
+ end
73
+
74
+ return suggestions
75
+ end
75
76
  end
@@ -1,208 +1,211 @@
1
1
  class GoogleSuggest
2
- GOOGLE_HOSTS = {
3
- ac: 'www.google.ac',
4
- ad: 'www.google.ad',
5
- ae: 'www.google.ae',
6
- af: 'www.google.com.af',
7
- ag: 'www.google.com.ag',
8
- ag: 'www.google.com.ag',
9
- ai: 'www.google.com.ai',
10
- al: 'www.google.al',
11
- am: 'www.google.am',
12
- ao: 'www.google.am',
13
- ar: 'www.google.com.ar',
14
- as: 'www.google.as',
15
- at: 'www.google.at',
16
- au: 'www.google.com.au',
17
- az: 'www.google.az',
18
- ba: 'www.google.ga',
19
- bd: 'www.google.com.bd',
20
- be: 'www.google.be',
21
- bf: 'www.google.bf',
22
- bg: 'www.google.bg',
23
- bh: 'www.google.com.bh',
24
- bi: 'www.google.bi',
25
- bj: 'www.google.bj',
26
- bn: 'www.google.com.bn',
27
- bo: 'www.google.com.bo',
28
- br: 'www.google.com.br',
29
- bs: 'www.google.bs',
30
- bt: 'www.google.bt',
31
- bw: 'www.google.co.bw',
32
- by: 'www.google.by',
33
- bz: 'www.google.com.bz',
34
- ca: 'www.google.ca',
35
- kh: 'www.google.com.kh',
36
- cc: 'www.google.cc',
37
- cd: 'www.google.cd',
38
- cf: 'www.google.cf',
39
- cat: 'www.google.cat',
40
- cg: 'www.google.cg',
41
- ch: 'www.google.ch',
42
- ci: 'www.google.ci',
43
- ck: 'www.google.co.ck',
44
- cl: 'www.google.cl',
45
- cm: 'www.google.cm',
46
- cn: 'www.google.cn',
47
- co: 'www.google.com.co',
48
- cr: 'www.google.co.cr',
49
- cu: 'www.google.com.cu',
50
- cv: 'www.google.cv',
51
- cy: 'www.google.com.cy',
52
- cz: 'www.google.cz',
53
- de: 'www.google.de',
54
- dj: 'www.google.dj',
55
- dk: 'www.google.dk',
56
- dm: 'www.google.dm',
57
- do: 'www.google.com.do',
58
- dz: 'www.google.dz',
59
- ec: 'www.google.com.ec',
60
- ee: 'www.google.ee',
61
- eg: 'www.google.com.eg',
62
- es: 'www.google.es',
63
- et: 'www.google.com.et',
64
- fi: 'www.google.fi',
65
- fj: 'www.google.com.fj',
66
- fm: 'www.google.fm',
67
- fr: 'www.google.fr',
68
- ga: 'www.google.ga',
69
- ge: 'www.google.ge',
70
- gf: 'www.google.gf',
71
- gg: 'www.google.gg',
72
- gh: 'www.google.com.gh',
73
- gi: 'www.google.com.gi',
74
- gl: 'www.google.gl',
75
- gm: 'www.google.gm',
76
- gp: 'www.google.gp',
77
- gr: 'www.google.gr',
78
- gt: 'www.google.com.gt',
79
- gy: 'www.google.gy',
80
- hk: 'www.google.com.hk',
81
- hn: 'www.google.hn',
82
- hr: 'www.google.hr',
83
- ht: 'www.google.ht',
84
- hu: 'www.google.hu',
85
- id: 'www.google.co.id',
86
- iq: 'www.google.iq',
87
- ie: 'www.google.ie',
88
- il: 'www.google.co.il',
89
- im: 'www.google.im',
90
- in: 'www.google.co.in',
91
- io: 'www.google.io',
92
- is: 'www.google.is',
93
- it: 'www.google.it',
94
- je: 'www.google.je',
95
- jm: 'www.google.com.jm',
96
- jo: 'www.google.jo',
97
- jp: 'www.google.co.jp',
98
- ke: 'www.google.co.ke',
99
- ki: 'www.google.ki',
100
- kg: 'www.google.kg',
101
- kr: 'www.google.co.kr',
102
- kw: 'www.google.com.kw',
103
- kz: 'www.google.kz',
104
- la: 'www.google.la',
105
- lb: 'www.google.com.lb',
106
- lc: 'www.google.com.lc',
107
- li: 'www.google.li',
108
- lk: 'www.google.lk',
109
- ls: 'www.google.co.ls',
110
- lt: 'www.google.lt',
111
- lu: 'www.google.lu',
112
- lv: 'www.google.lv',
113
- ly: 'www.google.com.ly',
114
- ma: 'www.google.co.ma',
115
- md: 'www.google.md',
116
- me: 'www.google.me',
117
- mg: 'www.google.mg',
118
- mk: 'www.google.mk',
119
- ml: 'www.google.ml',
120
- mm: 'www.google.com.mm',
121
- mn: 'www.google.mn',
122
- ms: 'www.google.ms',
123
- mt: 'www.google.com.mt',
124
- mu: 'www.google.mu',
125
- mv: 'www.google.mv',
126
- mz: 'www.google.co.mz',
127
- na: 'www.google.com.na',
128
- ne: 'www.google.ne',
129
- nf: 'www.google.com.nf',
130
- ng: 'www.google.com.ng',
131
- ni: 'www.google.com.ni',
132
- nl: 'www.google.nl',
133
- no: 'www.google.no',
134
- np: 'www.google.com.np',
135
- nr: 'www.google.nr',
136
- nu: 'www.google.nu',
137
- nz: 'www.google.co.nz',
138
- om: 'www.google.com.om',
139
- pk: 'www.google.com.pk',
140
- pa: 'www.google.com.pa',
141
- pe: 'www.google.com.pe',
142
- ph: 'www.google.com.ph',
143
- pl: 'www.google.pl',
144
- pg: 'www.google.com.pg',
145
- pn: 'www.google.pn',
146
- pr: 'www.google.com.pr',
147
- ps: 'www.google.ps',
148
- pt: 'www.google.pt',
149
- py: 'www.google.com.py',
150
- qa: 'www.google.com.qa',
151
- ro: 'www.google.ro',
152
- rs: 'www.google.rs',
153
- ru: 'www.google.ru',
154
- rw: 'www.google.rw',
155
- sa: 'www.google.com.sa',
156
- sb: 'www.google.com.sb',
157
- sc: 'www.google.sc',
158
- se: 'www.google.se',
159
- sg: 'www.google.com.sg',
160
- sh: 'www.google.sh',
161
- si: 'www.google.si',
162
- sk: 'www.google.sk',
163
- sl: 'www.google.sl',
164
- sn: 'www.google.sn',
165
- sm: 'www.google.sm',
166
- so: 'www.google.so',
167
- st: 'www.google.st',
168
- sr: 'www.google.sr',
169
- sv: 'www.google.com.sv',
170
- td: 'www.google.td',
171
- tg: 'www.google.tg',
172
- th: 'www.google.co.th',
173
- tj: 'www.google.com.tj',
174
- tk: 'www.google.tk',
175
- tl: 'www.google.tl',
176
- tm: 'www.google.tm',
177
- to: 'www.google.to',
178
- tn: 'www.google.tn',
179
- tr: 'www.google.com.tr',
180
- tt: 'www.google.tt',
181
- tw: 'www.google.com.tw',
182
- tz: 'www.google.co.tz',
183
- ua: 'www.google.com.ua',
184
- ug: 'www.google.co.ug',
185
- uk: 'www.google.co.uk',
186
- com: 'www.google.com',
187
- uy: 'www.google.com.uy',
188
- uz: 'www.google.co.uz',
189
- vc: 'www.google.com.vc',
190
- ve: 'www.google.co.ve',
191
- vg: 'www.google.vg',
192
- vi: 'www.google.co.vi',
193
- vn: 'www.google.com.vn',
194
- vu: 'www.google.vu',
195
- ws: 'www.google.ws',
196
- za: 'www.google.co.za',
197
- zm: 'www.google.co.zm',
198
- zw: 'www.google.co.zw'
199
- }
200
-
201
2
  class Region
3
+ GOOGLE_HOSTS = { # :nodoc:
4
+ ac: 'www.google.ac',
5
+ ad: 'www.google.ad',
6
+ ae: 'www.google.ae',
7
+ af: 'www.google.com.af',
8
+ ag: 'www.google.com.ag',
9
+ ag: 'www.google.com.ag',
10
+ ai: 'www.google.com.ai',
11
+ al: 'www.google.al',
12
+ am: 'www.google.am',
13
+ ao: 'www.google.am',
14
+ ar: 'www.google.com.ar',
15
+ as: 'www.google.as',
16
+ at: 'www.google.at',
17
+ au: 'www.google.com.au',
18
+ az: 'www.google.az',
19
+ ba: 'www.google.ga',
20
+ bd: 'www.google.com.bd',
21
+ be: 'www.google.be',
22
+ bf: 'www.google.bf',
23
+ bg: 'www.google.bg',
24
+ bh: 'www.google.com.bh',
25
+ bi: 'www.google.bi',
26
+ bj: 'www.google.bj',
27
+ bn: 'www.google.com.bn',
28
+ bo: 'www.google.com.bo',
29
+ br: 'www.google.com.br',
30
+ bs: 'www.google.bs',
31
+ bt: 'www.google.bt',
32
+ bw: 'www.google.co.bw',
33
+ by: 'www.google.by',
34
+ bz: 'www.google.com.bz',
35
+ ca: 'www.google.ca',
36
+ kh: 'www.google.com.kh',
37
+ cc: 'www.google.cc',
38
+ cd: 'www.google.cd',
39
+ cf: 'www.google.cf',
40
+ cat: 'www.google.cat',
41
+ cg: 'www.google.cg',
42
+ ch: 'www.google.ch',
43
+ ci: 'www.google.ci',
44
+ ck: 'www.google.co.ck',
45
+ cl: 'www.google.cl',
46
+ cm: 'www.google.cm',
47
+ cn: 'www.google.cn',
48
+ co: 'www.google.com.co',
49
+ cr: 'www.google.co.cr',
50
+ cu: 'www.google.com.cu',
51
+ cv: 'www.google.cv',
52
+ cy: 'www.google.com.cy',
53
+ cz: 'www.google.cz',
54
+ de: 'www.google.de',
55
+ dj: 'www.google.dj',
56
+ dk: 'www.google.dk',
57
+ dm: 'www.google.dm',
58
+ do: 'www.google.com.do',
59
+ dz: 'www.google.dz',
60
+ ec: 'www.google.com.ec',
61
+ ee: 'www.google.ee',
62
+ eg: 'www.google.com.eg',
63
+ es: 'www.google.es',
64
+ et: 'www.google.com.et',
65
+ fi: 'www.google.fi',
66
+ fj: 'www.google.com.fj',
67
+ fm: 'www.google.fm',
68
+ fr: 'www.google.fr',
69
+ ga: 'www.google.ga',
70
+ ge: 'www.google.ge',
71
+ gf: 'www.google.gf',
72
+ gg: 'www.google.gg',
73
+ gh: 'www.google.com.gh',
74
+ gi: 'www.google.com.gi',
75
+ gl: 'www.google.gl',
76
+ gm: 'www.google.gm',
77
+ gp: 'www.google.gp',
78
+ gr: 'www.google.gr',
79
+ gt: 'www.google.com.gt',
80
+ gy: 'www.google.gy',
81
+ hk: 'www.google.com.hk',
82
+ hn: 'www.google.hn',
83
+ hr: 'www.google.hr',
84
+ ht: 'www.google.ht',
85
+ hu: 'www.google.hu',
86
+ id: 'www.google.co.id',
87
+ iq: 'www.google.iq',
88
+ ie: 'www.google.ie',
89
+ il: 'www.google.co.il',
90
+ im: 'www.google.im',
91
+ in: 'www.google.co.in',
92
+ io: 'www.google.io',
93
+ is: 'www.google.is',
94
+ it: 'www.google.it',
95
+ je: 'www.google.je',
96
+ jm: 'www.google.com.jm',
97
+ jo: 'www.google.jo',
98
+ jp: 'www.google.co.jp',
99
+ ke: 'www.google.co.ke',
100
+ ki: 'www.google.ki',
101
+ kg: 'www.google.kg',
102
+ kr: 'www.google.co.kr',
103
+ kw: 'www.google.com.kw',
104
+ kz: 'www.google.kz',
105
+ la: 'www.google.la',
106
+ lb: 'www.google.com.lb',
107
+ lc: 'www.google.com.lc',
108
+ li: 'www.google.li',
109
+ lk: 'www.google.lk',
110
+ ls: 'www.google.co.ls',
111
+ lt: 'www.google.lt',
112
+ lu: 'www.google.lu',
113
+ lv: 'www.google.lv',
114
+ ly: 'www.google.com.ly',
115
+ ma: 'www.google.co.ma',
116
+ md: 'www.google.md',
117
+ me: 'www.google.me',
118
+ mg: 'www.google.mg',
119
+ mk: 'www.google.mk',
120
+ ml: 'www.google.ml',
121
+ mm: 'www.google.com.mm',
122
+ mn: 'www.google.mn',
123
+ ms: 'www.google.ms',
124
+ mt: 'www.google.com.mt',
125
+ mu: 'www.google.mu',
126
+ mv: 'www.google.mv',
127
+ mz: 'www.google.co.mz',
128
+ na: 'www.google.com.na',
129
+ ne: 'www.google.ne',
130
+ nf: 'www.google.com.nf',
131
+ ng: 'www.google.com.ng',
132
+ ni: 'www.google.com.ni',
133
+ nl: 'www.google.nl',
134
+ no: 'www.google.no',
135
+ np: 'www.google.com.np',
136
+ nr: 'www.google.nr',
137
+ nu: 'www.google.nu',
138
+ nz: 'www.google.co.nz',
139
+ om: 'www.google.com.om',
140
+ pk: 'www.google.com.pk',
141
+ pa: 'www.google.com.pa',
142
+ pe: 'www.google.com.pe',
143
+ ph: 'www.google.com.ph',
144
+ pl: 'www.google.pl',
145
+ pg: 'www.google.com.pg',
146
+ pn: 'www.google.pn',
147
+ pr: 'www.google.com.pr',
148
+ ps: 'www.google.ps',
149
+ pt: 'www.google.pt',
150
+ py: 'www.google.com.py',
151
+ qa: 'www.google.com.qa',
152
+ ro: 'www.google.ro',
153
+ rs: 'www.google.rs',
154
+ ru: 'www.google.ru',
155
+ rw: 'www.google.rw',
156
+ sa: 'www.google.com.sa',
157
+ sb: 'www.google.com.sb',
158
+ sc: 'www.google.sc',
159
+ se: 'www.google.se',
160
+ sg: 'www.google.com.sg',
161
+ sh: 'www.google.sh',
162
+ si: 'www.google.si',
163
+ sk: 'www.google.sk',
164
+ sl: 'www.google.sl',
165
+ sn: 'www.google.sn',
166
+ sm: 'www.google.sm',
167
+ so: 'www.google.so',
168
+ st: 'www.google.st',
169
+ sr: 'www.google.sr',
170
+ sv: 'www.google.com.sv',
171
+ td: 'www.google.td',
172
+ tg: 'www.google.tg',
173
+ th: 'www.google.co.th',
174
+ tj: 'www.google.com.tj',
175
+ tk: 'www.google.tk',
176
+ tl: 'www.google.tl',
177
+ tm: 'www.google.tm',
178
+ to: 'www.google.to',
179
+ tn: 'www.google.tn',
180
+ tr: 'www.google.com.tr',
181
+ tt: 'www.google.tt',
182
+ tw: 'www.google.com.tw',
183
+ tz: 'www.google.co.tz',
184
+ ua: 'www.google.com.ua',
185
+ ug: 'www.google.co.ug',
186
+ uk: 'www.google.co.uk',
187
+ com: 'www.google.com',
188
+ uy: 'www.google.com.uy',
189
+ uz: 'www.google.co.uz',
190
+ vc: 'www.google.com.vc',
191
+ ve: 'www.google.co.ve',
192
+ vg: 'www.google.vg',
193
+ vi: 'www.google.co.vi',
194
+ vn: 'www.google.com.vn',
195
+ vu: 'www.google.vu',
196
+ ws: 'www.google.ws',
197
+ za: 'www.google.co.za',
198
+ zm: 'www.google.co.zm',
199
+ zw: 'www.google.co.zw'
200
+ }.freeze
201
+
202
202
  def self.host_for(region_code=nil)
203
- region_code = :com if region_code.nil?
204
203
  region_code = region_code.to_sym if region_code.is_a?(String)
205
- GOOGLE_HOSTS[region_code] || DEFAULT_GOOGLE_HOST
204
+ GOOGLE_HOSTS[region_code] || GOOGLE_HOSTS[:com]
205
+ end
206
+
207
+ def self.codes
208
+ GOOGLE_HOSTS.keys
206
209
  end
207
210
  end
208
211
  end
@@ -1,3 +1,3 @@
1
1
  class GoogleSuggest
2
- VERSION = '0.1.0'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -18,5 +18,19 @@ describe GoogleSuggest::Region do
18
18
  should be_eql('www.google.ac')
19
19
  end
20
20
  end
21
+ context 'when giving an undefined region code like "zz"' do
22
+ let(:region_code) { 'zz' }
23
+
24
+ it 'should be the default host' do
25
+ should be_eql('www.google.com')
26
+ end
27
+ end
28
+ end
29
+
30
+ describe '.codes' do
31
+ subject { GoogleSuggest::Region.codes }
32
+
33
+ it { should be_a(Array) }
34
+ it { should be_all { |k| k.is_a?(Symbol) } }
21
35
  end
22
36
  end
@@ -107,14 +107,7 @@ describe GoogleSuggest do
107
107
  it 'all suggestions should have the value of the key \'suggest\' 'do
108
108
  suggestions = @google_suggest.suggest_for 'google'
109
109
  suggestions.should be_all do |suggest|
110
- not suggest['suggest'].nil?
111
- end
112
- end
113
-
114
- it 'all suggestions should have the value of the key \'num_queries\' 'do
115
- suggestions = @google_suggest.suggest_for 'google'
116
- suggestions.should be_all do |suggest|
117
- not suggest['num_queries'].nil?
110
+ not suggest.nil?
118
111
  end
119
112
  end
120
113
  end
@@ -137,7 +130,8 @@ describe GoogleSuggest do
137
130
  end
138
131
  allow(@google_suggest).to receive(:http_get) { res }
139
132
  end
140
- subject {@google_suggest.suggest_for('グーグル').shift['suggestion']}
133
+
134
+ subject { @google_suggest.suggest_for('グーグル').shift }
141
135
 
142
136
  its(:encoding) { should be Encoding.find("UTF-8") }
143
137
  it { should be_valid_encoding }
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_suggest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tatsuya Sato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-23 00:00:00.000000000 Z
11
+ date: 2016-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: nokogiri
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 1.6.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 1.6.0
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement