Class: Gem::Release::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/gem/release/context.rb,
lib/gem/release/context/ui.rb,
lib/gem/release/context/gem.rb,
lib/gem/release/context/git.rb,
lib/gem/release/context/paths.rb,
lib/gem/release/context/github.rb,
lib/gem/release/context/gemspec.rb

Defined Under Namespace

Modules: Ui Classes: Gem, Gemspec, Git, Github, Paths

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Context

Returns a new instance of Context.


11
12
13
14
15
16
17
18
# File 'lib/gem/release/context.rb', line 11

def initialize(*args)
  opts = args.last.is_a?(Hash) ? args.pop : {}
  name = args.shift
  @config = Config.new
  @gem    = Gem.new(name || File.basename(Dir.pwd))
  @git    = Git.new
  @ui     = Ui.new(opts)
end

Instance Attribute Details

#configObject

Returns the value of attribute config


9
10
11
# File 'lib/gem/release/context.rb', line 9

def config
  @config
end

#gemObject

Returns the value of attribute gem


9
10
11
# File 'lib/gem/release/context.rb', line 9

def gem
  @gem
end

#gitObject

Returns the value of attribute git


9
10
11
# File 'lib/gem/release/context.rb', line 9

def git
  @git
end

#uiObject

Returns the value of attribute ui


9
10
11
# File 'lib/gem/release/context.rb', line 9

def ui
  @ui
end

Instance Method Details

#abort(str) ⇒ Object


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

def abort(str)
  ui.error(str)
  exit 1
end

#gem_cmd(cmd, *args) ⇒ Object


24
25
26
27
28
# File 'lib/gem/release/context.rb', line 24

def gem_cmd(cmd, *args)
  ::Gem::Commands.const_get("#{cmd.to_s.capitalize}Command").new.invoke(*args.flatten)
  # TODO what's with the return value? maybe add our own abstraction that can check the result?
  true
end

#in_dirs(args, opts, &block) ⇒ Object


30
31
32
# File 'lib/gem/release/context.rb', line 30

def in_dirs(args, opts, &block)
  Paths::ByNames.new(args, opts).in_dirs(&block)
end

#in_gem_dirs(args, opts, &block) ⇒ Object


34
35
36
# File 'lib/gem/release/context.rb', line 34

def in_gem_dirs(args, opts, &block)
  Paths::ByGemspecs.new(args, opts).in_dirs(&block)
end

#run(cmd) ⇒ Object


20
21
22
# File 'lib/gem/release/context.rb', line 20

def run(cmd)
  system(cmd)
end