Class: Jeweler::Commands::ReleaseToRubyforge

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeReleaseToRubyforge

Returns a new instance of ReleaseToRubyforge.



8
9
10
# File 'lib/jeweler/commands/release_to_rubyforge.rb', line 8

def initialize
  self.output = $stdout
end

Instance Attribute Details

#gemspecObject

Returns the value of attribute gemspec.



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

def gemspec
  @gemspec
end

#gemspec_helperObject

Returns the value of attribute gemspec_helper.



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

def gemspec_helper
  @gemspec_helper
end

#outputObject

Returns the value of attribute output.



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

def output
  @output
end

#rubyforgeObject

Returns the value of attribute rubyforge.



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

def rubyforge
  @rubyforge
end

#versionObject

Returns the value of attribute version.



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

def version
  @version
end

Class Method Details

.build_for(jeweler) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/jeweler/commands/release_to_rubyforge.rb', line 38

def self.build_for(jeweler)
  command = new
  command.gemspec = jeweler.gemspec
  command.gemspec_helper = jeweler.gemspec_helper
  command.version = jeweler.version
  command.rubyforge = jeweler.rubyforge
  command.output = jeweler.output

  command
end

Instance Method Details

#runObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/jeweler/commands/release_to_rubyforge.rb', line 12

def run
  raise NoRubyForgeProjectInGemspecError unless @gemspec.rubyforge_project
  
  @rubyforge.configure rescue nil

  output.puts 'Logging in rubyforge'
  @rubyforge.

  @rubyforge.userconfig['release_notes'] = @gemspec.description if @gemspec.description
  @rubyforge.userconfig['preformatted'] = true

  output.puts "Releasing #{@gemspec.name}-#{@version} to #{@gemspec.rubyforge_project}"
  begin
    @rubyforge.add_release(@gemspec.rubyforge_project, @gemspec.name, @version.to_s, @gemspec_helper.gem_path)
  rescue StandardError => e
    case e.message
    when /no <group_id> configured for <#{Regexp.escape @gemspec.rubyforge_project}>/
      raise RubyForgeProjectNotConfiguredError, @gemspec.rubyforge_project
    when /no <package_id> configured for <#{Regexp.escape @gemspec.name}>/i
      raise MissingRubyForgePackageError, @gemspec.name
    else
      raise
    end
  end
end