refinerycms-s3assets 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/README.md +57 -0
- data/lib/refinerycms-s3assets.rb +29 -21
- data/lib/refinerycms-s3assets/version.rb +1 -1
- data/refinerycms-s3assets.gemspec +2 -2
- metadata +44 -80
- data/Gemfile.lock +0 -22
- data/README.rdoc +0 -41
data/.gitignore
CHANGED
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# refinerycms-s3assets
|
2
|
+
|
3
|
+
A common development scenario, when using a Heroku-hosted Refinery CMS app, is to copy production data to development via the use of `heroku db:pull`.
|
4
|
+
This gem adds a rake task to your Refinery CMS project which copies your production assets stored on s3 onto the local filesystem.
|
5
|
+
|
6
|
+
## Requirements
|
7
|
+
|
8
|
+
1. Mac OS X, Linux, or UNIX.
|
9
|
+
2. A Heroku account (or S3 credentials).
|
10
|
+
3. A Refinery CMS project
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Open up your Gemfile and add at the bottom this line:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'refinerycms-s3assets'
|
18
|
+
```
|
19
|
+
|
20
|
+
Now, run:
|
21
|
+
|
22
|
+
```shell
|
23
|
+
bundle install
|
24
|
+
```
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
This gem assumes that your production Heroku app is storing assets on Amazon s3
|
29
|
+
and that your Heroku app has the following three config vars properly defined:
|
30
|
+
`S3_BUCKET`, `S3_KEY` and `S3_SECRET` ( see http://devcenter.heroku.com/articles/config-vars for more info).
|
31
|
+
|
32
|
+
Start by copying your production database to your local database:
|
33
|
+
|
34
|
+
```shell
|
35
|
+
heroku db:pull
|
36
|
+
```
|
37
|
+
|
38
|
+
To copy all Image and Resource files from S3 you can now run the following:
|
39
|
+
|
40
|
+
```shell
|
41
|
+
bundle exec rake refinery:download_s3_assets
|
42
|
+
```
|
43
|
+
|
44
|
+
If you do not have a Heroku application but you do know the S3 credentials then you
|
45
|
+
can provide these manually as ENV variables:
|
46
|
+
|
47
|
+
```shell
|
48
|
+
S3_KEY=key S3_SECRET=secret S3_BUCKET=bucket bundle exec rake refinery:download_s3_assets
|
49
|
+
```
|
50
|
+
|
51
|
+
## License
|
52
|
+
|
53
|
+
Please see MIT-LICENSE for more details.
|
54
|
+
|
55
|
+
## Copyright
|
56
|
+
|
57
|
+
Copyright (c) 2011 Rounders Consulting Inc.
|
data/lib/refinerycms-s3assets.rb
CHANGED
@@ -9,36 +9,36 @@ module Refinery
|
|
9
9
|
Dir[File.join(File.dirname(__FILE__),'tasks/*.rake')].each { |f| load f }
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
class Util
|
14
14
|
|
15
15
|
def self.pull
|
16
|
-
raise(StandardError, "no S3_KEY config var or environment variable found") if s3_config[:
|
17
|
-
raise(StandardError, "no S3_SECRET config var or environment variable found") if s3_config[:
|
18
|
-
raise(StandardError, "no S3_BUCKET config var or environment variable found") if s3_config[:
|
19
|
-
copy_s3_bucket(s3_config[:
|
16
|
+
raise(StandardError, "no S3_KEY config var or environment variable found") if s3_config[:key].nil?
|
17
|
+
raise(StandardError, "no S3_SECRET config var or environment variable found") if s3_config[:secret].nil?
|
18
|
+
raise(StandardError, "no S3_BUCKET config var or environment variable found") if s3_config[:bucket].nil?
|
19
|
+
copy_s3_bucket(s3_config[:key], s3_config[:secret], s3_config[:bucket], 'public/system/refinery')
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
private
|
23
23
|
|
24
24
|
def self.copy_s3_bucket(s3_key, s3_secret, s3_bucket, output_path)
|
25
25
|
AWS::S3::Base.establish_connection!(:access_key_id => s3_key, :secret_access_key => s3_secret)
|
26
26
|
bucket = AWS::S3::Bucket.find(s3_bucket)
|
27
27
|
|
28
|
-
puts "There are #{Image.count} images in the #{s3_bucket} bucket"
|
28
|
+
puts "There are #{Image.count} images in the #{s3_bucket} bucket"
|
29
29
|
Image.all.each do |image|
|
30
30
|
s3_object = AWS::S3::S3Object.find image.image_uid,s3_bucket
|
31
31
|
dest = File.join(output_path,"images",s3_object.key)
|
32
32
|
copy_s3_object(s3_object,dest)
|
33
33
|
end
|
34
|
-
|
35
|
-
puts "\n\nThere are #{Resource.count} resources in the #{s3_bucket} bucket"
|
34
|
+
|
35
|
+
puts "\n\nThere are #{Resource.count} resources in the #{s3_bucket} bucket"
|
36
36
|
Resource.all.each do |resource|
|
37
37
|
s3_object = AWS::S3::S3Object.find resource.file_uid,s3_bucket
|
38
38
|
dest = File.join(output_path,"resources",s3_object.key)
|
39
39
|
copy_s3_object(s3_object,dest)
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
end
|
43
43
|
|
44
44
|
def self.copy_s3_object(s3_object, to)
|
@@ -58,25 +58,33 @@ module Refinery
|
|
58
58
|
|
59
59
|
puts "\n=======================================\n"
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
def self.s3_config
|
63
63
|
return @s3_config unless @s3_config.nil?
|
64
|
-
|
64
|
+
is_heroku_app = false
|
65
|
+
|
65
66
|
begin
|
66
67
|
base = Heroku::Command::BaseWithApp.new
|
67
68
|
app = base.app
|
68
|
-
|
69
|
-
|
70
|
-
exit
|
69
|
+
is_heroku_app = true
|
70
|
+
rescue
|
71
71
|
end
|
72
|
-
|
73
|
-
config_vars =
|
74
|
-
|
72
|
+
|
73
|
+
config_vars = is_heroku_app ? base.heroku.config_vars(app) : {}
|
74
|
+
|
75
75
|
@s3_config = {
|
76
|
-
:
|
77
|
-
:
|
78
|
-
:
|
76
|
+
:key => ENV['S3_KEY'] || config_vars['S3_KEY'],
|
77
|
+
:secret => ENV['S3_SECRET'] || config_vars['S3_SECRET'],
|
78
|
+
:bucket => ENV['S3_BUCKET'] || config_vars['S3_BUCKET']
|
79
79
|
}
|
80
|
+
|
81
|
+
unless [:key, :secret, :bucket].all?{|s3| @s3_config[s3].present?}
|
82
|
+
puts "Could not get complete s3 configuration."
|
83
|
+
puts "This application is not a Heroku application." unless is_heroku_app
|
84
|
+
exit 1
|
85
|
+
end
|
86
|
+
|
87
|
+
@s3_config
|
80
88
|
end
|
81
89
|
|
82
90
|
end
|
@@ -11,9 +11,9 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = ""
|
12
12
|
s.summary = %q{copies s3 assets from production refinerycms app hosted on Heroku to local}
|
13
13
|
s.description = %q{copies s3 assets from production refinerycms app hosted on Heroku to local}
|
14
|
-
|
14
|
+
|
15
15
|
s.add_dependency("aws-s3", "~> 0.6.2")
|
16
|
-
s.add_dependency("heroku", "~> 2.
|
16
|
+
s.add_dependency("heroku", "~> 2.19.1")
|
17
17
|
s.add_dependency("progress_bar", "~> 0.3.4")
|
18
18
|
|
19
19
|
s.rubyforge_project = "refinerycms-s3assets"
|
metadata
CHANGED
@@ -1,124 +1,88 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-s3assets
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 5
|
10
|
-
version: 0.0.5
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Francois Harbec
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-02-07 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: aws-s3
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70332380816420 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
18
|
+
requirements:
|
27
19
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 6
|
33
|
-
- 2
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 0.6.2
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: heroku
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: *70332380816420
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: heroku
|
27
|
+
requirement: &70332380815800 !ruby/object:Gem::Requirement
|
41
28
|
none: false
|
42
|
-
requirements:
|
29
|
+
requirements:
|
43
30
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
segments:
|
47
|
-
- 2
|
48
|
-
- 0
|
49
|
-
- 4
|
50
|
-
version: 2.0.4
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.19.1
|
51
33
|
type: :runtime
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: progress_bar
|
55
34
|
prerelease: false
|
56
|
-
|
35
|
+
version_requirements: *70332380815800
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: progress_bar
|
38
|
+
requirement: &70332380815240 !ruby/object:Gem::Requirement
|
57
39
|
none: false
|
58
|
-
requirements:
|
40
|
+
requirements:
|
59
41
|
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
hash: 27
|
62
|
-
segments:
|
63
|
-
- 0
|
64
|
-
- 3
|
65
|
-
- 4
|
42
|
+
- !ruby/object:Gem::Version
|
66
43
|
version: 0.3.4
|
67
44
|
type: :runtime
|
68
|
-
|
69
|
-
|
70
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70332380815240
|
47
|
+
description: copies s3 assets from production refinerycms app hosted on Heroku to
|
48
|
+
local
|
49
|
+
email:
|
71
50
|
- fharbec@gmail.com
|
72
51
|
executables: []
|
73
|
-
|
74
52
|
extensions: []
|
75
|
-
|
76
53
|
extra_rdoc_files: []
|
77
|
-
|
78
|
-
files:
|
54
|
+
files:
|
79
55
|
- .gitignore
|
80
56
|
- Gemfile
|
81
|
-
- Gemfile.lock
|
82
57
|
- MIT-LICENSE
|
83
|
-
- README.
|
58
|
+
- README.md
|
84
59
|
- Rakefile
|
85
60
|
- lib/refinerycms-s3assets.rb
|
86
61
|
- lib/refinerycms-s3assets/version.rb
|
87
62
|
- lib/tasks/s3assets.rake
|
88
63
|
- refinerycms-s3assets.gemspec
|
89
|
-
|
90
|
-
homepage: ""
|
64
|
+
homepage: ''
|
91
65
|
licenses: []
|
92
|
-
|
93
66
|
post_install_message:
|
94
67
|
rdoc_options: []
|
95
|
-
|
96
|
-
require_paths:
|
68
|
+
require_paths:
|
97
69
|
- lib
|
98
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
71
|
none: false
|
100
|
-
requirements:
|
101
|
-
- -
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
|
104
|
-
|
105
|
-
- 0
|
106
|
-
version: "0"
|
107
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
77
|
none: false
|
109
|
-
requirements:
|
110
|
-
- -
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
|
113
|
-
segments:
|
114
|
-
- 0
|
115
|
-
version: "0"
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
116
82
|
requirements: []
|
117
|
-
|
118
83
|
rubyforge_project: refinerycms-s3assets
|
119
|
-
rubygems_version: 1.
|
84
|
+
rubygems_version: 1.8.15
|
120
85
|
signing_key:
|
121
86
|
specification_version: 3
|
122
87
|
summary: copies s3 assets from production refinerycms app hosted on Heroku to local
|
123
88
|
test_files: []
|
124
|
-
|
data/Gemfile.lock
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
refinerycms-s3assets (0.0.1)
|
5
|
-
aws-s3 (~> 0.6.2)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: http://rubygems.org/
|
9
|
-
specs:
|
10
|
-
aws-s3 (0.6.2)
|
11
|
-
builder
|
12
|
-
mime-types
|
13
|
-
xml-simple
|
14
|
-
builder (3.0.0)
|
15
|
-
mime-types (1.16)
|
16
|
-
xml-simple (1.0.15)
|
17
|
-
|
18
|
-
PLATFORMS
|
19
|
-
ruby
|
20
|
-
|
21
|
-
DEPENDENCIES
|
22
|
-
refinerycms-s3assets!
|
data/README.rdoc
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
= refinerycms-s3assets
|
2
|
-
|
3
|
-
A common development scenario, when using a Heroku-hosted RefineryCMS app, is to copy production data to development via the use of heroku db:pull. This gem adds a rake task to your RefineryCMS project which copies your production assets stored on s3 onto the local filesystem.
|
4
|
-
|
5
|
-
= Requirements
|
6
|
-
|
7
|
-
1. Mac OS X, Linux, or UNIX.
|
8
|
-
2. A Heroku account.
|
9
|
-
3. A Refinery CMS project
|
10
|
-
|
11
|
-
== Installation
|
12
|
-
|
13
|
-
Open up your Gemfile and add at the bottom this line:
|
14
|
-
|
15
|
-
gem 'refinerycms-s3assets'
|
16
|
-
|
17
|
-
Now, run:
|
18
|
-
|
19
|
-
$ bundle install
|
20
|
-
|
21
|
-
== Usage
|
22
|
-
|
23
|
-
This gem assumes that your production Heroku app is storing assets on Amazon s3 and that your Heroku app has the following three config vars properly defined: S3_BUCKET, S3_KEY and S3_SECRET ( see http://devcenter.heroku.com/articles/config-vars for more info).
|
24
|
-
|
25
|
-
Start by copying your production database to your local database:
|
26
|
-
|
27
|
-
$ heroku db:pull
|
28
|
-
|
29
|
-
To copy all Image and Resource files from S3 you can now run the following:
|
30
|
-
|
31
|
-
$ rake refinery:download_s3_assets
|
32
|
-
|
33
|
-
== License
|
34
|
-
|
35
|
-
Please see MIT-LICENSE for more details.
|
36
|
-
|
37
|
-
== Copyright
|
38
|
-
|
39
|
-
Copyright (c) 2011 Rounders Consulting Inc.
|
40
|
-
|
41
|
-
|