wistia-api 0.1.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/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.2@wistia-api
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem 'activeresource', '> 2.3.8'
7
+ gem 'configatron', '>= 2.6.4'
8
+
9
+ # Add dependencies to develop your gem here.
10
+ # Include everything needed to run rake, tests, features, etc.
11
+ group :development do
12
+ gem "rspec", "~> 2.3.0"
13
+ gem "bundler", "~> 1.0.0"
14
+ gem "jeweler", "~> 1.5.2"
15
+ gem "rcov", ">= 0"
16
+ end
17
+
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activemodel (3.0.3)
5
+ activesupport (= 3.0.3)
6
+ builder (~> 2.1.2)
7
+ i18n (~> 0.4)
8
+ activeresource (3.0.3)
9
+ activemodel (= 3.0.3)
10
+ activesupport (= 3.0.3)
11
+ activesupport (3.0.3)
12
+ builder (2.1.2)
13
+ configatron (2.6.4)
14
+ yamler (>= 0.1.0)
15
+ diff-lcs (1.1.2)
16
+ git (1.2.5)
17
+ i18n (0.5.0)
18
+ jeweler (1.5.2)
19
+ bundler (~> 1.0.0)
20
+ git (>= 1.2.5)
21
+ rake
22
+ rake (0.8.7)
23
+ rcov (0.9.9)
24
+ rspec (2.3.0)
25
+ rspec-core (~> 2.3.0)
26
+ rspec-expectations (~> 2.3.0)
27
+ rspec-mocks (~> 2.3.0)
28
+ rspec-core (2.3.1)
29
+ rspec-expectations (2.3.0)
30
+ diff-lcs (~> 1.1.2)
31
+ rspec-mocks (2.3.0)
32
+ yamler (0.1.0)
33
+
34
+ PLATFORMS
35
+ ruby
36
+
37
+ DEPENDENCIES
38
+ activeresource (> 2.3.8)
39
+ bundler (~> 1.0.0)
40
+ configatron (>= 2.6.4)
41
+ jeweler (~> 1.5.2)
42
+ rcov
43
+ rspec (~> 2.3.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Wistia, Inc.
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.rdoc ADDED
@@ -0,0 +1,23 @@
1
+ = wistia-api
2
+
3
+ Ruby wrapper for Wistia's API
4
+
5
+ == Installation
6
+
7
+ <tt>gem install wistia-api</tt>
8
+
9
+ == Usage
10
+
11
+ Start by requiring wistia:
12
+
13
+ <tt>require 'wistia'</tt>
14
+
15
+ Now you can use the <tt>Wistia::Media</tt> and <tt>Wistia::Project</tt> classes as ActiveResource wrappers around Wistia's API.
16
+
17
+ See http://wistia.com/doc/data-api for more info.
18
+
19
+ == Copyright
20
+
21
+ Copyright (c) 2011 Wistia, Inc. See LICENSE.txt for
22
+ further details.
23
+
data/Rakefile ADDED
@@ -0,0 +1,53 @@
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 is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "wistia-api"
16
+ gem.homepage = "http://github.com/wistia/wistia-api"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Ruby wrapper for Wistia's API}
19
+ gem.description = %Q{A ruby library for working with Wistia's data API.}
20
+ gem.email = "support@wistia.com"
21
+ gem.authors = ["Jim Bancroft", "Mark Bates"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ gem.add_runtime_dependency 'activeresource', '> 2.3.8'
27
+ gem.add_runtime_dependency 'configatron', '>= 2.6.4'
28
+ end
29
+ Jeweler::RubygemsDotOrgTasks.new
30
+
31
+ require 'rspec/core'
32
+ require 'rspec/core/rake_task'
33
+ RSpec::Core::RakeTask.new(:spec) do |spec|
34
+ spec.pattern = FileList['spec/**/*_spec.rb']
35
+ end
36
+
37
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
38
+ spec.pattern = 'spec/**/*_spec.rb'
39
+ spec.rcov = true
40
+ end
41
+
42
+ task :default => :spec
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "wistia-api #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
53
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/lib/config.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'configatron'
2
+
3
+ #configatron.wistia.api.key = ''
4
+ configatron.wistia.api.key = 'test'
5
+ configatron.wistia.api.user = 'api'
6
+ configatron.wistia.api.format = :json
7
+ #configatron.wistia.api.url = 'https://api.wistia.com/v1/'
8
+ configatron.wistia.api.url = 'http://api.wistia.local:3000/v1/'
9
+
@@ -0,0 +1,15 @@
1
+ require File.join(File.dirname(__FILE__), 'config')
2
+
3
+ module Wistia
4
+ class Base < ActiveResource::Base
5
+ self.site = Wistia::Config.config.api.url
6
+ self.user = Wistia::Config.config.api.user
7
+ self.password = Wistia::Config.config.api.key
8
+ self.format = Wistia::Config.config.api.format
9
+
10
+ def to_json(options = {})
11
+ return self.attributes.to_json(options)
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,25 @@
1
+ module Wistia
2
+
3
+ class << self
4
+
5
+ def config(&block)
6
+ Wistia::Config.config(&block)
7
+ end
8
+
9
+ end
10
+
11
+ module Config
12
+
13
+ class << self
14
+
15
+ def config(&block)
16
+ yield configatron.wistia if block_given?
17
+ configatron.wistia
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+
@@ -0,0 +1,26 @@
1
+ module Wistia
2
+ class Media < Wistia::Base
3
+
4
+ def still(width = 640, options = {})
5
+ options = {:format => 'jpg', :style => 'image_resize'}.merge(options)
6
+ matcher = self.type == 'Image' ? /OriginalFile/ : /StillImage/
7
+ self.assets.each do |asset|
8
+ if asset.type.match(matcher)
9
+ url = asset.url.gsub(/\.bin$/, ".#{options[:format]}?#{options[:style]}=#{width}")
10
+ return url
11
+ end
12
+ end
13
+ return nil
14
+ end
15
+
16
+ # Needed when deserializing from cache:
17
+ class Thumbnail < Wistia::Base
18
+ end # Thumbnail
19
+
20
+ # Needed when deserializing from cache:
21
+ class Asset < Wistia::Base
22
+ end # Asset
23
+
24
+ end # Media
25
+ end # Wistia
26
+
@@ -0,0 +1,5 @@
1
+ module Wistia
2
+ class Project < Wistia::Base
3
+
4
+ end
5
+ end
data/lib/wistia.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'config'
2
+ require 'active_resource'
3
+ require 'wistia/base'
4
+ require 'wistia/media'
5
+ require 'wistia/project'
@@ -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 'wistia-api'
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,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "WistiaApi" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,201 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wistia-api
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Jim Bancroft
13
+ - Mark Bates
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-21 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: activeresource
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">"
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 2
30
+ - 3
31
+ - 8
32
+ version: 2.3.8
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: configatron
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 2
45
+ - 6
46
+ - 4
47
+ version: 2.6.4
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: rspec
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 2
60
+ - 3
61
+ - 0
62
+ version: 2.3.0
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ name: bundler
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 1
75
+ - 0
76
+ - 0
77
+ version: 1.0.0
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: *id004
81
+ - !ruby/object:Gem::Dependency
82
+ name: jeweler
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ segments:
89
+ - 1
90
+ - 5
91
+ - 2
92
+ version: 1.5.2
93
+ type: :development
94
+ prerelease: false
95
+ version_requirements: *id005
96
+ - !ruby/object:Gem::Dependency
97
+ name: rcov
98
+ requirement: &id006 !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ segments:
104
+ - 0
105
+ version: "0"
106
+ type: :development
107
+ prerelease: false
108
+ version_requirements: *id006
109
+ - !ruby/object:Gem::Dependency
110
+ name: activeresource
111
+ requirement: &id007 !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ">"
115
+ - !ruby/object:Gem::Version
116
+ segments:
117
+ - 2
118
+ - 3
119
+ - 8
120
+ version: 2.3.8
121
+ type: :runtime
122
+ prerelease: false
123
+ version_requirements: *id007
124
+ - !ruby/object:Gem::Dependency
125
+ name: configatron
126
+ requirement: &id008 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ segments:
132
+ - 2
133
+ - 6
134
+ - 4
135
+ version: 2.6.4
136
+ type: :runtime
137
+ prerelease: false
138
+ version_requirements: *id008
139
+ description: A ruby library for working with Wistia's data API.
140
+ email: support@wistia.com
141
+ executables: []
142
+
143
+ extensions: []
144
+
145
+ extra_rdoc_files:
146
+ - LICENSE.txt
147
+ - README.rdoc
148
+ files:
149
+ - .document
150
+ - .rspec
151
+ - .rvmrc
152
+ - Gemfile
153
+ - Gemfile.lock
154
+ - LICENSE.txt
155
+ - README.rdoc
156
+ - Rakefile
157
+ - VERSION
158
+ - lib/config.rb
159
+ - lib/wistia.rb
160
+ - lib/wistia/base.rb
161
+ - lib/wistia/config.rb
162
+ - lib/wistia/media.rb
163
+ - lib/wistia/project.rb
164
+ - spec/spec_helper.rb
165
+ - spec/wistia-api_spec.rb
166
+ has_rdoc: true
167
+ homepage: http://github.com/wistia/wistia-api
168
+ licenses:
169
+ - MIT
170
+ post_install_message:
171
+ rdoc_options: []
172
+
173
+ require_paths:
174
+ - lib
175
+ required_ruby_version: !ruby/object:Gem::Requirement
176
+ none: false
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ hash: 4356228871564884655
181
+ segments:
182
+ - 0
183
+ version: "0"
184
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ segments:
190
+ - 0
191
+ version: "0"
192
+ requirements: []
193
+
194
+ rubyforge_project:
195
+ rubygems_version: 1.3.7
196
+ signing_key:
197
+ specification_version: 3
198
+ summary: Ruby wrapper for Wistia's API
199
+ test_files:
200
+ - spec/spec_helper.rb
201
+ - spec/wistia-api_spec.rb