Class: Bundler::GemHelper

Inherits:
Object
  • Object
show all
Defined in:
ext/gem_rake.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base, name = nil) ⇒ GemHelper

Returns a new instance of GemHelper.



11
12
13
14
15
# File 'ext/gem_rake.rb', line 11

def initialize(base, name = nil)
  @base = base
  @name = name || interpolate_name
  @spec_path = File.join(@base, "#{@name}.gemspec")
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



9
10
11
# File 'ext/gem_rake.rb', line 9

def base
  @base
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'ext/gem_rake.rb', line 9

def name
  @name
end

#spec_pathObject (readonly)

Returns the value of attribute spec_path.



9
10
11
# File 'ext/gem_rake.rb', line 9

def spec_path
  @spec_path
end

Class Method Details

.install_tasksObject



4
5
6
7
# File 'ext/gem_rake.rb', line 4

def self.install_tasks
  dir = caller.find{|c| /Rakefile:/}[/^(.*?)\/Rakefile:/, 1]
  GemHelper.new(dir).install
end

Instance Method Details

#build_gemObject



34
35
36
37
38
39
40
41
42
# File 'ext/gem_rake.rb', line 34

def build_gem
  file_name = nil
  sh("gem build #{spec_path}") {
    file_name = File.basename(built_gem_path)
    FileUtils.mkdir_p(File.join(base, 'pkg'))
    FileUtils.mv(built_gem_path, 'pkg')
  }
  File.join(base, 'pkg', file_name)
end

#installObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'ext/gem_rake.rb', line 17

def install
  desc 'Build your gem into the pkg directory'
  task 'build' do
    build_gem
  end

  desc 'Install your gem into the pkg directory'
  task 'install' do
    install_gem
  end

  desc 'Push your gem to rubygems'
  task 'push' do
    push_gem
  end
end

#install_gemObject



44
45
46
47
# File 'ext/gem_rake.rb', line 44

def install_gem
  built_gem_path = build_gem
  sh("gem install #{built_gem_path}")
end

#push_gemObject



49
50
51
52
53
54
55
56
# File 'ext/gem_rake.rb', line 49

def push_gem
  guard_clean
  guard_already_tagged
  tag_version {
    git_push
    rubygem_push(build_gem)
  }
end