Class: Cameleon
- Inherits:
-
Object
- Object
- Cameleon
- Defined in:
- lib/cameleon.rb,
lib/cameleon/app.rb,
lib/cameleon/action.rb,
lib/cameleon/renderer.rb
Defined Under Namespace
Classes: Action, App, Renderer, ValidationError
Constant Summary collapse
- @@imported =
{}
- @@config =
nil
Class Method Summary collapse
-
.config ⇒ Object
import.
- .import(file) ⇒ Object
-
.load_setup ⇒ Object
config.
- .root ⇒ Object
-
.setup(&block) ⇒ Object
call from initializer.rb.
- .version ⇒ Object
Class Method Details
.config ⇒ Object
import
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cameleon.rb', line 35 def config @config ||= begin path = "./cameleon.yml" unless File.exist? path return nil end Hashie::Mash.new YAML.load(File.read(path)) end load_setup @config end |
.import(file) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cameleon.rb', line 16 def import(file) raise "file not found" unless File.exists? file = File::stat(file).mtime if @@imported.include?(file) = @@imported[file] if ( > ) @@imported[file] = load(file) return true else return false end else @@imported[file] = load(file) return true end end |
.load_setup ⇒ Object
config
47 48 49 50 |
# File 'lib/cameleon.rb', line 47 def load_setup path = './initializer.rb' require path if File.exist? path end |
.root ⇒ Object
12 13 14 |
# File 'lib/cameleon.rb', line 12 def root File.join File.dirname(__FILE__), "../" end |
.setup(&block) ⇒ Object
call from initializer.rb
53 54 55 |
# File 'lib/cameleon.rb', line 53 def setup(&block) block.call(@config) end |