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.8.2 lib/writefully/tools/hammer.rb
writefully-0.8.1 lib/writefully/tools/hammer.rb
writefully-0.8.0 lib/writefully/tools/hammer.rb
writefully-0.7.1 lib/writefully/tools/hammer.rb
writefully-0.6.12 lib/writefully/tools/hammer.rb
writefully-0.6.11 lib/writefully/tools/hammer.rb
writefully-0.6.10 lib/writefully/tools/hammer.rb
writefully-0.6.9 lib/writefully/tools/hammer.rb
writefully-0.6.7 lib/writefully/tools/hammer.rb
writefully-0.6.6 lib/writefully/tools/hammer.rb
writefully-0.6.5 lib/writefully/tools/hammer.rb
writefully-0.6.4 lib/writefully/tools/hammer.rb
writefully-0.6.3 lib/writefully/tools/hammer.rb
writefully-0.6.2 lib/writefully/tools/hammer.rb
writefully-0.5.1 lib/writefully/tools/hammer.rb
writefully-0.5.0 lib/writefully/tools/hammer.rb
writefully-0.4.10 lib/writefully/tools/hammer.rb
writefully-0.4.8 lib/writefully/tools/hammer.rb
writefully-0.4.7 lib/writefully/tools/hammer.rb
writefully-0.4.6 lib/writefully/tools/hammer.rb