chrome_store_search 0.0.6 → 0.0.7

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: 6f8edd3b6a1153ac7c274d02fd9bf90c4b78bb13
4
- data.tar.gz: 7fbb8b3f76beb5f6f06922d7429f8ae3c2b1b47f
3
+ metadata.gz: 9a7308dd2be4ba22354cdb6b0da9c42f6950bd1e
4
+ data.tar.gz: 1866bf6e5acfbb179017b569565c8c3cf3429153
5
5
  SHA512:
6
- metadata.gz: 1f563c053e20a668adb929e109745fd03426b1513fa1bfe2b306aead612541fc780508f4f7e29aa1dfa211e8b3e55c1679d2dd6c9f3008aa40567a55d12b10d5
7
- data.tar.gz: 34c8c15048d605c5b9b1fafab3e45115ec9ec33986dc9eb1f90f80c78f780ce53e1b87ab600eb3662c7602e65f927580cb7a9b1225bd825776af0b46a2daba32
6
+ metadata.gz: 6a873280fe46559a93421ffe5bbbad072af44c1e4ee42681e7f301208e9fc0c076ad4cc85c2ae41d29deeea63d606869bdb992a5fd5457210a4cb710d255f1cd
7
+ data.tar.gz: d7f06752de98f53213846756bbda647ebbf4188a8815a885bed6ba14cb3d17fb878799211bce249b1360328b8f839747129e2493d34790935901f4d3013bf691
@@ -44,7 +44,7 @@ module ChromeStoreSearch
44
44
  def init_detail_url(id)
45
45
  detail_url = APP_DETAIL_BASE_URL
46
46
  detail_url << "hl=#{@parmeter[:hl]}"
47
- detail_url << "&pv=1394218756"
47
+ detail_url << "&pv=#{StringUtility.get_pv}"
48
48
  detail_url << "&id=#{id}"
49
49
  detail_url << "&container=CHROME"
50
50
  end
@@ -2,13 +2,12 @@ require 'rubygems'
2
2
  require 'cgi'
3
3
  require 'faraday'
4
4
  require File.expand_path(File.dirname(__FILE__) + '/app_parser')
5
+ require File.expand_path(File.dirname(__FILE__) + '/string_utility')
5
6
 
6
7
  module ChromeStoreSearch
7
8
  class Search
8
9
 
9
- CHROME_STORE_URL = "https://chrome.google.com/webstore/"
10
-
11
- CHROME_STORE_SEARCH_URL = CHROME_STORE_URL + "ajax/item?"
10
+ CHROME_STORE_SEARCH_URL = "https://chrome.google.com/webstore/ajax/item?"
12
11
 
13
12
  DEFAULT_SEARCH_CONDITION = {:hl =>"en-US",
14
13
  :count => 20,
@@ -35,20 +34,10 @@ module ChromeStoreSearch
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
- query_url << "&pv=#{get_pv}"
37
+ query_url << "&pv=#{StringUtility.get_pv}"
39
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
43
-
44
- def get_pv
45
- conn = Faraday.new(:url => CHROME_STORE_URL) do |faraday|
46
- faraday.request :url_encoded # form-encode POST params
47
- faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
48
- end
49
- res = conn.get ''
50
- res.body.match(/\/webstore\/static\/(\d+)\/wall/)[1]
51
- end
52
-
53
42
  end
54
- end
43
+ end
@@ -1,5 +1,10 @@
1
+ require 'faraday'
2
+
1
3
  module ChromeStoreSearch
2
4
  class StringUtility
5
+
6
+ CHROME_STORE_URL = "https://chrome.google.com/webstore/"
7
+
3
8
  def self.gsub_continuation_commas(json_str)
4
9
  json_str.gsub(/,,,*/) do |commas_str|
5
10
  replace_str = ""
@@ -9,5 +14,15 @@ module ChromeStoreSearch
9
14
  commas_str = replace_str + ","
10
15
  end
11
16
  end
17
+
18
+
19
+ def self.get_pv
20
+ conn = Faraday.new(:url => CHROME_STORE_URL) do |faraday|
21
+ faraday.request :url_encoded # form-encode POST params
22
+ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
23
+ end
24
+ res = conn.get ''
25
+ res.body.match(/\/webstore\/static\/(\d+)\/wall/)[1]
26
+ end
12
27
  end
13
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chrome_store_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grant Chen