Sha256: 6ea4ddd9cedbe7b3fe2898c274f509e9feedcebf327f225fa81789683b474f00

Contents?: true

Size: 838 Bytes

Versions: 1

Compression:

Stored size: 838 Bytes

Contents

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

    attr_reader :data, :repo, :tag

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

    private

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

    def create
      @client.create_release(@repo, @tag)
      @data = find
    end

    def _create_options
      [:prerelease, :target_commitish].each_with_object({}) do |option, hash|
        hash[option] = @options[option] if @options[option]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
targit-0.1.0 lib/targit/release.rb