google_suggest 1.0.2 → 1.0.3

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: cda7a8c51269519a0b274daf814125cc62438dc749a969b1287befa05481282a
4
- data.tar.gz: a3d5628a8ac383e32ecaa008b594e56491ba07905b799d25061ceabd3b062713
3
+ metadata.gz: 6a3e9bdc9fbba9c974aaef9edc750bf7e25ada054f4b4d61bce93f024092abda
4
+ data.tar.gz: 33ddf30287efc93bf8a52ae5e1d3db696203d88a6b2baea9a16d3d5abf13d783
5
5
  SHA512:
6
- metadata.gz: 1595d5acf65ae8e05c1367dee6cd8702093e0f6de4e5d6703edd73ad9b01278a1b5e9b157e2596fb4ff72ce02b665093476fed827ede375f94e1122b57e15a89
7
- data.tar.gz: cbf6177ab3bfd89da79ffd9ba50e380609b50ef48f514229073b36b51fbff91f6bf149671b4e847867424918d1d912090456a767887543199e54767972a0ae37
6
+ metadata.gz: 597d07a3b8abc51b26c02e16c7e14ba13a515e2a81f5358a782b2f8e5fcdc11310ef0d6b9ded2670c531e2831a47c161ab805a38ead317cdf05b86055160846e
7
+ data.tar.gz: b88ec7c3f0d8f42b3439a840d49b952a8824a2852277e45b00537c9a3d38c5b30de4f6e7ac491fa58d90b238cf8a560bcf7bbcbcdb361fcd40bf4af261119107
@@ -1,6 +1,10 @@
1
1
  # ChangeLog
2
2
 
3
- ## (Next Release)
3
+ ## GoogleSuggest 1.0.3
4
+
5
+ * BugFix: Failed to parse Suggest API response since encoding issue. [#29](https://github.com/satoryu/google_suggest/pull/29)
6
+
7
+ ## GoogleSuggest 1.0.2
4
8
 
5
9
  * Drop ruby 2.3 from supported ruby versions. [#25](https://github.com/satoryu/google_suggest/pull/25)
6
10
  * Made `Region` module since it has never been instantiated. [#26](https://github.com/satoryu/google_suggest/pull/26)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- google_suggest (1.0.2)
4
+ google_suggest (1.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -64,13 +64,10 @@ class GoogleSuggest
64
64
  end
65
65
 
66
66
  def parse(doc)
67
+ doc = doc.encode('UTF-8', 'Shift_JIS') unless doc.valid_encoding?
67
68
  xml = REXML::Document.new(doc)
68
- suggestions = REXML::XPath.match(xml, '/toplevel/CompleteSuggestion/suggestion').each_with_object([]) do |suggest, res|
69
- data = suggest.attribute('data').value
70
- if data && !data.valid_encoding?
71
- data.force_encoding('Shift_JIS').encode!('UTF-8')
72
- end
73
- res << data
69
+ suggestions = REXML::XPath.match(xml, '/toplevel/CompleteSuggestion/suggestion').map do |suggest|
70
+ suggest.attribute('data').value
74
71
  end
75
72
 
76
73
  suggestions
@@ -1,3 +1,3 @@
1
1
  class GoogleSuggest
2
- VERSION = '1.0.2'.freeze
2
+ VERSION = '1.0.3'.freeze
3
3
  end
@@ -99,7 +99,7 @@ describe GoogleSuggest do
99
99
  end
100
100
  end
101
101
 
102
- describe '#suggest_from' do
102
+ describe '#suggest_for' do
103
103
  before :all do
104
104
  GoogleSuggest.configure do |c|
105
105
  c.home_language = 'us'
@@ -1 +1 @@
1
- <?xml version="1.0"?><toplevel><CompleteSuggestion><suggestion data="グーグル"/><num_queries int="13000000"/></CompleteSuggestion><CompleteSuggestion><suggestion data="グーグルマップ"/><num_queries int="293000000"/></CompleteSuggestion><CompleteSuggestion><suggestion data="グーグルアース"/><num_queries int="183000000"/></CompleteSuggestion><CompleteSuggestion><suggestion data="グーグルクローム"/><num_queries int="782000"/></CompleteSuggestion><CompleteSuggestion><suggestion data="グーグルカレンダー"/><num_queries int="9830000"/></CompleteSuggestion><CompleteSuggestion><suggestion data="グーグル翻訳"/><num_queries int="5140000"/></CompleteSuggestion><CompleteSuggestion><suggestion data="グーグルショッピング"/><num_queries int="21900000"/></CompleteSuggestion><CompleteSuggestion><suggestion data="グーグルスカラー"/><num_queries int="91600"/></CompleteSuggestion><CompleteSuggestion><suggestion data="グーグルメール"/><num_queries int="62700000"/></CompleteSuggestion><CompleteSuggestion><suggestion data="グーグルドキュメント"/><num_queries int="2260000"/></CompleteSuggestion></toplevel>
1
+ <?xml version="1.0"?><toplevel><CompleteSuggestion><suggestion data="�O�[�O���}�b�v"/></CompleteSuggestion><CompleteSuggestion><suggestion data="�O�[�O��"/></CompleteSuggestion><CompleteSuggestion><suggestion data="�O�[�O���|��"/></CompleteSuggestion><CompleteSuggestion><suggestion data="�O�[�O���A�[�X"/></CompleteSuggestion><CompleteSuggestion><suggestion data="�O�[�O���h���C�u"/></CompleteSuggestion><CompleteSuggestion><suggestion data="�O�[�O���t�H�g"/></CompleteSuggestion><CompleteSuggestion><suggestion data="�O�[�O���J�����_�["/></CompleteSuggestion><CompleteSuggestion><suggestion data="�O�[�O���A�J�E���g"/></CompleteSuggestion><CompleteSuggestion><suggestion data="�O�[�O���A�i���e�B�N�X"/></CompleteSuggestion><CompleteSuggestion><suggestion data="�O�[�O���t�H�[��"/></CompleteSuggestion></toplevel>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_suggest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tatsuya Sato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-01 00:00:00.000000000 Z
11
+ date: 2019-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake