microstatic 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,48 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+
4
+ module Microstatic module Rake
5
+
6
+ class S3DeployTask < ::Rake::TaskLib
7
+ attr_accessor :name, :bucket_name, :source_dir, :aws_access_key_id, :aws_secret_access_key
8
+
9
+ def initialize( opts = {} )
10
+ if opts.is_a?(String) || opts.is_a?(Symbol)
11
+ opts = { name: opts }
12
+ end
13
+
14
+ @name = opts.fetch( :name ) { :s3deploy }
15
+ @aws_access_key_id = opts.fetch( :aws_access_key_id ) { ENV.fetch('AWS_ACCESS_KEY_ID') }
16
+ @aws_secret_access_key = opts.fetch( :aws_secret_access_key ) { ENV.fetch('AWS_SECRET_ACCESS_KEY') }
17
+ @bucket_name = opts.fetch( :bucket_name, false )
18
+ @source_dir = opts.fetch( :source_dir, false )
19
+ end
20
+
21
+ def define
22
+ require 'microstatic'
23
+
24
+ raise 'must specify bucket_name' unless bucket_name
25
+ raise 'must specify source_dir' unless source_dir
26
+ raise 'must specify aws_access_key_id' unless aws_access_key_id
27
+ raise 'must specify aws_secret_access_key' unless aws_secret_access_key
28
+
29
+ aws_creds = {
30
+ :access_key_id => aws_access_key_id,
31
+ :secret_access_key => aws_secret_access_key
32
+ }
33
+
34
+ desc "deploy to the '#{bucket_name}' S3 bucket" unless ::Rake.application.last_comment
35
+ task name do
36
+ deployer = Microstatic::S3Deployer.new( source_dir, bucket_name, aws_creds )
37
+ deployer.upload
38
+ end
39
+ end
40
+ end
41
+
42
+ def self.s3_deploy_task(opts)
43
+ task = S3DeployTask.new( opts )
44
+ yield task if block_given?
45
+ task.define
46
+ end
47
+
48
+ end end
@@ -1,3 +1,3 @@
1
1
  module Microstatic
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: microstatic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
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-05-26 00:00:00.000000000 Z
12
+ date: 2013-05-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-s3
@@ -106,6 +106,7 @@ files:
106
106
  - README.md
107
107
  - Rakefile
108
108
  - lib/microstatic.rb
109
+ - lib/microstatic/rake.rb
109
110
  - lib/microstatic/s3_deployer.rb
110
111
  - lib/microstatic/version.rb
111
112
  - microstatic.gemspec