datarank-v2 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cbbd9653bcb72faad9457a9214f41d85e00330dd
4
+ data.tar.gz: 35472803e629c3474b0720e65853052f081bf88b
5
+ SHA512:
6
+ metadata.gz: 92adfa552b18d5849acd5c3f05e26762763ffe661e8edc9d0d2028bc8e5e3b79af0e018904834d41fbaa9ddf9f222dcb21c11676f3b54a7e39cd87232e466563
7
+ data.tar.gz: e7bec3d0271f5d24922a7fa7d533db3000b6fd3ed0c2c66777d796e4ac6bac307fb7c6e17cf7c6aea292ec38dca6fef723d2ed6ac23a5bf312df51b3df1d56ae
@@ -0,0 +1,37 @@
1
+ .idea
2
+
3
+ *.gem
4
+ *.rbc
5
+ /.config
6
+ /coverage/
7
+ /InstalledFiles
8
+ /pkg/
9
+ /spec/reports/
10
+ /test/tmp/
11
+ /test/version_tmp/
12
+ /tmp/
13
+ /vendor/
14
+
15
+ ## Specific to RubyMotion:
16
+ .dat*
17
+ .repl_history
18
+ build/
19
+
20
+ ## Documentation cache and generated files:
21
+ /.yardoc/
22
+ /_yardoc/
23
+ /doc/
24
+ /rdoc/
25
+
26
+ ## Environment normalisation:
27
+ /.bundle/
28
+ /lib/bundler/man/
29
+
30
+ # for a library or gem, you might want to ignore these files since the code is
31
+ # intended to run in multiple environments; otherwise, check them in:
32
+ # Gemfile.lock
33
+ # .ruby-version
34
+ # .ruby-gemset
35
+
36
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
37
+ .rvmrc
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+ env:
7
+ global:
@@ -0,0 +1 @@
1
+ --no-private
@@ -0,0 +1,3 @@
1
+ 0.1-0.2
2
+ ---
3
+ Alpha release of DataRank Ruby Library
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'guard-rspec'
5
+ gem 'guard-yard'
6
+ gem 'pry'
7
+ gem 'yard'
8
+ gem 'rb-readline'
9
+ end
10
+
11
+ group :test do
12
+ gem 'rspec'
13
+ gem 'simplecov', :require => false
14
+ gem 'vcr', '~> 2.9.0'
15
+ gem 'webmock', '>= 1.18.0'
16
+ gem "codeclimate-test-reporter", require: nil
17
+ end
18
+
19
+ gemspec
@@ -0,0 +1,117 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ datarank (1.3.0)
5
+ hashie (>= 1.2.0)
6
+ httparty (>= 0.8.3)
7
+ json (>= 1.8.2)
8
+ multi_json (>= 1.3.4)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ addressable (2.3.7)
14
+ celluloid (0.16.0)
15
+ timers (~> 4.0.0)
16
+ codeclimate-test-reporter (0.4.7)
17
+ simplecov (>= 0.7.1, < 1.0.0)
18
+ coderay (1.1.0)
19
+ crack (0.4.2)
20
+ safe_yaml (~> 1.0.0)
21
+ diff-lcs (1.2.5)
22
+ docile (1.1.5)
23
+ ffi (1.9.8)
24
+ formatador (0.2.5)
25
+ guard (2.12.5)
26
+ formatador (>= 0.2.4)
27
+ listen (~> 2.7)
28
+ lumberjack (~> 1.0)
29
+ nenv (~> 0.1)
30
+ notiffany (~> 0.0)
31
+ pry (>= 0.9.12)
32
+ shellany (~> 0.0)
33
+ thor (>= 0.18.1)
34
+ guard-compat (1.2.1)
35
+ guard-rspec (4.5.0)
36
+ guard (~> 2.1)
37
+ guard-compat (~> 1.1)
38
+ rspec (>= 2.99.0, < 4.0)
39
+ guard-yard (2.1.4)
40
+ guard (>= 1.1.0)
41
+ yard (>= 0.7.0)
42
+ hashie (3.4.2)
43
+ hitimes (1.2.2)
44
+ httparty (0.13.5)
45
+ json (~> 1.8)
46
+ multi_xml (>= 0.5.2)
47
+ json (1.8.3)
48
+ listen (2.9.0)
49
+ celluloid (>= 0.15.2)
50
+ rb-fsevent (>= 0.9.3)
51
+ rb-inotify (>= 0.9)
52
+ lumberjack (1.0.9)
53
+ method_source (0.8.2)
54
+ multi_json (1.11.0)
55
+ multi_xml (0.5.5)
56
+ nenv (0.2.0)
57
+ notiffany (0.0.6)
58
+ nenv (~> 0.1)
59
+ shellany (~> 0.0)
60
+ pry (0.10.1)
61
+ coderay (~> 1.1.0)
62
+ method_source (~> 0.8.1)
63
+ slop (~> 3.4)
64
+ rake (10.4.2)
65
+ rb-fsevent (0.9.4)
66
+ rb-inotify (0.9.5)
67
+ ffi (>= 0.5.0)
68
+ rb-readline (0.5.2)
69
+ rspec (3.2.0)
70
+ rspec-core (~> 3.2.0)
71
+ rspec-expectations (~> 3.2.0)
72
+ rspec-mocks (~> 3.2.0)
73
+ rspec-core (3.2.2)
74
+ rspec-support (~> 3.2.0)
75
+ rspec-expectations (3.2.0)
76
+ diff-lcs (>= 1.2.0, < 2.0)
77
+ rspec-support (~> 3.2.0)
78
+ rspec-mocks (3.2.1)
79
+ diff-lcs (>= 1.2.0, < 2.0)
80
+ rspec-support (~> 3.2.0)
81
+ rspec-support (3.2.2)
82
+ safe_yaml (1.0.4)
83
+ shellany (0.0.1)
84
+ simplecov (0.9.2)
85
+ docile (~> 1.1.0)
86
+ multi_json (~> 1.0)
87
+ simplecov-html (~> 0.9.0)
88
+ simplecov-html (0.9.0)
89
+ slop (3.6.0)
90
+ thor (0.19.1)
91
+ timers (4.0.1)
92
+ hitimes
93
+ vcr (2.9.3)
94
+ webmock (1.20.4)
95
+ addressable (>= 2.3.6)
96
+ crack (>= 0.3.2)
97
+ yard (0.8.7.6)
98
+
99
+ PLATFORMS
100
+ ruby
101
+
102
+ DEPENDENCIES
103
+ codeclimate-test-reporter
104
+ datarank!
105
+ guard-rspec
106
+ guard-yard
107
+ pry
108
+ rake
109
+ rb-readline
110
+ rspec
111
+ simplecov
112
+ vcr (~> 2.9.0)
113
+ webmock (>= 1.18.0)
114
+ yard
115
+
116
+ BUNDLED WITH
117
+ 1.10.5
@@ -0,0 +1,11 @@
1
+ guard :rspec do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
6
+
7
+ guard 'yard' do
8
+ watch(%r{lib/.+\.rb})
9
+ watch(%r{docs/.+\.md})
10
+ watch(%r{README\.md})
11
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2015 DataRank, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,63 @@
1
+ # DataRank API Ruby Library
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/datarank.svg)](http://badge.fury.io/rb/datarank)
4
+ [![Build Status](https://travis-ci.org/datarank/datarank-ruby.svg)](https://travis-ci.org/datarank/datarank-ruby/master)
5
+ [![Code Climate](https://codeclimate.com/github/datarank/datarank-ruby/badges/gpa.svg)](https://codeclimate.com/github/datarank/
6
+ datarank-ruby)
7
+
8
+ ## Documentation
9
+
10
+ [http://www.rubydoc.info/github/datarank/datarank-ruby/master](http://www.rubydoc.info/github/datarank/datarank-ruby/master)
11
+
12
+ ## Installation
13
+
14
+ ` gem install datarank `
15
+
16
+ ## Getting Started
17
+
18
+
19
+ **Instance method usage:**
20
+ ```ruby
21
+ client = Datarank::Client.new(api_key, api_version)
22
+ topics = client.all_topics
23
+ ```
24
+
25
+ ### Authentication
26
+
27
+ ```ruby
28
+ client = Datarank::Client.new(api_key, api_version)
29
+ ```
30
+
31
+ ## More Examples
32
+
33
+ **Fetch comments for a topic**
34
+
35
+ ```ruby
36
+ client = Datarank::Client.new(api_key, api_version)
37
+ comments = client.comments_search "tide-pods", {limit: 10}
38
+ ```
39
+
40
+
41
+ ## License
42
+
43
+ The MIT License (MIT)
44
+
45
+ Copyright (c) 2014-2015 DataRank, Inc.
46
+
47
+ Permission is hereby granted, free of charge, to any person obtaining a copy
48
+ of this software and associated documentation files (the "Software"), to deal
49
+ in the Software without restriction, including without limitation the rights
50
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
51
+ copies of the Software, and to permit persons to whom the Software is
52
+ furnished to do so, subject to the following conditions:
53
+
54
+ The above copyright notice and this permission notice shall be included in all
55
+ copies or substantial portions of the Software.
56
+
57
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
58
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
59
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
60
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
61
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
62
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
63
+ SOFTWARE.
@@ -0,0 +1,9 @@
1
+ require 'bundler'
2
+
3
+ Bundler::GemHelper.install_tasks
4
+
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :test => :spec
9
+ task :default => :spec
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'datarank/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "datarank-v2"
8
+ gem.version = Datarank::Version.to_s
9
+ gem.authors = ["Evan Sitzes"]
10
+ gem.email = ["evan@simplymeasured.com"]
11
+ gem.description = "Ruby Wrapper for the DataRank REST API"
12
+ gem.summary = [""]
13
+ gem.homepage = "https://github.com/datarank/datarank-ruby"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency "rake"
21
+
22
+ gem.add_dependency "httparty", ">= 0.8.3"
23
+ gem.add_dependency "multi_json", ">= 1.3.4"
24
+ gem.add_dependency "hashie", ">= 1.2.0"
25
+ gem.add_dependency "json", ">= 1.8.2"
26
+ end
@@ -0,0 +1,27 @@
1
+ require "json"
2
+ require "datarank/version"
3
+ require "datarank/client"
4
+
5
+ module Datarank
6
+ class << self
7
+
8
+ # A Datarank::Client, used when calling methods on the Datarank module itself.
9
+ #
10
+ # @return [Datarank::Client]
11
+ def client(api_key=nil, api_version=nil, options={})
12
+ @client ||= Datarank::Client.new(api_key, api_version, options)
13
+ end
14
+
15
+ def respond_to?(method_name, include_private = false)
16
+ client.respond_to?(method_name, include_private) || super
17
+ end
18
+
19
+ # private
20
+
21
+ # def method_missing(method_name, *args, &block)
22
+ # return super unless client.respond_to?(method_name)
23
+ # client.send(method_name, *args, &block)
24
+ # end
25
+
26
+ end
27
+ end
@@ -0,0 +1,116 @@
1
+ require 'httparty'
2
+ require 'multi_json'
3
+ require 'hashie'
4
+ require 'time'
5
+ require 'securerandom'
6
+
7
+ require "datarank/comments"
8
+ require "datarank/datasources"
9
+ require "datarank/fizzle"
10
+ require "datarank/interaction"
11
+ require "datarank/likes"
12
+ require "datarank/live"
13
+ require "datarank/locations"
14
+ require "datarank/reach"
15
+ require "datarank/retailers"
16
+ require "datarank/sentiment"
17
+ require "datarank/themes"
18
+ require "datarank/topic_administration"
19
+ require "datarank/topics"
20
+ require "datarank/volume"
21
+ require "datarank/wordcloud"
22
+ require "datarank/search"
23
+ require "datarank/social_stats"
24
+
25
+
26
+ module Datarank
27
+ class Client
28
+ include HTTParty
29
+
30
+ include Datarank::Client::Topics
31
+ include Datarank::Client::Comments
32
+ include Datarank::Client::Datasources
33
+ include Datarank::Client::Fizzle
34
+ include Datarank::Client::Interaction
35
+ include Datarank::Client::Likes
36
+ include Datarank::Client::Live
37
+ include Datarank::Client::Locations
38
+ include Datarank::Client::Reach
39
+ include Datarank::Client::Retailers
40
+ include Datarank::Client::Sentiment
41
+ include Datarank::Client::Themes
42
+ include Datarank::Client::Volume
43
+ include Datarank::Client::Wordcloud
44
+ include Datarank::Client::Search
45
+ include Datarank::Client::SocialStats
46
+ include Datarank::Client::TopicAdministration
47
+
48
+ BASE_URI = 'https://api.datarank.com'
49
+
50
+ def initialize(api_key=nil, api_version=nil, options={})
51
+ @api_key = api_key
52
+ @api_version = api_version ? api_version : "v1";
53
+
54
+ # defaults
55
+ options[:base_uri] ||= BASE_URI
56
+ @base_uri = options[:base_uri]
57
+ options[:format] ||= :json
58
+ options.each do |k,v|
59
+ self.class.send k, v
60
+ end
61
+ end
62
+
63
+ # Wrappers for the main HTTP verbs
64
+
65
+ def get(path, options={})
66
+ http_verb :get, path, options
67
+ end
68
+
69
+ def post(path, options={})
70
+ http_verb :post, path, options
71
+ end
72
+
73
+ def put(path, options={})
74
+ http_verb :put, path, options
75
+ end
76
+
77
+ def delete(path, options={})
78
+ http_verb :delete, path, options
79
+ end
80
+
81
+ def http_verb(verb, path, options={})
82
+
83
+ if [:get, :delete].include? verb
84
+ request_options = {}
85
+ path = "#{path}?#{URI.encode_www_form(options)}" if !options.empty?
86
+ else
87
+ request_options = {body: options.to_json}
88
+ end
89
+
90
+ headers = {
91
+ 'Authorization' => "Bearer #{@api_key}",
92
+ "Content-Type" => "application/json",
93
+ "Accept" => "application/vnd.datarank.#{@api_version}+json"
94
+ }
95
+
96
+ request_options[:headers] = headers
97
+
98
+ r = self.class.send(verb, path, request_options)
99
+ # FIXME: raise errors on actual error packages
100
+ parsed_json = JSON.parse(r.body)
101
+ if parsed_json.is_a? Array
102
+ parsed_json = {objects: parsed_json}
103
+ end
104
+
105
+ hash = Hashie::Mash.new(parsed_json)
106
+ raise Error.new(hash.error) if hash.error
107
+ raise Error.new(hash.errors.join(", ")) if hash.errors
108
+ hash
109
+ end
110
+
111
+ class Error < StandardError; end
112
+
113
+ private
114
+
115
+ end
116
+ end
@@ -0,0 +1,26 @@
1
+ module Datarank
2
+ class Client
3
+
4
+ # Module containing methods for interacting with comments
5
+ module Comments
6
+
7
+ # Query interface for comments correlated to a topic
8
+ #
9
+ # @param slug [String] A topic's unique identifier slug
10
+ # @option options [1..1000] :limit The number of items to return.
11
+ # @option options - all query options available in API docs
12
+ def comments_search(slug, options={})
13
+ get "/topics/#{slug}/comments", options
14
+ end
15
+
16
+ # Query interface for top 20 comments correlated to a topic by datarank score
17
+ #
18
+ # @param slug [String] A topic's unique identifier slug
19
+ def comments_top(slug, options={})
20
+ get "/topics/#{slug}/comments/top", options
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ module Datarank
2
+ class Client
3
+
4
+ # Module containing methods for interacting with datasources
5
+ module Datasources
6
+
7
+ # Return unique datasources correlated to a topic
8
+ #
9
+ # @param slug [String] A topic's unique identifier slug
10
+ def datasources(slug, options={})
11
+ get "/topics/#{slug}/datasources", options
12
+ end
13
+
14
+ # Return unique datasources correlated to a topic grouped by type
15
+ #
16
+ # @param slug [String] A topic's unique identifier slug
17
+ def datasources_by_type(slug, options={})
18
+ get "/topics/#{slug}/datasources/types", options
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,34 @@
1
+ module Datarank
2
+ class Client
3
+
4
+ module Fizzle
5
+
6
+ # Validate a fizzle query's syntax
7
+ #
8
+ # @param options [String] :q Fizzle Query
9
+ # @note Fizzle query requires 'fizzle: ' be prepended to query
10
+ def fizzle_validate query
11
+ post "/fizzle/validate", {q: query}
12
+ end
13
+
14
+ # Test a fizzle query against a given set of comments
15
+ #
16
+ # @param query [String] :q Fizzle Query
17
+ # @param query [Array< Hash{ comment: String } >] :comments Array of comments to match against
18
+ # @note Fizzle query requires 'fizzle: ' be prepended to query
19
+ def fizzle_match query
20
+ post "/fizzle/match", query
21
+ end
22
+
23
+ # Filter a 100,000 comment sample with a fizzle query
24
+ #
25
+ # @param query [String] :q Fizzle Query
26
+ # @note Fizzle query requires 'fizzle: ' be prepended to query
27
+ def fizzle_search query
28
+ post "/fizzle/search", {q: query}
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,45 @@
1
+ module Datarank
2
+ class Client
3
+
4
+ # Module containing methods for interacting with a topic's interaction data
5
+ module Interaction
6
+
7
+ # Fetch interaction for a topic grouped by a time interval
8
+ #
9
+ # @param slug [String] A topic's unique identifier slug
10
+ def interaction_secondly(slug, options={})
11
+ get "/topics/#{slug}/interaction/secondly", options
12
+ end
13
+
14
+ def interaction_minutely(slug, options={})
15
+ get "/topics/#{slug}/interaction/minutely", options
16
+ end
17
+
18
+ def interaction_hourly(slug, options={})
19
+ get "/topics/#{slug}/interaction/hourly", options
20
+ end
21
+
22
+ def interaction_daily(slug, options={})
23
+ get "/topics/#{slug}/interaction/daily", options
24
+ end
25
+
26
+ def interaction_weekly(slug, options={})
27
+ get "/topics/#{slug}/interaction/weekly", options
28
+ end
29
+
30
+ def interaction_monthly(slug, options={})
31
+ get "/topics/#{slug}/interaction/monthly", options
32
+ end
33
+
34
+ def interaction_quarterly(slug, options={})
35
+ get "/topics/#{slug}/interaction/quarterly", options
36
+ end
37
+
38
+ def interaction_yearly(slug, options={})
39
+ get "/topics/#{slug}/interaction/yearly", options
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,45 @@
1
+ module Datarank
2
+ class Client
3
+
4
+ # Module containing methods for interacting with a topic's likes data
5
+ module Likes
6
+
7
+ # Fetch likes for a topic grouped by a time interval
8
+ #
9
+ # @param slug [String] A topic's unique identifier slug
10
+ def likes_secondly(slug, options={})
11
+ get "/topics/#{slug}/likes/secondly", options
12
+ end
13
+
14
+ def likes_minutely(slug, options={})
15
+ get "/topics/#{slug}/likes/minutely", options
16
+ end
17
+
18
+ def likes_hourly(slug, options={})
19
+ get "/topics/#{slug}/likes/hourly", options
20
+ end
21
+
22
+ def likes_daily(slug, options={})
23
+ get "/topics/#{slug}/likes/daily", options
24
+ end
25
+
26
+ def likes_weekly(slug, options={})
27
+ get "/topics/#{slug}/likes/weekly", options
28
+ end
29
+
30
+ def likes_monthly(slug, options={})
31
+ get "/topics/#{slug}/likes/monthly", options
32
+ end
33
+
34
+ def likes_quarterly(slug, options={})
35
+ get "/topics/#{slug}/likes/quarterly", options
36
+ end
37
+
38
+ def likes_yearly(slug, options={})
39
+ get "/topics/#{slug}/likes/yearly", options
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,24 @@
1
+ module Datarank
2
+ class Client
3
+
4
+ # Module containing methods for interacting with live search
5
+ module Live
6
+
7
+ # Query twitter data with a query string and return volume points grouped by day
8
+ #
9
+ # @param query [String] Phrase to search twitter
10
+ def twitter_volume_daily query
11
+ get "/search/twitter/volume/daily", {query: query}
12
+ end
13
+
14
+ # Query twitter data with a query string and return tweets
15
+ #
16
+ # @param query [String] Phrase to search twitter
17
+ def tweets query
18
+ get "/search/twitter", {query: query}
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,31 @@
1
+ module Datarank
2
+ class Client
3
+
4
+ # Module containing methods for interacting with geocoded data
5
+ module Locations
6
+
7
+ # Fetch location pins for a topic
8
+ #
9
+ # @param slug [String] A topic's unique identifier slug
10
+ def location_pins(slug, options={})
11
+ get "/topics/#{slug}/location/pins", options
12
+ end
13
+
14
+ # Fetch location provinces data for a topic
15
+ #
16
+ # @param slug [String] A topic's unique identifier slug
17
+ def location_provinces(slug, options={})
18
+ get "/topics/#{slug}/location/provinces", options
19
+ end
20
+
21
+ # Fetch location heatmap data for a topic
22
+ #
23
+ # @param slug [String] A topic's unique identifier slug
24
+ def location_heatmap(slug, options={})
25
+ get "/topics/#{slug}/location/heatmap", options
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,45 @@
1
+ module Datarank
2
+ class Client
3
+
4
+ # Module containing methods for interacting with a topic's reach data
5
+ module Reach
6
+
7
+ # Fetch reach for a topic grouped by a time interval
8
+ #
9
+ # @param slug [String] A topic's unique identifier slug
10
+ def reach_secondly(slug, options={})
11
+ get "/topics/#{slug}/reach/secondly", options
12
+ end
13
+
14
+ def reach_minutely(slug, options={})
15
+ get "/topics/#{slug}/reach/minutely", options
16
+ end
17
+
18
+ def reach_hourly(slug, options={})
19
+ get "/topics/#{slug}/reach/hourly", options
20
+ end
21
+
22
+ def reach_daily(slug, options={})
23
+ get "/topics/#{slug}/reach/daily", options
24
+ end
25
+
26
+ def reach_weekly(slug, options={})
27
+ get "/topics/#{slug}/reach/weekly", options
28
+ end
29
+
30
+ def reach_monthly(slug, options={})
31
+ get "/topics/#{slug}/reach/monthly", options
32
+ end
33
+
34
+ def reach_quarterly(slug, options={})
35
+ get "/topics/#{slug}/reach/quarterly", options
36
+ end
37
+
38
+ def reach_yearly(slug, options={})
39
+ get "/topics/#{slug}/reach/yearly", options
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,17 @@
1
+ module Datarank
2
+ class Client
3
+
4
+ # Module containing methods for interacting with a topic's correlated retailers
5
+ module Retailers
6
+
7
+ # Fetch retailers correlated to a topic
8
+ #
9
+ # @param slug [String] A topic's unique identifier slug
10
+ def retailers(slug, options={})
11
+ get "/topics/#{slug}/retailers", options
12
+ end
13
+
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ module Datarank
2
+ class Client
3
+
4
+ # Module containing methods raw search
5
+ module Search
6
+
7
+ # Return comments based on an elastic search json compliant query
8
+ #
9
+ # @param search_object [String] A JSON object compliant with Elastic Search query format
10
+ # @param slug [String] A topic's unique identifier slug
11
+ def search(topic_slug, search_object)
12
+ post "/topics/#{topic_slug}/search", search_object
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,45 @@
1
+ module Datarank
2
+ class Client
3
+
4
+ # Module containing methods for interacting with a topic's sentiment data
5
+ module Sentiment
6
+
7
+ # Fetch sentiment for a topic grouped by a time interval
8
+ #
9
+ # @param slug [String] A topic's unique identifier slug
10
+ def sentiment_secondly(slug, options={})
11
+ get "/topics/#{slug}/sentiment/secondly", options
12
+ end
13
+
14
+ def sentiment_minutely(slug, options={})
15
+ get "/topics/#{slug}/sentiment/minutely", options
16
+ end
17
+
18
+ def sentiment_hourly(slug, options={})
19
+ get "/topics/#{slug}/sentiment/hourly", options
20
+ end
21
+
22
+ def sentiment_daily(slug, options={})
23
+ get "/topics/#{slug}/sentiment/daily", options
24
+ end
25
+
26
+ def sentiment_weekly(slug, options={})
27
+ get "/topics/#{slug}/sentiment/weekly", options
28
+ end
29
+
30
+ def sentiment_monthly(slug, options={})
31
+ get "/topics/#{slug}/sentiment/monthly", options
32
+ end
33
+
34
+ def sentiment_quarterly(slug, options={})
35
+ get "/topics/#{slug}/sentiment/quarterly", options
36
+ end
37
+
38
+ def sentiment_yearly(slug, options={})
39
+ get "/topics/#{slug}/sentiment/yearly", options
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,17 @@
1
+ module Datarank
2
+ class Client
3
+
4
+ # Module containing methods for interacting with a topic's social stats
5
+ module SocialStats
6
+
7
+ # Fetch social stats correlated to a topic
8
+ #
9
+ # @param slug [String] A topic's unique identifier slug
10
+ def social_stats(slug, options={})
11
+ get "/topics/#{slug}/social/stats", options
12
+ end
13
+
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,32 @@
1
+ module Datarank
2
+ class Client
3
+
4
+ # Module containing methods for interacting with a topic's themes
5
+ module Themes
6
+
7
+ # Return themes assigned to a topic
8
+ #
9
+ # @param slug [String] A topic's unique identifier slug
10
+ def themes(slug, options={})
11
+ get "/topics/#{slug}/themes", options
12
+ end
13
+
14
+ # Return trend for a specific theme on a topic
15
+ #
16
+ # @param slug [String] A topic's unique identifier slug
17
+ # @param theme_id [Integer] Unique ID of theme
18
+ def themes_trend(slug, theme_id, options={})
19
+ get "/topics/#{slug}/themes/trend/#{theme_id}", options
20
+ end
21
+
22
+ # Return table for correlation between all themes on a topic
23
+ #
24
+ # @param slug [String] A topic's unique identifier slug
25
+ def themes_correlation(slug, options={})
26
+ get "/topics/#{slug}/themes/correlation", options
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,22 @@
1
+ module Datarank
2
+ class Client
3
+
4
+ # Module containing method for interacting with the topic CRUD endpoints
5
+ module TopicAdministration
6
+
7
+ def create_topic(options={})
8
+ post "/topics", options
9
+ end
10
+
11
+ def edit_topic(slug, options={})
12
+ put "/topics/#{slug}", options
13
+ end
14
+
15
+ def delete_topic(slug)
16
+ delete "/topics/#{slug}"
17
+ end
18
+
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,24 @@
1
+ module Datarank
2
+ class Client
3
+
4
+ # Module containing methods for interacting with topics
5
+ module Topics
6
+
7
+ # Return all topics
8
+ #
9
+ # @option options [1..1000] :limit The number of items to return.
10
+ def all_topics options={}
11
+ get '/topics', options
12
+ end
13
+
14
+ # Return single topic by slug
15
+ #
16
+ # @param slug [String] A topic's unique identifier slug
17
+ def find_topic(slug, options={})
18
+ get "/topics/#{slug}", options
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,14 @@
1
+ module Datarank
2
+ # A class for managing Datarank's Version
3
+ class Version
4
+ MAJOR = 1
5
+ MINOR = 0
6
+ PATCH = 0
7
+
8
+ class << self
9
+ def to_s
10
+ [MAJOR, MINOR, PATCH].join('.')
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,66 @@
1
+ module Datarank
2
+ class Client
3
+
4
+ # Module containing methods for interacting with topics
5
+ module Volume
6
+
7
+ # Return volume for a topic grouped by a time interval
8
+ #
9
+ # @param slug [String] A topic's unique identifier slug
10
+ def volume_secondly(slug, options={})
11
+ get "/topics/#{slug}/volume/secondly", options
12
+ end
13
+
14
+ def volume_minutely(slug, options={})
15
+ get "/topics/#{slug}/volume/minutely", options
16
+ end
17
+
18
+ def volume_hourly(slug, options={})
19
+ get "/topics/#{slug}/volume/hourly", options
20
+ end
21
+
22
+ def volume_daily(slug, options={})
23
+ get "/topics/#{slug}/volume/daily", options
24
+ end
25
+
26
+ def volume_weekly(slug, options={})
27
+ get "/topics/#{slug}/volume/weekly", options
28
+ end
29
+
30
+ def volume_monthly(slug, options={})
31
+ get "/topics/#{slug}/volume/monthly", options
32
+ end
33
+
34
+ def volume_quarterly(slug, options={})
35
+ get "/topics/#{slug}/volume/quarterly", options
36
+ end
37
+
38
+ def volume_yearly(slug, options={})
39
+ get "/topics/#{slug}/volume/yearly", options
40
+ end
41
+
42
+ # Return hourly average volume for a topic
43
+ #
44
+ # @param slug [String] A topic's unique identifier slug
45
+ def volume_hourly_average(slug, options={})
46
+ get "/topics/#{slug}/volume/hourly/average", options
47
+ end
48
+
49
+ # Return day-of-week volume for a topic
50
+ #
51
+ # @param slug [String] A topic's unique identifier slug
52
+ def volume_weekday(slug, options={})
53
+ get "/topics/#{slug}/volume/weekday", options
54
+ end
55
+
56
+ # Return hourly day-of-week heatmap information for a topic
57
+ #
58
+ # @param slug [String] A topic's unique identifier slug
59
+ def volume_weekday_heatmap_hourly(slug, options={})
60
+ get "/topics/#{slug}/volume/weekday/heatmap/hourly", options
61
+ end
62
+
63
+ end
64
+
65
+ end
66
+ end
@@ -0,0 +1,18 @@
1
+ module Datarank
2
+ class Client
3
+
4
+ # Module containing methods for interacting with a topic's word cloud
5
+ module Wordcloud
6
+
7
+
8
+ # Return word cloud for a topic
9
+ #
10
+ # @param slug [String] A topic's unique identifier slug
11
+ def wordcloud(slug, options={})
12
+ get "/topics/#{slug}/wordcloud", options
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Datarank do
4
+
5
+ it "returns a Datarank::Client" do
6
+ expect(Datarank.client).to be_kind_of Datarank::Client
7
+ end
8
+
9
+ # it "responds to methods on its client" do
10
+ # expect(RedditKit.respond_to?(:username)).to be true
11
+ # end
12
+
13
+ # it "forwards methods to its client" do
14
+ # expect { RedditKit.username }.not_to raise_error
15
+ # end
16
+
17
+ end
@@ -0,0 +1,45 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
+ require 'simplecov'
4
+
5
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[SimpleCov::Formatter::HTMLFormatter]
6
+ SimpleCov.start
7
+
8
+ # require 'dotenv'
9
+ # Dotenv.load
10
+
11
+ require 'datarank'
12
+ require 'rspec'
13
+ require 'webmock/rspec'
14
+ require 'vcr'
15
+
16
+ VCR.configure do |c|
17
+ c.configure_rspec_metadata!
18
+
19
+ c.cassette_library_dir = 'spec/cassettes'
20
+ c.hook_into :webmock
21
+ c.default_cassette_options = { :record => :new_episodes }
22
+ end
23
+
24
+ # The API key for use during testing
25
+ #
26
+ # @return The account's username.
27
+ def datarank_apikey
28
+ ENV.fetch 'DATARANK_AUTHORIZATION_KEY'
29
+ end
30
+
31
+ # The API Version for testing
32
+ #
33
+ # @return The account's username.
34
+ def datarank_api_version
35
+ ENV.fetch 'DATARANK_API_VERSION'
36
+ end
37
+
38
+ # An Datarank object
39
+ #
40
+ # @return The authenticated client.
41
+ def authenticated_client
42
+ VCR.use_cassette('authenticated_client') do
43
+ Datarank::Client.new datarank_apikey, datarank_api_version
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: datarank-v2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Evan Sitzes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-05-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: httparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.8.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.8.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: multi_json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.3.4
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.3.4
55
+ - !ruby/object:Gem::Dependency
56
+ name: hashie
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.2.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.2.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: json
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: 1.8.2
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.8.2
83
+ description: Ruby Wrapper for the DataRank REST API
84
+ email:
85
+ - evan@simplymeasured.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .travis.yml
92
+ - .yardopts
93
+ - CHANGELOG.md
94
+ - Gemfile
95
+ - Gemfile.lock
96
+ - Guardfile
97
+ - LICENSE.md
98
+ - README.md
99
+ - Rakefile
100
+ - datarank.gemspec
101
+ - lib/datarank.rb
102
+ - lib/datarank/client.rb
103
+ - lib/datarank/comments.rb
104
+ - lib/datarank/datasources.rb
105
+ - lib/datarank/fizzle.rb
106
+ - lib/datarank/interaction.rb
107
+ - lib/datarank/likes.rb
108
+ - lib/datarank/live.rb
109
+ - lib/datarank/locations.rb
110
+ - lib/datarank/reach.rb
111
+ - lib/datarank/retailers.rb
112
+ - lib/datarank/search.rb
113
+ - lib/datarank/sentiment.rb
114
+ - lib/datarank/social_stats.rb
115
+ - lib/datarank/themes.rb
116
+ - lib/datarank/topic_administration.rb
117
+ - lib/datarank/topics.rb
118
+ - lib/datarank/version.rb
119
+ - lib/datarank/volume.rb
120
+ - lib/datarank/wordcloud.rb
121
+ - spec/datarank_spec.rb
122
+ - spec/spec_helper.rb
123
+ homepage: https://github.com/datarank/datarank-ruby
124
+ licenses: []
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - '>='
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 2.0.14.1
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: '[""]'
146
+ test_files:
147
+ - spec/datarank_spec.rb
148
+ - spec/spec_helper.rb