Class: Middleman::S3SyncExtension
- Inherits:
-
Extension
- Object
- Extension
- Middleman::S3SyncExtension
- Defined in:
- lib/middleman-s3_sync/extension.rb
Instance Method Summary collapse
- #after_build ⇒ Object
- #after_configuration ⇒ Object
- #caching_policy(content_type, policy = {}) ⇒ Object
- #default_caching_policy(policy = {}) ⇒ 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.
35 36 37 |
# File 'lib/middleman-s3_sync/extension.rb', line 35 def initialize(app, = {}, &block) super end |
Instance Method Details
#after_build ⇒ Object
53 54 55 |
# File 'lib/middleman-s3_sync/extension.rb', line 53 def after_build ::Middleman::S3Sync.sync() if .after_build end |
#after_configuration ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/middleman-s3_sync/extension.rb', line 39 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 + "/" .prefix = "" if .prefix == "/" end ::Middleman::S3Sync. = end |
#caching_policy(content_type, policy = {}) ⇒ Object
92 93 94 |
# File 'lib/middleman-s3_sync/extension.rb', line 92 def caching_policy(content_type, policy = {}) ::Middleman::S3Sync.add_caching_policy(content_type, policy) end |
#default_caching_policy(policy = {}) ⇒ Object
88 89 90 |
# File 'lib/middleman-s3_sync/extension.rb', line 88 def default_caching_policy(policy = {}) ::Middleman::S3Sync.add_caching_policy(:default, policy) end |
#manipulate_resource_list(mm_resources) ⇒ Object
57 58 59 |
# File 'lib/middleman-s3_sync/extension.rb', line 57 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.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/middleman-s3_sync/extension.rb', line 70 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
61 62 63 |
# File 'lib/middleman-s3_sync/extension.rb', line 61 def end |