Class: MidwireCommon::RakeHelper

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/midwire_common/rake_helper.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base) ⇒ RakeHelper



15
16
17
# File 'lib/midwire_common/rake_helper.rb', line 15

def initialize(base)
  @base = base
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



13
14
15
# File 'lib/midwire_common/rake_helper.rb', line 13

def base
  @base
end

Class Method Details

.install_tasks(opts = {}) ⇒ Object



8
9
10
11
# File 'lib/midwire_common/rake_helper.rb', line 8

def self.install_tasks(opts = {})
  dir = opts[:dir] || Dir.pwd
  self.new(dir).install
end

Instance Method Details

#installObject



19
20
21
22
# File 'lib/midwire_common/rake_helper.rb', line 19

def install
  task_dir = File.expand_path("../tasks", File.dirname(__FILE__))
  Dir["#{task_dir}/*.rake"].sort.each { |ext| load ext }
end

#install_gemObject

def build_gem

file_name = nil
sh("gem build -V '#{spec_path}'") { |out, code|
  file_name = File.basename(built_gem_path)
  FileUtils.mkdir_p(File.join(base, 'pkg'))
  FileUtils.mv(built_gem_path, 'pkg')
  Bundler.ui.confirm "#{name} #{version} built to pkg/#{file_name}"
}
File.join(base, 'pkg', file_name)

end



35
36
37
38
39
40
# File 'lib/midwire_common/rake_helper.rb', line 35

def install_gem
  built_gem_path = build_gem
  out, _ = sh_with_code("gem install '#{built_gem_path}'")
  raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output" unless out[/Successfully installed/]
  Bundler.ui.confirm "#{name} (#{version}) installed"
end

#release_gemObject



42
43
44
45
46
47
48
49
50
# File 'lib/midwire_common/rake_helper.rb', line 42

def release_gem
  guard_clean
  guard_already_tagged
  built_gem_path = build_gem
  tag_version {
    git_push
    rubygem_push(built_gem_path)
  }
end