Class: Dayvan::Project
- Inherits:
-
Object
- Object
- Dayvan::Project
- Defined in:
- lib/dayvan/project.rb
Instance Method Summary collapse
- #config ⇒ Object
- #config_path ⇒ 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
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dayvan/project.rb', line 32 def config_path dirname = dir..basename ["#{dirname}.yaml", "#{dirname}.yml", 'divan.yaml', 'divan.yml']. inject([]) {|dirs, f| dirs << dir.join('config',f) dirs << dir.join(f) dirs }. find {|dir| dir.file? && dir.readable?} || raise(Dayvan::ConfigError) end |
#create_database! ⇒ Object
44 45 46 47 |
# File 'lib/dayvan/project.rb', line 44 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']. 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
49 50 51 52 53 |
# File 'lib/dayvan/project.rb', line 49 def push! designs.each do |d| d.push end end |