Sha256: b23d5ad101d487c4c0bb177dde2bb38d9aad84ee999af979f17a310e219b5ace

Contents?: true

Size: 875 Bytes

Versions: 11

Compression:

Stored size: 875 Bytes

Contents

module Targit
  ##
  # GitHub Release object
  class Release
    include Targit::Client

    attr_reader :repo, :tag

    def initialize(repo, tag, params = {})
      @repo = repo
      @tag = tag
      @options = params
      @options[:client] ||= client
      @data = create if @options.include?(:create) && data.nil?
      raise('No release found') if data.nil?
    end

    def data
      @data ||= _data
    end

    private

    def _data
      client.releases(@repo).find { |x| x[:tag_name] == @tag }
    end

    def create
      client.create_release(@repo, @tag, create_options)
    end

    def create_options
      opts = {}
      opts[:name] = @options[:release_name] if @options[:release_name]
      %i[prerelease target_commitish].each_with_object(opts) do |option, hash|
        hash[option] = @options[option] if @options[option]
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
targit-2.5.2 lib/targit/release.rb
targit-2.5.1 lib/targit/release.rb
targit-2.5.0 lib/targit/release.rb
targit-2.4.8 lib/targit/release.rb
targit-2.4.7 lib/targit/release.rb
targit-2.4.6 lib/targit/release.rb
targit-2.4.5 lib/targit/release.rb
targit-2.4.4 lib/targit/release.rb
targit-2.4.3 lib/targit/release.rb
targit-2.4.2 lib/targit/release.rb
targit-2.4.1 lib/targit/release.rb