google-search_rank 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/google/search_rank.rb +17 -27
- data/lib/google/search_rank/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 979b91a4dd13f3617cbd4d4cbf5871b08c7fc716
|
4
|
+
data.tar.gz: c9914adc001381e0e58af8b3e5c5aebcb4b76168
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf571ce192b8025d9330285b4ca9671d2043988ae1f13fb118d5f0162b8c9126e373ae1360b5cd102559fcf1b014c988b0897ea9f5f543d75ce0247d91a89d41
|
7
|
+
data.tar.gz: d7ced24c85d9e68c85289655ad4c2146859824c53d11783a3aa7f799f97841fe2cec247690f5e8fcbb99d7649b22dbdfecdaebeb0883236c5e9814aa82b39ab2
|
data/README.md
CHANGED
@@ -20,7 +20,10 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
```ruby
|
24
|
+
client = Google::SearchRank.new(api_key: "xxxx", cse_id: "xxxx")
|
25
|
+
rank = client.find("KEYWORD", %r{http://example.com/.*})
|
26
|
+
```
|
24
27
|
|
25
28
|
## Development
|
26
29
|
|
data/lib/google/search_rank.rb
CHANGED
@@ -7,42 +7,32 @@ module Google
|
|
7
7
|
AUDIENCE = "https://accounts.google.com/o/oauth2/token"
|
8
8
|
SCOPE = "https://www.googleapis.com/auth/cse"
|
9
9
|
|
10
|
-
def initialize(
|
11
|
-
|
12
|
-
api_key
|
13
|
-
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@client_id = client_id
|
17
|
-
@client_secret = client_secret
|
10
|
+
def initialize(application_name: "google-search_rank",
|
11
|
+
application_version: "1.0",
|
12
|
+
api_key:,
|
13
|
+
cse_id:)
|
14
|
+
@application_name = application_name
|
15
|
+
@application_version = application_version
|
18
16
|
@api_key = api_key
|
19
17
|
@cse_id = cse_id
|
20
18
|
end
|
21
19
|
|
22
|
-
def
|
23
|
-
|
24
|
-
application_name: @
|
20
|
+
def client
|
21
|
+
Google::APIClient.new(
|
22
|
+
application_name: @application_name,
|
23
|
+
application_version: @application_version,
|
24
|
+
authorization: nil
|
25
25
|
)
|
26
|
-
key = Google::APIClient::KeyUtils.load_from_pkcs12(
|
27
|
-
@key_path, @key_pass
|
28
|
-
)
|
29
|
-
@client.authorization = Signet::OAuth2::Client.new(
|
30
|
-
:token_credential_uri => TOKEN_CREDENTIAL_URI,
|
31
|
-
:audience => AUDIENCE,
|
32
|
-
:scope => SCOPE,
|
33
|
-
:issuer => @client_secret,
|
34
|
-
:signing_key => key,
|
35
|
-
)
|
36
|
-
@client.authorization.fetch_access_token!
|
37
|
-
@search = @client.discovered_api('customsearch')
|
38
26
|
end
|
39
27
|
|
40
|
-
def
|
41
|
-
|
28
|
+
def service
|
29
|
+
client.discovered_api('customsearch')
|
30
|
+
end
|
42
31
|
|
32
|
+
def find(query, link, page = 1)
|
43
33
|
start = (page - 1) * 10 + 1
|
44
|
-
result =
|
45
|
-
|
34
|
+
result = client.execute(
|
35
|
+
service.cse.list,
|
46
36
|
'key' => @api_key,
|
47
37
|
'cx' => @cse_id,
|
48
38
|
'q' => query,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-search_rank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaki Komagata
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-api-client
|
@@ -96,3 +96,4 @@ signing_key:
|
|
96
96
|
specification_version: 4
|
97
97
|
summary: Easy to get to Google Search ranks.
|
98
98
|
test_files: []
|
99
|
+
has_rdoc:
|