Sha256: 74c8b9d3b0e61106051d999ca5646dc5588f2b4dc614947220d77166d67743ae

Contents?: true

Size: 1.3 KB

Versions: 8

Compression:

Stored size: 1.3 KB

Contents

require 'gems'

module DPL
  class Provider
    class RubyGems < Provider
      def setup_auth
        ::Gems.key = option(:api_key) if options[:api_key]
        ::Gems.username = option(:user, :username) unless options[:api_key]
        ::Gems.password = option(:password) unless options[:api_key]
      end

      def needs_key?
        false
      end

      def setup_gem
        options[:gem] ||= options[:app]
      end

      def gemspec
        options[:gemspec].gsub('.gemspec', '') if options[:gemspec]
      end

      def check_app
        setup_auth
        setup_gem
        log "Looking up gem #{options[:gem]}"
        info = ::Gems.info(options[:gem])
        log "Found gem #{info['name']}"
      end

      def check_auth
        setup_auth
        log "Authenticated with username #{::Gems.username}" if ::Gems.username
      end

      def push_app
        setup_auth
        setup_gem
        context.shell "for f in #{gemspec_glob}; do gem build $f; done"
        Dir.glob("#{option(:gem)}-*.gem") do |f|
          if options[:host]
            log ::Gems.push(File.new(f), options[:host])
          else
            log ::Gems.push(File.new f)
          end
        end
      end

      def gemspec_glob
        options[:gemspec_glob] || "#{gemspec || option(:gem)}.gemspec"
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dpl-rubygems-1.10.17.travis.6637.6 lib/dpl/provider/rubygems.rb
dpl-rubygems-1.10.16 lib/dpl/provider/rubygems.rb
dpl-rubygems-1.10.16.travis.6625.6 lib/dpl/provider/rubygems.rb
dpl-rubygems-1.10.16.travis.6619.6 lib/dpl/provider/rubygems.rb
dpl-rubygems-1.10.16.travis.5961.5 lib/dpl/provider/rubygems.rb
dpl-rubygems-1.10.15 lib/dpl/provider/rubygems.rb
dpl-rubygems-1.10.15.travis.5877.5 lib/dpl/provider/rubygems.rb
dpl-rubygems-1.10.14 lib/dpl/provider/rubygems.rb