Module: S3::Deploy
- Defined in:
- lib/s3-deploy.rb,
lib/s3-deploy/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
-
.config(path = "../aws.yml") ⇒ Object
Loads the aws config from one level up by default.
-
.files(source = ".") ⇒ Object
Collects all files from the public directory for the upload.
-
.upload!(params = {}) ⇒ Object
Takes the file list and uploads it to the S3 bucket.
Class Method Details
.config(path = "../aws.yml") ⇒ Object
Loads the aws config from one level up by default
10 11 12 |
# File 'lib/s3-deploy.rb', line 10 def config path = "../aws.yml" @@config ||= OpenStruct.new(YAML.load_file(path)) end |
.files(source = ".") ⇒ Object
Collects all files from the public directory for the upload
15 16 17 |
# File 'lib/s3-deploy.rb', line 15 def files source = "." Dir["#{source}/**/*"].select{ |path| !File.directory?(path) } end |
.upload!(params = {}) ⇒ Object
Takes the file list and uploads it to the S3 bucket
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/s3-deploy.rb', line 20 def upload! params = {} puts "\nUploading to S3:#{config.bucket}" puts "--------------------------------" params[:source] ||= "." params[:prefix] ||= "" files(params[:source]).each do |file| # Build path and check if file was updated locally file_without_source = file.gsub("#{params[:source]}/", "") target = "#{params[:prefix]}#{file_without_source}" modified = file_was_updated_locally?(file, target) # Show upload progress puts "#{'# ' unless modified}#{file} -> #{target}" # Upload write_to_S3(file, target) if modified end puts "--------------------------------" puts "Done\n" end |