Class: Coatepec::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/coatepec/project.rb

Overview

A Rails application checkout rooted at an absolute path (must contain a Gemfile); knows where its own and pack/engine/gem spec directories live.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ Project

Returns a new instance of Project.

Raises:



9
10
11
12
13
14
15
# File 'lib/coatepec/project.rb', line 9

def initialize(root)
  @root = File.expand_path(root)

  return if File.exist?(File.join(@root, "Gemfile"))

  raise Coatepec::Error.new(:project_not_found, "No Gemfile found at #{@root}")
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



7
8
9
# File 'lib/coatepec/project.rb', line 7

def root
  @root
end

Instance Method Details

#configObject



26
27
28
# File 'lib/coatepec/project.rb', line 26

def config
  @config ||= ProjectConfig.new(root)
end

#spec_root_candidatesObject



17
18
19
20
21
22
23
24
# File 'lib/coatepec/project.rb', line 17

def spec_root_candidates
  [
    File.join(root, "spec"),
    *Dir.glob(File.join(root, "packs/*/spec")),
    *Dir.glob(File.join(root, "engines/*/spec")),
    *Dir.glob(File.join(root, "gems/*/spec"))
  ].select { |path| File.directory?(path) }
end