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-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/gem_publisher-1.5.0/lib/gem_publisher/publisher.rb