Module: Razor::CLI::Views

Defined in:
lib/razor/cli/views.rb

Class Method Summary collapse

Class Method Details

.find_formatting(spec, format, remaining_navigation) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/razor/cli/views.rb', line 12

def find_formatting(spec, format, remaining_navigation)
  remaining_navigation ||= ''
  # Scope will narrow by traversing the spec.
  scope = views
  spec = spec ? spec.split('/').drop_while { |i| i != 'collections'} : []
  spec = spec + remaining_navigation.split(' ')
  while spec.any?
    val = spec.shift
    scope = (scope[val] or {})
  end
  scope["+#{format}"] or {}
end

.transform(item, transform_name) ⇒ Object



8
9
10
# File 'lib/razor/cli/views.rb', line 8

def transform(item, transform_name)
  Razor::CLI::Transforms.send(transform_name || 'identity', item)
end

.viewsObject



4
5
6
# File 'lib/razor/cli/views.rb', line 4

def views
  @views ||= YAML::load_file(File::join(File::dirname(__FILE__), "views.yaml"))
end