chrome_store_search 0.0.12 → 0.0.13

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: be6b9f3bae780ac91fcd65f3b0e92441fd469cfb
4
- data.tar.gz: 21c60e6280cab6dd033bdb030ddf0820ad9ec6a1
3
+ metadata.gz: 8c330206c99634a44751e3bdbb2dd31bbcd574e3
4
+ data.tar.gz: 1ec9e1d8b01e0528c99b41615ba5d364a4dbd1c4
5
5
  SHA512:
6
- metadata.gz: 77d28d08d1e51fbcfb01c4e38b3c45e6a43f2c552584ee46891ccd0151214d7197d7ae392caebaf49c3ce4c711c84c2c1288aa9f366d5070d71ef0f797338751
7
- data.tar.gz: 1b3075ed5dffd8224fc9f44823f92d18cb418ebaaf7e66269895d86c5cd87c66a9a36781ee0711fe31c071bcd0fae3d012957126b5a44a64c0e740072a2ad5a2
6
+ metadata.gz: c993f2576278ec87c32dfeab444ef5a3f20eca184126536ee1d9c7e0c996c1d332457a3d92fd166da6390dff5209361dd3b51ec9eb229441d3309c694ee9bc3b
7
+ data.tar.gz: 9fffdbd04cf4232d2a1fea9de2f129a237ec14565a82c06002f03717ccd4f99479286a3c266b08a070cf901172d90c56ce1d94a22edfc203fcd6e5311f6aa654
@@ -7,12 +7,11 @@ require File.expand_path(File.dirname(__FILE__) + '/string_utility')
7
7
 
8
8
  module ChromeStoreSearch
9
9
  class Search
10
+ CHROME_STORE_SEARCH_URL = 'https://chrome.google.com/webstore/ajax/item?'.freeze
10
11
 
11
- CHROME_STORE_SEARCH_URL = "https://chrome.google.com/webstore/ajax/item?"
12
-
13
- DEFAULT_SEARCH_CONDITION = {:hl =>"en-US",
14
- :count => 20,
15
- :category => nil}
12
+ DEFAULT_SEARCH_CONDITION = { hl: 'en-US',
13
+ count: 20,
14
+ category: nil }.freeze
16
15
 
17
16
  def initialize(search_condition = DEFAULT_SEARCH_CONDITION)
18
17
  @search_condition = DEFAULT_SEARCH_CONDITION.merge(search_condition)
@@ -20,7 +19,7 @@ module ChromeStoreSearch
20
19
 
21
20
  def search(keyword)
22
21
  @keyword = keyword
23
- conn = Faraday.new(:url => init_query_url) do |faraday|
22
+ conn = Faraday.new(url: init_query_url) do |faraday|
24
23
  faraday.request :url_encoded # form-encode POST params
25
24
  faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
26
25
  end
@@ -31,12 +30,12 @@ module ChromeStoreSearch
31
30
  private
32
31
 
33
32
  def init_query_url
34
- query_url = ""
33
+ query_url = ''
35
34
  query_url << CHROME_STORE_SEARCH_URL
36
35
  query_url << "hl=#{@search_condition[:hl]}"
37
36
  query_url << "&count=#{@search_condition[:count]}"
38
37
  query_url << "&pv=#{StringUtility.get_pv}"
39
- query_url << "&container=CHROME&sortBy=0"
38
+ query_url << '&container=CHROME&sortBy=0'
40
39
  query_url << "&category=#{@search_condition[:category]}" if @search_condition[:category]
41
40
  query_url << "&searchTerm=#{CGI.escape(@keyword)}"
42
41
  end
@@ -4,28 +4,27 @@ require 'nokogiri'
4
4
 
5
5
  module ChromeStoreSearch
6
6
  class StringUtility
7
-
8
- CHROME_STORE_URL = "https://chrome.google.com/webstore/category/apps"
7
+ CHROME_STORE_URL = 'https://chrome.google.com/webstore/category/apps'.freeze
9
8
 
10
9
  def self.gsub_continuation_commas(json_str)
11
10
  json_str.gsub(/,,,*/) do |commas_str|
12
- replace_str = ""
13
- (commas_str.size-1).times do |index|
14
- replace_str += ",\"\""
11
+ replace_str = ''
12
+ (commas_str.size - 1).times do |_index|
13
+ replace_str += ',""'
15
14
  end
16
- commas_str = replace_str + ","
15
+ commas_str = replace_str + ','
17
16
  end
18
17
  end
19
18
 
20
19
  def self.get_pv
21
- conn = Faraday.new(:url => CHROME_STORE_URL) do |faraday|
20
+ conn = Faraday.new(url: CHROME_STORE_URL) do |faraday|
22
21
  faraday.request :url_encoded # form-encode POST params
23
22
  faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
24
23
  end
25
24
  res = conn.get ''
26
25
  doc = Nokogiri::HTML(res.body)
27
- cws_session_data = doc.xpath("//script[@id='cws-session-data']").first.content
28
- JSON.parse(cws_session_data)[-9]
26
+ cws_session_data = doc.xpath("//script[@id='cws-session-data']").first.content
27
+ JSON.parse(cws_session_data)[-12]
29
28
  end
30
29
  end
31
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chrome_store_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grant Chen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-09 00:00:00.000000000 Z
11
+ date: 2015-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  version: '0'
102
102
  requirements: []
103
103
  rubyforge_project:
104
- rubygems_version: 2.4.5
104
+ rubygems_version: 2.5.1
105
105
  signing_key:
106
106
  specification_version: 4
107
107
  summary: chrome web store search