zencoder-fetcher 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/zencoder_fetcher.rb +8 -4
  2. metadata +3 -3
@@ -4,7 +4,7 @@ require 'json'
4
4
  require 'time'
5
5
 
6
6
  module ZencoderFetcher
7
- FETCHER_VERSION = [0,2,1] unless defined?(FETCHER_VERSION)
7
+ FETCHER_VERSION = [0,2,2] unless defined?(FETCHER_VERSION)
8
8
 
9
9
  def self.version
10
10
  FETCHER_VERSION.join(".")
@@ -20,6 +20,9 @@ module ZencoderFetcher
20
20
  query = query.map{|k,v| "#{k}=#{v}" }.join("&")
21
21
 
22
22
  local_url = options[:url] || "http://localhost:3000/"
23
+ auth = local_url.match(/^https?:\/\/([^\/]+):([^\/]+)@/) ? {:username=>$1, :password=>$2} : {}
24
+
25
+ puts auth
23
26
 
24
27
  response = HTTParty.get("https://#{options[:endpoint] || 'app'}.zencoder.com/api/notifications.json?#{query}",
25
28
  :headers => { "HTTP_X_FETCHER_VERSION" => version })
@@ -31,9 +34,10 @@ module ZencoderFetcher
31
34
  else
32
35
  response["notifications"].each do |notification|
33
36
  begin
34
- HTTParty.post(local_url,
35
- :body => notification.to_json,
36
- :headers => { "Content-type" => "application/json" })
37
+ options = {:body => notification.to_json,
38
+ :headers => { "Content-type" => "application/json"}}
39
+ options = options.merge({:basic_auth => auth}) if !auth.empty?
40
+ HTTParty.post(local_url, options)
37
41
  rescue Errno::ECONNREFUSED => e
38
42
  puts "Unable to connect to your local server at #{local_url}. Is it running?"
39
43
  raise FetcherLocalConnectionError
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: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chris Warren