Class: R10K::Module::Git
Instance Attribute Summary collapse
-
#working_dir ⇒ Object
readonly
Returns the value of attribute working_dir.
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, basedir, args) ⇒ Git
constructor
A new instance of Git.
- #status ⇒ Object
- #sync ⇒ Object
- #version ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(name, basedir, args) ⇒ Git
Returns a new instance of Git.
19 20 21 22 23 24 25 26 27 |
# File 'lib/r10k/module/git.rb', line 19 def initialize(name, basedir, args) @name, @basedir, @args = name, basedir, args (args) @full_path = Pathname.new(File.join(basedir, name)) @working_dir = R10K::Git::WorkingDir.new(@ref, @remote, @basedir, @name) end |
Instance Attribute Details
#working_dir ⇒ Object (readonly)
Returns the value of attribute working_dir.
17 18 19 |
# File 'lib/r10k/module/git.rb', line 17 def working_dir @working_dir end |
Class Method Details
.implement?(name, args) ⇒ Boolean
8 9 10 11 12 |
# File 'lib/r10k/module/git.rb', line 8 def self.implement?(name, args) args.is_a? Hash and args.has_key?(:git) rescue false end |
Instance Method Details
#status ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/r10k/module/git.rb', line 45 def status if not @working_dir.exist? return :absent elsif not @working_dir.git? return :mismatched elsif not @remote == @working_dir.remote return :mismatched end if @working_dir.outdated? return :outdated end return :insync end |
#sync ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/r10k/module/git.rb', line 33 def sync case status when :absent install when :mismatched uninstall install when :outdated @working_dir.sync end end |
#version ⇒ Object
29 30 31 |
# File 'lib/r10k/module/git.rb', line 29 def version @ref end |