flixit 0.0.19 → 0.0.20

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/flixit/record.rb +21 -8
  3. data/spec/job_spec.rb +16 -2
  4. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.19
1
+ 0.0.20
@@ -33,20 +33,33 @@ protected
33
33
  def post(path, body)
34
34
  begin
35
35
  flixcloud = RestClient::Resource.new(
36
- "https://flixcloud.com/#{path}",
36
+ "https://www.flixcloud.com/#{path}",
37
37
  # :ssl_client_cert => OpenSSL::X509::Certificate.new(File.read("host.cert")),
38
38
  # :ssl_client_key => OpenSSL::PKey::RSA.new(File.read("host.key"), ""),
39
39
  # :ssl_ca_file => Flixit::CA_FILE,
40
40
  # :verify_ssl => OpenSSL::SSL::VERIFY_PEER
41
41
  :verify_ssl => false
42
42
  )
43
- Flixit::Response.new(flixcloud.post body, :content_type => 'application/xml', :accept => 'text/xml')
44
- # rescue HTTPClient::KeepAliveDisconnected
45
- # raise Flixit::ServerBrokeConnection, $!.message
46
- # rescue HTTPClient::ReceiveTimeoutError
47
- # raise Flixit::RequestTimeout, $!.message
48
- # rescue HTTPClient::ConnectTimeoutError
49
- # raise Flixit::ConnectionRefused, $!.message
43
+ Flixit::Response.new(flixcloud.post(body, :content_type => 'application/xml', :accept => 'text/xml') do |response, &block|
44
+ if [301, 302, 303].include? response.code
45
+ response.follow_redirection &block
46
+ else
47
+ response.return! &block
48
+ end
49
+ end)
50
+ # flixcloud.post body |response, &block|
51
+ # if [301, 302].include? response.code
52
+ # response.follow_redirection &block
53
+ # else
54
+ # response.return! &block
55
+ # end
56
+ # }
57
+ # rescue HTTPClient::KeepAliveDisconnected
58
+ # raise Flixit::ServerBrokeConnection, $!.message
59
+ # rescue HTTPClient::ReceiveTimeoutError
60
+ # raise Flixit::RequestTimeout, $!.message
61
+ # rescue HTTPClient::ConnectTimeoutError
62
+ # raise Flixit::ConnectionRefused, $!.message
50
63
  end
51
64
  end
52
65
 
@@ -9,7 +9,7 @@ context "Create a Job" do
9
9
  :output => {:url => 's3://flixcloud/somefile.flv'},
10
10
  :thumbnails => {:url => "s3://flixcloud/somefile/",:prefix => 'thumbnail'}})
11
11
  Fredo.post "https://www.flixcloud.com/jobs" do
12
- %{<?xml version="1.0" encoding="UTF-8"?><job><id type="integer">3254</id><initialized-job-at type="datetime">2009-02-11T01:23:54Z</initialized-job-at></job>}
12
+ [201, {}, %{<?xml version="1.0" encoding="UTF-8"?><job><id type="integer">3254</id><initialized-job-at type="datetime">2009-02-11T01:23:54Z</initialized-job-at></job>}]
13
13
  end
14
14
 
15
15
  end
@@ -19,7 +19,7 @@ context "Create a Job" do
19
19
  end
20
20
 
21
21
  it "posts a message to flixcloud" do
22
- @job.save
22
+ @job.save.should be_true
23
23
  end
24
24
 
25
25
  it "has a passthrough option" do
@@ -35,4 +35,18 @@ context "Create a Job" do
35
35
  YAML.load(request['api_request']['pass_through']).should eql({:key => 'value'})
36
36
  end
37
37
 
38
+ it "should follow redirects" do
39
+ # Setup redirection to http
40
+ Fredo.forget
41
+ Fredo.post "https://www.flixcloud.com/jobs" do
42
+ if env['rack.url_scheme'] == 'https'
43
+ [303, {'LOCATION' => "http://www.flixcloud.com/jobs"}, 'This item has moved permanently']
44
+ else
45
+ [201, {}, %{<?xml version="1.0" encoding="UTF-8"?><job><id type="integer">3254</id><initialized-job-at type="datetime">2009-02-11T01:23:54Z</initialized-job-at></job>}]
46
+ end
47
+ end
48
+
49
+ @job.should be_valid
50
+ @job.save.should be_true
51
+ end
38
52
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 19
9
- version: 0.0.19
8
+ - 20
9
+ version: 0.0.20
10
10
  platform: ruby
11
11
  authors:
12
12
  - Leandro Pedroni