Class: Garlic::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/garlic/target.rb

Defined Under Namespace

Classes: Runner

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(garlic, options = {}) ⇒ Target

Returns a new instance of Target.



7
8
9
10
11
12
13
14
15
16
# File 'lib/garlic/target.rb', line 7

def initialize(garlic, options = {})
  @garlic = garlic
  @tree_ish = Repo.tree_ish(options) || 'origin/master'
  @rails_repo_name = options[:rails] || 'rails'
  @path = options[:path] or raise ArgumentError, "Target requires a :path"
  @path = File.expand_path(@path)
  @name = options[:name] || File.basename(@path)
  @prepare = options[:prepare]
  @run = options[:run]
end

Instance Attribute Details

#garlicObject (readonly)

Returns the value of attribute garlic.



5
6
7
# File 'lib/garlic/target.rb', line 5

def garlic
  @garlic
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/garlic/target.rb', line 5

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/garlic/target.rb', line 5

def path
  @path
end

#rails_repo_nameObject (readonly)

Returns the value of attribute rails_repo_name.



5
6
7
# File 'lib/garlic/target.rb', line 5

def rails_repo_name
  @rails_repo_name
end

#tree_ishObject (readonly)

Returns the value of attribute tree_ish.



5
6
7
# File 'lib/garlic/target.rb', line 5

def tree_ish
  @tree_ish
end

Instance Method Details

#prepareObject



18
19
20
21
22
# File 'lib/garlic/target.rb', line 18

def prepare
  puts "\nPreparing target #{name} (#{tree_ish})"
  install_rails
  runner.run(&@prepare) if @prepare
end

#rails_shaObject



28
29
30
# File 'lib/garlic/target.rb', line 28

def rails_sha
  read_sha('vendor/rails')
end

#runObject



24
25
26
# File 'lib/garlic/target.rb', line 24

def run
  runner.run(&@run) if @run
end

#shellObject



32
33
34
35
36
37
38
39
# File 'lib/garlic/target.rb', line 32

def shell
  unless @shell
    @shell = Shell.new
    @shell.verbose = false
    @shell.cd path
  end
  @shell
end