Class: Release::Gem::Engine::GemEngine

Inherits:
Object
  • Object
show all
Includes:
TR::CondUtils
Defined in:
lib/release/gem/gem_engine.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ GemEngine

Returns a new instance of GemEngine.



14
15
16
17
18
19
20
21
# File 'lib/release/gem/gem_engine.rb', line 14

def initialize(*args, &block)
  opts = args.first
  @root = opts[:root]
  @ui = opts[:ui]
  @var = {}
  
  exec(&block)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(mtd, *args, &block) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/release/gem/gem_engine.rb', line 55

def method_missing(mtd, *args, &block)
  if mtd.to_s.start_with?("gem_cli_")
    Gem.logger.debug "Passing method '#{mtd}' to gem_cli action"
    pmtd = mtd.to_s[8..-1].to_sym
    gem_cli_action_inst.send(pmtd, *args, &block)

  elsif mtd.to_s.start_with?("vcs_cli_")
    Gem.logger.debug "Passing method '#{mtd}' to vcs_cli action"
    pmtd = mtd.to_s[8..-1].to_sym
    vcs_cli_action_inst.send(pmtd, *args, &block)
 
  elsif mtd.to_s.start_with?("gem_")
    Gem.logger.debug "Passing method '#{mtd}' to gem action"
    pmtd = mtd.to_s[4..-1].to_sym
    gem_action_inst.send(pmtd, *args, &block)

  elsif mtd.to_s.start_with?("vcs_")
    pmtd = mtd.to_s[4..-1].to_sym
    vcs_action_inst.send(pmtd, *args, &block)

  else
    super
  end
end

Instance Method Details

#exec(&block) ⇒ Object



23
24
25
# File 'lib/release/gem/gem_engine.rb', line 23

def exec(&block)
  instance_eval(&block) if block
end

#gem_action(&block) ⇒ Object



39
40
41
# File 'lib/release/gem/gem_engine.rb', line 39

def gem_action(&block)
  gem_action_inst.exec(&block) 
end

#gem_action_instObject



87
88
89
90
91
92
# File 'lib/release/gem/gem_engine.rb', line 87

def gem_action_inst
  if @gemAct.nil?
    @gemAct = Action::GemAction.new(@root, { ui: @ui, engine: self})
  end
  @gemAct
end

#gem_cli_action(&block) ⇒ Object



43
44
45
# File 'lib/release/gem/gem_engine.rb', line 43

def gem_cli_action(&block)
  gem_cli_action_inst.exec(&block)
end

#gem_cli_action_instObject



101
102
103
104
105
106
# File 'lib/release/gem/gem_engine.rb', line 101

def gem_cli_action_inst
  if @gemCliAct.nil?
    @gemCliAct = Cli::GemAction.new(@root, { engine: self})
  end
  @gemCliAct
end

#register(key, value) ⇒ Object



31
32
33
# File 'lib/release/gem/gem_engine.rb', line 31

def register(key,value)
  @var[key] = value if not_empty?(key) 
end

#run_test(eng) ⇒ Object



27
28
29
# File 'lib/release/gem/gem_engine.rb', line 27

def run_test(eng)
  puts "run test : #{eng}" 
end

#value(key) ⇒ Object



35
36
37
# File 'lib/release/gem/gem_engine.rb', line 35

def value(key)
  @var[key]
end

#vcs_action(&block) ⇒ Object



47
48
49
# File 'lib/release/gem/gem_engine.rb', line 47

def vcs_action(&block)
  vcs_action_inst.exec(&block) 
end

#vcs_action_instObject



80
81
82
83
84
85
# File 'lib/release/gem/gem_engine.rb', line 80

def vcs_action_inst
  if @vcsAct.nil?
    @vcsAct = Action::VcsAction.new(@root,{ ui: @ui, engine: self })
  end
  @vcsAct
end

#vcs_cli_action(&block) ⇒ Object



51
52
53
# File 'lib/release/gem/gem_engine.rb', line 51

def vcs_cli_action(&block)
  vcs_cli_action_inst.exec(&block) 
end

#vcs_cli_action_instObject



94
95
96
97
98
99
# File 'lib/release/gem/gem_engine.rb', line 94

def vcs_cli_action_inst
  if @vcsCliAct.nil?
    @vcsCliAct = Cli::VcsAction.new(@root,{ engine: self })
  end
  @vcsCliAct
end