ThreeStore 0.0.1.b → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -2
- data/README.rdoc +1 -28
- data/lib/ThreeStore.rb +9 -16
- data/lib/ThreeStore/version.rb +1 -1
- data/spec/lib/ThreeStore_spec.rb +10 -20
- metadata +44 -77
data/.gitignore
CHANGED
data/README.rdoc
CHANGED
@@ -5,34 +5,7 @@ http://travis-ci.org/cowmanifestation/ThreeStore.png ({More info}[http://travis-
|
|
5
5
|
|
6
6
|
== Tutorial
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
Perhaps you are storing your s3 secret access key id and secret access key as environment variables - you can access them like this:
|
11
|
-
|
12
|
-
@store = ThreeStore.new(ENV['S3_KEY'], ENV['S3_SECRET'], 'my-bucket')
|
13
|
-
|
14
|
-
If you are storing aforementioned credentials in a yaml file:
|
15
|
-
|
16
|
-
@yaml = 'path_to_my_yaml_file.yml'
|
17
|
-
@store = ThreeStore.new(@yaml[:access_key_id], @yaml[:secret_access_key], 'my-bucket')
|
18
|
-
|
19
|
-
To upload a file, use ThreeStore#store_on_s3:
|
20
|
-
|
21
|
-
@store.store_on_s3(:url => 'http://example.com/assets/picture.png', :key => 'picture.png', :content_type => 'image/png', :access => 'public-read')
|
22
|
-
|
23
|
-
Options to pass to +store_on_s3+:
|
24
|
-
* :url, the url or path from which to fetch the file
|
25
|
-
* :key, the that you wish your object to have on s3
|
26
|
-
* :content_type (optional) - the content type will be inferred from the file extension, but it can be passed in if needed
|
27
|
-
* :access (optional) - Default access is private, but can be set to 'public-read' and maybe even 'public-write'
|
28
|
-
|
29
|
-
(For more information on access level options, look in the Amazon S3 docs: http://aws.amazon.com/documentation)
|
30
|
-
|
31
|
-
This will return your file's new location on s3:
|
32
|
-
|
33
|
-
=> 'http://s3.amazonaws.com/my-bucket/picture.png'
|
34
|
-
|
35
|
-
The destination path is constructed thus: http://s3.amazonaws.com/ + bucket name + key
|
8
|
+
TODO
|
36
9
|
|
37
10
|
== FAQ
|
38
11
|
|
data/lib/ThreeStore.rb
CHANGED
@@ -1,30 +1,23 @@
|
|
1
1
|
require 'open-uri'
|
2
2
|
require 'aws/s3'
|
3
|
-
require 'digest/md5'
|
4
3
|
autoload :VERSION, "ThreeStore/version"
|
5
4
|
|
5
|
+
# maybe a class:
|
6
|
+
# def initalize(key, secret, bucket)
|
6
7
|
class ThreeStore
|
7
8
|
def initialize(key, secret, bucket)
|
8
9
|
AWS::S3::Base.establish_connection!(:access_key_id => key, :secret_access_key => secret)
|
9
10
|
@bucket = bucket
|
10
11
|
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
# access_level,
|
15
|
-
# key (destination on s3)
|
16
|
-
|
17
|
-
def store_on_s3(options)
|
18
|
-
# Deleting :url from options because we don't want it in the options that we pass to s3
|
19
|
-
# and removing some characters that aren't allowed in urls
|
20
|
-
url = options.delete(:url).gsub(/ /, '%20').gsub(/\^/, '%5E')
|
13
|
+
def store_on_s3(url)
|
14
|
+
url.gsub!(/ /, '%20')
|
21
15
|
file = open(url)
|
16
|
+
AWS::S3::S3Object.store(url, file.read, @bucket)
|
17
|
+
end
|
22
18
|
|
23
|
-
key = options.delete(:key)
|
24
19
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
"http://s3.amazonaws.com/" + @bucket + "/" + key
|
29
|
-
end
|
20
|
+
# store method should return location of thing being stored
|
21
|
+
# maybe also add a hexdigest to the name
|
22
|
+
# def store(url)
|
30
23
|
end
|
data/lib/ThreeStore/version.rb
CHANGED
data/spec/lib/ThreeStore_spec.rb
CHANGED
@@ -1,15 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'yaml'
|
3
2
|
|
4
3
|
describe ThreeStore do
|
4
|
+
|
5
5
|
before(:all) do
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@store = ThreeStore.new(@yaml[:access_key_id], @yaml[:secret_access_key], @test_bucket)
|
9
|
-
end
|
10
|
-
|
11
|
-
after(:all) do
|
12
|
-
AWS::S3::Bucket.find(@test_bucket).clear
|
6
|
+
@test_bucket = 'hedgeye-test-bucket-3'
|
7
|
+
@store = ThreeStore.new(ENV['S3_KEY'], ENV['S3_SECRET'], @test_bucket)
|
13
8
|
end
|
14
9
|
|
15
10
|
it "should establish a connection with s3" do
|
@@ -17,21 +12,16 @@ describe ThreeStore do
|
|
17
12
|
end
|
18
13
|
|
19
14
|
it "should put a given file on s3" do
|
20
|
-
url =
|
21
|
-
s3_object_path = @store.store_on_s3(:url => url, :key => "hedgeye-button-sprite.png", :access => 'public-read')
|
15
|
+
url = "http://app.quotemedia.com/quotetools/getChart.go?webmasterId=98924&symbol=COMP&chsym=Nasdaq%20Comp&chscale=5d&chtype=AreaChart&chfrmon=on&chfrm=ffffff&chbdron=on&chbdr=cccccc&chbg=ffffff&chbgch=ffffff&chln=465665&chfill=1B57AA&chfill2=c0c9d2&chgrdon=on&chgrd=cccccc&chton=on&chtcol=000000&chxyc=111111&chpcon=on&chpccol=ee0000&chmrg=2&chhig=250&chwid=380"
|
22
16
|
|
23
|
-
|
17
|
+
@store.store_on_s3(url)
|
18
|
+
AWS::S3::S3Object.exists?(url, @test_bucket).should be_true
|
24
19
|
end
|
25
20
|
|
26
|
-
|
27
|
-
|
28
|
-
url = "http://app.quotemedia.com/quotetools/getChart.go?webmasterId=500&symbol=^DOW&chsym=^DOW Comp" +
|
29
|
-
"&chscale=5d&chtype=AreaChart&chfrmon=on&chfrm=ffffff&chbdron=on&chbdr=cccccc&chbg=ffffff" +
|
30
|
-
"&chbgch=ffffff&chln=465665&chfill=1B57AA&chfill2=c0c9d2&chgrdon=on&chgrd=cccccc&chton=on" +
|
31
|
-
"&chtcol=000000&chxyc=111111&chpcon=on&chpccol=ee0000&chmrg=2&chhig=250&chwid=380"
|
32
|
-
|
33
|
-
s3_object_path = @store.store_on_s3(:url => url, :key => "quotemedia_chart.png", :content_type => 'image/png', :access => 'public-read')
|
21
|
+
it "should function with a url containing spaces" do
|
22
|
+
url = "http://app.quotemedia.com/quotetools/getChart.go?webmasterId=98924&symbol=COMP&chsym=Nasdaq Comp&chscale=5d&chtype=AreaChart&chfrmon=on&chfrm=ffffff&chbdron=on&chbdr=cccccc&chbg=ffffff&chbgch=ffffff&chln=465665&chfill=1B57AA&chfill2=c0c9d2&chgrdon=on&chgrd=cccccc&chton=on&chtcol=000000&chxyc=111111&chpcon=on&chpccol=ee0000&chmrg=2&chhig=250&chwid=380"
|
34
23
|
|
35
|
-
|
24
|
+
@store.store_on_s3(url)
|
25
|
+
AWS::S3::S3Object.exists?(url, @test_bucket).should be_true
|
36
26
|
end
|
37
27
|
end
|
metadata
CHANGED
@@ -1,80 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ThreeStore
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
- b
|
11
|
-
version: 0.0.1.b
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
12
6
|
platform: ruby
|
13
|
-
authors:
|
7
|
+
authors:
|
14
8
|
- Chenoa Siegenthaler
|
15
9
|
autorequire:
|
16
10
|
bindir: bin
|
17
11
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-11-30 00:00:00.000000000 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
22
16
|
name: aws-s3
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: &2156749340 !ruby/object:Gem::Requirement
|
25
18
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
33
23
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: rake
|
37
24
|
prerelease: false
|
38
|
-
|
25
|
+
version_requirements: *2156749340
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rake
|
28
|
+
requirement: &2156748840 !ruby/object:Gem::Requirement
|
39
29
|
none: false
|
40
|
-
requirements:
|
30
|
+
requirements:
|
41
31
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
hash: 11
|
44
|
-
segments:
|
45
|
-
- 0
|
46
|
-
- 9
|
47
|
-
- 2
|
48
|
-
- 2
|
32
|
+
- !ruby/object:Gem::Version
|
49
33
|
version: 0.9.2.2
|
50
34
|
type: :development
|
51
|
-
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: rspec
|
54
35
|
prerelease: false
|
55
|
-
|
36
|
+
version_requirements: *2156748840
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec
|
39
|
+
requirement: &2156748340 !ruby/object:Gem::Requirement
|
56
40
|
none: false
|
57
|
-
requirements:
|
41
|
+
requirements:
|
58
42
|
- - ~>
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
hash: 27
|
61
|
-
segments:
|
62
|
-
- 2
|
63
|
-
- 5
|
64
|
-
- 0
|
43
|
+
- !ruby/object:Gem::Version
|
65
44
|
version: 2.5.0
|
66
45
|
type: :development
|
67
|
-
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *2156748340
|
68
48
|
description: Get files from a url and store them on s3
|
69
|
-
email:
|
49
|
+
email:
|
70
50
|
- cowmanifestation@gmail.com
|
71
51
|
executables: []
|
72
|
-
|
73
52
|
extensions: []
|
74
|
-
|
75
53
|
extra_rdoc_files: []
|
76
|
-
|
77
|
-
files:
|
54
|
+
files:
|
78
55
|
- .gitignore
|
79
56
|
- .rspec
|
80
57
|
- .travis.yml
|
@@ -86,41 +63,31 @@ files:
|
|
86
63
|
- lib/ThreeStore/version.rb
|
87
64
|
- spec/lib/ThreeStore_spec.rb
|
88
65
|
- spec/spec_helper.rb
|
66
|
+
has_rdoc: true
|
89
67
|
homepage: http://github.com/cowmanifestation/threestore
|
90
68
|
licenses: []
|
91
|
-
|
92
69
|
post_install_message:
|
93
70
|
rdoc_options: []
|
94
|
-
|
95
|
-
require_paths:
|
71
|
+
require_paths:
|
96
72
|
- lib
|
97
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
74
|
none: false
|
99
|
-
requirements:
|
100
|
-
- -
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
|
103
|
-
|
104
|
-
- 0
|
105
|
-
version: "0"
|
106
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
80
|
none: false
|
108
|
-
requirements:
|
109
|
-
- -
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
|
112
|
-
segments:
|
113
|
-
- 1
|
114
|
-
- 3
|
115
|
-
- 1
|
116
|
-
version: 1.3.1
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
117
85
|
requirements: []
|
118
|
-
|
119
86
|
rubyforge_project: ThreeStore
|
120
|
-
rubygems_version: 1.
|
87
|
+
rubygems_version: 1.6.2
|
121
88
|
signing_key:
|
122
89
|
specification_version: 3
|
123
90
|
summary: Get files from a url and store them on s3
|
124
|
-
test_files:
|
91
|
+
test_files:
|
125
92
|
- spec/lib/ThreeStore_spec.rb
|
126
93
|
- spec/spec_helper.rb
|