Module: MSPRelease::Project::Gem

Includes:
Exec::Helpers
Defined in:
lib/msp_release/project/gem.rb

Defined Under Namespace

Classes: BuildResult

Instance Method Summary collapse

Methods included from Exec::Helpers

#exec

Instance Method Details

#build_commandObject



65
66
67
# File 'lib/msp_release/project/gem.rb', line 65

def build_command
  "gem build #{gemspec_file}"
end

#build_result(output_directory) ⇒ Object



69
70
71
# File 'lib/msp_release/project/gem.rb', line 69

def build_result(output_directory)
  BuildResult.new(@dir, self)
end

#gemspec_fileObject



21
22
23
24
25
26
27
28
# File 'lib/msp_release/project/gem.rb', line 21

def gemspec_file
  files = Dir.glob("#{@dir}/*.gemspec")

  LOG.warn "Warning: more than one gemspec found" if files.count > 1
  raise "Can't find gemspec" if files.count < 0

  files.first
end

#gemspec_nameObject



30
31
32
33
34
35
36
37
# File 'lib/msp_release/project/gem.rb', line 30

def gemspec_name
  @gemspec_name ||= Dir.chdir(@dir) do
    File.new(gemspec_file, 'r').readlines.find { |l|
      l =~ /\w+\.name\s*=\s*(['"])([\w-]+)\1/
    }
    $2
  end
end

#nameObject



39
40
41
# File 'lib/msp_release/project/gem.rb', line 39

def name
  gemspec_name
end

#next_version_for_release(options = {}) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'lib/msp_release/project/gem.rb', line 43

def next_version_for_release(options={})
  tag = "release-#{version}"
  check_tag = exec("git show-ref --tags #{tag}", :status => [0,1])
  unless check_tag == ""
     LOG.error "Tag #{tag} already exists, you must bump the version before"\
       " the next release"
     exit(1)
  end
  version
end

#prepare_for_build(branch_name, options = {}) ⇒ Object



54
55
56
57
58
59
60
61
62
63
# File 'lib/msp_release/project/gem.rb', line 54

def prepare_for_build(branch_name, options={})
  # new_dir = "#{gemspec_name}"

  # FileUtils.mv(@dir, new_dir)
  # @dir = new_dir

  clean_checkout

  super if defined?(super)
end