best3 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +22 -2
- data/lib/best3.rb +21 -9
- metadata +25 -10
data/README
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
-
I'm still working on this, I'll try and be as polite as possible when I say 'go fart yourself'.
|
2
1
|
|
3
|
-
|
2
|
+
PETE MADE A BETTER ONE!
|
3
|
+
https://github.com/envato/awsraw
|
4
|
+
|
5
|
+
|
6
|
+
#EXAMPLE:
|
7
|
+
|
8
|
+
# api wrapper w/ your aws credentials
|
9
|
+
s3 = Best3(aws_key, aws_secret_key).s3()
|
10
|
+
|
11
|
+
# make a call to s3, args are: http method, REST uri (w/ params), request headers, request body
|
12
|
+
|
13
|
+
# get a list of buckets
|
14
|
+
puts s3.('GET', '/').inspect
|
15
|
+
|
16
|
+
# put a custom acl on an object
|
17
|
+
puts s3.('PUT', '/path/to/object?acl', {'Content-Type' => 'text/xml'}, acl_in_xml)
|
18
|
+
|
19
|
+
# NOTES:
|
20
|
+
# all output is in the raw rest api output
|
21
|
+
# wraps signing of requests for you, which is a pain
|
22
|
+
# currently works with s3 and cloudfront
|
23
|
+
# very alpha so not all stuff is tested but the library is small
|
data/lib/best3.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
|
1
|
+
#raise 'Best3 gem requires Ruby 1.9.x' unless RUBY_VERSION.include? '1.9.'
|
2
2
|
|
3
|
-
|
4
|
-
%w(rubygems openssl bundler/setup typhoeus nokogiri strscan ostruct digest/sha1 time).each { |lib| require(lib) }
|
3
|
+
%w(rubygems bundler/setup typhoeus nokogiri strscan ostruct digest/sha1 time openssl).each { |lib| require(lib) }
|
5
4
|
|
6
5
|
class Best3
|
7
|
-
VERSION = '0.0.
|
6
|
+
VERSION = '0.0.3'
|
8
7
|
|
9
8
|
def initialize(*args)
|
10
9
|
@key, @secret = args
|
@@ -27,14 +26,19 @@ class Best3
|
|
27
26
|
end
|
28
27
|
|
29
28
|
def call(request_method, uri, headers = {}, body = nil)
|
30
|
-
|
29
|
+
YESTHISMETHODISCALLEDUNDERSCORE!(request_method, uri, headers.clone, body)
|
31
30
|
end
|
32
31
|
|
33
32
|
private
|
34
33
|
|
35
|
-
def
|
34
|
+
def YESTHISMETHODISCALLEDUNDERSCORE!(request_method, uri, headers, body = nil)
|
36
35
|
response = Typhoeus::Request.send(request_method.downcase, "#{@host}#{uri}", :headers => make_headers(request_method, uri, headers, body), :body => body)
|
37
|
-
|
36
|
+
body = if response.headers_hash['Content-Type'] == 'application/xml'
|
37
|
+
Nokogiri::XML(response.body) # wrap up xml
|
38
|
+
else
|
39
|
+
response.body # pass through everything else
|
40
|
+
end
|
41
|
+
OpenStruct.new({:success? => response.code == 200, :code => response.code, :headers => response.headers_hash, :body => body, :response => response})
|
38
42
|
end
|
39
43
|
|
40
44
|
def make_headers(request_method, uri, headers, body = nil)
|
@@ -59,10 +63,18 @@ class Best3
|
|
59
63
|
str << headers[key] # other headers just send the value
|
60
64
|
end
|
61
65
|
end
|
62
|
-
if uri.
|
63
|
-
|
66
|
+
if uri.match(/\?versioning|\?location|\?acl|\?torrent|\?lifecycle|\?versionid/) # if there's a sub resource
|
67
|
+
if uri.include?('&')
|
68
|
+
str << "#{StringScanner.new(uri).scan_until(/&/)[0..-2]}"
|
69
|
+
else
|
70
|
+
str << uri
|
71
|
+
end
|
64
72
|
else
|
73
|
+
if uri.include?('?')
|
74
|
+
str << "#{StringScanner.new(uri).scan_until(/\?/)[0..-2]}"
|
75
|
+
else
|
65
76
|
str << uri
|
77
|
+
end
|
66
78
|
end
|
67
79
|
str = str.join("\n").chomp
|
68
80
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: best3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-06-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: typhoeus
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: nokogiri
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,7 +53,12 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
description: Are you depressed? Has high interest rates got you down? My name is Meatwad
|
48
63
|
and today I'm here to offer you a once in a lifetime opportunity. Sell your organs,
|
49
64
|
live, over the internet. Get money back on your baby!
|
@@ -75,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
90
|
version: '0'
|
76
91
|
segments:
|
77
92
|
- 0
|
78
|
-
hash:
|
93
|
+
hash: 2535164541368506169
|
79
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
95
|
none: false
|
81
96
|
requirements:
|
@@ -84,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
99
|
version: '0'
|
85
100
|
requirements: []
|
86
101
|
rubyforge_project: best3
|
87
|
-
rubygems_version: 1.8.
|
102
|
+
rubygems_version: 1.8.23
|
88
103
|
signing_key:
|
89
104
|
specification_version: 3
|
90
105
|
summary: Minimal library for interacting with the Amazon Web Service API.
|