tangerine 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.pairs ADDED
File without changes
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm ree@tangerine
data/Gemfile ADDED
@@ -0,0 +1,13 @@
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.3.0"
9
+ gem "yard", "~> 0.6.0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.5.2"
12
+ gem "rcov", ">= 0"
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,34 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ crack (0.1.8)
5
+ diff-lcs (1.1.2)
6
+ git (1.2.5)
7
+ httparty (0.7.4)
8
+ crack (= 0.1.8)
9
+ jeweler (1.5.2)
10
+ bundler (~> 1.0.0)
11
+ git (>= 1.2.5)
12
+ rake
13
+ rake (0.8.7)
14
+ rcov (0.9.9)
15
+ rspec (2.3.0)
16
+ rspec-core (~> 2.3.0)
17
+ rspec-expectations (~> 2.3.0)
18
+ rspec-mocks (~> 2.3.0)
19
+ rspec-core (2.3.1)
20
+ rspec-expectations (2.3.0)
21
+ diff-lcs (~> 1.1.2)
22
+ rspec-mocks (2.3.0)
23
+ yard (0.6.4)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.0.0)
30
+ httparty
31
+ jeweler (~> 1.5.2)
32
+ rcov
33
+ rspec (~> 2.3.0)
34
+ yard (~> 0.6.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Anthony Navarre
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.
data/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # Tangerine
2
+
3
+ Tangerine is a gem that uses ActiveResource to wrap the Ooyala API. Currently in its infancy, so YMMV.
4
+
5
+ ## Installation
6
+
7
+ gem install tangerine
8
+
9
+ [Tangerine on RubyGems](http://rubygems.org/gems/tangerine)
10
+
11
+ ## Usage
12
+
13
+ The following is only a proposed usage -- most of this is not yet implemented since the gem is still in development:
14
+
15
+ ### Authorization with your Ooyala Account
16
+
17
+ You can find your Partner and Secret codes under the Developers area of the Backlot Account tab.
18
+
19
+ OOYALA_CREDENTIALS = {
20
+ :pcode => **<YOUR PCODE HERE>**,
21
+ :signature => **<YOUR SIGNATURE HERE>**
22
+ }
23
+ tangerine_client = Tangerine::Backlot.new(OOYALA_CREDENTIALS)
24
+
25
+ ### Queries
26
+
27
+ tangerine_client.query(:status => 'live')
28
+
29
+ * TODO: Make certain queries a bit more like a DSL (eg: tangerine_client.live instead of tangerine_client.query(:status => 'live'))
30
+
31
+ [Ooyala Backlot Query API](http://www.ooyala.com/support/docs/backlot_api#query)
32
+
33
+ ### Thumbnails
34
+
35
+ Feature pending.
36
+
37
+ [Ooyala Backlot Thumbnail Query API](http://www.ooyala.com/support/docs/backlot_api#thumbnail)
38
+
39
+ ### Attribute Updates
40
+
41
+ Feature pending.
42
+
43
+ [Ooyala Backlot Attribute Update API](http://www.ooyala.com/support/docs/backlot_api#attribute)
44
+
45
+ ### Custom Metadata
46
+
47
+ Feature pending.
48
+
49
+ [Ooyala Custom Metadata API](http://www.ooyala.com/support/docs/backlot_api#metadata)
50
+
51
+ ### Label Management
52
+
53
+ Feature pending.
54
+
55
+ [Ooyala Label Management API](http://www.ooyala.com/support/docs/backlot_api#label)
56
+
57
+ ### Player Management
58
+
59
+ Feature pending.
60
+
61
+ [Ooyala Player Management API](http://www.ooyala.com/support/docs/backlot_api#player)
62
+
63
+ ### Channel
64
+
65
+ Feature pending.
66
+
67
+ [Ooyala Channel API](http://www.ooyala.com/support/docs/backlot_api#channel)
68
+
69
+ ### Channel Set
70
+
71
+ Feature pending.
72
+
73
+ [Ooyala Channel Set API](http://www.ooyala.com/support/docs/backlot_api#channel_set)
74
+
75
+ ### Dynamic Channel
76
+
77
+ Feature pending.
78
+
79
+ [Ooyala Dynamic Channel API](http://www.ooyala.com/support/docs/backlot_api#dynamic_channel)
80
+
81
+ ### High Performance
82
+
83
+ Feature pending.
84
+
85
+ [Ooyala High Performance API](http://www.ooyala.com/support/docs/backlot_api#high_performance)
86
+
87
+ ## Contribute
88
+
89
+ The gem has an .rvmrc file, and is currently associated with ree 1.8.7 with its own [RVM](http://rvm.beginrescueend.com/) gemset.
90
+
91
+ If you don't have 'rvm_install_on_use_flag' turned on in your system/user .rvmrc file, just add the proper ree and gemset when prompted after cd'ing into the project.
92
+
93
+ [GitHub Repository](http://github.com/factorylabs/tangerine/tree/master)
94
+
95
+ ## Copyright
96
+
97
+ Copyright (c) 2011 Anthony Navarre. Released under the MIT license. See LICENSE.txt for
98
+ further details.
99
+
data/ROADMAP.md ADDED
@@ -0,0 +1,3 @@
1
+ # Roadmap
2
+
3
+ * content types to be implemented: Video, VideoAd, Channel, Alias, AliasAd, MultiChannel, Autosynd
data/Rakefile ADDED
@@ -0,0 +1,41 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ gem.name = "tangerine"
15
+ gem.homepage = "http://github.com/factorylabs/tangerine"
16
+ gem.license = "MIT"
17
+ gem.summary = %Q{Ooyala Backlot API Wrapper}
18
+ gem.description = %Q{Ooyala Backlot API Wrapper. Read more about the Ooyala Backlot API at http://www.ooyala.com/support/docs/backlot_api}
19
+ gem.email = "anthony.navarre@factorylabs.com"
20
+ gem.authors = ["Anthony Navarre"]
21
+
22
+ # Dependencies
23
+ gem.add_dependency 'httparty'
24
+ end
25
+ Jeweler::RubygemsDotOrgTasks.new
26
+
27
+ require 'rspec/core'
28
+ require 'rspec/core/rake_task'
29
+ RSpec::Core::RakeTask.new(:spec) do |spec|
30
+ spec.pattern = FileList['spec/**/*_spec.rb']
31
+ end
32
+
33
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
34
+ spec.pattern = 'spec/**/*_spec.rb'
35
+ spec.rcov = true
36
+ end
37
+
38
+ task :default => :spec
39
+
40
+ require 'yard'
41
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
@@ -0,0 +1,9 @@
1
+ class Tangerine::Query
2
+ attr_reader :response
3
+
4
+ def initialize(options)
5
+ @response = Tangerine::Backlot::API.get('/query', options)
6
+ end
7
+
8
+ end
9
+
@@ -0,0 +1,6 @@
1
+ class Tangerine::Video
2
+ def self.all
3
+ Tangerine::Query.new('contentType' => 'Video').response
4
+ end
5
+ end
6
+
@@ -0,0 +1,41 @@
1
+ require 'httparty'
2
+ require 'base64'
3
+ require 'digest/sha2'
4
+
5
+ module Tangerine
6
+ module Backlot
7
+ class HTTP
8
+ include HTTParty
9
+ base_uri 'http://api.ooyala.com/partner'
10
+ end
11
+
12
+ class API
13
+
14
+ def self.authenticate!(credentials)
15
+ @provider_code = credentials[:provider_code]
16
+ @secret = credentials[:secret]
17
+ end
18
+
19
+ def self.get(request_type, params={})
20
+ HTTP.default_params :signature => self.signature(params)
21
+ HTTP.default_params :pcode => @provider_code
22
+ HTTP.get(request_type)
23
+ end
24
+
25
+ # TODO: Refactor this method since it's doing double-duty ... not sure why Ooyala API doesn't like
26
+ # it if we assign some values to params instead of default params
27
+ def self.signature(params)
28
+ params['expires'] ||= (Time.now.to_i + 10).to_s
29
+ string_to_sign = params.keys.sort.inject(@secret) do |memo, key|
30
+ HTTP.default_params key => params[key]
31
+ memo += "#{key}=#{params[key]}"
32
+ end
33
+ digest = Digest::SHA256.digest(string_to_sign)
34
+ Base64::encode64(digest).chomp.gsub(/=+$/, '')
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+ end
41
+
data/lib/tangerine.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'tangerine/backlot'
2
+ require 'tangerine/backlot/query'
3
+ require 'tangerine/backlot/video'
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'tangerine'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
@@ -0,0 +1,5 @@
1
+ def authenticate!
2
+ # Publicly-available Ooyala Provider account creds for testing purposes
3
+ let(:credentials) { {:provider_code => 'lsNTrbQBqCQbH-VA6ALCshAHLWrV', :secret => 'hn-Rw2ZH-YwllUYkklL5Zo_7lWJVkrbShZPb5CD1'} }
4
+ before { Tangerine::Backlot::API.authenticate! credentials }
5
+ end
@@ -0,0 +1,31 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Tangerine::Backlot do
4
+ authenticate!
5
+
6
+ describe Tangerine::Backlot::HTTP do
7
+ subject { Tangerine::Backlot::HTTP }
8
+ its(:base_uri) { should == 'http://api.ooyala.com/partner' }
9
+ end
10
+
11
+ describe Tangerine::Backlot::API do
12
+ context 'class methods' do
13
+ subject { Tangerine::Backlot::API }
14
+ let(:params) { {'some_key' => 'some_value'} }
15
+
16
+ # it { puts subject.get('/query', 'contentType' => 'MultiChannel').inspect }
17
+ describe '.get' do
18
+ let(:response) { mock }
19
+ let(:request) { '/some-request-path' }
20
+ before { Tangerine::Backlot::HTTP.should_receive(:get).with(request).and_return(response) }
21
+
22
+ it 'returns the HTTP response' do
23
+ subject.get(request, params).should == response
24
+ end
25
+ end
26
+
27
+ end
28
+ end
29
+
30
+ end
31
+
@@ -0,0 +1,25 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Tangerine::Video do
4
+ authenticate!
5
+
6
+ context 'class methods' do
7
+ subject { Tangerine::Video }
8
+
9
+ describe '.all' do
10
+
11
+ let(:mock_response) { mock }
12
+ let(:query_double) { double(:response => mock_response) }
13
+ let(:params) { {'contentType' => 'Video'} }
14
+ subject { Tangerine::Video.all }
15
+ before { Tangerine::Query.should_receive(:new).with(params).and_return(query_double) }
16
+
17
+ it 'returns the response of the query' do
18
+ subject.should == mock_response
19
+ end
20
+
21
+ end
22
+ end
23
+
24
+ end
25
+
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tangerine
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
+ platform: ruby
12
+ authors:
13
+ - Anthony Navarre
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-08 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ version_requirements: *id001
32
+ name: httparty
33
+ prerelease: false
34
+ type: :runtime
35
+ - !ruby/object:Gem::Dependency
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ hash: 3
42
+ segments:
43
+ - 2
44
+ - 3
45
+ - 0
46
+ version: 2.3.0
47
+ version_requirements: *id002
48
+ name: rspec
49
+ prerelease: false
50
+ type: :development
51
+ - !ruby/object:Gem::Dependency
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ hash: 7
58
+ segments:
59
+ - 0
60
+ - 6
61
+ - 0
62
+ version: 0.6.0
63
+ version_requirements: *id003
64
+ name: yard
65
+ prerelease: false
66
+ type: :development
67
+ - !ruby/object:Gem::Dependency
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ hash: 23
74
+ segments:
75
+ - 1
76
+ - 0
77
+ - 0
78
+ version: 1.0.0
79
+ version_requirements: *id004
80
+ name: bundler
81
+ prerelease: false
82
+ type: :development
83
+ - !ruby/object:Gem::Dependency
84
+ requirement: &id005 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ hash: 7
90
+ segments:
91
+ - 1
92
+ - 5
93
+ - 2
94
+ version: 1.5.2
95
+ version_requirements: *id005
96
+ name: jeweler
97
+ prerelease: false
98
+ type: :development
99
+ - !ruby/object:Gem::Dependency
100
+ requirement: &id006 !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
108
+ version: "0"
109
+ version_requirements: *id006
110
+ name: rcov
111
+ prerelease: false
112
+ type: :development
113
+ - !ruby/object:Gem::Dependency
114
+ requirement: &id007 !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ hash: 3
120
+ segments:
121
+ - 0
122
+ version: "0"
123
+ version_requirements: *id007
124
+ name: httparty
125
+ prerelease: false
126
+ type: :runtime
127
+ description: Ooyala Backlot API Wrapper. Read more about the Ooyala Backlot API at http://www.ooyala.com/support/docs/backlot_api
128
+ email: anthony.navarre@factorylabs.com
129
+ executables: []
130
+
131
+ extensions: []
132
+
133
+ extra_rdoc_files:
134
+ - LICENSE.txt
135
+ - README.md
136
+ files:
137
+ - .document
138
+ - .pairs
139
+ - .rspec
140
+ - .rvmrc
141
+ - Gemfile
142
+ - Gemfile.lock
143
+ - LICENSE.txt
144
+ - README.md
145
+ - ROADMAP.md
146
+ - Rakefile
147
+ - VERSION
148
+ - lib/tangerine.rb
149
+ - lib/tangerine/backlot.rb
150
+ - lib/tangerine/backlot/query.rb
151
+ - lib/tangerine/backlot/video.rb
152
+ - spec/spec_helper.rb
153
+ - spec/support/authentication.rb
154
+ - spec/tangerine/backlot_spec.rb
155
+ - spec/tangerine/video_spec.rb
156
+ has_rdoc: true
157
+ homepage: http://github.com/factorylabs/tangerine
158
+ licenses:
159
+ - MIT
160
+ post_install_message:
161
+ rdoc_options: []
162
+
163
+ require_paths:
164
+ - lib
165
+ required_ruby_version: !ruby/object:Gem::Requirement
166
+ none: false
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ hash: 3
171
+ segments:
172
+ - 0
173
+ version: "0"
174
+ required_rubygems_version: !ruby/object:Gem::Requirement
175
+ none: false
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ hash: 3
180
+ segments:
181
+ - 0
182
+ version: "0"
183
+ requirements: []
184
+
185
+ rubyforge_project:
186
+ rubygems_version: 1.6.0
187
+ signing_key:
188
+ specification_version: 3
189
+ summary: Ooyala Backlot API Wrapper
190
+ test_files:
191
+ - spec/spec_helper.rb
192
+ - spec/support/authentication.rb
193
+ - spec/tangerine/backlot_spec.rb
194
+ - spec/tangerine/video_spec.rb