zencoder-fetcher 0.1.0

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,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 chriswarren
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,30 @@
1
+ = zencoder-fetcher
2
+
3
+ Fetcher is for developers working with Zencoder. If Zencoder can't notify your server when a job has completed, like if you're at localhost:3000, Fetcher can get the responses and push them to the server for you.
4
+
5
+ == Commands
6
+
7
+ Run with the
8
+
9
+ zencoder_fetcher [options] API_KEY
10
+
11
+ Options:
12
+ * --url, -u: URL to post the Zencoder notification (default: http://localhost:3000)
13
+ * --loop, -l: Run the notifier in a loop.
14
+ * --seconds, -s <i>: Check every x seconds. (Default: 60)
15
+ * --count, -c <i>: Number of notifications to retrieve per page. (Default: 50)
16
+ * --page, -p <i>: The page to load. (Default: 1)
17
+
18
+ == Note on Patches/Pull Requests
19
+
20
+ * Fork the project.
21
+ * Make your feature addition or bug fix.
22
+ * Add tests for it. This is important so I don't break it in a
23
+ future version unintentionally.
24
+ * Commit, do not mess with rakefile, version, or history.
25
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
26
+ * Send me a pull request. Bonus points for topic branches.
27
+
28
+ == Copyright
29
+
30
+ Copyright (c) 2010 Zencoder. See LICENSE for details.
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "zencoder-fetcher"
8
+ gem.summary = %Q{Fetches notifications from Zencoder for local development.}
9
+ gem.description = %Q{Fetches notifications from Zencoder for local development where Zencoder is unable to communicate to the server, usually because it's localhost.}
10
+ gem.email = "chris@zencoder.com"
11
+ gem.homepage = "http://github.com/zencoder/zencoder-fetcher"
12
+ gem.authors = ["chriswarren"]
13
+ gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
+ gem.add_dependency 'httparty'
15
+ gem.add_dependency 'json'
16
+ gem.executables = %w( zencoder_fetcher)
17
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+ rescue LoadError
21
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
+ end
23
+
24
+ require 'rake/testtask'
25
+ Rake::TestTask.new(:test) do |test|
26
+ test.libs << 'lib' << 'test'
27
+ test.pattern = 'test/**/test_*.rb'
28
+ test.verbose = true
29
+ end
30
+
31
+ begin
32
+ require 'rcov/rcovtask'
33
+ Rcov::RcovTask.new do |test|
34
+ test.libs << 'test'
35
+ test.pattern = 'test/**/test_*.rb'
36
+ test.verbose = true
37
+ end
38
+ rescue LoadError
39
+ task :rcov do
40
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
41
+ end
42
+ end
43
+
44
+ task :test => :check_dependencies
45
+
46
+ task :default => :test
47
+
48
+ require 'rake/rdoctask'
49
+ Rake::RDocTask.new do |rdoc|
50
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "zencoder-notifier #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/zencoder_fetcher.rb')
3
+ require 'trollop'
4
+
5
+ #
6
+ # Configure options
7
+ #
8
+
9
+ opts = Trollop::options do
10
+ version "Zencoder Fetcher #{ZencoderFetcher.version} (c) Zencoder Inc. All rights reserved, etc."
11
+ banner <<-EOS
12
+ Zencoder Fetcher helps developers create applications using Zencoder.
13
+
14
+ Usage:
15
+ bin/zencoder_fetcher [options] <api_key>
16
+
17
+ where [options] are:
18
+ EOS
19
+ opt :url, "URL to post the Zencoder notification", :short => 'u', :type => String, :default => "http://localhost:3000"
20
+ opt :loop, "Run the notifier in a loop.", :short => 'l', :default => false
21
+ opt :seconds, "Check every x seconds.", :short => 's', :type => Integer, :default => 60
22
+ opt :count, "Number of notifications to retrieve per page.", :short => 'c', :type => Integer, :default => 50
23
+ opt :page, "The page to load.", :short => 'p', :type => Integer, :default => 1
24
+ end
25
+
26
+ #
27
+ # Validate input
28
+ #
29
+
30
+ if ARGV[0].nil?
31
+ puts <<-EOS
32
+ Error: no API Key specified
33
+
34
+ Usage:
35
+
36
+ bin/zencoder_notifier [options] <api_key>
37
+
38
+ EOS
39
+ exit -1
40
+ end
41
+
42
+ #
43
+ # Run Zencoder Notifier
44
+ #
45
+
46
+ options = {}
47
+ options[:api_key] = ARGV[0]
48
+ options[:url] = opts[:url]
49
+ options[:count] = opts[:count]
50
+ options[:page] = opts[:page]
51
+
52
+ begin
53
+ if opts[:loop]
54
+ loop do
55
+ puts "Checking Zencoder for Notifications at #{Time.now}"
56
+ ZencoderFetcher.request(options)
57
+ sleep opts[:seconds]
58
+ end
59
+ else
60
+ ZencoderFetcher.request(options)
61
+ end
62
+ rescue SystemExit, Interrupt
63
+ raise "Quitting..."
64
+ rescue Exception => e
65
+ puts e.class
66
+ puts e.message
67
+ puts e.backtrace
68
+ raise
69
+ end
@@ -0,0 +1,33 @@
1
+ require 'rubygems'
2
+ require 'httparty'
3
+ require 'json'
4
+
5
+ module ZencoderFetcher
6
+ FETCHER_VERSION = [0,1] unless defined?(FETCHER_VERSION)
7
+
8
+ def self.version
9
+ FETCHER_VERSION.join(".")
10
+ end
11
+
12
+ def self.request(options={})
13
+ api_key = options[:api_key]
14
+ post_uri = options[:url] ? options[:url] : "http://localhost:3000"
15
+ per_page = options[:count] ? options[:count] : 50
16
+ page = options[:page] ? options[:page] : 1
17
+
18
+ begin
19
+ response = HTTParty.get("http://app.zencoder.com/api/notifications.json?api_key=#{api_key}&per_page=#{per_page}&page=#{page}")
20
+ if response.is_a?(Array)
21
+ response.each do |job|
22
+ job = JSON.parse(job)
23
+ HTTParty.post(post_uri, job)
24
+ end
25
+ puts "#{response.size} notifications retrieved and posted to #{post_uri}"
26
+ else
27
+ puts JSON.parse(response.body)["errors"]
28
+ end
29
+ rescue Exception => e
30
+ raise e
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'zencoder-notifier'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestZencoderNotifier < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,63 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{zencoder-fetcher}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["chriswarren"]
12
+ s.date = %q{2010-05-04}
13
+ s.default_executable = %q{zencoder_fetcher}
14
+ s.description = %q{Fetches notifications from Zencoder for local development where Zencoder is unable to communicate to the server, usually because it's localhost.}
15
+ s.email = %q{chris@zencoder.com}
16
+ s.executables = ["zencoder_fetcher"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/zencoder_fetcher",
29
+ "lib/zencoder_fetcher.rb",
30
+ "test/helper.rb",
31
+ "test/test_zencoder-fetcher.rb",
32
+ "zencoder-fetcher.gemspec"
33
+ ]
34
+ s.homepage = %q{http://github.com/zencoder/zencoder-fetcher}
35
+ s.rdoc_options = ["--charset=UTF-8"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.3.6}
38
+ s.summary = %q{Fetches notifications from Zencoder for local development.}
39
+ s.test_files = [
40
+ "test/helper.rb",
41
+ "test/test_zencoder-fetcher.rb"
42
+ ]
43
+
44
+ if s.respond_to? :specification_version then
45
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
49
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
50
+ s.add_runtime_dependency(%q<httparty>, [">= 0"])
51
+ s.add_runtime_dependency(%q<json>, [">= 0"])
52
+ else
53
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
54
+ s.add_dependency(%q<httparty>, [">= 0"])
55
+ s.add_dependency(%q<json>, [">= 0"])
56
+ end
57
+ else
58
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
59
+ s.add_dependency(%q<httparty>, [">= 0"])
60
+ s.add_dependency(%q<json>, [">= 0"])
61
+ end
62
+ end
63
+
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zencoder-fetcher
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
+ - chriswarren
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-05-04 00:00:00 -05:00
18
+ default_executable: zencoder_fetcher
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: thoughtbot-shoulda
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :development
31
+ version_requirements: *id001
32
+ - !ruby/object:Gem::Dependency
33
+ name: httparty
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
41
+ version: "0"
42
+ type: :runtime
43
+ version_requirements: *id002
44
+ - !ruby/object:Gem::Dependency
45
+ name: json
46
+ prerelease: false
47
+ requirement: &id003 !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ type: :runtime
55
+ version_requirements: *id003
56
+ description: Fetches notifications from Zencoder for local development where Zencoder is unable to communicate to the server, usually because it's localhost.
57
+ email: chris@zencoder.com
58
+ executables:
59
+ - zencoder_fetcher
60
+ extensions: []
61
+
62
+ extra_rdoc_files:
63
+ - LICENSE
64
+ - README.rdoc
65
+ files:
66
+ - .document
67
+ - .gitignore
68
+ - LICENSE
69
+ - README.rdoc
70
+ - Rakefile
71
+ - VERSION
72
+ - bin/zencoder_fetcher
73
+ - lib/zencoder_fetcher.rb
74
+ - test/helper.rb
75
+ - test/test_zencoder-fetcher.rb
76
+ - zencoder-fetcher.gemspec
77
+ has_rdoc: true
78
+ homepage: http://github.com/zencoder/zencoder-fetcher
79
+ licenses: []
80
+
81
+ post_install_message:
82
+ rdoc_options:
83
+ - --charset=UTF-8
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ segments:
98
+ - 0
99
+ version: "0"
100
+ requirements: []
101
+
102
+ rubyforge_project:
103
+ rubygems_version: 1.3.6
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: Fetches notifications from Zencoder for local development.
107
+ test_files:
108
+ - test/helper.rb
109
+ - test/test_zencoder-fetcher.rb