Class: Middleman::Sprockets::Extension
- Inherits:
-
Extension
- Object
- Extension
- Middleman::Sprockets::Extension
- Defined in:
- lib/middleman-sprockets/extension.rb,
lib/middleman-sprockets/extension/context_methods.rb,
lib/middleman-sprockets/extension/expose_middleman_helpers.rb
Defined Under Namespace
Modules: ContextMethods, ExposeMiddlemanHelpers
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#interface ⇒ Object
readonly
Returns the value of attribute interface.
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
Instance Method Summary collapse
- #after_configuration ⇒ Object
- #check_asset(path) ⇒ Object
-
#initialize(app, options_hash = {}, &block) ⇒ Extension
constructor
A new instance of Extension.
- #manipulate_resource_list(resources) ⇒ Object
- #processible?(r) ⇒ Boolean
- #sprockets_asset_path(sprockets_asset) ⇒ Object
Constructor Details
#initialize(app, options_hash = {}, &block) ⇒ Extension
Returns a new instance of Extension.
24 25 26 27 28 29 30 31 32 |
# File 'lib/middleman-sprockets/extension.rb', line 24 def initialize app, ={}, &block super @resources = ResourceStore.new @environment = ::Sprockets::Environment.new @interface = Interface.new , @environment use_sassc_if_available end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
12 13 14 |
# File 'lib/middleman-sprockets/extension.rb', line 12 def environment @environment end |
#interface ⇒ Object (readonly)
Returns the value of attribute interface.
12 13 14 |
# File 'lib/middleman-sprockets/extension.rb', line 12 def interface @interface end |
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
12 13 14 |
# File 'lib/middleman-sprockets/extension.rb', line 12 def resources @resources end |
Instance Method Details
#after_configuration ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/middleman-sprockets/extension.rb', line 35 def after_configuration @environment.append_path((app.source_dir + app.config[:js_dir]).to_s) @environment.append_path((app.source_dir + app.config[:css_dir]).to_s) @environment.append_path(app.source_dir.to_s) append_paths_from_gems the_app = app the_env = environment @environment.context_class.send(:define_method, :app) { the_app } @environment.context_class.send(:define_method, :data) { the_app.data } @environment.context_class.send(:define_method, :env) { the_env } @environment.context_class.send(:include, ContextMethods) @environment.context_class.send(:prepend, ExposeMiddlemanHelpers) if [:expose_middleman_helpers] end |
#check_asset(path) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/middleman-sprockets/extension.rb', line 77 def check_asset path if environment[path] true else false end end |
#manipulate_resource_list(resources) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/middleman-sprockets/extension.rb', line 54 def manipulate_resource_list resources sprockets_resources, base_resources = resources.partition(&method(:processible?)) ::Middleman::Util.instrument 'sprockets', name: 'manipulator.sprockets_resources' do sprockets_resources.map!(&method(:process_sprockets_resource)) end ::Middleman::Util.instrument 'sprockets', name: 'manipulator.ignore_resources' do all_resources = base_resources + sprockets_resources + linked_resources!.to_a if app.extensions[:sitemap_ignore].respond_to?(:manipulate_resource_list) app.extensions[:sitemap_ignore].manipulate_resource_list all_resources else all_resources end end end |
#processible?(r) ⇒ Boolean
72 73 74 |
# File 'lib/middleman-sprockets/extension.rb', line 72 def processible? r !r.is_a?(Resource) && !r.file_descriptor.nil? && interface.processible?(r.source_file) end |
#sprockets_asset_path(sprockets_asset) ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/middleman-sprockets/extension.rb', line 86 def sprockets_asset_path sprockets_asset if [:imported_asset_path].is_a?(String) File.join([:imported_asset_path], sprockets_asset.logical_path) else [:imported_asset_path].call(sprockets_asset) end end |