Module: Prepd::Component

Extended by:
ActiveSupport::Concern
Included in:
Cluster, Developer, Machine, Project
Defined in:
lib/prepd/models/base.rb

Instance Method Summary collapse

Instance Method Details

#component_dirObject



37
38
39
# File 'lib/prepd/models/base.rb', line 37

def component_dir
  "#{component_root}/#{name}"
end

#component_directory_does_not_existObject



26
27
28
29
# File 'lib/prepd/models/base.rb', line 26

def component_directory_does_not_exist
  return if Prepd.config.force
  errors.add(:directory_exists, component_dir) if Dir.exists?(component_dir)
end

#component_rootObject



47
48
49
# File 'lib/prepd/models/base.rb', line 47

def component_root
  "#{workspace_root}/#{self.class::WORK_DIR}"
end

#files_dirObject



64
65
66
# File 'lib/prepd/models/base.rb', line 64

def files_dir
  "#{Prepd.files_dir}/#{self.class::WORK_DIR}"
end

#in_component_dirObject



31
32
33
34
35
# File 'lib/prepd/models/base.rb', line 31

def in_component_dir
  in_component_root do
    Dir.chdir(name) { yield }
  end
end

#in_component_root(dir = self.class::WORK_DIR) ⇒ Object



41
42
43
44
45
# File 'lib/prepd/models/base.rb', line 41

def in_component_root(dir = self.class::WORK_DIR)
  in_workspace_root do
    Dir.chdir(dir) { yield }
  end
end

#in_workspace_rootObject

Raises:

  • (StandardError)


51
52
53
54
# File 'lib/prepd/models/base.rb', line 51

def in_workspace_root
  raise StandardError, 'Not a prepd workspace' if workspace_root.nil?
  Dir.chdir(workspace_root) { yield }
end

#klass_nameObject



68
69
70
71
# File 'lib/prepd/models/base.rb', line 68

def klass_name
  binding.pry
  "#{Prepd.files_dir}/#{self.class::WORK_DIR}"
end

#workspace_rootObject



56
57
58
59
60
61
62
# File 'lib/prepd/models/base.rb', line 56

def workspace_root
  path = Pathname.new(Prepd.config.working_dir)
  until path.root?
    break path if File.exists?("#{path}/prepd-workspace.yml")
    path = path.parent
  end
end