ghee 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -20,6 +20,8 @@ Create an OAuth access token:
20
20
 
21
21
  ## Gists
22
22
 
23
+ ### Usage
24
+
23
25
  List a user's gists:
24
26
 
25
27
  gh.user('jonmagic').gists
@@ -85,6 +87,119 @@ Get a single repo:
85
87
 
86
88
  gh.repos("rauhryan", "ghee")
87
89
 
90
+ ### Commits
91
+
92
+ List commits on a repo:
93
+
94
+ gh.repos("rauhryan", "ghee").commits
95
+
96
+ gh.repos("rauhryan", "ghee").commits({
97
+ :sha => "awesome_branch" # optional
98
+ })
99
+
100
+ gh.repos("rauhryan", "ghee").commits( {
101
+ :path => "/path/to/file" # only commits containing this path
102
+ })
103
+
104
+ Get a single commit:
105
+
106
+ gh.repos("rauhryan", "ghee").commits("sha")
107
+
108
+ List commit comments for a repo:
109
+
110
+ gh.repos("rauhryan", "ghee").comments
111
+
112
+ List comments for a single commit:
113
+
114
+ gh.repos("rauhryan", "ghee").commits("sha").comments
115
+
116
+ Create a commit comment:
117
+
118
+ gh.repos("rauhryan", "ghee").commits("sha").comments.create({
119
+ :body => "sweet codez yo!", #required
120
+ :commit_id => "sha", #required
121
+ :line => 123, #required
122
+ :path => "/path/to/file", #required
123
+ :position => 4 #required
124
+ })
125
+
126
+ Get a single commit comment:
127
+
128
+ gh.repos("rauhryan", "ghee").comments(123)
129
+
130
+ Update a commit comment:
131
+
132
+ gh.repos("rauhryan", "ghee").comments(123).patch(:body => "new text")
133
+
134
+ Destroy a commit comment:
135
+
136
+ gh.repos("rauhryan", "ghee").comments(123).destroy
137
+
138
+ Compare two commits:
139
+
140
+ gh.repos("rauhryan", "ghee").compare("basesha","headsha")
141
+
142
+ ### Collaborators
143
+
144
+ List a repos collaborators:
145
+
146
+ gh.repos("rauhryan", "ghee").collaborators
147
+
148
+ Get a single collaborator:
149
+
150
+ gh.repos("rauhryan", "ghee").collaborators("herp") # => false
151
+
152
+ gh.repos("rauhryan", "ghee").collaborators("jonmagic") # => true
153
+
154
+ Add a collaborator:
155
+
156
+ gh.repos("rauhryan", "ghee").collaborators.add("herp") # => true
157
+
158
+ Remove a collaborator:
159
+
160
+ gh.repos("rauhryan", "ghee").collaborators.remove("herp") # => true
161
+
162
+ ### Forks
163
+
164
+ List the hooks for a repo:
165
+
166
+ gh.repos("rauhryan", "ghee").forks
167
+
168
+ gh.repos("rauhryan", "ghee").forks(:sort => "newest") # => `newest`, `oldest`, `watchers`
169
+
170
+ Create a fork:
171
+
172
+ gh.repos("rauhryan", "ghee").forks.create # => forks the repo to the authenticated user
173
+
174
+ ### Keys
175
+
176
+ List the keys for a repo:
177
+
178
+ gh.repos("rauhryan", "ghee").keys
179
+
180
+ Get a single key for a repo:
181
+
182
+ gh.repos("rauhryan", "ghee").keys(123)
183
+
184
+ Create a key for a repo:
185
+
186
+ gh.repos("rauhryan", "ghee").keys.create({
187
+ :title => "customer deploy key",
188
+ :key => "ssh-rsa AAA ..."
189
+ })
190
+
191
+ Update a key for a repo:
192
+
193
+ gh.repos("rauhryan", "ghee").keys.patch({
194
+ :title => "customer deploy key",
195
+ :key => "ssh-rsa AAA ..."
196
+ })
197
+
198
+ Destroy a key for a repo:
199
+
200
+ gh.repos("rauhryan", "ghee").keys(123).destroy # => true
201
+
202
+
88
203
  ### Hooks
89
204
 
90
205
  Get the hooks for a repo:
@@ -129,7 +244,31 @@ Create a download for a repo:
129
244
 
130
245
  Destroy a download for a repo:
131
246
 
132
- gh.repos("rauhryan", "ghee").downloads.destroy
247
+ gh.repos("rauhryan", "ghee").downloads(12).destroy
248
+
249
+ ### Watchers
250
+
251
+ List watchers for a repo:
252
+
253
+ gh.repos("rauhryan", "ghee").watchers
254
+
255
+ List repos being watched:
256
+
257
+ gh.user.watched
258
+
259
+ gh.users("jonmagic").watched
260
+
261
+ Check if you are watching a repo:
262
+
263
+ gh.user.watching? "rauhryan", "huboard"
264
+
265
+ Watch a repo:
266
+
267
+ gh.user.watch "rauhryan", "huboard"
268
+
269
+ Unwatch a repo:
270
+
271
+ gh.user.watch! "rauhryan", "huboard"
133
272
 
134
273
  ### Milestones
135
274
 
@@ -214,6 +353,8 @@ Destroy a comment for an issue
214
353
 
215
354
  ## Orgs
216
355
 
356
+ ### Usage
357
+
217
358
  Get a list of orgs for the current user:
218
359
 
219
360
  gh.orgs
@@ -226,12 +367,16 @@ Patch an organization:([see docs for all possible params](http://developer.githu
226
367
 
227
368
  gh.orgs("huboard").patch({ :company => "awesome company" })
228
369
 
370
+ ### Repos
371
+
229
372
  Get a list of repos for an org:
230
373
 
231
374
  gh.orgs("huboard").repos
232
375
 
233
376
  > Notes: see above for all the available api methods for repos
234
377
 
378
+ ### Teams
379
+
235
380
  Get a list of teams for an org:
236
381
 
237
382
  gh.orgs("huboard").teams
@@ -252,6 +397,8 @@ Delete a team for an org:
252
397
 
253
398
  gh.orgs("huboard").teams(110234).delete
254
399
 
400
+ ### Members
401
+
255
402
  Get a list of members for a team:
256
403
 
257
404
  gh.orgs("huboard").teams(110234).members
@@ -266,6 +413,8 @@ Remove a member from a team:
266
413
 
267
414
  ## Teams
268
415
 
416
+ ### Usage
417
+
269
418
  Get a single team:
270
419
 
271
420
  gh.team(110234)
@@ -282,6 +431,8 @@ Delete a team:
282
431
 
283
432
  gh.team(110234).delete
284
433
 
434
+ ### Members
435
+
285
436
  Get a list of members for a team:
286
437
 
287
438
  gh.team(110234).members
@@ -296,6 +447,8 @@ Remove a member from a team:
296
447
 
297
448
  ## Users
298
449
 
450
+ ### Usage
451
+
299
452
  Get a single user:
300
453
 
301
454
  gh.users('jonmagic')
@@ -313,6 +466,36 @@ Update authenticated user ([see docs for all possible params](http://developer.g
313
466
  # …etc
314
467
  })
315
468
 
469
+ ### Keys
470
+
471
+ List the keys for a user:
472
+
473
+ gh.user.keys
474
+
475
+ Get a single key for a user:
476
+
477
+ gh.user.keys(123)
478
+
479
+ Create a key for a user:
480
+
481
+ gh.user.keys.create({
482
+ :title => "customer deploy key",
483
+ :key => "ssh-rsa AAA ..."
484
+ })
485
+
486
+ Update a key for a user:
487
+
488
+ gh.user.keys.patch({
489
+ :title => "customer deploy key",
490
+ :key => "ssh-rsa AAA ..."
491
+ })
492
+
493
+ Destroy a key for a user:
494
+
495
+ gh.user.keys(123).destroy # => true
496
+
497
+ ### Repos
498
+
316
499
  Get a list of repos for the current user:
317
500
 
318
501
  gh.user.repos
@@ -341,14 +524,152 @@ Get a list of orgs for a specific user:
341
524
 
342
525
  > Notes: see above for all the available api methods for orgs
343
526
 
527
+ ### Followers
528
+
529
+ Get the followers for a user:
530
+
531
+ gh.user.followers
532
+
533
+ gh.users("rauhryan").followers
534
+
535
+ Get users following another user:
536
+
537
+ gh.users("rauhryan").following
538
+
539
+ gh.user.following
540
+
541
+ Check if you are following a user:
542
+
543
+ gh.user.following? "rauhryan"
544
+
545
+ Follow a user:
546
+
547
+ gh.user.follow "rauhryan"
548
+
549
+ Unfollow a user:
550
+
551
+ gh.user.follow! "rauhryan"
552
+
553
+ ## Git Data
554
+
555
+ ### Blobs
556
+
557
+ Get a blob:
558
+
559
+ gh.repos("rauhryan","huboard").git.blobs("sha")
560
+
561
+ Create a blob:
562
+
563
+ gh.repos("rauhryan","huboard").git.blobs.create({
564
+ :content => "Contents of blob",
565
+ :encoding => "utf-8"
566
+ })
567
+
568
+
569
+ ### Commit
570
+
571
+ Get a commit:
572
+
573
+ gh.repos("rauhryan","huboard").git.commits("sha")
574
+
575
+ Create a commit:
576
+
577
+ gh.repos("rauhryan","huboard").git.commits.create({
578
+ :message => "message of commit",
579
+ :tree => "sha",
580
+ :parents => ["sha","sha"]
581
+ })
582
+
583
+ ### References
584
+
585
+ Get a reference:
586
+
587
+ gh.repos("rauhryan","huboard").git.refs("heads/master")
588
+
589
+ Get all references:
590
+
591
+ gh.repos("rauhryan","huboard").git.refs
592
+
593
+ gh.repos("rauhryan","huboard").git.refs("tags")
594
+
595
+ gh.repos("rauhryan","huboard").git.refs("heads")
596
+
597
+ Create a reference:
598
+
599
+ gh.repos("rauhryan","huboard").git.refs.create({
600
+ :ref => "refs/heads/master",
601
+ :sha => "287efc2351325e215j235f25215el1"
602
+ })
603
+
604
+ Update a reference:
605
+
606
+ gh.repos("rauhryan","huboard").git.refs("heads/master").patch({
607
+ :sha => "287efc2351325e215j235f25215el1",
608
+ :force => true
609
+ })
610
+
611
+ Delete a reference:
612
+
613
+ gh.repos("rauhryan","huboard").git.refs("tags/v1.0").destroy
614
+
615
+ ### Tags
616
+
617
+ Get a tag:
618
+
619
+ gh.repos("rauhryan","huboard").git.tags("sha")
620
+
621
+ Create a tag:
622
+
623
+ gh.repos("rauhryan","huboard").git.tags.create({
624
+ :tag => "v1.0",
625
+ :message => "tag message",
626
+ :object => "sha", #sha of the object you are tagging, usually a commit
627
+ :type => "commit", #the type of object you are tagging
628
+ :tagger => {
629
+ :name => "Ryan Rauh",
630
+ :email => "rauh.ryan@gmail.com",
631
+ :date => "2011-06-17T14:53:35-07:00"
632
+ }
633
+ })
634
+
635
+ ### Trees
636
+
637
+ Get a tree:
638
+
639
+ gh.repos("rauhryan","huboard").git.trees("sha")
640
+
641
+ Get a tree recursively:
642
+
643
+ gh.repos("rauhryan","huboard").git.trees("sha",{:recursive => 1})
644
+
645
+ Create a tree:
646
+
647
+ gh.repos("rauhryan","huboard").git.trees.create({
648
+ :base_tree => "sha", #optional
649
+ :tree => [
650
+ {
651
+ :path => "/path/to/thing",
652
+ :mode => 100644,
653
+ :type => "blob",
654
+ :sha => "sha"
655
+ # :content => "" # can use this instead of sha
656
+ }
657
+ ]
658
+ })
659
+
660
+
344
661
  ## Events
345
662
 
663
+ ### Usage
664
+
346
665
  List public events:
347
666
 
348
667
  gh.events
349
668
 
350
669
  ## Pagination
351
670
 
671
+ ### Usage
672
+
352
673
  Ghee fully supports pagination for anything that returns a list, for
353
674
  example repo issues.
354
675
 
@@ -365,6 +686,8 @@ Ghee also provides a convienence method for all the pages
365
686
 
366
687
  ## Filtering parameters
367
688
 
689
+ ### Usage
690
+
368
691
  Many of the api calls allow you to pass in additional paramters to
369
692
  filter and sort your data, for example issues provide
370
693
 
data/lib/ghee.rb CHANGED
@@ -13,6 +13,15 @@ require 'ghee/api/milestones'
13
13
  require 'ghee/api/orgs'
14
14
  require 'ghee/api/git_data'
15
15
  require 'ghee/api/downloads'
16
+ require 'ghee/api/labels'
17
+ require 'ghee/api/hooks'
18
+ require 'ghee/api/collaborators'
19
+ require 'ghee/api/forks'
20
+ require 'ghee/api/commits'
21
+ require 'ghee/api/keys'
22
+ require 'ghee/api/watchers'
23
+ require 'ghee/api/emails'
24
+ require 'ghee/api/followers'
16
25
 
17
26
  class Ghee
18
27
  attr_reader :connection
@@ -22,8 +31,6 @@ class Ghee
22
31
  include Ghee::API::Users
23
32
  include Ghee::API::Events
24
33
  include Ghee::API::Repos
25
- include Ghee::API::Issues
26
- include Ghee::API::Milestones
27
34
  include Ghee::API::Orgs
28
35
 
29
36
  # Instantiates Ghee, accepts an access_token
@@ -0,0 +1,37 @@
1
+ class Ghee
2
+
3
+ # API module encapsulates all of API endpoints
4
+ # implemented thus far
5
+ #
6
+ module API
7
+
8
+ # The Repos module handles all of the Github Repo
9
+ # API endpoints
10
+ #
11
+ module Repos
12
+
13
+ module Collaborators
14
+ class Proxy < ::Ghee::ResourceProxy
15
+ def add(member)
16
+ connection.put("#{path_prefix}/#{member}").status == 204
17
+ end
18
+
19
+ def remove(member)
20
+ connection.delete("#{path_prefix}/#{member}").status == 204
21
+ end
22
+ end
23
+ end
24
+
25
+ # Gists::Proxy inherits from Ghee::Proxy and
26
+ # enables defining methods on the proxy object
27
+ #
28
+ class Proxy < ::Ghee::ResourceProxy
29
+ def collaborators(user=nil)
30
+ prefix = user ? "#{path_prefix}/collaborators/#{user}" : "#{path_prefix}/collaborators"
31
+ return user ? connection.get(prefix).status == 204 : Ghee::API::Repos::Collaborators::Proxy.new(connection, prefix)
32
+ end
33
+ end
34
+
35
+ end
36
+ end
37
+ end