Class: Dockdev::Workspace

Inherits:
Object
  • Object
show all
Defined in:
lib/dockdev/workspace.rb

Instance Method Summary collapse

Constructor Details

#initialize(root = Dir.getwd) ⇒ Workspace

Returns a new instance of Workspace.



6
7
8
# File 'lib/dockdev/workspace.rb', line 6

def initialize(root = Dir.getwd)
  @root = root
end

Instance Method Details

#dockerfileObject



30
31
32
33
34
35
36
# File 'lib/dockdev/workspace.rb', line 30

def dockerfile
  if has_dockerfile?
    dockerfiles.first
  else
    nil
  end
end

#dockerfilesObject



26
27
28
# File 'lib/dockdev/workspace.rb', line 26

def dockerfiles
  Dir.glob(File.join(@root,"Dockerfile*"))
end

#found_dockerfile_countObject



18
19
20
# File 'lib/dockdev/workspace.rb', line 18

def found_dockerfile_count
  dockerfiles.length 
end

#has_docker_compose?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/dockdev/workspace.rb', line 38

def has_docker_compose?
  Dir.glob(File.join(@root,"docker-compose.yml")).length > 0
end

#has_dockerfile?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/dockdev/workspace.rb', line 14

def has_dockerfile?
  found_dockerfile_count > 0
end

#has_multiple_dockerfiles?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/dockdev/workspace.rb', line 22

def has_multiple_dockerfiles?
  found_dockerfile_count > 1
end

#nameObject



10
11
12
# File 'lib/dockdev/workspace.rb', line 10

def name
  File.dirname(@root)
end