Module: Capigen::Plugins::Base

Defined in:
lib/capigen/plugins/base.rb

Overview

Recipe helpers

  • Loads the configuration
  • Generates files from templates

Instance Method Summary collapse

Instance Method Details

#relative_to_root(path = nil, check_exist = false) ⇒ Object

Path relative to project root



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/capigen/plugins/base.rb', line 21

def relative_to_root(path = nil, check_exist = false)
  if path
    root_path = File.join(root, path)
  else
    root_path = root
  end
  
  # Check for file existance
  if check_exist and !File.exist?(root_path)
    raise <<-EOS
      
      File not found: #{File.expand_path(root_path)}
      
      This is loaded for the capigen plugin. View the README in:
      #{File.expand_path(File.dirname(__FILE__) + "/../doc/README")}
    EOS
  end
  
  root_path
end

#rootObject

Project root (for rails)



12
13
14
15
16
17
18
# File 'lib/capigen/plugins/base.rb', line 12

def root
  if respond_to?(:fetch)
    return fetch(:project_root)
  else
    RAILS_ROOT
  end
end