Class: Jeweler::Commands::SetupRubyforge

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gemspecObject

Returns the value of attribute gemspec.



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

def gemspec
  @gemspec
end

#outputObject

Returns the value of attribute output.



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

def output
  @output
end

#rubyforgeObject

Returns the value of attribute rubyforge.



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

def rubyforge
  @rubyforge
end

Class Method Details

.build_for(jeweler) ⇒ Object



46
47
48
49
50
51
52
53
54
# File 'lib/jeweler/commands/setup_rubyforge.rb', line 46

def self.build_for(jeweler)
  command = new

  command.gemspec = jeweler.gemspec
  command.output = jeweler.output
  command.rubyforge = jeweler.rubyforge

  command
end

Instance Method Details

#create_packageObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/jeweler/commands/setup_rubyforge.rb', line 33

def create_package
  begin
    @rubyforge.create_package(@gemspec.rubyforge_project, @gemspec.name)
  rescue StandardError => e
    case e.message
    when /no <group_id> configured for <#{Regexp.escape @gemspec.rubyforge_project}>/
      raise RubyForgeProjectNotConfiguredError, @gemspec.rubyforge_project
    else
      raise
    end
  end
end

#package_exists?Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
31
# File 'lib/jeweler/commands/setup_rubyforge.rb', line 23

def package_exists?
  begin
    @rubyforge.lookup 'package', @gemspec.name
    true
  rescue RuntimeError => e
    raise unless e.message == "no <package_id> configured for <#{@gemspec.name}>"
    false
  end
end

#runObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/jeweler/commands/setup_rubyforge.rb', line 6

def run
  raise NoRubyForgeProjectInGemspecError unless @gemspec.rubyforge_project

  @rubyforge.configure

  output.puts "Logging into rubyforge"
  @rubyforge.

  if package_exists?
    output.puts "#{@gemspec.name} package already exists in the #{@gemspec.rubyforge_project} project"
    return
  end

  output.puts "Creating #{@gemspec.name} package in the #{@gemspec.rubyforge_project} project"
  create_package
end