Sha256: 39ac2ed6ef94565caa4b4fb7264ff595f18be93eb8f328778fda57d3ec558685

Contents?: true

Size: 865 Bytes

Versions: 2

Compression:

Stored size: 865 Bytes

Contents

require 'pushpop'
require 'github_api'

module Pushpop

  class Github < Step

    PLUGIN_NAME = 'github'

    Pushpop::Job.register_plugin(PLUGIN_NAME, self)

    attr_accessor :_user
    attr_accessor :_repository

    def run(last_response=nil, step_responses=nil)
      self.configure(last_response, step_responses)

      if self._user && self._repository
        get_repository_from_api
      else
        raise 'Please set user and repository fields'
      end
    end

    def user(user)
      self._user = user
    end

    def repository(repository)
      self._repository = repository
    end

    def get_repository_from_api
      ::Github::Repos.new(:user => self._user, :repo => self._repository).get
    end

    def configure(last_response=nil, step_responses=nil)
      self.instance_exec(last_response, step_responses, &block)
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pushpop-github-0.1.1 lib/pushpop-github.rb
pushpop-github-0.1.0 lib/pushpop-github.rb