Class: Picobox::Utils::Project
- Inherits:
-
Object
- Object
- Picobox::Utils::Project
- Defined in:
- lib/picobox/utils/project.rb
Instance Method Summary collapse
-
#initialize(os) ⇒ Project
constructor
A new instance of Project.
- #project_initialized? ⇒ Boolean
- #root ⇒ Object
- #running? ⇒ Boolean
Constructor Details
#initialize(os) ⇒ Project
Returns a new instance of Project.
4 5 6 |
# File 'lib/picobox/utils/project.rb', line 4 def initialize(os) @os = os end |
Instance Method Details
#project_initialized? ⇒ Boolean
9 10 11 12 13 14 15 16 |
# File 'lib/picobox/utils/project.rb', line 9 def project_initialized? return false if os.project_root.nil? root = os.project_root target = os.current_dir target[0...root.size] == root && (target.size == root.size || target[root.size] == ?/) end |
#root ⇒ Object
19 20 21 |
# File 'lib/picobox/utils/project.rb', line 19 def root find_root_from Pathname.new(os.current_dir) end |
#running? ⇒ Boolean
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/picobox/utils/project.rb', line 24 def running? result = %x[docker-compose ps] result = result.split("\n") result = result.select { |line| line.match /_dev|_test/ } result = result.map { |line| line.split(' ')[2] } result.uniq! # There are no container stopped or started (all removed or first run) return false if result.empty? # Get the status and return the correct value (result.include? 'Exit') ? false : true end |