Class: Middleman::S3SyncExtension
- Inherits:
-
Extension
- Object
- Extension
- Middleman::S3SyncExtension
- Defined in:
- lib/middleman-s3_sync/extension.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #after_build ⇒ Object
- #after_configuration ⇒ Object
-
#initialize(app, options_hash = {}, &block) ⇒ S3SyncExtension
constructor
A new instance of S3SyncExtension.
- #manipulate_resource_list(mm_resources) ⇒ Object
-
#read_config(io = nil) ⇒ void
Read config options from an IO stream and set them on ‘self`.
- #s3_sync_options ⇒ Object
Constructor Details
#initialize(app, options_hash = {}, &block) ⇒ S3SyncExtension
Returns a new instance of S3SyncExtension.
29 30 31 32 33 34 |
# File 'lib/middleman-s3_sync/extension.rb', line 29 def initialize(app, = {}, &block) super app.define_hook :after_s3_sync # Temporary workaround for 3.3 and 3.4. app.send :include, ClassMethods end |
Instance Method Details
#after_build ⇒ Object
49 50 51 |
# File 'lib/middleman-s3_sync/extension.rb', line 49 def after_build ::Middleman::S3Sync.sync() if .after_build end |
#after_configuration ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/middleman-s3_sync/extension.rb', line 36 def after_configuration read_config .aws_access_key_id ||= ENV['AWS_ACCESS_KEY_ID'] .aws_secret_access_key ||= ENV['AWS_SECRET_ACCESS_KEY'] .bucket ||= ENV['AWS_BUCKET'] .http_prefix = app.http_prefix if app.respond_to? :http_prefix .build_dir ||= app.build_dir if app.respond_to? :build_dir if .prefix .prefix = .prefix.end_with?("/") ? .prefix : .prefix + "/" end ::Middleman::S3Sync. = end |
#manipulate_resource_list(mm_resources) ⇒ Object
53 54 55 |
# File 'lib/middleman-s3_sync/extension.rb', line 53 def manipulate_resource_list(mm_resources) ::Middleman::S3Sync.mm_resources = mm_resources end |
#read_config(io = nil) ⇒ void
This method returns an undefined value.
Read config options from an IO stream and set them on ‘self`. Defaults to reading from the `.s3_sync` file in the MM project root if it exists.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/middleman-s3_sync/extension.rb', line 66 def read_config(io = nil) unless io root_path = ::Middleman::Application.root config_file_path = File.join(root_path, ".s3_sync") # skip if config file does not exist return unless File.exists?(config_file_path) io = File.open(config_file_path, "r") end config = (YAML.load(io) || {}).symbolize_keys config.each do |key, value| [key.to_sym] = value end end |
#s3_sync_options ⇒ Object
57 58 59 |
# File 'lib/middleman-s3_sync/extension.rb', line 57 def end |