datarank 0.2

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: 304cf6063603e0cc2f5f5a6f18d869a7e6b64e87
4
+ data.tar.gz: c15fb91c2288492cb93605775d24aa9518dc0203
5
+ SHA512:
6
+ metadata.gz: 893780eec58cb8bebde06311eebd649fd50ed42151e2fabe17e79f826a950dc2c8d9f1cbb7a90813fb7e9115490e1315286d29d2f4db4c2a851f57d2cd10e427
7
+ data.tar.gz: 532b7098f0aa936ed66c0e258c54bd37b0ebebcfe2a3a7d3e5540d9a9a211cf049da0c883aba5d92381b185a8c33aa1b3f354fee3b125ad3a788fc0802610b08
@@ -0,0 +1,34 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
@@ -0,0 +1,3 @@
1
+ 0.1
2
+ ---
3
+ Alpha release of DataRank Ruby Library
data/Gemfile ADDED
@@ -0,0 +1,10 @@
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
+ end
9
+
10
+ gemspec
@@ -0,0 +1,83 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ datarank (0.2)
5
+ hashie (>= 1.2.0)
6
+ httparty (>= 0.8.3)
7
+ multi_json (>= 1.3.4)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ celluloid (0.16.0)
13
+ timers (~> 4.0.0)
14
+ coderay (1.1.0)
15
+ diff-lcs (1.2.5)
16
+ fakeweb (1.3.0)
17
+ ffi (1.9.6)
18
+ formatador (0.2.5)
19
+ guard (2.10.1)
20
+ formatador (>= 0.2.4)
21
+ listen (~> 2.7)
22
+ lumberjack (~> 1.0)
23
+ pry (>= 0.9.12)
24
+ thor (>= 0.18.1)
25
+ guard-rspec (4.3.1)
26
+ guard (~> 2.1)
27
+ rspec (>= 2.14, < 4.0)
28
+ guard-yard (2.1.4)
29
+ guard (>= 1.1.0)
30
+ yard (>= 0.7.0)
31
+ hashie (3.3.2)
32
+ hitimes (1.2.2)
33
+ httparty (0.13.3)
34
+ json (~> 1.8)
35
+ multi_xml (>= 0.5.2)
36
+ json (1.8.1)
37
+ listen (2.8.3)
38
+ celluloid (>= 0.15.2)
39
+ rb-fsevent (>= 0.9.3)
40
+ rb-inotify (>= 0.9)
41
+ lumberjack (1.0.9)
42
+ method_source (0.8.2)
43
+ multi_json (1.10.1)
44
+ multi_xml (0.5.5)
45
+ pry (0.10.0)
46
+ coderay (~> 1.1.0)
47
+ method_source (~> 0.8.1)
48
+ slop (~> 3.4)
49
+ rake (10.4.2)
50
+ rb-fsevent (0.9.4)
51
+ rb-inotify (0.9.5)
52
+ ffi (>= 0.5.0)
53
+ rspec (2.99.0)
54
+ rspec-core (~> 2.99.0)
55
+ rspec-expectations (~> 2.99.0)
56
+ rspec-mocks (~> 2.99.0)
57
+ rspec-core (2.99.2)
58
+ rspec-expectations (2.99.2)
59
+ diff-lcs (>= 1.1.3, < 2.0)
60
+ rspec-mocks (2.99.2)
61
+ simplecov (0.7.1)
62
+ multi_json (~> 1.0)
63
+ simplecov-html (~> 0.7.1)
64
+ simplecov-html (0.7.1)
65
+ slop (3.6.0)
66
+ thor (0.18.1)
67
+ timers (4.0.1)
68
+ hitimes
69
+ yard (0.8.7.6)
70
+
71
+ PLATFORMS
72
+ ruby
73
+
74
+ DEPENDENCIES
75
+ datarank!
76
+ fakeweb (~> 1.3.0)
77
+ guard-rspec
78
+ guard-yard
79
+ pry
80
+ rake
81
+ rspec (~> 2.12)
82
+ simplecov (~> 0.7.1)
83
+ yard
@@ -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 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,59 @@
1
+ # DataRank API Ruby Library
2
+
3
+ ## Documentation
4
+
5
+ [http://www.rubydoc.info/github/datarank/datarank-ruby/master](http://www.rubydoc.info/github/datarank/datarank-ruby/master)
6
+
7
+ ## Installation
8
+
9
+ ` gem install datarank `
10
+
11
+ ## Getting Started
12
+
13
+ Using bundler, datarank will be automatically included for your project through your gemfile. If you would like to interactively play with the API, use `bundle console`.
14
+
15
+ **Instance method usage:**
16
+ ```ruby
17
+ client = Datarank::Client.new(api_key,api_version)
18
+ topics = client.all_topics
19
+ ```
20
+
21
+ ### Authentication
22
+
23
+ ```ruby
24
+ client = Datarank::Client.new(api_key,api_version)
25
+ ```
26
+
27
+ ## More Examples
28
+
29
+ ** Fetch comments for a topic
30
+
31
+ ```ruby
32
+ client = Datarank::Client.new(api_key,api_version)
33
+ comments = client.comments_search "tide-pods", {limit: 10}
34
+ ```
35
+
36
+
37
+ ## License
38
+
39
+ The MIT License (MIT)
40
+
41
+ Copyright (c) 2014 DataRank, Inc.
42
+
43
+ Permission is hereby granted, free of charge, to any person obtaining a copy
44
+ of this software and associated documentation files (the "Software"), to deal
45
+ in the Software without restriction, including without limitation the rights
46
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
47
+ copies of the Software, and to permit persons to whom the Software is
48
+ furnished to do so, subject to the following conditions:
49
+
50
+ The above copyright notice and this permission notice shall be included in all
51
+ copies or substantial portions of the Software.
52
+
53
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
54
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
55
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
56
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
57
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
58
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
59
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :test => :spec
8
+ task :default => :spec
@@ -0,0 +1,28 @@
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"
8
+ gem.version = Datarank::VERSION
9
+ gem.authors = ["Addam Hardy"]
10
+ gem.email = ["addam@datarank.com"]
11
+ gem.description = ["Ruby Wrapper for the DataRank REST API"]
12
+ gem.summary = [""]
13
+ gem.homepage = "http://www.datarank.com"
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 "rspec", "~> 2.12"
21
+ gem.add_development_dependency "fakeweb", "~> 1.3.0"
22
+ gem.add_development_dependency "rake"
23
+ gem.add_development_dependency 'simplecov', '~> 0.7.1'
24
+
25
+ gem.add_dependency "httparty", ">= 0.8.3"
26
+ gem.add_dependency "multi_json", ">= 1.3.4"
27
+ gem.add_dependency "hashie", ">= 1.2.0"
28
+ 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,79 @@
1
+ require 'httparty'
2
+ require 'multi_json'
3
+ require 'hashie'
4
+ require 'time'
5
+ require 'securerandom'
6
+
7
+ require "datarank/topics"
8
+ require "datarank/comments"
9
+
10
+ module Datarank
11
+ class Client
12
+ include HTTParty
13
+
14
+ include Datarank::Client::Topics
15
+ include Datarank::Client::Comments
16
+
17
+ BASE_URI = 'https://api.datarank.com'
18
+
19
+ def initialize(api_key=nil, api_version=nil, options={})
20
+ @api_key = api_key
21
+ @api_version = api_version ? api_version : "v1";
22
+
23
+ # defaults
24
+ options[:base_uri] ||= BASE_URI
25
+ @base_uri = options[:base_uri]
26
+ options[:format] ||= :json
27
+ options.each do |k,v|
28
+ self.class.send k, v
29
+ end
30
+ end
31
+
32
+ # Wrappers for the main HTTP verbs
33
+
34
+ def get(path, options={})
35
+ http_verb :get, path, options
36
+ end
37
+
38
+ def post(path, options={})
39
+ http_verb :post, path, options
40
+ end
41
+
42
+ def put(path, options={})
43
+ http_verb :put, path, options
44
+ end
45
+
46
+ def delete(path, options={})
47
+ http_verb :delete, path, options
48
+ end
49
+
50
+ def http_verb(verb, path, options={})
51
+
52
+ if [:get, :delete].include? verb
53
+ request_options = {}
54
+ path = "#{path}?#{URI.encode_www_form(options)}" if !options.empty?
55
+ else
56
+ request_options = {body: options.to_json}
57
+ end
58
+
59
+ headers = {
60
+ 'Authorization' => @api_key,
61
+ "Content-Type" => "application/json",
62
+ "Accept" => "application/vnd.datarank.#{@api_version}+json"
63
+ }
64
+
65
+ request_options[:headers] = headers
66
+
67
+ r = self.class.send(verb, path, request_options)
68
+ hash = Hashie::Mash.new(JSON.parse(r.body))
69
+ raise Error.new(hash.error) if hash.error
70
+ raise Error.new(hash.errors.join(", ")) if hash.errors
71
+ hash
72
+ end
73
+
74
+ class Error < StandardError; end
75
+
76
+ private
77
+
78
+ end
79
+ end
@@ -0,0 +1,9 @@
1
+ module Datarank
2
+ class Client
3
+ module Comments
4
+ def comments_search(slug, options={})
5
+ get "/topics/#{slug}/comments", options
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Datarank
2
+ class Client
3
+ module Topics
4
+ def all_topics options={}
5
+ get '/topics', options
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Datarank
2
+ VERSION = "0.2"
3
+ end
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: datarank
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.2'
5
+ platform: ruby
6
+ authors:
7
+ - Addam Hardy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fakeweb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.3.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.7.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.7.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: httparty
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 0.8.3
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 0.8.3
83
+ - !ruby/object:Gem::Dependency
84
+ name: multi_json
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 1.3.4
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 1.3.4
97
+ - !ruby/object:Gem::Dependency
98
+ name: hashie
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 1.2.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 1.2.0
111
+ description: '["Ruby Wrapper for the DataRank REST API"]'
112
+ email:
113
+ - addam@datarank.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - CHANGELOG.md
120
+ - Gemfile
121
+ - Gemfile.lock
122
+ - Guardfile
123
+ - LICENSE.md
124
+ - README.md
125
+ - Rakefile
126
+ - datarank.gemspec
127
+ - lib/datarank.rb
128
+ - lib/datarank/client.rb
129
+ - lib/datarank/comments.rb
130
+ - lib/datarank/topics.rb
131
+ - lib/datarank/version.rb
132
+ homepage: http://www.datarank.com
133
+ licenses: []
134
+ metadata: {}
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 2.2.2
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: '[""]'
155
+ test_files: []
156
+ has_rdoc: