Class: ViewAssets::Finder::Finder

Inherits:
Object
  • Object
show all
Defined in:
lib/view_assets/finder/finder.rb

Direct Known Subclasses

CssFinder, JsFinder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFinder

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

#actionObject (readonly)

Returns the value of attribute action.



15
16
17
# File 'lib/view_assets/finder/finder.rb', line 15

def action
  @action
end

#assetsObject (readonly)

Returns the value of attribute assets.



15
16
17
# File 'lib/view_assets/finder/finder.rb', line 15

def assets
  @assets
end

#controllerObject (readonly)

Returns the value of attribute controller.



15
16
17
# File 'lib/view_assets/finder/finder.rb', line 15

def controller
  @controller
end

#parsed_manifestsObject (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

#emptyObject



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 = '', options = {})
  options = { :full => false, :tagged => false, :shallow => false }.update(options)

  @assets            = []
  @parsed_manifests  = []
  @controller        = controller
  @action            = action
  @shallow_retrieval = options[:shallow]

  retrieve_controller_assets
  retrieve_action_assets if @action != ''
  @assets.uniq!

  @assets.map! { |asset| PathInfo.new(asset).abs } if options[:full]
  @assets.map! { |asset| tag("/#{asset.rel}") }    if options[: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, options = {})
  options = { :full => false, :tagged => false, :shallow => false, :non_ext => true }.update(options)

  @assets            = []
  @parsed_manifests  = []
  @controller        = options[:controller]
  @action            = options[:action]
  @shallow_retrieval = options[:shallow]

  @assets = meta_retrieve(root, manifest)
  @assets.uniq!

  @assets.map! { |asset| PathInfo.new(asset).abs } if options[:full]
  @assets.map! { |asset| tag("/#{asset.rel}") }    if options[:tagged]

  @assets
end