s3itch_client 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -11,6 +11,7 @@ spec/reports
11
11
  test/tmp
12
12
  test/version_tmp
13
13
  tmp
14
+ Gemfile.lock
14
15
 
15
16
  # YARD artifacts
16
17
  .yardoc
data/Gemfile CHANGED
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in s3itch_cli.gemspec
4
4
  gemspec
5
+
6
+ platforms :jruby do
7
+ gem "jruby-openssl"
8
+ end
@@ -14,22 +14,27 @@ module S3itchClient
14
14
  raise ArgumentError, "A URL must be provided"
15
15
  end
16
16
 
17
- url = options[:url]
17
+ uri = URI.parse(options[:url])
18
18
  username = options[:username]
19
19
  password = options[:password]
20
20
 
21
21
  if File.exists?(filepath) && !File.directory?(filepath)
22
22
  uniq_name = build_unique_name(filepath)
23
23
 
24
- uri = URI.parse "#{url}/#{uniq_name}"
24
+ uri.path = "/#{uniq_name}"
25
25
 
26
26
  http = Net::HTTP.new(uri.host, uri.port)
27
+
28
+ if uri.scheme == "https"
29
+ http.use_ssl = true
30
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
31
+ end
32
+
27
33
  request = Net::HTTP::Put.new(uri.request_uri)
28
34
 
29
35
  if username && password
30
36
  request.basic_auth(username, password)
31
37
  end
32
-
33
38
  request.content_type = "application/octet-stream"
34
39
  response = http.request(request, File.open(filepath).read)
35
40
 
@@ -1,3 +1,3 @@
1
1
  module S3itchClient
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  require "spec_helper"
2
3
 
3
4
  describe S3itchClient do
@@ -46,6 +47,10 @@ describe S3itchClient do
46
47
  :password => "secret"
47
48
  }
48
49
  end
50
+ let(:http_stub) do
51
+ stub = stub_request(:put, /s3itch.herokuapp.com/).
52
+ to_return(:body => "", :status => 201, :headers => { "Location" => "http://s3itch.example.com/kitten.jpeg" })
53
+ end
49
54
 
50
55
 
51
56
  it "raises an exception if no url is defined" do
@@ -57,10 +62,18 @@ describe S3itchClient do
57
62
  end
58
63
 
59
64
  it "sends files to s3itch" do
60
- stub = stub_request(:put, /s3itch.herokuapp.com/).
61
- to_return(:body => "", :status => 201, :headers => { "Location" => "http://s3itch.exmaple.com/kitten.jpeg" })
62
- S3itchClient.upload(kitten_path, options).should == "http://s3itch.exmaple.com/kitten.jpeg"
63
- stub.should have_been_requested
65
+ http_stub
66
+ S3itchClient.upload(kitten_path, options).should == "http://s3itch.example.com/kitten.jpeg"
67
+ http_stub.should have_been_requested
68
+ end
69
+
70
+ it "uses HTTPS if necessary" do
71
+ http_stub
72
+ https_options = options
73
+ https_options[:url] = "https://s3itch.herokuapp.com"
74
+ S3itchClient.upload(kitten_path, options).should == "http://s3itch.example.com/kitten.jpeg"
75
+ http_stub.should have_been_requested
76
+ WebMock.should have_requested(:put, /s3itch.herokuapp.com/).with { |req| req.uri.scheme == "https" }
64
77
  end
65
78
 
66
79
  it "raises an exception if the 'Location' header returned" do
metadata CHANGED
@@ -1,96 +1,96 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3itch_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 1.1.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Matias Korhonen
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-30 00:00:00.000000000 Z
12
+ date: 2012-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
16
+ version_requirements: !ruby/object:Gem::Requirement
18
17
  requirements:
19
18
  - - ! '>='
20
19
  - !ruby/object:Gem::Version
21
20
  version: '0'
22
- type: :development
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
21
  none: false
22
+ requirement: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
27
+ none: false
28
+ prerelease: false
29
+ type: :development
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rake
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
32
+ version_requirements: !ruby/object:Gem::Requirement
34
33
  requirements:
35
34
  - - ! '>='
36
35
  - !ruby/object:Gem::Version
37
36
  version: '0'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
37
  none: false
38
+ requirement: !ruby/object:Gem::Requirement
42
39
  requirements:
43
40
  - - ! '>='
44
41
  - !ruby/object:Gem::Version
45
42
  version: '0'
43
+ none: false
44
+ prerelease: false
45
+ type: :development
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rspec
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
48
+ version_requirements: !ruby/object:Gem::Requirement
50
49
  requirements:
51
50
  - - ~>
52
51
  - !ruby/object:Gem::Version
53
52
  version: 2.11.0
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
53
  none: false
54
+ requirement: !ruby/object:Gem::Requirement
58
55
  requirements:
59
56
  - - ~>
60
57
  - !ruby/object:Gem::Version
61
58
  version: 2.11.0
59
+ none: false
60
+ prerelease: false
61
+ type: :development
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: webmock
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
64
+ version_requirements: !ruby/object:Gem::Requirement
66
65
  requirements:
67
66
  - - ~>
68
67
  - !ruby/object:Gem::Version
69
68
  version: 1.8.11
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
69
  none: false
70
+ requirement: !ruby/object:Gem::Requirement
74
71
  requirements:
75
72
  - - ~>
76
73
  - !ruby/object:Gem::Version
77
74
  version: 1.8.11
75
+ none: false
76
+ prerelease: false
77
+ type: :development
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: simplecov
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
80
+ version_requirements: !ruby/object:Gem::Requirement
82
81
  requirements:
83
82
  - - ~>
84
83
  - !ruby/object:Gem::Version
85
84
  version: 0.6.4
86
- type: :development
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
85
  none: false
86
+ requirement: !ruby/object:Gem::Requirement
90
87
  requirements:
91
88
  - - ~>
92
89
  - !ruby/object:Gem::Version
93
90
  version: 0.6.4
91
+ none: false
92
+ prerelease: false
93
+ type: :development
94
94
  description: Send files to s3itch from the command line
95
95
  email:
96
96
  - me@matiaskorhonen.fi
@@ -104,7 +104,6 @@ files:
104
104
  - .travis.yml
105
105
  - CONTRIBUTING.md
106
106
  - Gemfile
107
- - Gemfile.lock
108
107
  - LICENSE.txt
109
108
  - README.md
110
109
  - Rakefile
@@ -118,35 +117,36 @@ files:
118
117
  - spec/support/kitten.jpeg
119
118
  homepage: https://github.com/k33l0r/s3itch_client
120
119
  licenses: []
121
- post_install_message:
120
+ post_install_message:
122
121
  rdoc_options: []
123
122
  require_paths:
124
123
  - lib
125
124
  required_ruby_version: !ruby/object:Gem::Requirement
126
- none: false
127
125
  requirements:
128
126
  - - ! '>='
129
127
  - !ruby/object:Gem::Version
130
- version: '0'
131
128
  segments:
132
129
  - 0
133
- hash: -3642218463313132411
134
- required_rubygems_version: !ruby/object:Gem::Requirement
130
+ version: '0'
131
+ hash: 2
135
132
  none: false
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
134
  requirements:
137
135
  - - ! '>='
138
136
  - !ruby/object:Gem::Version
139
- version: '0'
140
137
  segments:
141
138
  - 0
142
- hash: -3642218463313132411
139
+ version: '0'
140
+ hash: 2
141
+ none: false
143
142
  requirements: []
144
- rubyforge_project:
143
+ rubyforge_project:
145
144
  rubygems_version: 1.8.24
146
- signing_key:
145
+ signing_key:
147
146
  specification_version: 3
148
147
  summary: Upload files to S3 via your own s3itch instance
149
148
  test_files:
150
149
  - spec/s3itch_client_spec.rb
151
150
  - spec/spec_helper.rb
152
151
  - spec/support/kitten.jpeg
152
+ ...
@@ -1,40 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- s3itch_client (1.0.1)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- addressable (2.3.2)
10
- crack (0.3.1)
11
- diff-lcs (1.1.3)
12
- multi_json (1.3.6)
13
- rake (0.9.2.2)
14
- rspec (2.11.0)
15
- rspec-core (~> 2.11.0)
16
- rspec-expectations (~> 2.11.0)
17
- rspec-mocks (~> 2.11.0)
18
- rspec-core (2.11.1)
19
- rspec-expectations (2.11.3)
20
- diff-lcs (~> 1.1.3)
21
- rspec-mocks (2.11.2)
22
- simplecov (0.6.4)
23
- multi_json (~> 1.0)
24
- simplecov-html (~> 0.5.3)
25
- simplecov-html (0.5.3)
26
- webmock (1.8.11)
27
- addressable (>= 2.2.7)
28
- crack (>= 0.1.7)
29
-
30
- PLATFORMS
31
- java
32
- ruby
33
-
34
- DEPENDENCIES
35
- bundler
36
- rake
37
- rspec (~> 2.11.0)
38
- s3itch_client!
39
- simplecov (~> 0.6.4)
40
- webmock (~> 1.8.11)