ghrh 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ghrh (0.0.1)
4
+ ghrh (0.0.3)
5
5
  clamp (~> 0.6.1)
6
6
  highline (~> 1.6.19)
7
7
  httparty (~> 0.11.0)
data/README.md CHANGED
@@ -2,18 +2,18 @@
2
2
 
3
3
  Manage GitHub repository [hooks](http://developer.github.com/v3/repos/hooks/) easily on the command line.
4
4
 
5
- # Installation
5
+ ## Installation
6
6
 
7
7
  Install the ruby gem:
8
8
 
9
- ```
9
+ ``` sh
10
10
  $ gem install ghrh
11
11
  ```
12
12
 
13
- # Usage
13
+ ## Usage
14
14
 
15
- ## General help
16
- ```
15
+ ### General help
16
+ ``` sh
17
17
  $ ghrh --help
18
18
  Usage:
19
19
  ghrh [OPTIONS] SUBCOMMAND [ARG] ...
@@ -37,23 +37,23 @@ Options:
37
37
  ```
38
38
  Pass `--help` to each sub command for its usage.
39
39
 
40
- ## Setting up
40
+ ### Setting up
41
41
  The Github token (`ghrh.token`), repository (`github.repo`), user (`github.user`) and host (`github.host`) are set and picked up from
42
42
  the local or global git config. Environment variables work too `GITHUB_REPO`, `GITHUB_USER`, etc.
43
43
 
44
- ```
44
+ ``` sh
45
45
  # fetch and set GitHub token, also can be set repository specific (pass --local)
46
46
  $ ghrh auth r4um
47
47
  Enter password for user r4um (never stored):
48
48
  ghrh.token set to xyz012345 in global git config
49
49
  ```
50
50
 
51
- ## Managing hooks
51
+ ### Managing hooks
52
52
 
53
53
  ghrh caches the hooks metadata from GitHub host in `~/.ghrh`.
54
54
 
55
- To see a list of hooks available
56
- ```
55
+ List available hooks
56
+ ``` sh
57
57
  $ ghrh hooks
58
58
  activecollab
59
59
  acunote
@@ -68,8 +68,8 @@ backlog
68
68
  ---cut---
69
69
  ```
70
70
 
71
- To see what paramaters (the schema ) a hook expects
72
- ```
71
+ View what paramaters (the schema) hook expects
72
+ ``` sh
73
73
  $ ghrh hooks email
74
74
  {"name"=>"email",
75
75
  "events"=>["push"],
@@ -80,8 +80,8 @@ $ ghrh hooks email
80
80
  ["boolean", "send_from_author"]]}
81
81
  ```
82
82
 
83
- The parameters are passed as key=value pairs, for example create an email and web hook
84
- ```
83
+ The parameters are passed as `key=value` pairs, for example create an email and a web hook
84
+ ``` sh
85
85
  $ ghrh create -r r4um/dotfiles email address=pranay.kanwar@gmail.com send_from_author=1
86
86
  201 Created
87
87
  $ ghrh create -r r4um/dotfiles web url=http://foo.com content_type=text/json
@@ -93,7 +93,7 @@ If no repository is provided its picked up from `github.repo` git config setting
93
93
 
94
94
  Too see a list of hooks
95
95
 
96
- ```
96
+ ``` sh
97
97
  $ ghrh list r4um/dotfiles
98
98
  -------------------------------
99
99
  id name active events
@@ -103,9 +103,9 @@ $ ghrh list r4um/dotfiles
103
103
  -------------------------------
104
104
  ```
105
105
 
106
- Hooks can be viewed, edited or deleted by their id from the list above.
106
+ Hooks can be viewed, edited, tested or deleted by their id from the list above.
107
107
 
108
- ```
108
+ ``` sh
109
109
  $ ghrh edit -r r4um/dotfiles 954777 address=nobody@localhost
110
110
  200 OK
111
111
  $ ghrh get -r r4um/dotfiles 954777
@@ -120,6 +120,9 @@ $ ghrh get -r r4um/dotfiles 954777
120
120
  "last_response"=>{"code"=>200, "status"=>"ok", "message"=>"OK"},
121
121
  "updated_at"=>"2013-05-14T12:19:30Z",
122
122
  "created_at"=>"2013-05-13T19:52:50Z"}
123
+ $ ghrh test -t r4um/dotfiles 954777
124
+ 204 No Content
125
+ nil
123
126
  $ ghrh delete -r r4um/dotfiles 954777
124
127
  204 No Content
125
128
 
@@ -127,10 +130,10 @@ Deleted
127
130
  ```
128
131
 
129
132
  To refresh the hooks cache
130
- ```
133
+ ``` sh
131
134
  $ ghrh hooks --refresh
132
135
  Wrote hooks cache to /Users/pranay.kanwar/.ghrh/hooks_api.github.com.json
133
136
  ```
134
137
 
135
- # LICENSE
138
+ ### LICENSE
136
139
  [MIT](LICENSE)
@@ -33,7 +33,7 @@ module GHRH
33
33
  # make sure config settings given exist in the schema
34
34
  config_list.each do |arg|
35
35
  k,v = arg.split(/=/,2)
36
- raise "Invalid setting #{k} for hook #{name}" if not schema[k]
36
+ raise "Invalid setting #{k} for hook #{name}" if not schema.include? k
37
37
  config[k]=v
38
38
  end
39
39
 
@@ -42,7 +42,7 @@ module GHRH
42
42
  if events
43
43
  events_list = events.split(/,/)
44
44
  events_list.each do |event|
45
- raise "Invalid event #{event} for hook #{name}" if not supported_events.index(event)
45
+ raise "Invalid event #{event} for hook #{name}" if not supported_events.include? event
46
46
  end
47
47
  end
48
48
 
@@ -15,11 +15,7 @@ module GHRH
15
15
 
16
16
  res = GHRH::Client.get("/repos/#{repo}/hooks/#{id}")
17
17
 
18
- if not res['name']
19
- puts "Invalid hook ID #{id}"
20
- puts res
21
- exit 1
22
- end
18
+ raise "Invalid hook ID #{id}" if not res['name']
23
19
 
24
20
  name = res['name']
25
21
  hook = hooks[name]
@@ -39,7 +35,7 @@ module GHRH
39
35
  # make sure config settings given exist in the schema
40
36
  config_list.each do |arg|
41
37
  k,v = arg.split(/=/,2)
42
- raise "Invalid setting #{k} for hook #{name}" if not schema[k]
38
+ raise "Invalid setting #{k} for hook #{id} (#{name})" if not schema.include? k
43
39
  config[k]=v
44
40
  end
45
41
 
@@ -48,7 +44,7 @@ module GHRH
48
44
  if events
49
45
  events_list = events.split(/,/)
50
46
  events_list.each do |event|
51
- raise "Invalid event #{event} for hook #{id}" if not supported_events.index(event)
47
+ raise "Invalid event #{event} for hook #{id} (#{name})" if not supported_events.include? event
52
48
  end
53
49
  end
54
50
 
@@ -5,10 +5,7 @@ module GHRH
5
5
  option "--refresh", :flag, "Refresh hooks cache"
6
6
 
7
7
  def execute
8
- if refresh?
9
- GHRH::Config.fetch_hooks
10
- exit 0
11
- end
8
+ GHRH::Config.fetch_hooks if refresh?
12
9
 
13
10
  hooks = GHRH::Config.hooks
14
11
 
@@ -4,7 +4,12 @@ module GHRH
4
4
  parameter "[REPO]", "repo", :default => GHRH::Config.get('github.repo')
5
5
 
6
6
  def execute
7
+ raise "No repo specified or set (github.repo)" if not repo
8
+
7
9
  resp = GHRH::Client.get("/repos/#{repo}/hooks")
10
+
11
+ raise "Unexpected response #{resp.code} #{resp.message}" if resp.code != 200
12
+
8
13
  tbl = Tabularize.new :vborder => '', :iborder => ''
9
14
  tbl << %w(id name active events)
10
15
  tbl.separator!
@@ -1,3 +1,3 @@
1
1
  module GHRH
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ghrh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-14 00:00:00.000000000 Z
12
+ date: 2013-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clamp