awsraw 1.0.0.alpha.1 → 1.0.0.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74ab136d9a8688640905f2ffd967f828dc960f42
4
- data.tar.gz: d961172c156fe8a271b94d33665597cea23e249b
3
+ metadata.gz: 64214884680bff94ead6d97622548ca2b2220696
4
+ data.tar.gz: fb9def9e60782f6a8fcea2925cffffb87df7aa87
5
5
  SHA512:
6
- metadata.gz: 2512ee73dde56b39b937258e0432eacd3b12a2056905ae28b921df5afb758d7d98cafe8225f3d96cefbcb9daf2833c42037724e8e9cc04ff57024f64b1c22d6d
7
- data.tar.gz: c39c859a8b5516efaf9fd33dd0afc234c23efa70d79d802571b0baf68aebc81af417afcaae06a5886b830e46be35a9f9a6ea02e76f37f0dd92fe9882f559dab3
6
+ metadata.gz: efd7197aad5e071fb3706845c324230891b80d736be0fb9eaebe9989a9faf3563abb064f237853c0b6371e99996d4ba0be30b2a63c9bd0abe0f556cd439e84b5
7
+ data.tar.gz: c460f8556b43325d1355f71aad38fa870122e9d19aa41193e6c9f51808ac09871faf587346676c22c04b1b05e1f485c8dae0176d0bc04a7379f813e3d01da1c1
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
data/README.md CHANGED
@@ -1,19 +1,36 @@
1
1
  # AWSRaw
2
2
 
3
- A client for [Amazon Web Services](http://www.amazonaws.com/) in the style of
3
+ A client for [Amazon Web Services](http://www.amazonaws.com/) inspired by
4
4
  [FlickRaw](http://hanklords.github.com/flickraw/).
5
5
 
6
+
6
7
  ## Background
7
8
 
8
9
  AWSRaw has a simple goal: to let you follow the [AWS API
9
10
  docs](http://aws.amazon.com/documentation/), and translate that into Ruby code
10
- with the minimum of fuss.
11
+ with the minimum of fuss. It adds as little abstraction as possible on top of
12
+ the AWS REST API. (Think of it as the opposite of [fog](http://fog.io).)
13
+
14
+ You use a regular HTTP library
15
+ ([Faraday](https://github.com/lostisland/faraday)) to make requests, and AWSRaw
16
+ provides useful additions like request signing.
17
+
18
+
19
+ ## Status [![Build Status](https://travis-ci.org/envato/awsraw.png)](https://travis-ci.org/envato/awsraw) [![Code Climate](https://codeclimate.com/github/envato/awsraw.png)](https://codeclimate.com/github/envato/awsraw)
11
20
 
12
- This is the opposite of [fog](http://fog.io). AWSRaw tries to add as little
13
- abstraction as possible on top of the AWS REST API.
21
+ This is a pre-release of 1.0, so to install it as a gem you'll need to use `gem
22
+ install --pre awsraw`, or declare it as `gem 'awsraw', '~>1.0.0.alpha'` in your
23
+ `Gemfile`.
24
+
25
+ 1.0 has solid tests, but has only had light use so far, and feedback is
26
+ definitely welcome.
27
+
28
+ So far we've only built S3 support. We'd love to see pull requests for other
29
+ AWS services.
14
30
 
15
- You use a regular HTTP library to make requests, and AWSRaw provides useful
16
- additions like request signing.
31
+ The old, 0.1 version lives on the
32
+ [0.1-maintenance](https://github.com/envato/awsraw/tree/0.1-maintenance)
33
+ branch.
17
34
 
18
35
 
19
36
  ## Examples
@@ -63,15 +80,15 @@ for all the requests you can make.
63
80
 
64
81
  #### On request bodies
65
82
 
66
- If your request has a body and you don't provide a Content-MD5 header for it,
67
- AWSRaw will try to calculate one. (The S3 API requires the Content-MD5 header
83
+ If your request has a body and you don't provide a `Content-MD5` header for it,
84
+ AWSRaw will try to calculate one. (The S3 API requires the `Content-MD5` header
68
85
  for correct request signing.)
69
86
 
70
- It can handle the body behaving as either a String or a File. If you want to do
71
- something different with the body, you'll need to set the Content-MD5 header
72
- yourself.
87
+ It can handle the body behaving as either a `String` or a `File`. If you want
88
+ to do something different with the body, you'll need to set the `Content-MD5`
89
+ header yourself.
73
90
 
74
- You must also provide a Content-Type header for your request if there's a
91
+ You must also provide a `Content-Type` header for your request if there's a
75
92
  request body. AWSRaw will raise an exception if you don't.
76
93
 
77
94
 
@@ -117,19 +134,6 @@ Then get your browser to do an XHR request using the http_post_variables, and
117
134
  Bob's your aunty.
118
135
 
119
136
 
120
- ## Status
121
-
122
- This is still a bit experimental, and is missing some key features, but what's
123
- there is solid and well tested.
124
-
125
- Right now AWSRaw only has direct support for
126
- [Faraday](https://github.com/lostisland/faraday), but you could still use it
127
- with other client libraries with a bit of work.
128
-
129
- So far we've only built S3 support. We'd love to see pull requests for other
130
- AWS services.
131
-
132
-
133
137
  ## Contributing
134
138
 
135
139
  1. Fork it
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -1,4 +1,5 @@
1
1
  require 'uri'
2
+ require 'cgi'
2
3
 
3
4
  module AWSRaw
4
5
  module S3
@@ -39,9 +40,17 @@ module AWSRaw
39
40
  # that are overridden by parameters, nor does it handle the "delete"
40
41
  # parameter for multi-object Delete requests.
41
42
  def self.canonicalized_subresources(query)
42
- query ||= ""
43
- subresources = query.split("&") & VALID_SUBRESOURCES
44
- "?#{subresources.sort.join('&')}" unless subresources.empty?
43
+ params = CGI.parse(query || "")
44
+ subresources = params.keys & VALID_SUBRESOURCES
45
+ return nil if subresources.empty?
46
+
47
+ '?' + subresources.sort.collect { |subresource|
48
+ if params[subresource].empty?
49
+ subresource
50
+ else
51
+ params[subresource].collect { |value| "#{subresource}=#{value}" }
52
+ end
53
+ }.flatten.join('&')
45
54
  end
46
55
 
47
56
  end
@@ -20,7 +20,7 @@ module AWSRaw
20
20
  end
21
21
 
22
22
  env[:request_headers]['Date'] ||= Time.now.httpdate
23
- env[:request_headers]['Content-MD5'] ||= ContentMD5Header.generate_content_md5(env[:body])
23
+ env[:request_headers]['Content-MD5'] ||= ContentMD5Header.generate_content_md5(env[:body]) if env[:body]
24
24
 
25
25
  string_to_sign = StringToSign.string_to_sign(
26
26
  :method => env[:method].to_s.upcase,
@@ -32,8 +32,9 @@ module AWSRaw
32
32
  )
33
33
 
34
34
  env[:request_headers]['Authorization'] = Signature.authorization_header(string_to_sign, @credentials)
35
- end
36
35
 
36
+ @app.call(env)
37
+ end
37
38
  end
38
39
  end
39
40
  end
@@ -1,3 +1,3 @@
1
1
  module AWSRaw
2
- VERSION = "1.0.0.alpha.1"
2
+ VERSION = "1.0.0.alpha.2"
3
3
  end
@@ -46,6 +46,10 @@ describe AWSRaw::S3::CanonicalizedResource do
46
46
  it "sorts the subresources" do
47
47
  expect(subject.canonicalized_subresources("website&acl")).to eq("?acl&website")
48
48
  end
49
+
50
+ it "includes subresources with parameters" do
51
+ expect(subject.canonicalized_subresources("uploadId=foo")).to eq("?uploadId=foo")
52
+ end
49
53
  end
50
54
 
51
55
  end
@@ -10,8 +10,9 @@ describe AWSRaw::S3::FaradayMiddleware do
10
10
  )
11
11
  end
12
12
 
13
- let(:app) { double("app") }
14
- let(:time) { Time.parse("2013-09-19 19:22:13 +1000") }
13
+ let(:app) { double("app", :call => response) }
14
+ let(:time) { Time.parse("2013-09-19 19:22:13 +1000") }
15
+ let(:response) { double "response" }
15
16
 
16
17
  subject { described_class.new(app, credentials) }
17
18
 
@@ -85,4 +86,25 @@ describe AWSRaw::S3::FaradayMiddleware do
85
86
  expect { subject.call(env) }.to raise_error(AWSRaw::Error, "Can't make a request with a body but no Content-Type header")
86
87
  end
87
88
 
89
+ it "does not set the MD5 header if no body is supplied" do
90
+ env = {
91
+ :method => :get,
92
+ :url => "http://s3.amazonaws.com/johnsmith/my-file.txt",
93
+ :request_headers => { }
94
+ }
95
+ subject.call(env)
96
+ expect(env[:request_headers].keys).to_not include("Content-MD5")
97
+ end
98
+
99
+ it "passes on the call to the app" do
100
+ env = {
101
+ :method => :get,
102
+ :url => "http://s3.amazonaws.com/johnsmith/my-file.txt",
103
+ :request_headers => { }
104
+ }
105
+
106
+ app.should_receive(:call).with(env)
107
+
108
+ subject.call(env)
109
+ end
88
110
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awsraw
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha.1
4
+ version: 1.0.0.alpha.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Yandell
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-10-10 00:00:00.000000000 Z
13
+ date: 2013-11-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -78,6 +78,8 @@ extensions: []
78
78
  extra_rdoc_files: []
79
79
  files:
80
80
  - .gitignore
81
+ - .rspec
82
+ - .travis.yml
81
83
  - Gemfile
82
84
  - LICENSE
83
85
  - README.md