class Cult::Project
Constants
- CULT_RC
Attributes
cult_version[RW]
default_ip_protocol[RW]
default_provider[W]
We allow setting to a lookup value instead of an instance
git?[RW]
git_integration[RW]
path[R]
Public Class Methods
from_cwd()
click to toggle source
# File lib/cult/project.rb, line 125 def self.from_cwd locate Dir.getwd end
locate(path)
click to toggle source
# File lib/cult/project.rb, line 109 def self.locate(path) path = File.expand_path(path) loop do return nil if path == '/' unless File.directory?(path) path = File.dirname(path) end candidate = File.join(path, CULT_RC) return new(path) if File.exist?(candidate) path = File.dirname(path) end end
new(path)
click to toggle source
# File lib/cult/project.rb, line 13 def initialize(path) @default_ip_protocol = :ipv4 @path = path end
Public Instance Methods
constructed?()
click to toggle source
# File lib/cult/project.rb, line 61 def constructed? File.exist?(cultrc) end
Also aliased as: exist?
cultrc()
click to toggle source
# File lib/cult/project.rb, line 24 def cultrc location_of(CULT_RC) end
default_provider()
click to toggle source
# File lib/cult/project.rb, line 88 def default_provider @default_provider_instance ||= begin case @default_provider when Cult::Provider @default_provider when nil; providers.first else providers[@default_provider] end end end
development?()
click to toggle source
# File lib/cult/project.rb, line 158 def development? env == 'development' end
drivers()
click to toggle source
# File lib/cult/project.rb, line 102 def drivers @drivers ||= begin Cult::Drivers.all end end
env()
click to toggle source
# File lib/cult/project.rb, line 147 def env ENV['CULT_ENV'] || begin if git_branch&.match(/\bdev(el(opment)?)?\b/) 'development' else 'production' end end end
execute_cultrc()
click to toggle source
# File lib/cult/project.rb, line 29 def execute_cultrc load(cultrc) end
git_branch()
click to toggle source
# File lib/cult/project.rb, line 132 def git_branch res = %x(git -C #{Shellwords.escape(path)} branch --no-color) if res && (m = res.match(/^\* (.*)/)) return m[1].chomp end end
git_commit_id(short: false)
click to toggle source
# File lib/cult/project.rb, line 139 def git_commit_id(short: false) short = short ? "--short" : '' cmd = "git -C #{Shellwords.escape(path)} rev-parse #{short} " + "--verify HEAD" %x(#{cmd}).chomp end
inspect()
click to toggle source
# File lib/cult/project.rb, line 34 def inspect "\#<#{self.class.name} name=#{name.inspect} path=#{path.inspect}>" end
Also aliased as: to_s
location_of(file)
click to toggle source
# File lib/cult/project.rb, line 40 def location_of(file) File.join(path, file) end
name()
click to toggle source
# File lib/cult/project.rb, line 19 def name File.basename(path) end
nodes()
click to toggle source
# File lib/cult/project.rb, line 66 def nodes @nodes ||= begin Node.all(self) end end
providers()
click to toggle source
# File lib/cult/project.rb, line 80 def providers @providers ||= begin Cult::Provider.all(self) end end
relative_path(obj_path)
click to toggle source
# File lib/cult/project.rb, line 45 def relative_path(obj_path) prefix = "#{path}/" if obj_path.start_with?(prefix) return obj_path[prefix.length .. -1] end fail ArgumentError, "#{path} isn't in the project" end
remote_path()
click to toggle source
# File lib/cult/project.rb, line 56 def remote_path "cult" end
roles()
click to toggle source
# File lib/cult/project.rb, line 73 def roles @roles ||= begin Role.all(self) end end