t_bird 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +53 -42
- data/lib/t_bird/processor.rb +6 -4
- data/lib/t_bird/transmitter.rb +13 -23
- data/lib/t_bird/uploader.rb +11 -11
- data/lib/t_bird/version.rb +1 -1
- data/spec/spec_helper.rb +6 -4
- data/spec/t_bird/processor_spec.rb +17 -17
- data/spec/t_bird/transmitter_spec.rb +18 -15
- data/spec/t_bird/uploader_spec.rb +13 -7
- data/t_bird.gemspec +6 -3
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 133ff6c9059ab7d0d5b3752c1bfbcdfcf7b2df3e
|
4
|
+
data.tar.gz: 37421c6e9a79f1f40f3e6eef1028ddb1ebaf4ca5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7493c8a2691ac3033a2887193a58b15ed268d7dd7dd82be6bef6069ce81cba0200ec9e997082de2026d052eb48bad63cd89bab0e5a749c390d5aef985e7bc373
|
7
|
+
data.tar.gz: c368763040e81bf9155e79a4011309e21113d71fbe9fbcbd64bc31ea89236ba90b41e7f475cf9c58a95a6ecd00ecbb934c0d4384a2b5f72acf04f28e158d861e
|
data/README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# t_bird
|
2
2
|
|
3
|
-
|
3
|
+
Straight forward uploads for your Ruby apps.
|
4
4
|
|
5
|
+
_Uploading is... fun, fun, fun, until daddy takes the `t_bird` away._
|
5
6
|
|
6
7
|
## Project Status
|
7
8
|
|
9
|
+
- Version: [![Gem Version](https://badge.fury.io/rb/t_bird.png)](http://badge.fury.io/rb/t_bird)
|
8
10
|
- Build: [![Build Status](https://secure.travis-ci.org/xentek/t_bird.png)](http://travis-ci.org/xentek/t_bird)
|
9
11
|
- Dependencies: [![Dependency Status](https://gemnasium.com/xentek/t_bird.png)](https://gemnasium.com/xentek/t_bird)
|
10
12
|
- Code Quality: [![Code Climate](https://d3s6mut3hikguw.cloudfront.net/github/xentek/t_bird.png)](https://codeclimate.com/github/xentek/t_bird)
|
@@ -13,7 +15,7 @@ Uploading is... fun, fun, fun, until daddy takes the `t_bird` away.
|
|
13
15
|
|
14
16
|
Add this line to your application's Gemfile:
|
15
17
|
|
16
|
-
gem 't_bird'
|
18
|
+
gem 't_bird', require: false
|
17
19
|
|
18
20
|
And then execute:
|
19
21
|
|
@@ -22,20 +24,20 @@ And then execute:
|
|
22
24
|
## Why?
|
23
25
|
|
24
26
|
I became frustrated by the very coupled design of the leading ruby
|
25
|
-
upload libraries and wanted something that was
|
26
|
-
allow for flexibility), wasn't glued to a `
|
27
|
-
most common use case out of the box:
|
27
|
+
upload libraries and wanted something that was more modular (to
|
28
|
+
allow for flexibility), wasn't glued to a `Model` (or any other class),
|
29
|
+
and fulfilled my most common use case out of the box:
|
28
30
|
|
29
31
|
- Upload an image, posted from a multi-part form,
|
30
32
|
- process the file into 1 or more versions (resize, crop, etc),
|
31
|
-
- and
|
32
|
-
the local filesystem.
|
33
|
+
- and upload the file(s) to S3 for storage.
|
33
34
|
|
34
35
|
## Usage
|
35
36
|
|
36
37
|
First, configure `t_bird` with a few settings:
|
37
38
|
|
38
39
|
````ruby
|
40
|
+
require 't_bird'
|
39
41
|
TBird::Configuration.configure |config|
|
40
42
|
config.aws_key 'amazon access key id'
|
41
43
|
config.aws_secret 'amazon secret access key'
|
@@ -45,8 +47,8 @@ end
|
|
45
47
|
````
|
46
48
|
Place this code so that it runs when your app boots.
|
47
49
|
|
48
|
-
- If you're using Sinatra or Rack, `config.ru` is probably a good spot.
|
49
|
-
- If you're using Rails, put the configuration in an initializer, e.g. `config/initializers/t_bird.rb`.
|
50
|
+
- If you're using Sinatra or Rack, `config.ru` is probably a good spot.
|
51
|
+
- If you're using Rails, put the configuration in an initializer, e.g. `config/initializers/t_bird.rb`.
|
50
52
|
|
51
53
|
Then, assuming you have a multipart form like this:
|
52
54
|
|
@@ -60,12 +62,19 @@ _Example is using [slim](http://slim-lang.com) for clarity and terseness, but th
|
|
60
62
|
In the action the form posts to, grab the uploaded file and upload it with `t_bird`:
|
61
63
|
|
62
64
|
````ruby
|
63
|
-
|
65
|
+
# prepended to your filename and enables you
|
66
|
+
# to create a path to your file on S3
|
67
|
+
options = { identifier: "images/brands" }
|
64
68
|
|
65
|
-
|
69
|
+
# instantiate your uploader, pass it your file
|
70
|
+
uploader = TBird::Uploader.new(params[:brand][:image], options)
|
66
71
|
|
67
|
-
|
68
|
-
|
72
|
+
# return value is the same as uploader.uploads
|
73
|
+
uploader.upload!
|
74
|
+
|
75
|
+
# returns a hash of the URL(s) to your uploads on S3
|
76
|
+
# store this in the way that makes the most sense for your app
|
77
|
+
brand.images = uploader.uploads
|
69
78
|
````
|
70
79
|
|
71
80
|
- By default, there are two `versions` defined: `:thumbnail` and `:original`.
|
@@ -78,25 +87,26 @@ uploader.uploads # returns a hash of urls pointing to your image versions
|
|
78
87
|
There are three options you can pass into your `TBird::Uploader` instance:
|
79
88
|
|
80
89
|
- `:identifer`
|
81
|
-
- app specific identifer for his upload, e.g. your model's databae ID, timestamp, whatever
|
90
|
+
- app specific identifer for his upload, e.g. your model's databae ID, the date or timestamp, whatever
|
82
91
|
- used as the folder this file's uploads are stored in on s3
|
83
92
|
- you can pass a path fragment here to create a folder heirarchy, e.g. 'uploads/images'
|
84
93
|
- don't want any folders?, just pass an empty string, e.g. `''`
|
85
94
|
- defaults to a `SHA1` digest of the `original_filename`
|
86
95
|
- value should be URL safe, no encoding is done for you by `t_bird`
|
87
96
|
- `:token`
|
88
|
-
- needs to be a unique value per upload, to help avoid name collisions and writing over existing files
|
97
|
+
- needs to be a unique value per upload, to help avoid name collisions and writing over any existing files
|
89
98
|
- used as part of the filename, version and extension are
|
90
99
|
automatically appended on to the end.
|
91
|
-
- defaults to a [UUID](http://en.wikipedia.org/wiki/Universally_unique_identifier)
|
100
|
+
- defaults to a [UUID](http://en.wikipedia.org/wiki/Universally_unique_identifier)
|
101
|
+
- think hard before straying from this strategy, UUIDs are generated quickly and
|
102
|
+
are nearly immune to collision (there is a higher probablity of you personally being
|
103
|
+
struck by a metorite than generating two UUIDs that have the same value.)
|
92
104
|
- value should be URL safe, no encoding is done for you by `t_bird`
|
93
105
|
- `:metadata`
|
94
|
-
- value must be a hash
|
95
|
-
-
|
96
|
-
|
97
|
-
-
|
98
|
-
the name/title of the model it's associated with, etc.
|
99
|
-
- `t_bird` doesn't provide any read access to this metadata, once it's stored on S3, so it's up to you to use S3's API to do anything with it.
|
106
|
+
- value must be a hash
|
107
|
+
- values in this hash will be stored, with your file, on S3
|
108
|
+
- this could be used for tagging your files, e.g. `tags: brands, images`, or anything else you might think of
|
109
|
+
- `t_bird` doesn't provide any read access to this metadata, once it's stored on S3. It's up to you to use S3's API to do anything with it.
|
100
110
|
|
101
111
|
## Custom Uploaders
|
102
112
|
|
@@ -110,12 +120,10 @@ class FileUploader < TBird::Uploader
|
|
110
120
|
end
|
111
121
|
````
|
112
122
|
|
113
|
-
- In this simple example we have created a subclass and defined a single
|
114
|
-
version, `:original`, that skips processing the file, making `FileUploader` suitable
|
115
|
-
for handling non-image uploads.
|
123
|
+
- In this simple example we have created a subclass and defined a single version, `:original`
|
116
124
|
- No other versions were defined, so only `:original` will be created.
|
117
|
-
- In other words, if you create a subclass without any `versions`
|
118
|
-
|
125
|
+
- In other words, if you create a subclass without any `versions` defined, your uploader
|
126
|
+
won't upload anything.
|
119
127
|
|
120
128
|
Here's a more complex example that defines several custom `versions`:
|
121
129
|
|
@@ -137,14 +145,16 @@ class ComplexUploader < TBird::Uploader
|
|
137
145
|
->(img) { img.resize '500x300' }
|
138
146
|
end
|
139
147
|
|
140
|
-
# custom thumbnail size, allowing your to ignore
|
148
|
+
# custom thumbnail size, allowing your to ignore
|
149
|
+
# the value of TBird::Configuration.thumbnail_size
|
141
150
|
# on an uploader by uploader basis
|
142
151
|
version :thumbnail do
|
143
152
|
->(img) { img.thumbnail 200 }
|
144
153
|
end
|
145
154
|
|
146
155
|
# want MOAR power?
|
147
|
-
# use process, which gets you inside a
|
156
|
+
# use process, which gets you inside a
|
157
|
+
# MiniMagick::Image#combine_options block
|
148
158
|
version :complex do
|
149
159
|
lambda do |img|
|
150
160
|
img.process do |magick|
|
@@ -158,21 +168,22 @@ end
|
|
158
168
|
````
|
159
169
|
For more information on `MiniMagick::Image#combine_options`, refer to the [mini_magick docs](https://github.com/minimagick/minimagick/blob/master/README.md).
|
160
170
|
|
161
|
-
:skull: `TBird::Processor#process` can be a _very sharp stick_, so carefully test your processing code with a variety of files in a non-production environment, and as usual be wary of using values from outside of your class as input for your processing routines.
|
171
|
+
:skull: `TBird::Processor#process` can be a _very sharp stick_, so carefully test your processing code with a variety of files in a non-production environment, and as usual, be wary of using values from outside of your class as input for your processing routines.
|
162
172
|
|
163
173
|
## More customization options
|
164
174
|
|
165
|
-
- Redefine the `namer` method in your subclass to switch out the object that's responsible for generating the name used on S3.
|
166
|
-
|
167
|
-
- Redefine the `processor` method in your subclass to switch out the processing library.
|
168
|
-
|
169
|
-
|
170
|
-
- Redefine the `upload!` to remix the whole
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
-
|
175
|
-
|
175
|
+
- Redefine the `namer` method in your subclass to switch out the object that's responsible for generating the name used on S3.
|
176
|
+
- Your object must respond to `new_name`, and take the `version`, which will be a symbol, as input.
|
177
|
+
- Redefine the `processor` method in your subclass to switch out the processing library.
|
178
|
+
- Blocks defined by the `version` macro will be passed an instance of your `processor`,
|
179
|
+
so be sure that your `processor` will respond to any methods the code inside your blocks call on it.
|
180
|
+
- Redefine the `upload!` method to remix the whole flow!
|
181
|
+
- really the sky's the limit here, but at some point you might be
|
182
|
+
better of just writing your own uploader class that doesn't sit on
|
183
|
+
top of `t_bird`
|
184
|
+
- Currently this is the only way to swith out S3 for another storage provider.
|
185
|
+
- Better support for changing the storage mechanism will likely come out in a future version.
|
186
|
+
- Talk to me __before working on a patch__ for this, so we can agree on implementation.
|
176
187
|
|
177
188
|
## Contributing
|
178
189
|
|
@@ -186,5 +197,5 @@ For more information on `MiniMagick::Image#combine_options`, refer to the [mini_
|
|
186
197
|
|
187
198
|
#### Colophon
|
188
199
|
|
189
|
-
- This project was not named after the Thunderbird model of car. Ford Motor Company does not have any connection to, or responsibility for this project, and does not endorse it in any way (or even know it exists).
|
200
|
+
- This project was not named after the Thunderbird model of car. Ford Motor Company does not have any connection to, or responsibility for this project, and does not endorse it in any way (or even know it exists. Probably).
|
190
201
|
- Sample image, used in tests, was provided by [cherrylet](http://www.flickr.com/photos/cherrylet/10258332985/sizes/o/in/photostream/), under the Creative Commons 2.0. No endorsement of this library by the photographer is intended or implied.
|
data/lib/t_bird/processor.rb
CHANGED
@@ -7,21 +7,23 @@ module TBird
|
|
7
7
|
attr_reader :image
|
8
8
|
def initialize(file_blob)
|
9
9
|
@image = MiniMagick::Image.read(file_blob)
|
10
|
+
@tempfile = Tempfile.new(SecureRandom.uuid)
|
10
11
|
end
|
11
12
|
|
12
13
|
def process(&block)
|
13
14
|
image.combine_options do |img|
|
14
15
|
block.call(img) if block_given?
|
15
16
|
end
|
16
|
-
|
17
|
+
write_to_file
|
17
18
|
end
|
18
19
|
|
19
|
-
def
|
20
|
-
image.write
|
20
|
+
def write_to_file
|
21
|
+
image.write @tempfile
|
22
|
+
@tempfile
|
21
23
|
end
|
22
24
|
|
23
25
|
def original
|
24
|
-
|
26
|
+
write_to_file
|
25
27
|
end
|
26
28
|
|
27
29
|
def resize(size)
|
data/lib/t_bird/transmitter.rb
CHANGED
@@ -4,37 +4,27 @@ require 'aws/s3'
|
|
4
4
|
|
5
5
|
module TBird
|
6
6
|
class Transmitter
|
7
|
-
|
8
|
-
|
9
|
-
def initialize(name, file, metadata = {})
|
10
|
-
@name = name
|
11
|
-
@file = file
|
12
|
-
@metadata = default_metadata.merge(metadata)
|
13
|
-
connect!
|
7
|
+
def initialize
|
8
|
+
@s3 = AWS::S3.new(access_key_id: Configuration.aws_key, secret_access_key: Configuration.aws_secret)
|
14
9
|
end
|
15
10
|
|
16
|
-
def transmit!
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
@success ||= Service.response.success?
|
21
|
-
@success
|
22
|
-
end
|
23
|
-
|
24
|
-
def url
|
25
|
-
@url ||= S3Object.url_for(name, Configuration.aws_bucket, authenticated: false, use_ssl: true)
|
11
|
+
def transmit!(name, file, options = {})
|
12
|
+
s3object = s3bucket.objects[name]
|
13
|
+
s3object.write(file, default_options.merge(options))
|
14
|
+
s3object.public_url(secure: true)
|
26
15
|
end
|
27
16
|
|
28
17
|
private
|
29
18
|
|
30
|
-
def
|
31
|
-
|
19
|
+
def s3bucket
|
20
|
+
@s3bucket ||= @s3.buckets[Configuration.aws_bucket]
|
32
21
|
end
|
33
22
|
|
34
|
-
def
|
35
|
-
{
|
36
|
-
|
37
|
-
content_type: 'binary/octet-stream'
|
23
|
+
def default_options
|
24
|
+
{
|
25
|
+
acl: :public_read,
|
26
|
+
content_type: 'binary/octet-stream',
|
27
|
+
metadata: {}
|
38
28
|
}
|
39
29
|
end
|
40
30
|
end
|
data/lib/t_bird/uploader.rb
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
module TBird
|
4
4
|
class Uploader
|
5
|
-
attr_reader :file, :options, :uploads, :content_type, :original_filename
|
5
|
+
attr_reader :file, :options, :uploads, :content_type, :original_filename, :metadata
|
6
6
|
def initialize(file, options = {})
|
7
7
|
@file = file
|
8
8
|
@options = default_options.merge(options)
|
9
9
|
@uploads = {}
|
10
|
-
@content_type = @file
|
11
|
-
@original_filename = @file
|
12
|
-
@options[:metadata]
|
10
|
+
@content_type = @file[:type]
|
11
|
+
@original_filename = @file[:filename]
|
12
|
+
@metadata = { content_type: content_type, metadata: @options[:metadata] || {} }
|
13
13
|
end
|
14
14
|
|
15
15
|
def namer
|
@@ -17,15 +17,16 @@ module TBird
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def processor
|
20
|
-
|
20
|
+
Processor.new(@file[:tempfile])
|
21
|
+
end
|
22
|
+
|
23
|
+
def transmitter
|
24
|
+
@transmitter ||= Transmitter.new
|
21
25
|
end
|
22
26
|
|
23
27
|
def upload!
|
24
28
|
versions.each do |version,block|
|
25
|
-
block.call(processor)
|
26
|
-
transmission = Transmitter.new(namer.new_name(version), processor.stream, options[:metadata])
|
27
|
-
transmission.transmit!
|
28
|
-
@uploads[version] = transmission.url
|
29
|
+
@uploads[version] = transmitter.transmit!(namer.new_name(version), block.call(processor), metadata)
|
29
30
|
end
|
30
31
|
uploads
|
31
32
|
end
|
@@ -51,8 +52,7 @@ module TBird
|
|
51
52
|
def default_options
|
52
53
|
{
|
53
54
|
identifier: nil,
|
54
|
-
token: nil
|
55
|
-
metadata: {}
|
55
|
+
token: nil
|
56
56
|
}
|
57
57
|
end
|
58
58
|
end
|
data/lib/t_bird/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -24,10 +24,12 @@ module TBirdSpecData
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def upload_file
|
27
|
-
Rack::Test::UploadedFile.new(sample_file, 'image/jpeg')
|
28
|
-
end
|
27
|
+
upload = Rack::Test::UploadedFile.new(sample_file, 'image/jpeg')
|
29
28
|
|
30
|
-
|
31
|
-
|
29
|
+
{
|
30
|
+
filename: upload.original_filename,
|
31
|
+
type: upload.content_type,
|
32
|
+
tempfile: upload.instance_variable_get(:@tempfile)
|
33
|
+
}
|
32
34
|
end
|
33
35
|
end
|
@@ -7,36 +7,36 @@ describe TBird::Processor do
|
|
7
7
|
|
8
8
|
before do
|
9
9
|
@custom_process = ->(img) { img.quality 88 }
|
10
|
-
@processor = TBird::Processor.new(upload_file)
|
10
|
+
@processor = TBird::Processor.new(upload_file[:tempfile])
|
11
11
|
end
|
12
12
|
|
13
13
|
it "can process an image" do
|
14
|
-
|
15
|
-
image.valid?.must_equal true
|
16
|
-
image.destroy!
|
14
|
+
@processor.process(&@custom_process)
|
15
|
+
@processor.image.valid?.must_equal true
|
16
|
+
@processor.image.destroy!
|
17
17
|
end
|
18
18
|
|
19
19
|
it "can thumbnail an image" do
|
20
|
-
|
21
|
-
image.valid?.must_equal true
|
22
|
-
image.destroy!
|
20
|
+
@processor.thumbnail
|
21
|
+
@processor.image.valid?.must_equal true
|
22
|
+
@processor.image.destroy!
|
23
23
|
end
|
24
24
|
|
25
25
|
it "can resize an image" do
|
26
|
-
|
27
|
-
image.valid?.must_equal true
|
28
|
-
image.destroy!
|
26
|
+
@processor.resize('300')
|
27
|
+
@processor.image.valid?.must_equal true
|
28
|
+
@processor.image.destroy!
|
29
29
|
end
|
30
30
|
|
31
31
|
it "can return the original image" do
|
32
|
-
|
33
|
-
image.valid?.must_equal true
|
34
|
-
image.destroy!
|
32
|
+
@processor.original
|
33
|
+
@processor.image.valid?.must_equal true
|
34
|
+
@processor.image.destroy!
|
35
35
|
end
|
36
36
|
|
37
|
-
it "can write image
|
38
|
-
|
39
|
-
@processor.
|
40
|
-
image.destroy!
|
37
|
+
it "can write image" do
|
38
|
+
@processor.resize('x200')
|
39
|
+
@processor.write_to_file.must_be_instance_of File
|
40
|
+
@processor.image.destroy!
|
41
41
|
end
|
42
42
|
end
|
@@ -10,27 +10,30 @@ describe TBird::Transmitter do
|
|
10
10
|
config.aws_secret = '123'
|
11
11
|
config.aws_bucket = 'bucket'
|
12
12
|
end
|
13
|
-
|
14
|
-
keys = { access_key_id: TBird::Configuration.aws_key,
|
15
|
-
secret_access_key: TBird::Configuration.aws_secret,
|
16
|
-
use_ssl: true }
|
17
|
-
|
18
|
-
AWS::S3::S3Object.stubs(:connected?).returns(true)
|
19
|
-
AWS::S3::Base.stubs(:establish_connection!).with(keys)
|
20
|
-
AWS::S3::Service.stubs(response: stub(:success? => true))
|
21
13
|
|
22
14
|
@stored_filename = '1/sample_original.jpg'
|
23
15
|
@upload = upload_file
|
24
|
-
@
|
16
|
+
@opts = { acl: :public_read, content_type: 'image/jpeg', metadata: {} }
|
17
|
+
@aws_config = stub_everything('aws_config')
|
18
|
+
@s3object = stub(public_url: "https://bucket.s3.amazonaws.com/#{@stored_filename}")
|
19
|
+
@bucket = mock('bucket').responds_like(AWS::S3::Bucket.new(TBird::Configuration.aws_bucket, config: @aws_config))
|
20
|
+
@bucket_collection = { TBird::Configuration.aws_bucket => @bucket }
|
21
|
+
end
|
22
|
+
|
23
|
+
it "can connect to s3" do
|
24
|
+
AWS::S3.expects(:new).with(access_key_id: TBird::Configuration.aws_key, secret_access_key: TBird::Configuration.aws_secret)
|
25
|
+
TBird::Transmitter.new
|
25
26
|
end
|
26
27
|
|
27
|
-
it "
|
28
|
-
AWS::S3::
|
29
|
-
|
28
|
+
it "can select s3 bucket" do
|
29
|
+
AWS::S3::BucketCollection.expects(:new).returns(@bucket_collection)
|
30
|
+
TBird::Transmitter.new.send(:s3bucket)
|
30
31
|
end
|
31
32
|
|
32
|
-
it "can
|
33
|
-
|
34
|
-
@
|
33
|
+
it "can transmit file to s3" do
|
34
|
+
@bucket.expects(:objects).returns({ @stored_filename => @s3object })
|
35
|
+
@s3object.expects(:write).with(@upload, { acl: :public_read, content_type: 'image/jpeg', metadata: {} }).returns(@s3object)
|
36
|
+
AWS::S3.stubs(:new).returns(stub(buckets: @bucket_collection))
|
37
|
+
TBird::Transmitter.new.transmit!(@stored_filename, @upload, { content_type: 'image/jpeg' }).must_equal "https://bucket.s3.amazonaws.com/1/sample_original.jpg"
|
35
38
|
end
|
36
39
|
end
|
@@ -16,9 +16,14 @@ describe TBird::Uploader do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "can return the options" do
|
19
|
-
@uploader.options.must_equal({ identifier: nil, token: nil
|
19
|
+
@uploader.options.must_equal({ identifier: nil, token: nil })
|
20
20
|
end
|
21
21
|
|
22
|
+
it "can return the metadata" do
|
23
|
+
@uploader.metadata.must_equal({ content_type: 'image/jpeg', metadata: {} })
|
24
|
+
end
|
25
|
+
|
26
|
+
|
22
27
|
it "can return the content type" do
|
23
28
|
@uploader.content_type.must_equal 'image/jpeg'
|
24
29
|
end
|
@@ -35,21 +40,22 @@ describe TBird::Uploader do
|
|
35
40
|
@uploader.namer.must_be_instance_of TBird::Namer
|
36
41
|
end
|
37
42
|
|
43
|
+
it "can return an instance of Transmitter" do
|
44
|
+
@uploader.transmitter.must_be_instance_of TBird::Transmitter
|
45
|
+
end
|
46
|
+
|
38
47
|
it "can return the registered versions" do
|
39
48
|
@uploader.versions.must_equal TBird::Uploader.versions
|
40
49
|
end
|
41
50
|
|
42
51
|
it "can upload all versions" do
|
43
|
-
TBird::Transmitter.any_instance.stubs(:transmit!)
|
44
|
-
TBird::Transmitter.any_instance.stubs(:url).returns(*@urls)
|
45
|
-
|
52
|
+
TBird::Transmitter.any_instance.stubs(:transmit!).returns(*@urls)
|
46
53
|
@uploader.upload!.must_equal({ thumbnail: @urls.first, original: @urls.last })
|
47
54
|
end
|
48
55
|
|
49
56
|
it "can return the upload urls" do
|
50
|
-
TBird::Transmitter.any_instance.stubs(:transmit!)
|
51
|
-
|
52
|
-
|
57
|
+
TBird::Transmitter.any_instance.stubs(:transmit!).returns(*@urls)
|
58
|
+
|
53
59
|
@uploader.upload!
|
54
60
|
@uploader.uploads.must_equal({ thumbnail: @urls.first, original: @urls.last })
|
55
61
|
end
|
data/t_bird.gemspec
CHANGED
@@ -8,9 +8,12 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = TBird::VERSION
|
9
9
|
gem.authors = ['Eric Marden']
|
10
10
|
gem.email = ['eric@xentek.net']
|
11
|
-
gem.description = %q{Straight forward file uploads for Ruby Apps.}
|
11
|
+
gem.description = %q{Straight forward file uploads for Ruby Apps. Decouple your uploads from your model.}
|
12
12
|
gem.summary = %q{Straight forward file uploads for Ruby Apps.}
|
13
|
-
gem.homepage = '
|
13
|
+
gem.homepage = 'http://xentek.github.io/t_bird'
|
14
|
+
gem.metadata = { 'Github' => 'https://github.com/xentek/t_bird',
|
15
|
+
'README' => 'https://github.com/xentek/t_bird/blob/master/README.md',
|
16
|
+
'Issues' => 'https://github.com/xentek/t_bird/issues' }
|
14
17
|
gem.license = 'MIT'
|
15
18
|
|
16
19
|
gem.files = `git ls-files`.split($/)
|
@@ -19,7 +22,7 @@ Gem::Specification.new do |gem|
|
|
19
22
|
gem.require_paths = ['lib']
|
20
23
|
|
21
24
|
gem.add_dependency 'mini_magick'
|
22
|
-
gem.add_dependency 'aws-
|
25
|
+
gem.add_dependency 'aws-sdk'
|
23
26
|
gem.add_development_dependency 'bundler', '~> 1.3'
|
24
27
|
gem.add_development_dependency 'rake'
|
25
28
|
gem.add_development_dependency 'gem-release'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: t_bird
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Marden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mini_magick
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: aws-
|
28
|
+
name: aws-sdk
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '>='
|
@@ -80,7 +80,8 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description: Straight forward file uploads for Ruby Apps.
|
83
|
+
description: Straight forward file uploads for Ruby Apps. Decouple your uploads from
|
84
|
+
your model.
|
84
85
|
email:
|
85
86
|
- eric@xentek.net
|
86
87
|
executables: []
|
@@ -108,10 +109,13 @@ files:
|
|
108
109
|
- spec/t_bird/transmitter_spec.rb
|
109
110
|
- spec/t_bird/uploader_spec.rb
|
110
111
|
- t_bird.gemspec
|
111
|
-
homepage:
|
112
|
+
homepage: http://xentek.github.io/t_bird
|
112
113
|
licenses:
|
113
114
|
- MIT
|
114
|
-
metadata:
|
115
|
+
metadata:
|
116
|
+
Github: https://github.com/xentek/t_bird
|
117
|
+
README: https://github.com/xentek/t_bird/blob/master/README.md
|
118
|
+
Issues: https://github.com/xentek/t_bird/issues
|
115
119
|
post_install_message:
|
116
120
|
rdoc_options: []
|
117
121
|
require_paths:
|