multi_encoder 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/README.md +11 -16
- data/lib/multi_encoder/storage.rb +7 -0
- data/lib/multi_encoder/storage/aws.rb +3 -3
- data/lib/multi_encoder/storage/filesystem.rb +3 -1
- data/lib/multi_encoder/version.rb +1 -1
- data/spec/multi_encoder/barcode_image_spec.rb +6 -1
- data/spec/multi_encoder/qrcode_image_spec.rb +6 -1
- metadata +5 -4
- data/.rvmrc +0 -1
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
multi-encoder
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-1.9.3-p286
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ You'll also need <tt>ImageMagick</tt> to generate the barcode png's.
|
|
19
19
|
|
20
20
|
Add this line to your application's Gemfile:
|
21
21
|
|
22
|
-
gem 'multi_encoder'
|
22
|
+
gem 'multi_encoder'
|
23
23
|
|
24
24
|
And then execute:
|
25
25
|
|
@@ -57,29 +57,24 @@ into the view.
|
|
57
57
|
|
58
58
|
There is nothing to configure if you want the resulting png's saved to
|
59
59
|
the filesystem. This is the default. If you want to upload the images to
|
60
|
-
AS3 you'll need to
|
60
|
+
AS3 you'll need to configure the sorage options, like so:
|
61
61
|
|
62
|
-
|
62
|
+
MultiEncoder::Storage.configure do |c|
|
63
|
+
c.destination = :aws
|
64
|
+
c.aws_bucket_prefix = SOME_PREFIX
|
65
|
+
c.aws_access_key = YOUR_ACCESS_KEY
|
66
|
+
c.aws_secret_access_key = YOUR_SECRET_ACCESS_KEY
|
67
|
+
end
|
63
68
|
|
64
|
-
|
65
|
-
|
66
|
-
If you want all environments to upload to aws, just add it to
|
67
|
-
<tt>application.rb</tt> or an initializer.
|
68
|
-
|
69
|
-
Second: export your AWS credentials as environment variables, like so in
|
70
|
-
<tt>.bash_profile</tt> or whatever:
|
71
|
-
|
72
|
-
export AWS_ACCESS_KEY="STHSTCHSTHSTHCONT"
|
73
|
-
export AWS_SECRET_ACCESS_KEY="YI7799xtuAAStEG8hmBGidoQ7hJJeHVEg"
|
69
|
+
It is also possible to set these values as environment valiables
|
74
70
|
|
75
71
|
That's it, you are ready to go.
|
76
72
|
|
77
73
|
The gem will create buckets with the following names, depending on the
|
78
74
|
Rails environment:
|
79
75
|
|
80
|
-
|
81
|
-
|
82
|
-
multi-encoder-production-barcodes
|
76
|
+
[prefix]-development-barcodes
|
77
|
+
[prefix]-development-qrcodes
|
83
78
|
|
84
79
|
and so on.
|
85
80
|
|
@@ -3,6 +3,13 @@ require 'active_support/core_ext/module/attribute_accessors'
|
|
3
3
|
module MultiEncoder
|
4
4
|
module Storage
|
5
5
|
mattr_reader :destination
|
6
|
+
mattr_accessor :aws_bucket_prefix
|
7
|
+
mattr_accessor :aws_access_key
|
8
|
+
mattr_accessor :aws_secret_access_key
|
9
|
+
|
10
|
+
def self.configure
|
11
|
+
yield self
|
12
|
+
end
|
6
13
|
|
7
14
|
def self.destination=(dest)
|
8
15
|
unless [:filesystem, :aws].include? dest
|
@@ -26,7 +26,7 @@ module MultiEncoder
|
|
26
26
|
def aws_directory
|
27
27
|
env = defined?(Rails) ? Rails.env : 'gem-dev'
|
28
28
|
@aws_directory ||= connection.directories.create({
|
29
|
-
key: "
|
29
|
+
key: "#{Storage.aws_bucket_prefix}-#{env}-#{type}",
|
30
30
|
public: true
|
31
31
|
})
|
32
32
|
end
|
@@ -64,8 +64,8 @@ module MultiEncoder
|
|
64
64
|
def connection
|
65
65
|
::Fog::Storage.new({
|
66
66
|
provider: 'AWS',
|
67
|
-
aws_access_key_id:
|
68
|
-
aws_secret_access_key:
|
67
|
+
aws_access_key_id: Storage.aws_access_key,
|
68
|
+
aws_secret_access_key: Storage.aws_secret_access_key
|
69
69
|
})
|
70
70
|
end
|
71
71
|
end
|
@@ -35,7 +35,12 @@ module MultiEncoder
|
|
35
35
|
|
36
36
|
context "AWS storage" do
|
37
37
|
before do
|
38
|
-
MultiEncoder::Storage.
|
38
|
+
MultiEncoder::Storage.configure do |c|
|
39
|
+
c.destination = :aws
|
40
|
+
c.aws_bucket_prefix = ENV['AWS_BUCKET_PREFIX']
|
41
|
+
c.aws_access_key = ENV['AWS_ACCESS_KEY']
|
42
|
+
c.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
|
43
|
+
end
|
39
44
|
end
|
40
45
|
|
41
46
|
after do
|
@@ -35,7 +35,12 @@ module MultiEncoder
|
|
35
35
|
|
36
36
|
context "AWS storage" do
|
37
37
|
before do
|
38
|
-
MultiEncoder::Storage.
|
38
|
+
MultiEncoder::Storage.configure do |c|
|
39
|
+
c.destination = :aws
|
40
|
+
c.aws_bucket_prefix = ENV['AWS_BUCKET_PREFIX']
|
41
|
+
c.aws_access_key = ENV['AWS_ACCESS_KEY']
|
42
|
+
c.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
|
43
|
+
end
|
39
44
|
end
|
40
45
|
|
41
46
|
after do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_encoder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: qrencoder
|
@@ -149,7 +149,8 @@ extra_rdoc_files: []
|
|
149
149
|
files:
|
150
150
|
- .gitignore
|
151
151
|
- .rspec
|
152
|
-
- .
|
152
|
+
- .ruby-gemset
|
153
|
+
- .ruby-version
|
153
154
|
- Gemfile
|
154
155
|
- LICENSE.txt
|
155
156
|
- README.md
|
@@ -209,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
210
|
version: '0'
|
210
211
|
segments:
|
211
212
|
- 0
|
212
|
-
hash:
|
213
|
+
hash: -335514368553364785
|
213
214
|
requirements:
|
214
215
|
- ImageMagick
|
215
216
|
rubyforge_project:
|
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm 1.9.3-p286@multi-encoder --create
|