class BrickAndMortar::Config
Attributes
store[RW]
Public Class Methods
new(store_)
click to toggle source
# File lib/brick_and_mortar/config.rb, line 10 def initialize(store_) @store = store_ end
Public Instance Methods
bricks_and_store_from_data(data)
click to toggle source
# File lib/brick_and_mortar/config.rb, line 37 def bricks_and_store_from_data(data) store_ = @store begin brick_data = if data['store'] && !data['store'].empty? store_ = data['store'] data['bricks'] elsif data['bricks'] data['bricks'] else [] end rescue TypeError brick_data = data end [brick_data, store_] end
create_store!()
click to toggle source
# File lib/brick_and_mortar/config.rb, line 18 def create_store! unless store_exists? FileUtils.mkpath @store fail "Could not create store at \"#{@store}\"" unless store_exists? end end
destroy_store!()
click to toggle source
# File lib/brick_and_mortar/config.rb, line 25 def destroy_store! FileUtils.rm_rf @store end
parse!(yaml)
click to toggle source
# File lib/brick_and_mortar/config.rb, line 54 def parse!(yaml) brick_data, store_ = bricks_and_store_from_data YAML.load(yaml) parse_data! brick_data, store_ end
parse_data!(brick_data, store_ = @store)
click to toggle source
# File lib/brick_and_mortar/config.rb, line 31 def parse_data!(brick_data, store_ = @store) brick_data.map do |brick| Brick::Config.new(brick, store_) end end
parse_file!(yaml_file)
click to toggle source
# File lib/brick_and_mortar/config.rb, line 59 def parse_file!(yaml_file) brick_data, store_ = bricks_and_store_from_data YAML.load_file(yaml_file) parse_data! brick_data, store_ end
store_exists?()
click to toggle source
# File lib/brick_and_mortar/config.rb, line 14 def store_exists? Dir.exist? @store end
Also aliased as: store_exist?