lita-google-ranking 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/LICENSE +19 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/lib/lita/handlers/google-ranking.rb +49 -0
- data/lib/lita-google-ranking.rb +1 -0
- data/lita-google-ranking.gemspec +24 -0
- data/spec/lita/handlers/google-ranking_spec.rb +16 -0
- data/spec/spec_helper.rb +2 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 70c45ed2588615a2f38d8d29fd02fc54382e8d89
|
4
|
+
data.tar.gz: 15fc50a7236af23397cf33c6183c6e119a35bb9e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ae65a1cd401f6154b4b81a13226a66e5ff7d184f8d87d35da9c6f4e574fbf218384692b5847f1b91dae04f460b77cf0cd9fc88cbe78115df181b36cd1f60ac12
|
7
|
+
data.tar.gz: cd5a74ed9f1bd8d136190bc70eab802b784b9373552bab930055fc5575a6089675ef80b1fbab0427db4ba4fc44336ce8cd8858f0567e1980b7d20e8da6e5c3f0
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2013 marsz
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# lita-google-ranking
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/marsz/lita-google-ranking.png?branch=master)](https://travis-ci.org/marsz/lita-google-ranking)
|
4
|
+
|
5
|
+
Lita (robot) handler for getting rank of DOMAIN on google web search with a KEYWORD.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add lita-google-ranking to your Lita instance's Gemfile:
|
10
|
+
|
11
|
+
``` ruby
|
12
|
+
gem "lita-google-ranking"
|
13
|
+
```
|
14
|
+
|
15
|
+
## Configuration
|
16
|
+
|
17
|
+
in `lita_config.rb`
|
18
|
+
|
19
|
+
```
|
20
|
+
config.google_ranking.gl = "tw"
|
21
|
+
config.google_ranking.lr = "lang_zh"
|
22
|
+
config.google_ranking.cr = "countryTW"
|
23
|
+
```
|
24
|
+
|
25
|
+
- `gl` : http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes
|
26
|
+
- `lr` : https://developers.google.com/custom-search/docs/xml_results?hl=en&csw=1#languageCollections
|
27
|
+
- `cr` : https://developers.google.com/custom-search/docs/xml_results?hl=en&csw=1#countryCollections
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
`lita gr DOMAIN KEYWORD` : send KEYWORD to google web search, and return rank of DOMAIN from search results
|
32
|
+
|
33
|
+
```
|
34
|
+
"KEYWORD" ranking of DOMAIN is 3
|
35
|
+
```
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
[MIT](http://opensource.org/licenses/MIT)
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require "lita"
|
2
|
+
require "google-search"
|
3
|
+
|
4
|
+
module Lita
|
5
|
+
module Handlers
|
6
|
+
class GoogleRanking < Handler
|
7
|
+
|
8
|
+
def self.default_config(config)
|
9
|
+
# http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes
|
10
|
+
config.gl = nil
|
11
|
+
# https://developers.google.com/custom-search/docs/xml_results?hl=en&csw=1#languageCollections
|
12
|
+
config.lr = nil
|
13
|
+
# https://developers.google.com/custom-search/docs/xml_results?hl=en&csw=1#countryCollections
|
14
|
+
config.cr = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
route /^gr\s+([^ ]+)\s+(.+)/i, :gr, :help => {
|
18
|
+
"gr DOMAIN KEYWORD" => "send KEYWORD to google web search, and return rank of DOMAIN from search results"
|
19
|
+
}
|
20
|
+
def gr(response)
|
21
|
+
# raise response.matches.inspect
|
22
|
+
domain = response.matches.first.first
|
23
|
+
keyword = response.matches.first[1]
|
24
|
+
results = Google::Search::Web.new(:query => keyword, :safety_level => :off, :gl => config(:gl), :lr => config(:lr), :cr => config(:cr), :size => :large)
|
25
|
+
rank = nil
|
26
|
+
results.each do |res|
|
27
|
+
if res.uri.index(domain)
|
28
|
+
rank = res.index + 1
|
29
|
+
break
|
30
|
+
end
|
31
|
+
end
|
32
|
+
if rank
|
33
|
+
response.reply "\"#{keyword}\" ranking of #{domain} is #{rank}"
|
34
|
+
else
|
35
|
+
response.reply "\"#{keyword}\" ranking of #{domain} doesn't appear in search restults"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def config(key)
|
42
|
+
Lita.config.handlers.google_ranking.send(key)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
Lita.register_handler(GoogleRanking)
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "lita/handlers/google-ranking"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-google-ranking"
|
3
|
+
spec.version = "1.0.0"
|
4
|
+
spec.authors = ["marsz"]
|
5
|
+
spec.email = ["marsz330@gmail.com"]
|
6
|
+
spec.description = "fetch keyword ranking on google search for a domain"
|
7
|
+
spec.summary = "fetch keyword ranking on google search for a domain"
|
8
|
+
spec.homepage = "https://github.com/marsz/lita-google-ranking"
|
9
|
+
spec.license = "MIT"
|
10
|
+
|
11
|
+
spec.files = `git ls-files`.split($/)
|
12
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
13
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
|
16
|
+
spec.add_runtime_dependency "lita", "~> 2.6"
|
17
|
+
spec.add_runtime_dependency "google-search", "~> 1.0.3"
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
+
spec.add_development_dependency "rake"
|
21
|
+
spec.add_development_dependency "rspec", ">= 2.14"
|
22
|
+
|
23
|
+
spec.metadata = { "lita_plugin_type" => "handler" }
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::GoogleRanking, :lita_handler => true do
|
4
|
+
|
5
|
+
context "#gr" do
|
6
|
+
|
7
|
+
it "success" do
|
8
|
+
send_command("gr apple.com mac")
|
9
|
+
expect(replies.size).to be > 0
|
10
|
+
expect(replies.first).not_to match("doesn't")
|
11
|
+
expect(replies.first).to match(" is ")
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-google-ranking
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- marsz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lita
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: google-search
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.14'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.14'
|
83
|
+
description: fetch keyword ranking on google search for a domain
|
84
|
+
email:
|
85
|
+
- marsz330@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- .rspec
|
92
|
+
- .travis.yml
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- lib/lita-google-ranking.rb
|
98
|
+
- lib/lita/handlers/google-ranking.rb
|
99
|
+
- lita-google-ranking.gemspec
|
100
|
+
- spec/lita/handlers/google-ranking_spec.rb
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
homepage: https://github.com/marsz/lita-google-ranking
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata:
|
106
|
+
lita_plugin_type: handler
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.1.5
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: fetch keyword ranking on google search for a domain
|
127
|
+
test_files:
|
128
|
+
- spec/lita/handlers/google-ranking_spec.rb
|
129
|
+
- spec/spec_helper.rb
|