Class: Jeweler::Commands::Release

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Release

Returns a new instance of Release.



6
7
8
9
10
11
12
# File 'lib/jeweler/commands/release.rb', line 6

def initialize(attributes = {})
  self.output = $stdout

  attributes.each_pair do |key, value|
    send("#{key}=", value)
  end
end

Instance Attribute Details

#base_dirObject

Returns the value of attribute base_dir.



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

def base_dir
  @base_dir
end

#gemspecObject

Returns the value of attribute gemspec.



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

def gemspec
  @gemspec
end

#gemspec_helperObject

Returns the value of attribute gemspec_helper.



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

def gemspec_helper
  @gemspec_helper
end

#outputObject

Returns the value of attribute output.



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

def output
  @output
end

#repoObject

Returns the value of attribute repo.



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

def repo
  @repo
end

#versionObject

Returns the value of attribute version.



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

def version
  @version
end

Class Method Details

.build_for(jeweler) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/jeweler/commands/release.rb', line 71

def self.build_for(jeweler)
  command = self.new

  command.base_dir = jeweler.base_dir
  command.gemspec = jeweler.gemspec
  command.version = jeweler.version
  command.repo = jeweler.repo
  command.output = jeweler.output
  command.gemspec_helper = jeweler.gemspec_helper

  command
end

Instance Method Details

#clean_staging_area?Boolean

Returns:

  • (Boolean)


28
29
30
31
# File 'lib/jeweler/commands/release.rb', line 28

def clean_staging_area?
  status = repo.status
  status.added.empty? && status.deleted.empty? && status.changed.empty?
end

#commit_gemspec!Object



41
42
43
44
45
# File 'lib/jeweler/commands/release.rb', line 41

def commit_gemspec!
  repo.add(gemspec_helper.path)
  output.puts "Committing #{gemspec_helper.path}"
  repo.commit "Regenerated gemspec for version #{version}"
end

#gemspec_changed?Boolean

Returns:

  • (Boolean)


61
62
63
64
65
# File 'lib/jeweler/commands/release.rb', line 61

def gemspec_changed?
  `git status` # OMGHAX. status always ends up being 'M' unless this runs
  status = repo.status[gemspec_helper.path]
  ! status.type.nil?
end

#regenerate_gemspec!Object



47
48
49
50
# File 'lib/jeweler/commands/release.rb', line 47

def regenerate_gemspec!
  gemspec_helper.update_version(version)
  gemspec_helper.write
end

#release_not_tagged?Boolean

Returns:

  • (Boolean)


56
57
58
59
# File 'lib/jeweler/commands/release.rb', line 56

def release_not_tagged?
  tag = repo.tag(release_tag) rescue nil
  tag.nil?
end

#release_tagObject



52
53
54
# File 'lib/jeweler/commands/release.rb', line 52

def release_tag
  "v#{version}"
end

#runObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/jeweler/commands/release.rb', line 14

def run
  raise "Hey buddy, try committing them files first" unless clean_staging_area?

  repo.checkout('master')

  regenerate_gemspec!
  commit_gemspec! if gemspec_changed?

  output.puts "Pushing master to origin"
  repo.push

  tag_release! if release_not_tagged?
end

#tag_release!Object



33
34
35
36
37
38
39
# File 'lib/jeweler/commands/release.rb', line 33

def tag_release!
  output.puts "Tagging #{release_tag}"
  repo.add_tag(release_tag)

  output.puts "Pushing #{release_tag} to origin"
  repo.push('origin', release_tag)
end