zencoder-fetcher 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -11,20 +11,24 @@ module ZencoderFetcher
11
11
 
12
12
  def self.request(options={})
13
13
  api_key = options[:api_key]
14
- post_uri = options[:url] ? options[:url] : "http://localhost:3000"
14
+ post_uri = options[:url] ? options[:url] : "http://localhost:3000/"
15
15
  per_page = options[:count] ? options[:count] : 50
16
16
  page = options[:page] ? options[:page] : 1
17
17
 
18
18
  begin
19
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)
20
+ if response.is_a?(String)
21
+ if response.body =~ /\{"errors"/
22
+ puts JSON.parse(response.body)["errors"]
23
+ else
24
+ i = 0
25
+ JSON.parse(response).each do |job|
26
+ options = {:headers => {"Content-type" => "application/json"}, :body => job}
27
+ HTTParty.post(post_uri, options)
28
+ i += 1
29
+ end
30
+ puts "#{i} notifications retrieved and posted to #{post_uri}"
24
31
  end
25
- puts "#{response.size} notifications retrieved and posted to #{post_uri}"
26
- elsif response.body =~ /errors/
27
- puts JSON.parse(response.body)["errors"]
28
32
  else
29
33
  puts "No notifications found."
30
34
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{zencoder-fetcher}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["chriswarren"]
12
- s.date = %q{2010-05-04}
12
+ s.date = %q{2010-05-06}
13
13
  s.default_executable = %q{zencoder_fetcher}
14
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
15
  s.email = %q{chris@zencoder.com}
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - chriswarren
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-04 00:00:00 -05:00
17
+ date: 2010-05-06 00:00:00 -05:00
18
18
  default_executable: zencoder_fetcher
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency