Sha256: f548a3df07d7a4c197af4706bc40f745de9346f2409ebb7b9c773ee3fdd8430e

Contents?: true

Size: 1.35 KB

Versions: 70

Compression:

Stored size: 1.35 KB

Contents

require "gem_publisher/git_remote"
require "gem_publisher/builder"
require "gem_publisher/pusher"
require "rubygems/specification"

module GemPublisher
  class Publisher
    attr_accessor :git_remote, :builder, :pusher
    attr_reader :version

    # Supported options:
    #   :tag_prefix - use a custom prefix for Git tags (defaults to 'v')
    def initialize(gemspec, options = {})
      @gemspec = gemspec
      @tag_prefix = options[:tag_prefix] || 'v'

      @version = eval(File.read(gemspec), TOPLEVEL_BINDING).version.to_s

      @git_remote = GitRemote.new
      @builder    = Builder.new
      @pusher     = Pusher.new
    end

    # Publish the gem if its version has changed since the last release.
    #
    # Supported options:
    #   :as - specify a shared account to publish the gem (Gemfury only)
    def publish_if_updated(method, options = {})
      return if version_released?
      @builder.build(@gemspec).tap { |gem|
        tag_prefix = options[:tag_prefix] || 'v'
        @pusher.push gem, method, options
        @git_remote.add_tag "#{@tag_prefix}#{@version}"
      }
    end

    def version_released?
      releases = @git_remote.tags.
        select { |t| t =~ /^#{@tag_prefix}\d+(\.\d+)+/ }.
        map { |t| t.scan(/\d+/).map(&:to_i) }
      this_release = @version.split(/\./).map(&:to_i)
      releases.include?(this_release)
    end
  end
end

Version data entries

70 entries across 66 versions & 18 rubygems

Version Path
logstash-filter-cache-redis-0.1.0 vendor/bundle/jruby/1.9/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-filter-csharp-0.1.0 vendor/bundle/jruby/2.3.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-filter-htmlentities-0.1.0 vendor/bundle/jruby/1.9/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-icinga-1.0.0 vendor/jruby/1.9/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-filter-zabbix-0.1.2 vendor/bundle/jruby/1.9/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-filter-zabbix-0.1.1 vendor/bundle/jruby/1.9/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-input-fifo-0.9.1 vendor/bundle/jruby/1.9/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-input-fifo-0.9.0 vendor/bundle/jruby/1.9/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-input-salesforce-3.0.0 vendor/jruby/1.9/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
ivanvc-logstash-input-s3-3.1.1.3 vendor/local/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
ivanvc-logstash-input-s3-3.1.1.2 vendor/local/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-filter-delta-1.1.0 vendor/bundle/jruby/2.2.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-filter-delta-1.0.1 vendor/bundle/jruby/2.2.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-filter-base64-1.0.4 vendor/bundle/jruby/2.2.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-filter-base64-1.0.3 vendor/bundle/jruby/2.2.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-filter-delta-1.0.0 vendor/bundle/jruby/2.2.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-filter-base64-1.0.2 vendor/bundle/jruby/2.3.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-filter-base64-1.0.1 vendor/bundle/jruby/2.3.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-filter-base64-1.0.0 vendor/bundle/jruby/2.3.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb