Class: Writefully::Tools::Hammer
- Inherits:
-
Object
- Object
- Writefully::Tools::Hammer
- Includes:
- Celluloid
- Defined in:
- lib/writefully/tools/hammer.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #add_hook_for(repo_name) ⇒ Object
- #forge ⇒ Object
- #hook_config ⇒ Object
-
#initialize(message) ⇒ Hammer
constructor
A new instance of Hammer.
Constructor Details
#initialize(message) ⇒ Hammer
Returns a new instance of Hammer.
8 9 10 11 |
# File 'lib/writefully/tools/hammer.rb', line 8 def initialize @message = @api = Github.new oauth_token: [:auth_token] end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
6 7 8 |
# File 'lib/writefully/tools/hammer.rb', line 6 def api @api end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'lib/writefully/tools/hammer.rb', line 6 def @message end |
Instance Method Details
#add_hook_for(repo_name) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/writefully/tools/hammer.rb', line 32 def add_hook_for repo_name Writefully.logger.info "Adding hook for #{[:site_slug]}" api.repos.hooks.create [:user_name], repo_name, hook_config rescue Exception => e raise e end |
#forge ⇒ Object
25 26 27 28 29 30 |
# File 'lib/writefully/tools/hammer.rb', line 25 def forge Writefully.logger.info "Forging #{[:site_slug]}" api.repos.create name: [:site_slug], auto_init: true rescue Exception => e raise e end |
#hook_config ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/writefully/tools/hammer.rb', line 13 def hook_config { name: 'web', events: ["push", "member"], active: true, config: { url: "#{[:domain]}/writefully/hook", content_type: 'json', secret: Writefully.[:hook_secret] } } end |