rovi 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MGRhZTM0YmE4Y2JlMWU5ZDJjOTc3ZTYzMTIyNWExY2VkOTRlNDNkMw==
5
+ data.tar.gz: !binary |-
6
+ OWM1Y2IzZGU4NWViMjI3MDQ4NDZhODcyMDJhZmQxYjNiOWI5NGE2Zg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ N2FjZjViMTc3ZjI1YjBhOWViYmY5ZmQ4MzgzMWYzOWU0NDBmYmFmZGY0Mzky
10
+ OGYxMzMyOTk5YjM5ZTE0MjkyMmFjMGExMDJhNGQyZTFhOTkxNGRiYWE0ZmE1
11
+ ODBhYTEzMzE2ZjJmMDYyOTQyY2NjMTNlOGViMWRhNDljZjQxYzU=
12
+ data.tar.gz: !binary |-
13
+ ZGJjNWUyNTBhMzYyNDMyZWYyYjFlZmNlMmI1M2U4MjNhODJjZWU0YmFlMDhi
14
+ NWY5MmZlYmI1ODcxM2YxMzM3NGMzYWM3NTk3MDlmNzE1ZTQwYjliZjk0Zjc2
15
+ YjY3NTRlOWVmMjI0ZGNlMTUzM2Q4YTM1NTBlM2YzMDg4YjEzZjM=
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
@@ -0,0 +1,49 @@
1
+ # rcov generated
2
+ coverage
3
+ coverage.data
4
+
5
+ # rdoc generated
6
+ rdoc
7
+
8
+ # yard generated
9
+ doc
10
+ .yardoc
11
+
12
+ # bundler
13
+ .bundle
14
+
15
+ # jeweler generated
16
+ pkg
17
+
18
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
19
+ #
20
+ # * Create a file at ~/.gitignore
21
+ # * Include files you want ignored
22
+ # * Run: git config --global core.excludesfile ~/.gitignore
23
+ #
24
+ # After doing this, these files will be ignored in all your git projects,
25
+ # saving you from having to 'pollute' every project you touch with them
26
+ #
27
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
28
+ #
29
+ # For MacOS:
30
+ #
31
+ #.DS_Store
32
+
33
+ # For TextMate
34
+ #*.tmproj
35
+ #tmtags
36
+
37
+ # For emacs:
38
+ #*~
39
+ #\#*
40
+ #.\#*
41
+
42
+ # For vim:
43
+ #*.swp
44
+
45
+ # For redcar:
46
+ #.redcar
47
+
48
+ # For rubinius:
49
+ #*.rbc
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'httparty'
4
+
5
+ # Add dependencies to develop your gem here.
6
+ # Include everything needed to run rake, tests, features, etc.
7
+ group :development do
8
+ gem "rspec", "~> 2.8.0"
9
+ gem "rdoc", "~> 3.12"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.8.3"
12
+ gem "timecop"
13
+ gem "mocha"
14
+ end
@@ -0,0 +1,43 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ git (1.2.5)
6
+ httparty (0.8.3)
7
+ multi_json (~> 1.0)
8
+ multi_xml
9
+ jeweler (1.8.3)
10
+ bundler (~> 1.0)
11
+ git (>= 1.2.5)
12
+ rake
13
+ rdoc
14
+ json (1.6.6)
15
+ metaclass (0.0.1)
16
+ mocha (0.10.0)
17
+ metaclass (~> 0.0.1)
18
+ multi_json (1.3.2)
19
+ multi_xml (0.4.4)
20
+ rake (0.9.2.2)
21
+ rdoc (3.12)
22
+ json (~> 1.4)
23
+ rspec (2.8.0)
24
+ rspec-core (~> 2.8.0)
25
+ rspec-expectations (~> 2.8.0)
26
+ rspec-mocks (~> 2.8.0)
27
+ rspec-core (2.8.0)
28
+ rspec-expectations (2.8.0)
29
+ diff-lcs (~> 1.1.2)
30
+ rspec-mocks (2.8.0)
31
+ timecop (0.3.5)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ bundler (~> 1.0.0)
38
+ httparty
39
+ jeweler (~> 1.8.3)
40
+ mocha
41
+ rdoc (~> 3.12)
42
+ rspec (~> 2.8.0)
43
+ timecop
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Dan Garland
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ = rovi
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to rovi
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2012 Dan Garland. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "rovi"
18
+ gem.homepage = "http://github.com/dmgarland/rovi"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{A gem for consuming the Rovi metadata API}
21
+ gem.description = %Q{A gem for well, consuming the Rovi metadata API}
22
+ gem.email = "dan@dangarland.co.uk"
23
+ gem.authors = ["Dan Garland"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "rovi #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,6 @@
1
+ require 'httparty'
2
+ require 'digest/md5'
3
+
4
+ require_relative 'rovi/api'
5
+ require_relative 'rovi/services/recommendations'
6
+ require_relative 'rovi/services/search'
@@ -0,0 +1,44 @@
1
+ module Rovi
2
+
3
+ class Api
4
+ include HTTParty
5
+
6
+ disable_rails_query_string_format
7
+ format :json
8
+ base_uri "http://api.rovicorp.com"
9
+ default_params format: 'json', country: 'US', language: 'en'
10
+
11
+ def initialize(api_key, api_secret)
12
+ @api_key, @api_secret = api_key, api_secret
13
+ @version = "v1"
14
+ @service_name = "data"
15
+ end
16
+
17
+ def get(category, method, params = {})
18
+ params.merge!(required_params)
19
+ options = self.class.default_options.dup.merge!({
20
+ query: params
21
+ })
22
+ path = build_path(category, method)
23
+
24
+ response = self.class.get(path, options)
25
+ response.parsed_response
26
+ end
27
+
28
+ private
29
+
30
+ def build_path(category, method)
31
+ ["", @service_name, @version, category, method].join("/")
32
+ end
33
+
34
+ def required_params
35
+ { :apikey => @api_key, :sig => generate_sig }
36
+ end
37
+
38
+ def generate_sig
39
+ Digest::MD5.hexdigest(@api_key + @api_secret + Time.now.to_i.to_s)
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,24 @@
1
+ module Rovi
2
+ class Response
3
+
4
+ def initialize(data = {})
5
+ @data = data
6
+ end
7
+
8
+ def success?
9
+ @data['status']
10
+ end
11
+
12
+ def method_missing(m)
13
+ key = m.to_s
14
+ if @hash != nil and @hash.has_key?(key)
15
+ v = @hash[key]
16
+ v = JsonResponse.new(v) if v.is_a?(Hash)
17
+ return v
18
+ else
19
+ super
20
+ end
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,13 @@
1
+ module Rovi
2
+ module Services
3
+ class Recommendations < Rovi::Api
4
+
5
+ def initialize(api_key, api_secret)
6
+ super(api_key, api_secret)
7
+ @service_name = "recs"
8
+ @version = "v2"
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Rovi
2
+ module Services
3
+ class Search < Rovi::Api
4
+
5
+ def initialize(api_key, api_secret)
6
+ super(api_key, api_secret)
7
+ @service_name = "search"
8
+ @version = "v2.1"
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,29 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "rovi"
8
+ s.version = "0.0.1"
9
+
10
+ s.authors = ["Dan Garland"]
11
+ s.date = "2012-04-24"
12
+ s.description = "A gem for well, consuming the Rovi metadata API"
13
+ s.email = "dan@dangarland.co.uk"
14
+
15
+ s.files = `git ls-files`.split($/)
16
+ s.homepage = "http://github.com/dmgarland/rovi"
17
+ s.licenses = ["MIT"]
18
+ s.require_paths = ["lib"]
19
+ s.summary = "A gem for consuming the Rovi metadata API"
20
+
21
+
22
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
23
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
24
+ s.add_development_dependency(%q<timecop>, [">= 0"])
25
+ s.add_development_dependency(%q<mocha>, [">= 0"])
26
+ s.add_dependency(%q<httparty>, [">= 0"])
27
+
28
+ end
29
+
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rovi::Api do
4
+
5
+ describe "A call to the data service album info endpoint" do
6
+ before do
7
+ params = {
8
+ :albumid => "MW0000111184"
9
+ }
10
+
11
+ Timecop.freeze(Time.local(2012, 1, 1)) do
12
+ @api = Rovi::Api.new("12345", "54321")
13
+ end
14
+ end
15
+
16
+ after do
17
+ Timecop.return
18
+ end
19
+
20
+ it 'should know the right endpoint for the data service' do
21
+ @api.instance_variable_set(:@api_function, "album")
22
+ @api.instance_variable_set(:@api_function_request, "info")
23
+ @api.send(:endpoint).should == "http://api.rovicorp.com/data/v1/album/info"
24
+ end
25
+
26
+ it 'should calculate the sig from the MD5 of the access key, secret and the current unix time' do
27
+ Timecop.freeze(Time.local(2012, 1, 1)) do
28
+ @api.send(:generate_sig).should == "0ff3ae460b0f7d821482204ca70c8fe8"
29
+ end
30
+ end
31
+
32
+ describe 'GET the response from the API' do
33
+ before do
34
+ mock_response = mock()
35
+ mock_response.expects(:parsed_response).returns({ "value" => { "nested" => "hi" }})
36
+
37
+ Rovi::Api.expects(:get).with('http://api.rovicorp.com/data/v1/album/info', {
38
+ :query => { :albumid => 'MW0000111184', :apikey => '12345',
39
+ :sig => '0ff3ae460b0f7d821482204ca70c8fe8'}}).returns(mock_response)
40
+
41
+ Timecop.freeze(Time.local(2012, 1, 1)) do
42
+ @response = @api.get("album", "info", { :albumid => "MW0000111184" })
43
+ end
44
+ end
45
+
46
+ it "should return a JsonResponse wrapper" do
47
+ @response.is_a?(Rovi::JsonResponse).should == true
48
+ end
49
+
50
+ it "should access hash keys using methods" do
51
+ @response.value.nested.should == "hi"
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,13 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'rovi'
5
+ require 'timecop'
6
+
7
+ # Requires supporting files with custom matchers and macros, etc,
8
+ # in ./support/ and its subdirectories.
9
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
10
+
11
+ RSpec.configure do |config|
12
+ config.mock_with :mocha
13
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rovi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dan Garland
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2012-04-24 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.8.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 2.8.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '3.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '3.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: timecop
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: mocha
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: httparty
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: A gem for well, consuming the Rovi metadata API
84
+ email: dan@dangarland.co.uk
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - .document
90
+ - .gitignore
91
+ - .rspec
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE.txt
95
+ - README.rdoc
96
+ - Rakefile
97
+ - VERSION
98
+ - lib/rovi.rb
99
+ - lib/rovi/api.rb
100
+ - lib/rovi/response.rb
101
+ - lib/rovi/services/recommendations.rb
102
+ - lib/rovi/services/search.rb
103
+ - rovi.gemspec
104
+ - spec/lib/api_spec.rb
105
+ - spec/spec_helper.rb
106
+ homepage: http://github.com/dmgarland/rovi
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.0.2
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: A gem for consuming the Rovi metadata API
130
+ test_files: []