Class: Tumbler::Gem

Inherits:
Object
  • Object
show all
Includes:
Informer, Runner
Defined in:
lib/tumbler/gem.rb

Constant Summary

Constants included from Informer

Informer::Colors

Instance Attribute Summary

Attributes included from Runner

#noop

Instance Method Summary collapse

Methods included from Informer

#inform

Methods included from Runner

#dry, #sh, #sh_with_code

Constructor Details

#initialize(manager) ⇒ Gem

Returns a new instance of Gem.



6
7
8
# File 'lib/tumbler/gem.rb', line 6

def initialize(manager)
  @manager = manager
end

Instance Method Details

#baseObject



10
11
12
# File 'lib/tumbler/gem.rb', line 10

def base
  @manager.base
end

#buildObject



40
41
42
43
44
45
46
47
48
# File 'lib/tumbler/gem.rb', line 40

def build
  inform "Building #{built_gem_path}" do
    sh("bundle exec gem build #{spec_path}")
    Dir.chdir(base) { 
      FileUtils.mkdir_p('pkg')
      FileUtils.mv(built_gem_base, 'pkg')
    }
  end
end

#built_gem_baseObject



14
15
16
# File 'lib/tumbler/gem.rb', line 14

def built_gem_base
  "#{@manager.name}-#{@manager.version.to_s}.gem"
end

#built_gem_pathObject



18
19
20
# File 'lib/tumbler/gem.rb', line 18

def built_gem_path
  File.join('pkg', built_gem_base)
end

#installObject



29
30
31
32
33
34
# File 'lib/tumbler/gem.rb', line 29

def install
  build
  inform "Installing #{built_gem_path}" do
    exec("gem install #{built_gem_path}")
  end
end

#pushObject



22
23
24
25
26
27
# File 'lib/tumbler/gem.rb', line 22

def push
  build
  inform "Pushing #{built_gem_path}" do
    sh("gem push #{built_gem_path}")
  end
end

#spec_pathObject



36
37
38
# File 'lib/tumbler/gem.rb', line 36

def spec_path
  "#{@manager.name}.gemspec"
end