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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3823a8eb83a04c2a03faa729634b5a02c139de68
4
- data.tar.gz: f72d313016ad47a314c00d7b2a09e935b504b7d0
3
+ metadata.gz: 77d7689f175035d99818de189bd3b5d034082a13
4
+ data.tar.gz: da54d6a65396032fbd551ac47c26ec6a795e1f29
5
5
  SHA512:
6
- metadata.gz: 4174cd166544e11299ef0fcbdad2baf23ee68031d4ec4cbde85f76af8657dd753fbb5ab9562e36d4d5c239fb8589a185b97853399da6996fe413eac5e619713b
7
- data.tar.gz: 009352e3a857d9be22ff42d92eca216c83aae4274752da89a9a4dc1a727ce27cd238c10cda6d62497b7ca94590b279ae96e90929b0285f8e2781dceb245c7ed8
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
- # Ggake
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
- * `s3cp`: Simple copy of a directory to an S3 bucket.
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
- ### s3cp
50
+ ### cloud_cp
48
51
 
49
- s3cp(directory, bucket: s3_bucket_name,
50
- access_key: aws_access_key,
51
- secret_key: aws_secret_key)
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
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  spec.add_development_dependency "rake"
25
25
  spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "fog"
26
27
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Ggake
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/ggake.rb CHANGED
@@ -2,4 +2,4 @@ require "ggake/version"
2
2
 
3
3
  require "ggake/haml"
4
4
  require "ggake/transient"
5
- require "ggake/s3cp"
5
+ require "ggake/cloud_cp"
@@ -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
@@ -4,8 +4,4 @@ describe Ggake do
4
4
  it 'should have a version number' do
5
5
  Ggake::VERSION.should_not be_nil
6
6
  end
7
-
8
- it 'should do something useful' do
9
- false.should be_true
10
- end
11
7
  end
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.1.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-17 00:00:00.000000000 Z
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