Class: ViewAssets::Finder::Finder
- Inherits:
-
Object
- Object
- ViewAssets::Finder::Finder
- Defined in:
- lib/view_assets/finder/finder.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#assets ⇒ Object
readonly
Returns the value of attribute assets.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#parsed_manifests ⇒ Object
readonly
Returns the value of attribute parsed_manifests.
Instance Method Summary collapse
- #empty ⇒ Object
-
#initialize ⇒ Finder
constructor
A new instance of Finder.
-
#retrieve(controller = '', action = '', options = {}) ⇒ Object
This method is the ENTRY of assets finder after its initializtion.
-
#retrieve_manifest(manifest, options = {}) ⇒ Object
manifest path should be a relative path.
Constructor Details
#initialize ⇒ Finder
Returns a new instance of Finder.
16 17 18 |
# File 'lib/view_assets/finder/finder.rb', line 16 def initialize empty end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
15 16 17 |
# File 'lib/view_assets/finder/finder.rb', line 15 def action @action end |
#assets ⇒ Object (readonly)
Returns the value of attribute assets.
15 16 17 |
# File 'lib/view_assets/finder/finder.rb', line 15 def assets @assets end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
15 16 17 |
# File 'lib/view_assets/finder/finder.rb', line 15 def controller @controller end |
#parsed_manifests ⇒ Object (readonly)
Returns the value of attribute parsed_manifests.
15 16 17 |
# File 'lib/view_assets/finder/finder.rb', line 15 def parsed_manifests @parsed_manifests end |
Instance Method Details
#empty ⇒ Object
20 21 22 23 24 25 |
# File 'lib/view_assets/finder/finder.rb', line 20 def empty @controller = '' @action = '' @assets = [] @parsed_manifests = [] end |
#retrieve(controller = '', action = '', options = {}) ⇒ Object
This method is the ENTRY of assets finder after its initializtion. It returns all asset paths wrapped inside a appropriated html options
:controller => nil
:action => nil
:full => false
:tagged => false
:tagged => false
:shallow => false
TODO: need to retrive action-less assets
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/view_assets/finder/finder.rb', line 38 def retrieve(controller = '', action = '', = {}) = { :full => false, :tagged => false, :shallow => false }.update() @assets = [] @parsed_manifests = [] @controller = controller @action = action @shallow_retrieval = [:shallow] retrieve_controller_assets retrieve_action_assets if @action != '' @assets.uniq! @assets.map! { |asset| PathInfo.new(asset).abs } if [:full] @assets.map! { |asset| tag("/#{asset.rel}") } if [:tagged] @assets end |
#retrieve_manifest(manifest, options = {}) ⇒ Object
manifest path should be a relative path
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/view_assets/finder/finder.rb', line 58 def retrieve_manifest(manifest, = {}) = { :full => false, :tagged => false, :shallow => false, :non_ext => true }.update() @assets = [] @parsed_manifests = [] @controller = [:controller] @action = [:action] @shallow_retrieval = [:shallow] @assets = (root, manifest) @assets.uniq! @assets.map! { |asset| PathInfo.new(asset).abs } if [:full] @assets.map! { |asset| tag("/#{asset.rel}") } if [:tagged] @assets end |