Class: Ecogem::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/ecogem/git.rb

Defined Under Namespace

Classes: CommandError

Instance Method Summary collapse

Constructor Details

#initialize(uri, ref) ⇒ Git

Returns a new instance of Git.



5
6
7
8
# File 'lib/ecogem/git.rb', line 5

def initialize(uri, ref)
  @uri = uri
  @ref = ref || 'master'
end

Instance Method Details

#dirObject



14
15
16
# File 'lib/ecogem/git.rb', line 14

def dir
  @dir ||= ::Ecogem.workspace.gitsfile.dir_of(key)
end

#exec(cmd) ⇒ Object



22
23
24
25
26
# File 'lib/ecogem/git.rb', line 22

def exec(cmd)
  puts "git: #{cmd}"
  cmd = "git #{cmd}"
  system("cd \"#{dir}\"; #{cmd}")
end

#gemfileObject



46
47
48
49
50
51
# File 'lib/ecogem/git.rb', line 46

def gemfile
  @gemfile ||= begin
    load
    ::Ecogem::Gemfile.new(gemfile_path) if ::File.file?(gemfile_path)
  end
end

#keyObject



10
11
12
# File 'lib/ecogem/git.rb', line 10

def key
  @key ||= "#{@uri} #{@ref}"
end

#uri_aliasObject



18
19
20
# File 'lib/ecogem/git.rb', line 18

def uri_alias
  @uri_alias ||= ::Ecogem.workspace.env.git_source_uri_to_alias(@uri)
end