Class: Dockit::Env
- Inherits:
-
Object
- Object
- Dockit::Env
- Defined in:
- lib/dockit.rb
Overview
This class encapsulates the environment used in the Dockit cli. The class has three main attributes:
- root
-
The (cached) root of the project.
- modules
-
The “modules”, a map of
Dockit.rb
files by directory name - services
-
The “services”, a map of
Dockit.yaml
files, by directory name
Constant Summary collapse
- BASENAME =
'Dockit'.freeze
Instance Attribute Summary collapse
-
#modules ⇒ Object
readonly
Returns the value of attribute modules.
-
#services ⇒ Object
readonly
Returns the value of attribute services.
Instance Method Summary collapse
-
#initialize(depth: 2, debug: false) ⇒ Env
constructor
Initialize services and modules in the project.
-
#root ⇒ Object
- The (cached) root of the project Returns [String]
-
The absolute path of the project root.
Constructor Details
#initialize(depth: 2, debug: false) ⇒ Env
Initialize services and modules in the project.
- depth [Integer]
-
How deep to recurse looking for modules/services
- debug [Boolean]
-
Log
docker-api
calls.
68 69 70 71 72 73 74 |
# File 'lib/dockit.rb', line 68 def initialize(depth: 2, debug: false) @root = nil @modules = find_subcommands(depth) @services = find_services(depth) Docker.logger = Dockit::Log.new if debug end |
Instance Attribute Details
#modules ⇒ Object (readonly)
Returns the value of attribute modules.
62 63 64 |
# File 'lib/dockit.rb', line 62 def modules @modules end |
#services ⇒ Object (readonly)
Returns the value of attribute services.
61 62 63 |
# File 'lib/dockit.rb', line 61 def services @services end |
Instance Method Details
#root ⇒ Object
The (cached) root of the project
- Returns [String]
-
The absolute path of the project root.
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/dockit.rb', line 79 def root return @root if @root @root = dir = Dir.pwd begin dir = File.dirname(dir) return @root = dir if File.exist?(File.join(dir, "#{BASENAME}.rb")) end while dir != '/' @root end |