Class: Stevenson::Deployer::S3
- Inherits:
-
Object
- Object
- Stevenson::Deployer::S3
- Includes:
- Base
- Defined in:
- lib/stevenson/deployers/s3.rb
Instance Attribute Summary collapse
-
#deployment_bucket_name ⇒ Object
readonly
Returns the value of attribute deployment_bucket_name.
-
#deployment_key ⇒ Object
readonly
Returns the value of attribute deployment_key.
Attributes included from Base
Instance Method Summary collapse
- #deploy!(directory) ⇒ Object
- #entries_for(directory) ⇒ Object
-
#initialize(options) ⇒ S3
constructor
A new instance of S3.
Methods included from Base
Constructor Details
#initialize(options) ⇒ S3
Returns a new instance of S3.
10 11 12 13 |
# File 'lib/stevenson/deployers/s3.rb', line 10 def initialize() @deployment_bucket_name, @deployment_key, @deployment_access_key, @deployment_access_secret = ["s3"] super end |
Instance Attribute Details
#deployment_bucket_name ⇒ Object (readonly)
Returns the value of attribute deployment_bucket_name.
8 9 10 |
# File 'lib/stevenson/deployers/s3.rb', line 8 def deployment_bucket_name @deployment_bucket_name end |
#deployment_key ⇒ Object (readonly)
Returns the value of attribute deployment_key.
8 9 10 |
# File 'lib/stevenson/deployers/s3.rb', line 8 def deployment_key @deployment_key end |
Instance Method Details
#deploy!(directory) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/stevenson/deployers/s3.rb', line 15 def deploy!(directory) entries_for(directory).each do |file_path, file_name| s3_bucket.files.create( key: File.join(deployment_key, file_name), body: File.read(file_path), public: true, ) if File.file?(file_path) end end |
#entries_for(directory) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/stevenson/deployers/s3.rb', line 25 def entries_for(directory) if File.file?(directory) [ [directory, File.basename(directory)] ] else Dir.glob("#{directory}/**/*").collect { |f| [f, f.partition(directory).last] } end end |