Sha256: b90ee7f3e96aeba7e2493afa044f843c72cc6982351f54e116a80ba40ddffa51

Contents?: true

Size: 997 Bytes

Versions: 26

Compression:

Stored size: 997 Bytes

Contents

module Writefully
  module Tools
    class Hammer
      include Celluloid

      attr_reader :api, :message

      def initialize message
        @message = message
        @api = Github.new oauth_token: message[:auth_token]
      end

      def hook_config
        { name: 'web',
          events: ["push", "member"],
          active: true,
          config: { 
            url: "#{message[:domain]}/writefully/hook", 
            content_type: 'json',
            secret: Writefully.options[:hook_secret]
          } 
        }
      end

      def forge
        Writefully.logger.info "Forging #{message[:site_slug]}"
        api.repos.create name: message[:site_slug], auto_init: true
      rescue Exception => e
        raise e
      end

      def add_hook_for repo_name
        Writefully.logger.info "Adding hook for #{message[:site_slug]}"
        api.repos.hooks.create message[:user_name], repo_name, hook_config
      rescue Exception => e
        raise e
      end

    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
writefully-0.4.5 lib/writefully/tools/hammer.rb
writefully-0.4.4 lib/writefully/tools/hammer.rb
writefully-0.4.2 lib/writefully/tools/hammer.rb
writefully-0.4.1 lib/writefully/tools/hammer.rb
writefully-0.4.0 lib/writefully/tools/hammer.rb
writefully-0.3.6 lib/writefully/tools/hammer.rb