zencoder-fetcher 0.2.2 → 0.2.3
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.
- data/README.rdoc +2 -0
- data/lib/zencoder_fetcher.rb +12 -7
- metadata +23 -7
data/README.rdoc
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
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
4
|
|
5
|
+
If you are testing notifications you can use the URL `http://zencoderfetcher/` to create a successful notification.
|
6
|
+
|
5
7
|
== Commands
|
6
8
|
|
7
9
|
Run with the
|
data/lib/zencoder_fetcher.rb
CHANGED
@@ -2,9 +2,10 @@ require 'rubygems'
|
|
2
2
|
require 'httparty'
|
3
3
|
require 'json'
|
4
4
|
require 'time'
|
5
|
+
require 'active_support'
|
5
6
|
|
6
7
|
module ZencoderFetcher
|
7
|
-
FETCHER_VERSION = [0,2,
|
8
|
+
FETCHER_VERSION = [0,2,3] unless defined?(FETCHER_VERSION)
|
8
9
|
|
9
10
|
def self.version
|
10
11
|
FETCHER_VERSION.join(".")
|
@@ -21,8 +22,6 @@ module ZencoderFetcher
|
|
21
22
|
|
22
23
|
local_url = options[:url] || "http://localhost:3000/"
|
23
24
|
auth = local_url.match(/^https?:\/\/([^\/]+):([^\/]+)@/) ? {:username=>$1, :password=>$2} : {}
|
24
|
-
|
25
|
-
puts auth
|
26
25
|
|
27
26
|
response = HTTParty.get("https://#{options[:endpoint] || 'app'}.zencoder.com/api/notifications.json?#{query}",
|
28
27
|
:headers => { "HTTP_X_FETCHER_VERSION" => version })
|
@@ -32,10 +31,17 @@ module ZencoderFetcher
|
|
32
31
|
puts response.body.to_s
|
33
32
|
raise
|
34
33
|
else
|
34
|
+
puts "Notifications retrieved: #{response["notifications"].size}"
|
35
|
+
puts "Posting to #{local_url}" if response["notifications"].size > 0
|
35
36
|
response["notifications"].each do |notification|
|
36
37
|
begin
|
37
|
-
|
38
|
-
|
38
|
+
format = notification.delete("format")
|
39
|
+
if format == "xml"
|
40
|
+
options = {:body => notification.to_xml}
|
41
|
+
else
|
42
|
+
options = {:body => notification.to_json}
|
43
|
+
end
|
44
|
+
options = options.merge({:headers => {"Content-Type" => "application/#{format}"}}) if format
|
39
45
|
options = options.merge({:basic_auth => auth}) if !auth.empty?
|
40
46
|
HTTParty.post(local_url, options)
|
41
47
|
rescue Errno::ECONNREFUSED => e
|
@@ -43,8 +49,7 @@ module ZencoderFetcher
|
|
43
49
|
raise FetcherLocalConnectionError
|
44
50
|
end
|
45
51
|
end
|
46
|
-
puts "
|
47
|
-
puts "Posted to: #{local_url}" if response["notifications"].size > 0
|
52
|
+
puts "Finished Posting" if response["notifications"].size > 0
|
48
53
|
puts
|
49
54
|
|
50
55
|
Time.parse(response["sent_at"].to_s)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zencoder-fetcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chris Warren
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-08-05 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -61,6 +61,22 @@ dependencies:
|
|
61
61
|
version: "0"
|
62
62
|
type: :runtime
|
63
63
|
version_requirements: *id003
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: activesupport
|
66
|
+
prerelease: false
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ~>
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 21
|
73
|
+
segments:
|
74
|
+
- 2
|
75
|
+
- 3
|
76
|
+
- 11
|
77
|
+
version: 2.3.11
|
78
|
+
type: :runtime
|
79
|
+
version_requirements: *id004
|
64
80
|
description: Fetches notifications from Zencoder for local development where Zencoder is unable to communicate to the server, usually because it's localhost.
|
65
81
|
email:
|
66
82
|
- chris@zencoder.com
|
@@ -103,10 +119,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
119
|
segments:
|
104
120
|
- 0
|
105
121
|
version: "0"
|
106
|
-
requirements:
|
107
|
-
|
122
|
+
requirements:
|
123
|
+
- A Zencoder Account - http://zencoder.com
|
108
124
|
rubyforge_project:
|
109
|
-
rubygems_version: 1.
|
125
|
+
rubygems_version: 1.6.2
|
110
126
|
signing_key:
|
111
127
|
specification_version: 3
|
112
128
|
summary: Fetches notifications from Zencoder for local development.
|