Class: Microstatic::Rake::S3DeployTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Microstatic::Rake::S3DeployTask
- Defined in:
- lib/microstatic/rake.rb
Instance Attribute Summary collapse
-
#aws_access_key_id ⇒ Object
Returns the value of attribute aws_access_key_id.
-
#aws_secret_access_key ⇒ Object
Returns the value of attribute aws_secret_access_key.
-
#bucket_name ⇒ Object
Returns the value of attribute bucket_name.
-
#exclude ⇒ Object
Returns the value of attribute exclude.
-
#name ⇒ Object
Returns the value of attribute name.
-
#source_dir ⇒ Object
Returns the value of attribute source_dir.
Instance Method Summary collapse
- #define ⇒ Object
-
#initialize(opts = {}) ⇒ S3DeployTask
constructor
A new instance of S3DeployTask.
Constructor Details
#initialize(opts = {}) ⇒ S3DeployTask
Returns a new instance of S3DeployTask.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/microstatic/rake.rb', line 9 def initialize( opts = {} ) if opts.is_a?(String) || opts.is_a?(Symbol) opts = { name: opts } end @name = opts.fetch( :name ) { :s3deploy } @aws_access_key_id = opts.fetch( :aws_access_key_id ) { ENV.fetch('AWS_ACCESS_KEY_ID',false) } @aws_secret_access_key = opts.fetch( :aws_secret_access_key ) { ENV.fetch('AWS_SECRET_ACCESS_KEY',false) } @bucket_name = opts.fetch( :bucket_name, false ) @source_dir = opts.fetch( :source_dir, false ) @exclude = opts.fetch( :exclude, false ) end |
Instance Attribute Details
#aws_access_key_id ⇒ Object
Returns the value of attribute aws_access_key_id.
7 8 9 |
# File 'lib/microstatic/rake.rb', line 7 def aws_access_key_id @aws_access_key_id end |
#aws_secret_access_key ⇒ Object
Returns the value of attribute aws_secret_access_key.
7 8 9 |
# File 'lib/microstatic/rake.rb', line 7 def aws_secret_access_key @aws_secret_access_key end |
#bucket_name ⇒ Object
Returns the value of attribute bucket_name.
7 8 9 |
# File 'lib/microstatic/rake.rb', line 7 def bucket_name @bucket_name end |
#exclude ⇒ Object
Returns the value of attribute exclude.
7 8 9 |
# File 'lib/microstatic/rake.rb', line 7 def exclude @exclude end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/microstatic/rake.rb', line 7 def name @name end |
#source_dir ⇒ Object
Returns the value of attribute source_dir.
7 8 9 |
# File 'lib/microstatic/rake.rb', line 7 def source_dir @source_dir end |
Instance Method Details
#define ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/microstatic/rake.rb', line 22 def define require 'microstatic' raise 'must specify bucket_name' unless bucket_name raise 'must specify source_dir' unless source_dir desc "deploy to the '#{bucket_name}' S3 bucket" unless ::Rake.application.last_comment task name do raise 'must specify aws_access_key_id' unless aws_access_key_id raise 'must specify aws_secret_access_key' unless aws_secret_access_key aws_creds = { :access_key_id => aws_access_key_id, :secret_access_key => aws_secret_access_key } deployer = Microstatic::S3Deployer.build( source_dir, bucket_name, aws_creds ) deployer.exclude_files(@exclude) if @exclude deployer.upload end end |