Class: Dayvan::Project
- Inherits:
-
Object
- Object
- Dayvan::Project
- Defined in:
- lib/dayvan/project.rb
Instance Method Summary collapse
- #config ⇒ Object
- #config_path ⇒ Object
- #config_search_paths ⇒ Object
- #create_database! ⇒ Object
- #db ⇒ Object
- #designs ⇒ Object
- #dir ⇒ Object
- #push! ⇒ Object
Instance Method Details
#config ⇒ Object
19 20 21 |
# File 'lib/dayvan/project.rb', line 19 def config @config ||= YAML.load(config_path.read) end |
#config_path ⇒ Object
42 43 44 45 |
# File 'lib/dayvan/project.rb', line 42 def config_path config_search_paths.find {|f| f.file? && f.readable?} || raise(Dayvan::ConfigError) end |
#config_search_paths ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/dayvan/project.rb', line 32 def config_search_paths dirname = dir..basename ["#{dirname}.yaml", "#{dirname}.yml", 'dayvan.yaml', 'dayvan.yml']. inject([]) {|dirs, f| dirs << dir.join('config',f) dirs << dir.join(f) dirs }.uniq end |
#create_database! ⇒ Object
47 48 49 50 |
# File 'lib/dayvan/project.rb', line 47 def create_database! db.put nil rescue RestClient::RequestFailed end |
#db ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/dayvan/project.rb', line 23 def db url, dbname = config['database']['url'], config['database']['name'] user, password = config['database']['user'], config['database']['password'] @db ||= RestClient::Resource.new(url, :user => user, :password => password )[dbname] end |
#designs ⇒ Object
14 15 16 17 |
# File 'lib/dayvan/project.rb', line 14 def designs (config['designs'] || [dir.basename]). map {|design| Dayvan::Design.new_from_config(design)} end |
#dir ⇒ Object
10 11 12 |
# File 'lib/dayvan/project.rb', line 10 def dir Pathname.pwd end |
#push! ⇒ Object
52 53 54 55 56 |
# File 'lib/dayvan/project.rb', line 52 def push! designs.each do |d| d.push end end |