Class: Jeweler::Commands::BuildGem

Inherits:
Object
  • Object
show all
Defined in:
lib/jeweler/commands/build_gem.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBuildGem

Returns a new instance of BuildGem.



6
7
8
# File 'lib/jeweler/commands/build_gem.rb', line 6

def initialize
  self.file_utils = FileUtils
end

Instance Attribute Details

#base_dirObject

Returns the value of attribute base_dir.



4
5
6
# File 'lib/jeweler/commands/build_gem.rb', line 4

def base_dir
  @base_dir
end

#file_utilsObject

Returns the value of attribute file_utils.



4
5
6
# File 'lib/jeweler/commands/build_gem.rb', line 4

def file_utils
  @file_utils
end

#gemspec_helperObject

Returns the value of attribute gemspec_helper.



4
5
6
# File 'lib/jeweler/commands/build_gem.rb', line 4

def gemspec_helper
  @gemspec_helper
end

#version_helperObject

Returns the value of attribute version_helper.



4
5
6
# File 'lib/jeweler/commands/build_gem.rb', line 4

def version_helper
  @version_helper
end

Class Method Details

.build_for(jeweler) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/jeweler/commands/build_gem.rb', line 29

def self.build_for(jeweler)
  command = new

  command.base_dir = jeweler.base_dir
  command.gemspec_helper = jeweler.gemspec_helper
  command.version_helper = jeweler.version_helper

  command
end

Instance Method Details

#runObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/jeweler/commands/build_gem.rb', line 10

def run
  gemspec_helper.update_version(version_helper) unless gemspec_helper.has_version?

  gemspec = gemspec_helper.parse

  if Gem::Version.new(`gem -v`) >= Gem::Version.new('2.0.0.a')
    gem_file_name = Gem::Package.build(gemspec)
  else
    require 'rubygems/builder'
    gem_file_name = Gem::Builder.new(gemspec).build
  end

  pkg_dir = File.join(base_dir, 'pkg')
  file_utils.mkdir_p pkg_dir

  gem_file_name = File.join(base_dir, gem_file_name)
  file_utils.mv gem_file_name, pkg_dir
end