Sha256: 497b57c1adcc0b3fa9d8ca61c0ef5fb7162a8f2ca48db0b6b31d9be97b9a1b78

Contents?: true

Size: 1.49 KB

Versions: 7

Compression:

Stored size: 1.49 KB

Contents

class Jeweler
  module Commands
    class SetupRubyforge
      attr_accessor :gemspec, :output, :rubyforge

      def run
        raise NoRubyForgeProjectInGemspecError unless @gemspec.rubyforge_project

        @rubyforge.configure

        output.puts "Logging into rubyforge"
        @rubyforge.login

        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

      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

      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

      def self.build_for(jeweler)
        command = new

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

        command
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 4 rubygems

Version Path
dima-jeweler-1.2.0 lib/jeweler/commands/setup_rubyforge.rb
mcornick-jeweler-1.2.0 lib/jeweler/commands/setup_rubyforge.rb
technicalpickles-jeweler-1.1.0 lib/jeweler/commands/setup_rubyforge.rb
technicalpickles-jeweler-1.2.1 lib/jeweler/commands/setup_rubyforge.rb
jeweler-1.2.1 lib/jeweler/commands/setup_rubyforge.rb
jeweler-1.2.0 lib/jeweler/commands/setup_rubyforge.rb
jeweler-1.1.0 lib/jeweler/commands/setup_rubyforge.rb