Sha256: 23ab0740306579e9361979e297be2ef8c73913a50f5d7753ba062cd4e9ba2350

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

module YSI
  class PublishedGem < Assertion
    needs "built_gem"

    def display_name
      "published gem"
    end

    def gem_file
      "#{@engine.project_name}-#{@engine.version}.gem"
    end

    def check
      begin
        json = RestClient.get("https://rubygems.org/api/v1/versions/#{engine.project_name}.json")
      rescue RestClient::ResourceNotFound
        return nil
      end
      versions = JSON.parse(json)
      versions.each do |version|
        if version["number"] == @engine.version
          return @engine.version
        end
      end
      nil
    end

    def assert(dry_run: false)
      if !dry_run
        begin
          if !File.exist?(File.expand_path("~/.gem/credentials"))
            @error = "You need to log in to Rubygems first by running `gem push #{gem_file}` manually"
            return nil
          end
          Cheetah.run(["gem", "push", gem_file])
        rescue Cheetah::ExecutionFailed => e
          @error = e.message
          return nil
        end
      end
      gem_file
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yes_ship_it-0.0.5 assertions/published_gem.rb