Class: BrickAndMortar::Project
- Inherits:
-
Object
- Object
- BrickAndMortar::Project
- Defined in:
- lib/brick_and_mortar/project.rb
Constant Summary collapse
- DEFAULT_BRICK_STORE =
File.join(Dir.home, '.bricks')
Instance Attribute Summary collapse
-
#bricks ⇒ Object
readonly
Returns the value of attribute bricks.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#project_root ⇒ Object
readonly
Returns the value of attribute project_root.
Instance Method Summary collapse
-
#initialize(brickfile, brick_store = DEFAULT_BRICK_STORE) ⇒ Project
constructor
A new instance of Project.
- #laid? ⇒ Boolean
- #lay! ⇒ Object
- #vendor ⇒ Object
Constructor Details
#initialize(brickfile, brick_store = DEFAULT_BRICK_STORE) ⇒ Project
Returns a new instance of Project.
10 11 12 13 14 15 |
# File 'lib/brick_and_mortar/project.rb', line 10 def initialize(brickfile, brick_store = DEFAULT_BRICK_STORE) @config = Config.new brick_store @config.create_store! @bricks = @config.parse_file! brickfile @project_root = File.dirname(brickfile) end |
Instance Attribute Details
#bricks ⇒ Object (readonly)
Returns the value of attribute bricks.
6 7 8 |
# File 'lib/brick_and_mortar/project.rb', line 6 def bricks @bricks end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/brick_and_mortar/project.rb', line 6 def config @config end |
#project_root ⇒ Object (readonly)
Returns the value of attribute project_root.
6 7 8 |
# File 'lib/brick_and_mortar/project.rb', line 6 def project_root @project_root end |
Instance Method Details
#laid? ⇒ Boolean
21 22 23 24 25 26 |
# File 'lib/brick_and_mortar/project.rb', line 21 def laid? @bricks.reduce(File.exist?(vendor)) do |has_been_laid, brick| break has_been_laid unless has_been_laid has_been_laid && brick.laid?(vendor) end end |
#lay! ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/brick_and_mortar/project.rb', line 28 def lay! FileUtils.mkpath vendor @bricks.each do |b| b.lay! vendor sub_brickfile = File.join(b.destination, 'Brickfile') if File.file?(sub_brickfile) Dir.chdir(b.destination) do |dir| subproject = Project.new(sub_brickfile, @config.store) subproject.lay! end end end end |
#vendor ⇒ Object
17 18 19 |
# File 'lib/brick_and_mortar/project.rb', line 17 def vendor File.join(@project_root, 'vendor') end |