Module: Assert::View

Defined in:
lib/assert/view.rb,
lib/assert/view/base.rb,
lib/assert/view/default_view.rb

Defined Under Namespace

Modules: Helpers Classes: Base, DefaultView

Class Method Summary collapse

Class Method Details

.require_user_view(view_name) ⇒ Object

this method is used to bring in custom user-specific views require views by passing either a full path to the view ruby file or passing the name of a view installed in ~/.assert/views



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/assert/view.rb', line 9

def self.require_user_view(view_name)
  views_file = File.expand_path(
    File.join("#{ENV['HOME']}/.assert/views", view_name, 'lib', view_name)
  )

  if File.exists?(view_name) || File.exists?(view_name + '.rb')
    require view_name
  elsif File.exists?(views_file + '.rb')
    require views_file
  else
    msg = "[WARN] Can't find or require #{view_name.inspect} view."
    msg << " Did you install it in `~/.assert/views`?" if !view_name.match(/\A\//)
    warn msg
  end
end