Class: Jeweler::Commands::ReleaseToGit

Inherits:
Object
  • Object
show all
Includes:
ReleaseCommon
Defined in:
lib/jeweler/commands/release_to_git.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ReleaseCommon

#clean_staging_area?

Constructor Details

#initialize(attributes = {}) ⇒ ReleaseToGit

Returns a new instance of ReleaseToGit.



11
12
13
14
15
16
17
# File 'lib/jeweler/commands/release_to_git.rb', line 11

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.



9
10
11
# File 'lib/jeweler/commands/release_to_git.rb', line 9

def base_dir
  @base_dir
end

#gemspecObject

Returns the value of attribute gemspec.



9
10
11
# File 'lib/jeweler/commands/release_to_git.rb', line 9

def gemspec
  @gemspec
end

#gemspec_helperObject

Returns the value of attribute gemspec_helper.



9
10
11
# File 'lib/jeweler/commands/release_to_git.rb', line 9

def gemspec_helper
  @gemspec_helper
end

#outputObject

Returns the value of attribute output.



9
10
11
# File 'lib/jeweler/commands/release_to_git.rb', line 9

def output
  @output
end

#repoObject

Returns the value of attribute repo.



9
10
11
# File 'lib/jeweler/commands/release_to_git.rb', line 9

def repo
  @repo
end

#versionObject

Returns the value of attribute version.



9
10
11
# File 'lib/jeweler/commands/release_to_git.rb', line 9

def version
  @version
end

Class Method Details

.build_for(jeweler) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/jeweler/commands/release_to_git.rb', line 48

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

#release_not_tagged?Boolean

Returns:

  • (Boolean)


43
44
45
46
# File 'lib/jeweler/commands/release_to_git.rb', line 43

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

#release_tagObject



39
40
41
# File 'lib/jeweler/commands/release_to_git.rb', line 39

def release_tag
  "v#{version}"
end

#runObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/jeweler/commands/release_to_git.rb', line 19

def run
  unless clean_staging_area?
    system "git status"
    raise "Unclean staging area! Be sure to commit or .gitignore everything first. See `git status` above."
  end

  #repo.checkout('master')
  branch = repo.current_branch
  output.puts "Pushing #{branch} to origin"
  repo.push('origin', branch)
  
  if release_not_tagged?
    output.puts "Tagging #{release_tag}"
    repo.add_tag(release_tag)

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