rb_raventools 0.0.3 → 0.0.4
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.
- data/lib/rb_raventools.rb +1 -0
- data/lib/rb_raventools/address.rb +22 -0
- data/lib/rb_raventools/client.rb +59 -29
- data/lib/rb_raventools/version.rb +1 -1
- metadata +2 -1
data/lib/rb_raventools.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
module RavenTools
|
2
|
+
class Address < Client
|
3
|
+
|
4
|
+
def self.build(method, options = {})
|
5
|
+
url = "#{RavenTools::API_BASE_URL}key=#{@@api_key}&format=#{@@format}&method=#{method}"
|
6
|
+
unless options[:domain] == nil
|
7
|
+
url << "&domain=#{options[:domain]}"
|
8
|
+
end
|
9
|
+
unless options[:start_date] == nil
|
10
|
+
url << "&start_date=#{options[:start_date]}"
|
11
|
+
end
|
12
|
+
unless options[:end_date] == nil
|
13
|
+
url << "&end_date=#{options[:end_date]}"
|
14
|
+
end
|
15
|
+
unless options[:engine] == nil
|
16
|
+
url << "&engine=#{options[:engine]}"
|
17
|
+
end
|
18
|
+
return url
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/lib/rb_raventools/client.rb
CHANGED
@@ -5,59 +5,89 @@ module RavenTools
|
|
5
5
|
|
6
6
|
class Client
|
7
7
|
|
8
|
-
attr_accessor :api_key
|
8
|
+
attr_accessor :api_key
|
9
9
|
|
10
10
|
def initialize(api_key)
|
11
|
+
@@api_key = api_key
|
12
|
+
@@format = "json"
|
11
13
|
self.api_key = api_key
|
12
|
-
@format = "json"
|
13
14
|
end
|
14
15
|
|
15
16
|
def profile_info
|
16
|
-
|
17
|
-
|
18
|
-
response = HTTParty.get(raven_url)
|
19
|
-
parsed_response = JSON.parse(response.body)
|
20
|
-
return parsed_response
|
17
|
+
response = HTTParty.get(RavenTools::Address.build("profile_info"))
|
18
|
+
JSON.parse(response.body)
|
21
19
|
end
|
22
20
|
|
23
21
|
def engines
|
24
|
-
|
25
|
-
|
26
|
-
response = HTTParty.get(raven_url)
|
27
|
-
parsed_response = JSON.parse(response.body)
|
28
|
-
return parsed_response
|
22
|
+
response = HTTParty.get(RavenTools::Address.build("engines"))
|
23
|
+
JSON.parse(response.body)
|
29
24
|
end
|
30
25
|
|
31
26
|
def domains
|
32
|
-
|
33
|
-
|
34
|
-
response = HTTParty.get(raven_url)
|
35
|
-
parsed_response = JSON.parse(response.body)
|
36
|
-
return parsed_response
|
27
|
+
response = HTTParty.get(RavenTools::Address.build("domains"))
|
28
|
+
JSON.parse(response.body)
|
37
29
|
end
|
38
30
|
|
39
31
|
def domain_info(domain)
|
40
|
-
|
41
|
-
|
42
|
-
response = HTTParty.get(raven_url)
|
43
|
-
parsed_response = JSON.parse(response.body)
|
44
|
-
return parsed_response
|
32
|
+
response = HTTParty.get(RavenTools::Address.build("domain_info", { domain: domain }))
|
33
|
+
JSON.parse(response.body)
|
45
34
|
end
|
46
35
|
|
47
36
|
def keywords(domain)
|
48
|
-
|
49
|
-
|
50
|
-
|
37
|
+
response = HTTParty.get(RavenTools::Address.build("keywords", { domain: domain }))
|
38
|
+
JSON.parse(response.body)
|
39
|
+
end
|
40
|
+
|
41
|
+
def keyword_info(domain, keyword)
|
42
|
+
method = "keywords_tags"
|
43
|
+
response = HTTParty.get(RavenTools::Address.build(method, { domain: domain }))
|
51
44
|
parsed_response = JSON.parse(response.body)
|
52
|
-
|
45
|
+
keyword_info = [{ keyword: keyword }]
|
46
|
+
parsed_response.each do |keywords|
|
47
|
+
if keywords['keyword'] == keyword
|
48
|
+
keyword_info << { tags: keywords['tags'].to_a }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
return keyword_info
|
53
52
|
end
|
54
53
|
|
55
54
|
def keywords_with_tags(domain)
|
55
|
+
response = HTTParty.get(RavenTools::Address.build("keywords_tags", { domain: domain }))
|
56
|
+
JSON.parse(response.body)
|
57
|
+
end
|
58
|
+
|
59
|
+
def tags(domain)
|
60
|
+
method = "keywords_tags"
|
61
|
+
response = HTTParty.get(RavenTools::Address.build(method, { domain: domain }))
|
62
|
+
parsed_response = JSON.parse(response.body)
|
63
|
+
tags = []
|
64
|
+
parsed_response.each do |keywords|
|
65
|
+
tag_list = keywords['tags'].to_a
|
66
|
+
unless tag_list.size < 1
|
67
|
+
tag_list.each do |tag|
|
68
|
+
unless tags.include? tag
|
69
|
+
tags << tag
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
return tags
|
75
|
+
end
|
76
|
+
|
77
|
+
def tag_info(domain, tag)
|
56
78
|
method = "keywords_tags"
|
57
|
-
|
58
|
-
response = HTTParty.get(raven_url)
|
79
|
+
response = HTTParty.get(RavenTools::Address.build(method, { domain: domain }))
|
59
80
|
parsed_response = JSON.parse(response.body)
|
60
|
-
|
81
|
+
tag_info = [{ tag: tag }]
|
82
|
+
keyword_list = []
|
83
|
+
parsed_response.each do |keywords|
|
84
|
+
tag_list = keywords['tags'].to_a
|
85
|
+
if tag_list.include? tag
|
86
|
+
keyword_list << keywords['keyword']
|
87
|
+
end
|
88
|
+
end
|
89
|
+
tag_info << { keywords: keyword_list }
|
90
|
+
return tag_info
|
61
91
|
end
|
62
92
|
|
63
93
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb_raventools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- README.md
|
58
58
|
- Rakefile
|
59
59
|
- lib/rb_raventools.rb
|
60
|
+
- lib/rb_raventools/address.rb
|
60
61
|
- lib/rb_raventools/base.rb
|
61
62
|
- lib/rb_raventools/client.rb
|
62
63
|
- lib/rb_raventools/version.rb
|