right_hook 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,9 +3,12 @@
3
3
  [![Build Status](https://travis-ci.org/mark-rushakoff/right_hook.png?branch=master)](https://travis-ci.org/mark-rushakoff/right_hook)
4
4
  [![Code Climate](https://codeclimate.com/github/mark-rushakoff/right_hook.png)](https://codeclimate.com/github/mark-rushakoff/right_hook)
5
5
  [![Coverage Status](https://coveralls.io/repos/mark-rushakoff/right_hook/badge.png)](https://coveralls.io/r/mark-rushakoff/right_hook)
6
+ [![Gem Version](https://badge.fury.io/rb/right_hook.png)](http://badge.fury.io/rb/right_hook)
6
7
 
7
8
  Right Hook is a collection of tools to aid in setting up a web app to handle GitHub repo hooks.
8
9
 
10
+ To see some example usage, head over to [right-hook/hookbooks](https://github.com/right-hook/hookbooks).
11
+
9
12
  ## Installation
10
13
 
11
14
  Add this line to your application's Gemfile:
@@ -29,13 +32,14 @@ Create an application by subclassing `RightHook::App`:
29
32
  ```ruby
30
33
  # app.rb
31
34
  require 'right_hook/app'
35
+ require 'right_hook/event'
32
36
 
33
37
  class MyApp < RightHook::App
34
38
  # You must supply a secret for each repository and hook.
35
39
  # The secret should only be known by GitHub; that's how we know the request is coming from GitHub's servers.
36
40
  # (You'll specify that secret when you go through subscription.)
37
41
  def secret(owner, repo_name, event_type)
38
- if owner == 'octocat' && repo_name == 'Spoon-Fork' && event_type == 'pull_request'
42
+ if owner == 'octocat' && repo_name == 'Spoon-Fork' && event_type == RightHook::Event::PULL_REQUEST
39
43
  'qwertyuiop'
40
44
  else
41
45
  raise 'unrecognized!'
@@ -62,12 +66,12 @@ You'll need to host your app online and hold on to the base URL so you can subsc
62
66
  To create hooks on GitHub repositories, you need to be authenticated as a collaborator on that repository.
63
67
  GitHub's UI currently only supports configuring push hooks, so you'll want to authenticate through Right Hook to set up custom hooks.
64
68
 
65
- Right Hook never stores your password.
66
- He always uses OAuth tokens.
67
- The only time he asks for your password is when he is creating a new token or listing existing tokens.
69
+ Right Hook never stores your password; instead, it always uses OAuth tokens.
70
+ The only time it asks for your password is when it is creating a new token or listing existing tokens.
68
71
 
69
72
  Right Hook doesn't store your tokens, either.
70
73
  It's your duty to manage storage of tokens.
74
+ Typically, tokens and other secret values are stored as environment variables for your app, rather than in a flat file or in a database.
71
75
 
72
76
  Here's one way you can generate and list tokens:
73
77
 
@@ -82,7 +86,7 @@ authenticator = RightHook::Client.interactive_build(username)
82
86
 
83
87
  # Note for the token (this will be displayed in the user's settings on GitHub)
84
88
  note = "Created in my awesome script"
85
- authenticator.create_authorization(note)
89
+ authenticator.find_or_create_authorization_by_note(note)
86
90
 
87
91
  authenticator.authorizations.each do |token|
88
92
  puts "Token: #{auth.token}\nNote: #{auth.note}\n\n"
@@ -91,7 +95,7 @@ end
91
95
 
92
96
  ### Subscribing to Hooks
93
97
 
94
- Right Hook provides a way to subscribe to hooks.
98
+ Right Hook provides a way to tell GitHub you want to subscribe your Right Hook application to GitHub's hooks.
95
99
  It's easy!
96
100
 
97
101
  ```ruby
@@ -114,6 +118,18 @@ subscriber.subscribe(
114
118
 
115
119
  (For more details, consult the RDoc documentation.)
116
120
 
121
+ ## License
122
+
123
+ Available under the terms of the MIT license.
124
+ See [license.txt](license.txt) for details.
125
+
126
+ ## Help
127
+
128
+ Is any documentation unclear?
129
+ Did you expect that Right Hook was going to help you in a particular way, and then it didn't?
130
+ Please open an issue!
131
+ One of the best ways to improve open source software is to make your needs known.
132
+
117
133
  ## Contributing
118
134
 
119
135
  1. Fork it
@@ -13,6 +13,7 @@ module RightHook
13
13
  # This approach is offered for convenience to make it easier to not store passwords on disk.
14
14
  def interactive_build(username)
15
15
  require 'io/console'
16
+ puts "What is the password for #{username}? (Your typing will be hidden.)"
16
17
  new(Octokit::Client.new(login: username, password: $stdin.noecho(&:gets).chomp))
17
18
  end
18
19
  end
@@ -1,3 +1,3 @@
1
1
  module RightHook
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -6,7 +6,7 @@ describe RightHook::Subscriber do
6
6
  oauth_token: 'my_token',
7
7
  owner: 'mark-rushakoff',
8
8
  base_url: 'http://example.com',
9
- event_type: 'issue',
9
+ event_type: RightHook::Event::ISSUE,
10
10
  )
11
11
  end
12
12
 
@@ -48,7 +48,7 @@ describe RightHook::Subscriber do
48
48
  oauth_token: 'my_token',
49
49
  owner: 'mark-rushakoff',
50
50
  base_url: 'http://example.com',
51
- event_type: 'issue'
51
+ event_type: RightHook::Event::ISSUE
52
52
  )
53
53
  expect(result).to eq(true)
54
54
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_hook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: