ggake 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/README.md +12 -6
- data/ggake.gemspec +1 -0
- data/lib/ggake/cloud_cp.rb +33 -0
- data/lib/ggake/version.rb +1 -1
- data/lib/ggake.rb +1 -1
- data/spec/cloud_cp_spec.rb +33 -0
- data/spec/ggake_spec.rb +0 -4
- metadata +21 -3
- data/lib/ggake/s3cp.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77d7689f175035d99818de189bd3b5d034082a13
|
4
|
+
data.tar.gz: da54d6a65396032fbd551ac47c26ec6a795e1f29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6595c1b86c7dd02e782294872632fd2458c43490f613c9bf25ae579ede004858abeb4e2e90f0bd46aca8b995443a862a12cc64c030fdf4d3eaa966ab9f180a72
|
7
|
+
data.tar.gz: 1ce7ecbe901e291f6e6dd98391ac467702f7543ed04c7a38d24beb87c697e0aa11ca5af744d3e90c7511ae52a1b4ebb6f592162871b78ac342bef5250f3aafb0
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ggake
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.0.0
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# ggake
|
2
2
|
|
3
3
|
Over time I've written a bunch of useful little functions and tasks
|
4
4
|
that have been handy in the build systems of my projects. Finally,
|
@@ -31,7 +31,8 @@ This gem provides the following utilities:
|
|
31
31
|
* `transient`: Allows a Rake task to depend on a transient value,
|
32
32
|
such as an environment variable.
|
33
33
|
|
34
|
-
* `
|
34
|
+
* `cloud_cp`: Simple copy of a directory to an S3, or other cloud
|
35
|
+
storage, bucket.
|
35
36
|
|
36
37
|
More detailed usage below.
|
37
38
|
|
@@ -41,14 +42,19 @@ More detailed usage below.
|
|
41
42
|
|
42
43
|
### transient
|
43
44
|
|
45
|
+
[What's this all about then?](http://overwatering.org/blog/2013/03/depending-on-transient-values-in-rake/)
|
46
|
+
|
44
47
|
transient :calatrava_env, ENV['CALATRAVA_ENV']
|
45
48
|
task :build => :calatrava_env
|
46
49
|
|
47
|
-
###
|
50
|
+
### cloud_cp
|
48
51
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
+
cloud_ cp(directory, bucket: bucket_name,
|
53
|
+
credentials: {
|
54
|
+
access_key: aws_access_key,
|
55
|
+
secret_key: aws_secret_key
|
56
|
+
},
|
57
|
+
public: true)
|
52
58
|
|
53
59
|
## Contributing
|
54
60
|
|
data/ggake.gemspec
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
module Rake
|
2
|
+
module DSL
|
3
|
+
|
4
|
+
def cloud_cp(dir, options)
|
5
|
+
# Done here to allow fog to be an optional dependency
|
6
|
+
require 'fog'
|
7
|
+
|
8
|
+
connection = Fog::Storage.new(options[:credentials])
|
9
|
+
cd dir do
|
10
|
+
upload_sub_dir(connection, '.', options[:bucket], options[:public] || false)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def upload_sub_dir(connection, dir, bucket, is_public)
|
15
|
+
is_public ||= false
|
16
|
+
Dir["#{dir}/*"].each do |file|
|
17
|
+
if File.directory? file
|
18
|
+
upload_sub_dir(connection, file, bucket, is_public)
|
19
|
+
else
|
20
|
+
file_name = file.gsub("./", '')
|
21
|
+
puts "Uploading: '#{file_name}'"
|
22
|
+
directory = connection.directories.get(bucket)
|
23
|
+
file = directory.files.create(
|
24
|
+
:key => file_name,
|
25
|
+
:body => IO.read(file),
|
26
|
+
:public => is_public
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/lib/ggake/version.rb
CHANGED
data/lib/ggake.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fog'
|
3
|
+
require 'rake'
|
4
|
+
|
5
|
+
describe 'cloud_cp' do
|
6
|
+
include Rake::DSL
|
7
|
+
|
8
|
+
let(:options) do
|
9
|
+
{
|
10
|
+
credentials: {
|
11
|
+
provider: 'AWS',
|
12
|
+
aws_access_key_id: 'whatever',
|
13
|
+
aws_secret_access_key: 'asdf'
|
14
|
+
},
|
15
|
+
bucket: 'my_bucket',
|
16
|
+
public: true
|
17
|
+
}
|
18
|
+
end
|
19
|
+
let(:directory) { 'lib' }
|
20
|
+
|
21
|
+
before :each do
|
22
|
+
Fog.mock!
|
23
|
+
|
24
|
+
connection = Fog::Storage.new(options[:credentials])
|
25
|
+
connection.directories.create(key: options[:bucket],
|
26
|
+
public: options[:public])
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should copy all directories to the cloud' do
|
30
|
+
cloud_cp(directory, options)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/spec/ggake_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ggake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giles Alexander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: fog
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: A collection of useful Rake utilities
|
70
84
|
email:
|
71
85
|
- giles.alexander@gmail.com
|
@@ -75,6 +89,8 @@ extra_rdoc_files: []
|
|
75
89
|
files:
|
76
90
|
- .gitignore
|
77
91
|
- .rspec
|
92
|
+
- .ruby-gemset
|
93
|
+
- .ruby-version
|
78
94
|
- .travis.yml
|
79
95
|
- Gemfile
|
80
96
|
- LICENSE.txt
|
@@ -82,10 +98,11 @@ files:
|
|
82
98
|
- Rakefile
|
83
99
|
- ggake.gemspec
|
84
100
|
- lib/ggake.rb
|
101
|
+
- lib/ggake/cloud_cp.rb
|
85
102
|
- lib/ggake/haml.rb
|
86
|
-
- lib/ggake/s3cp.rb
|
87
103
|
- lib/ggake/transient.rb
|
88
104
|
- lib/ggake/version.rb
|
105
|
+
- spec/cloud_cp_spec.rb
|
89
106
|
- spec/ggake_spec.rb
|
90
107
|
- spec/spec_helper.rb
|
91
108
|
homepage: http://github.com/gga/ggake
|
@@ -113,5 +130,6 @@ signing_key:
|
|
113
130
|
specification_version: 4
|
114
131
|
summary: A collection of useful Rake utilities
|
115
132
|
test_files:
|
133
|
+
- spec/cloud_cp_spec.rb
|
116
134
|
- spec/ggake_spec.rb
|
117
135
|
- spec/spec_helper.rb
|
data/lib/ggake/s3cp.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
module Rake
|
2
|
-
module DSL
|
3
|
-
|
4
|
-
def s3cp(dir, options)
|
5
|
-
# Done here to allow AWS::S3 to be an optional dependency
|
6
|
-
require 'aws/s3'
|
7
|
-
|
8
|
-
AWS::S3::Base.establish_connection!(:access_key_id => options[:access_key],
|
9
|
-
:secret_access_key => options[:secret_key])
|
10
|
-
cd dir do
|
11
|
-
upload_sub_dir('.', options[:bucket])
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def upload_sub_dir(dir, bucket)
|
16
|
-
Dir["#{dir}/*"].each do |file|
|
17
|
-
if File.directory? file
|
18
|
-
upload_sub_dir(file, bucket)
|
19
|
-
else
|
20
|
-
file_name = file.gsub("./", '')
|
21
|
-
puts "Uploading: '#{file_name}'"
|
22
|
-
AWS::S3::S3Object.store(file_name, open(file), bucket)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|