Permalink
Browse files

Initial commit.

  • Loading branch information...
1 parent 9ca4336 commit aa391488c209a3d26d46b0500fa4248e1618b17b Jim Bancroft committed Jan 21, 2011
View
4 .gitignore
@@ -27,7 +27,7 @@ pkg
#
# For MacOS:
#
-#.DS_Store
+.DS_Store
#
# For TextMate
#*.tmproj
@@ -39,4 +39,4 @@ pkg
#.\#*
#
# For vim:
-#*.swp
+*.swp
View
1 .rvmrc
@@ -0,0 +1 @@
+rvm use 1.9.2@wistia-api
View
4 Gemfile
@@ -3,6 +3,9 @@ source "http://rubygems.org"
# Example:
# gem "activesupport", ">= 2.3.5"
+gem 'activeresource', '> 2.3.8'
+gem 'configatron', '>= 2.6.4'
+
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
@@ -11,3 +14,4 @@ group :development do
gem "jeweler", "~> 1.5.2"
gem "rcov", ">= 0"
end
+
View
43 Gemfile.lock
@@ -0,0 +1,43 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ activemodel (3.0.3)
+ activesupport (= 3.0.3)
+ builder (~> 2.1.2)
+ i18n (~> 0.4)
+ activeresource (3.0.3)
+ activemodel (= 3.0.3)
+ activesupport (= 3.0.3)
+ activesupport (3.0.3)
+ builder (2.1.2)
+ configatron (2.6.4)
+ yamler (>= 0.1.0)
+ diff-lcs (1.1.2)
+ git (1.2.5)
+ i18n (0.5.0)
+ jeweler (1.5.2)
+ bundler (~> 1.0.0)
+ git (>= 1.2.5)
+ rake
+ rake (0.8.7)
+ rcov (0.9.9)
+ rspec (2.3.0)
+ rspec-core (~> 2.3.0)
+ rspec-expectations (~> 2.3.0)
+ rspec-mocks (~> 2.3.0)
+ rspec-core (2.3.1)
+ rspec-expectations (2.3.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.3.0)
+ yamler (0.1.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ activeresource (> 2.3.8)
+ bundler (~> 1.0.0)
+ configatron (>= 2.6.4)
+ jeweler (~> 1.5.2)
+ rcov
+ rspec (~> 2.3.0)
View
2 LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2011 Jim Bancroft
+Copyright (c) 2011 Wistia, Inc.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
4 README.rdoc
@@ -1,6 +1,6 @@
= wistia-api
-Description goes here.
+Ruby wrapper for Wistia's API
== Contributing to wistia-api
@@ -14,6 +14,6 @@ Description goes here.
== Copyright
-Copyright (c) 2011 Jim Bancroft. See LICENSE.txt for
+Copyright (c) 2011 Wistia, Inc. See LICENSE.txt for
further details.
View
11 Rakefile
@@ -15,14 +15,16 @@ Jeweler::Tasks.new do |gem|
gem.name = "wistia-api"
gem.homepage = "http://github.com/wistia/wistia-api"
gem.license = "MIT"
- gem.summary = %Q{TODO: one-line summary of your gem}
- gem.description = %Q{TODO: longer description of your gem}
- gem.email = "jbancroft@wistia.com"
- gem.authors = ["Jim Bancroft"]
+ gem.summary = %Q{Ruby wrapper for Wistia's API}
+ gem.description = %Q{A ruby library for working with Wistia's data API.}
+ gem.email = "support@wistia.com"
+ gem.authors = ["Jim Bancroft", "Mark Bates"]
# Include your dependencies below. Runtime dependencies are required when using your gem,
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
# gem.add_development_dependency 'rspec', '> 1.2.3'
+ gem.add_runtime_dependency 'activeresource', '> 2.3.8'
+ gem.add_runtime_dependency 'configatron', '>= 2.6.4'
end
Jeweler::RubygemsDotOrgTasks.new
@@ -48,3 +50,4 @@ Rake::RDocTask.new do |rdoc|
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
+
View
9 lib/config.rb
@@ -0,0 +1,9 @@
+require 'configatron'
+
+#configatron.wistia.api.key = ''
+configatron.wistia.api.key = 'test'
+configatron.wistia.api.user = 'api'
+configatron.wistia.api.format = :json
+#configatron.wistia.api.url = 'https://api.wistia.com/v1/'
+configatron.wistia.api.url = 'http://api.wistia.local:3000/v1/'
+
View
3 lib/wistia-api.rb
@@ -0,0 +1,3 @@
+require 'config'
+require 'wistia/media'
+require 'wistia/project'
View
BIN lib/wistia/.base.rb.swo
Binary file not shown.
View
BIN lib/wistia/.config.rb.swo
Binary file not shown.
View
BIN lib/wistia/.media.rb.swo
Binary file not shown.
View
16 lib/wistia/base.rb
@@ -0,0 +1,16 @@
+require File.join(File.dirname(__FILE__), 'config')
+
+module Wistia
+ class Base < ActiveResource::Base
+ self.site = Wistia::Config.config.api.url
+ self.user = Wistia::Config.config.api.user
+ self.password = Wistia::Config.config.api.key
+ self.format = Wistia::Config.config.api.format
+
+ def to_json(options = {})
+ # super({ :root => self.class.element_name }.merge(options))
+ return self.attributes.to_json(options)
+ end
+
+ end
+end
View
25 lib/wistia/config.rb
@@ -0,0 +1,25 @@
+module Wistia
+
+ class << self
+
+ def config(&block)
+ Wistia::Config.config(&block)
+ end
+
+ end
+
+ module Config
+
+ class << self
+
+ def config(&block)
+ yield configatron.wistia if block_given?
+ configatron.wistia
+ end
+
+ end
+
+ end
+
+end
+
View
40 lib/wistia/media.rb
@@ -0,0 +1,40 @@
+module Wistia
+ class Media < Wistia::Base
+
+=begin
+ class << self
+ def find_with_cache(id)
+ return nil if id.nil?
+ Wistia::Media::Cache.get(id) do |key|
+ media = Wistia::Media.find_without_cache(key)
+ Wistia::Media::Cache.set(key, media) if media.progress >= 1.0
+ media
+ end
+ end
+ alias_method_chain :find, :cache
+ end
+=end
+
+ def still(width = 640, options = {})
+ options = {:format => 'jpg', :style => 'image_resize'}.merge(options)
+ matcher = self.type == 'Image' ? /OriginalFile/ : /StillImage/
+ self.assets.each do |asset|
+ if asset.type.match(matcher)
+ url = asset.url.gsub(/\.bin$/, ".#{options[:format]}?#{options[:style]}=#{width}")
+ return url
+ end
+ end
+ return nil
+ end
+
+ # Needed when deserializing from cache:
+ class Thumbnail < Wistia::Base
+ end # Thumbnail
+
+ # Needed when deserializing from cache:
+ class Asset < Wistia::Base
+ end # Asset
+
+ end # Media
+end # Wistia
+
View
5 lib/wistia/project.rb
@@ -0,0 +1,5 @@
+module Wistia
+ class Project < Wistia::Base
+
+ end
+end

0 comments on commit aa39148

Please sign in to comment.