Class: Shipit::Commands

Inherits:
Object
  • Object
show all
Defined in:
lib/shipit/commands.rb

Direct Known Subclasses

StackCommands, TaskCommands

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for(model) ⇒ Object



6
7
8
# File 'lib/shipit/commands.rb', line 6

def for(model)
  "#{model.class.name}Commands".constantize.new(model)
end

.git_versionObject



10
11
12
# File 'lib/shipit/commands.rb', line 10

def git_version
  @git_version ||= parse_git_version(`git --version`)
end

.parse_git_version(raw_git_version) ⇒ Object



14
15
16
17
18
19
# File 'lib/shipit/commands.rb', line 14

def parse_git_version(raw_git_version)
  match_info = raw_git_version.match(/(\d+\.\d+\.\d+)/)
  raise 'git command not found' unless match_info

  Gem::Version.new(match_info[1])
end

Instance Method Details

#envObject



24
25
26
# File 'lib/shipit/commands.rb', line 24

def env
  base_env
end

#git(*args) ⇒ Object



28
29
30
31
32
# File 'lib/shipit/commands.rb', line 28

def git(*args)
  kwargs = args.extract_options!
  kwargs[:env] ||= base_env
  Command.new("git", *args, **kwargs)
end