octokit 1.8.1 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  # CHANGELOG
2
2
 
3
+ * [1.9.0 - July 11, 2012](https://github.com/pengwynn/octokit/compare/v1.8.1...v1.9.0)
3
4
  * [1.8.1 - June 18, 2012](https://github.com/pengwynn/octokit/compare/v1.8.0...v1.8.1)
4
5
  * [1.7.0 - June 18, 2012](https://github.com/pengwynn/octokit/compare/v1.6.1...v1.7.0)
5
6
  * [1.6.1 - June 14, 2012](https://github.com/pengwynn/octokit/compare/v1.6.0...v1.6.1)
data/README.md CHANGED
@@ -63,6 +63,20 @@ client = Octokit::Client.new(:login => "me", :oauth_token => "oauth2token")
63
63
  client.follow!("sferik")
64
64
  ```
65
65
 
66
+ ## Using with GitHub Enterprise
67
+
68
+ To use with [GitHub Enterprise](https://enterprise.github.com/), you'll need to
69
+ set the API and web endpoints before instantiating a client.
70
+
71
+ ```ruby
72
+ Octokit.configure do |c|
73
+ c.api_endpoint = 'https://github.company.com/api/v3'
74
+ c.web_endpoint = 'https://github.company.com/'
75
+ end
76
+
77
+ @client = Octokit::Client.new(:login => 'USERNAME', :password => 'PASSWORD')
78
+ ```
79
+
66
80
  ## Submitting a Pull Request
67
81
  1. [Fork the repository.][fork]
68
82
  2. [Create a topic branch.][branch]
@@ -21,6 +21,7 @@ require 'octokit/client/events'
21
21
  require 'octokit/client/authorizations'
22
22
  require 'octokit/client/refs'
23
23
  require 'octokit/client/contents'
24
+ require 'octokit/client/markdown'
24
25
 
25
26
  module Octokit
26
27
  class Client
@@ -54,5 +55,6 @@ module Octokit
54
55
  include Octokit::Client::Authorizations
55
56
  include Octokit::Client::Refs
56
57
  include Octokit::Client::Contents
58
+ include Octokit::Client::Markdown
57
59
  end
58
60
  end
@@ -1,51 +1,51 @@
1
1
  module Octokit
2
- class Client
3
- module Contents
2
+ class Client
3
+ module Contents
4
4
 
5
- # Receive the default Readme for a repository
6
- #
7
- # @param repo [String, Repository, Hash] A GitHub repository
8
- # @param ref [String] The String name of the Commit/Branch/Tag. Defaults to “master”.
9
- # @option options [String] :ref name of the Commit/Branch/Tag. Defaults to “master”.
10
- # @return [Hash] The detail of the readme
11
- # @see http://developer.github.com/v3/repos/contents/
12
- # @example Get the readme file for a repo
13
- # Octokit.readme("pengwynn/octokit")
14
- def readme(repo, options={})
15
- get("/repos/#{Repository.new repo}/readme", options, 3)
16
- end
5
+ # Receive the default Readme for a repository
6
+ #
7
+ # @param repo [String, Repository, Hash] A GitHub repository
8
+ # @param ref [String] The String name of the Commit/Branch/Tag. Defaults to “master”.
9
+ # @option options [String] :ref name of the Commit/Branch/Tag. Defaults to “master”.
10
+ # @return [Hash] The detail of the readme
11
+ # @see http://developer.github.com/v3/repos/contents/
12
+ # @example Get the readme file for a repo
13
+ # Octokit.readme("pengwynn/octokit")
14
+ def readme(repo, options={})
15
+ get("/repos/#{Repository.new repo}/readme", options, 3)
16
+ end
17
17
 
18
- # Receive a listing of a repository folder or the contents of a file
19
- #
20
- # @param repo [String, Repository, Hash] A GitHub repository
21
- # @option options [String] :path A folder or file path
22
- # @option options [String] :ref name of the Commit/Branch/Tag. Defaults to “master”.
23
- # @return [Hash] The contents of a file or list of the files in the folder
24
- # @see http://developer.github.com/v3/repos/contents/
25
- # @example List the contents of lib/octokit.rb
26
- # Octokit.contents("pengwynn/octokit", :path => 'lib/octokit.rb')
27
- def contents(repo, options={})
28
- repo_path = options.delete :path
29
- url = "/repos/#{Repository.new repo}/contents/#{repo_path}"
30
- get(url, options, 3)
31
- end
32
-
33
- # This method will provide a URL to download a tarball or zipball archive for a repository.
34
- #
35
- # @param repo [String, Repository, Hash] A GitHub repository.
36
- # @option options format [String] Either tarball (default) or zipball.
37
- # @option options [String] :ref Optional valid Git reference, defaults to master.
38
- # @return [String] Location of the download
39
- # @see http://developer.github.com/v3/repos/contents/
40
- # @example Get archive link for pengwynn/octokit
41
- # Octokit.archive_link("pengwynn/octokit")
42
- def archive_link(repo, options={})
43
- repo_ref = options.delete :ref
44
- format = (options.delete :format) || 'tarball'
45
- url = "/repos/#{Repository.new repo}/#{format}/#{repo_ref}"
46
- headers = get(url, options, 3, false, true).headers
47
- return headers['location']
48
- end
49
- end
18
+ # Receive a listing of a repository folder or the contents of a file
19
+ #
20
+ # @param repo [String, Repository, Hash] A GitHub repository
21
+ # @option options [String] :path A folder or file path
22
+ # @option options [String] :ref name of the Commit/Branch/Tag. Defaults to “master”.
23
+ # @return [Hash] The contents of a file or list of the files in the folder
24
+ # @see http://developer.github.com/v3/repos/contents/
25
+ # @example List the contents of lib/octokit.rb
26
+ # Octokit.contents("pengwynn/octokit", :path => 'lib/octokit.rb')
27
+ def contents(repo, options={})
28
+ repo_path = options.delete :path
29
+ url = "/repos/#{Repository.new repo}/contents/#{repo_path}"
30
+ get(url, options, 3)
31
+ end
32
+
33
+ # This method will provide a URL to download a tarball or zipball archive for a repository.
34
+ #
35
+ # @param repo [String, Repository, Hash] A GitHub repository.
36
+ # @option options format [String] Either tarball (default) or zipball.
37
+ # @option options [String] :ref Optional valid Git reference, defaults to master.
38
+ # @return [String] Location of the download
39
+ # @see http://developer.github.com/v3/repos/contents/
40
+ # @example Get archive link for pengwynn/octokit
41
+ # Octokit.archive_link("pengwynn/octokit")
42
+ def archive_link(repo, options={})
43
+ repo_ref = options.delete :ref
44
+ format = (options.delete :format) || 'tarball'
45
+ url = "/repos/#{Repository.new repo}/#{format}/#{repo_ref}"
46
+ headers = get(url, options, 3, false, true).headers
47
+ return headers['location']
48
+ end
49
+ end
50
+ end
50
51
  end
51
- end
@@ -0,0 +1,22 @@
1
+ module Octokit
2
+ class Client
3
+ module Markdown
4
+
5
+ # Receive the default Readme for a repository
6
+ #
7
+ # @param text [String] Markdown source
8
+ # @option options [String] (optional) :mode (`markdown` or `gfm`)
9
+ # @option options [String] (optional) :context Repo context
10
+ # @return [String] HTML renderization
11
+ # @see http://developer.github.com/v3/repos/markdown/
12
+ # @example Render some GFM
13
+ # Octokit.markdown('Fixed in #111', :mode => "gfm", :context => "pengwynn/octokit")
14
+ def markdown(text, options={})
15
+ options[:text] = text
16
+ options[:repo] = Repository.new(options[:repo]) if options[:repo]
17
+ post("/markdown", options, 3, true, true).body
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module Octokit
2
- VERSION = "1.8.1" unless defined?(Octokit::VERSION)
2
+ VERSION = "1.9.1" unless defined?(Octokit::VERSION)
3
3
  end
@@ -0,0 +1 @@
1
+ <p>This is for <a href="https://github.com/pengwynn/octokit/issues/111" class="issue-link" title="[GitHub Enterprise] Calls to custom endpoints return 404">#111</a></p>
@@ -1,48 +1,48 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  require 'helper'
3
3
 
4
- describe Octokit::Client::Contents do
4
+ describe Octokit::Client::Contents do
5
5
 
6
- before do
6
+ before do
7
7
  @client = Octokit::Client.new(:login => 'sferik')
8
8
  end
9
9
 
10
- describe ".readme" do
10
+ describe ".readme" do
11
11
 
12
- it "should return the default readme" do
13
- stub_get("/repos/pengwynn/octokit/readme").
14
- to_return(:body => fixture("v3/readme.json"))
15
- readme = @client.readme('pengwynn/octokit')
16
- readme.encoding.should == "base64"
17
- readme.type.should == "file"
18
- end
12
+ it "should return the default readme" do
13
+ stub_get("/repos/pengwynn/octokit/readme").
14
+ to_return(:body => fixture("v3/readme.json"))
15
+ readme = @client.readme('pengwynn/octokit')
16
+ readme.encoding.should == "base64"
17
+ readme.type.should == "file"
18
+ end
19
19
 
20
- end
20
+ end
21
21
 
22
- describe ".contents" do
22
+ describe ".contents" do
23
23
 
24
- it "should return the contents of a file" do
25
- stub_get("/repos/pengwynn/octokit/contents/lib/octokit.rb").
26
- to_return(:body => fixture("v3/contents.json"))
27
- contents = @client.contents('pengwynn/octokit', :path => "lib/octokit.rb")
28
- contents.path.should == "lib/octokit.rb"
29
- contents.name.should == "lib/octokit.rb"
30
- contents.encoding.should == "base64"
31
- contents.type.should == "file"
32
- end
24
+ it "should return the contents of a file" do
25
+ stub_get("/repos/pengwynn/octokit/contents/lib/octokit.rb").
26
+ to_return(:body => fixture("v3/contents.json"))
27
+ contents = @client.contents('pengwynn/octokit', :path => "lib/octokit.rb")
28
+ contents.path.should == "lib/octokit.rb"
29
+ contents.name.should == "lib/octokit.rb"
30
+ contents.encoding.should == "base64"
31
+ contents.type.should == "file"
32
+ end
33
33
 
34
- end
34
+ end
35
35
 
36
- describe ".archive_link" do
36
+ describe ".archive_link" do
37
37
 
38
- it "should return the headers of the request" do
39
- stub_get("/repos/pengwynn/octokit/tarball/master").
40
- to_return(:status => 302, :body => '', :headers =>
41
- { 'location' => "https://nodeload.github.com/repos/pengwynn/octokit/tarball/"})
42
- archive_link = @client.archive_link('pengwynn/octokit', :ref => "master")
43
- archive_link == "https://nodeload.github.com/pengwynn/octokit/tarball/"
44
- end
38
+ it "should return the headers of the request" do
39
+ stub_get("/repos/pengwynn/octokit/tarball/master").
40
+ to_return(:status => 302, :body => '', :headers =>
41
+ { 'location' => "https://nodeload.github.com/repos/pengwynn/octokit/tarball/"})
42
+ archive_link = @client.archive_link('pengwynn/octokit', :ref => "master")
43
+ archive_link == "https://nodeload.github.com/pengwynn/octokit/tarball/"
44
+ end
45
45
 
46
- end
46
+ end
47
47
 
48
- end
48
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ describe Octokit::Client::Markdown do
5
+
6
+ describe ".markdown" do
7
+
8
+ before do
9
+ @client = Octokit::Client.new
10
+ end
11
+
12
+ it "should render markdown" do
13
+ stub_post("/markdown").
14
+ to_return(:body => fixture("v3/markdown_gfm"))
15
+ text = "This is for #111"
16
+ markdown = @client.markdown(text, :context => 'pengwynn/octokit', :mode => 'gfm')
17
+
18
+ markdown.should include('https://github.com/pengwynn/octokit/issues/111')
19
+ end
20
+
21
+ end
22
+
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octokit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.9.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-06-29 00:00:00.000000000 Z
14
+ date: 2012-07-11 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: addressable
18
- requirement: &70210721954980 !ruby/object:Gem::Requirement
18
+ requirement: !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,15 @@ dependencies:
23
23
  version: '2.2'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70210721954980
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ version: '2.2'
27
32
  - !ruby/object:Gem::Dependency
28
33
  name: faraday
29
- requirement: &70210721954100 !ruby/object:Gem::Requirement
34
+ requirement: !ruby/object:Gem::Requirement
30
35
  none: false
31
36
  requirements:
32
37
  - - ~>
@@ -34,10 +39,15 @@ dependencies:
34
39
  version: '0.8'
35
40
  type: :runtime
36
41
  prerelease: false
37
- version_requirements: *70210721954100
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '0.8'
38
48
  - !ruby/object:Gem::Dependency
39
49
  name: faraday_middleware
40
- requirement: &70210721952980 !ruby/object:Gem::Requirement
50
+ requirement: !ruby/object:Gem::Requirement
41
51
  none: false
42
52
  requirements:
43
53
  - - ~>
@@ -45,10 +55,15 @@ dependencies:
45
55
  version: '0.8'
46
56
  type: :runtime
47
57
  prerelease: false
48
- version_requirements: *70210721952980
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: '0.8'
49
64
  - !ruby/object:Gem::Dependency
50
65
  name: hashie
51
- requirement: &70210721951360 !ruby/object:Gem::Requirement
66
+ requirement: !ruby/object:Gem::Requirement
52
67
  none: false
53
68
  requirements:
54
69
  - - ~>
@@ -56,10 +71,15 @@ dependencies:
56
71
  version: '1.2'
57
72
  type: :runtime
58
73
  prerelease: false
59
- version_requirements: *70210721951360
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: '1.2'
60
80
  - !ruby/object:Gem::Dependency
61
81
  name: multi_json
62
- requirement: &70210721950540 !ruby/object:Gem::Requirement
82
+ requirement: !ruby/object:Gem::Requirement
63
83
  none: false
64
84
  requirements:
65
85
  - - ~>
@@ -67,10 +87,15 @@ dependencies:
67
87
  version: '1.3'
68
88
  type: :runtime
69
89
  prerelease: false
70
- version_requirements: *70210721950540
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ~>
94
+ - !ruby/object:Gem::Version
95
+ version: '1.3'
71
96
  - !ruby/object:Gem::Dependency
72
97
  name: json
73
- requirement: &70210721950020 !ruby/object:Gem::Requirement
98
+ requirement: !ruby/object:Gem::Requirement
74
99
  none: false
75
100
  requirements:
76
101
  - - ! '>='
@@ -78,10 +103,15 @@ dependencies:
78
103
  version: '0'
79
104
  type: :development
80
105
  prerelease: false
81
- version_requirements: *70210721950020
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
82
112
  - !ruby/object:Gem::Dependency
83
113
  name: maruku
84
- requirement: &70210721948640 !ruby/object:Gem::Requirement
114
+ requirement: !ruby/object:Gem::Requirement
85
115
  none: false
86
116
  requirements:
87
117
  - - ! '>='
@@ -89,10 +119,15 @@ dependencies:
89
119
  version: '0'
90
120
  type: :development
91
121
  prerelease: false
92
- version_requirements: *70210721948640
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
93
128
  - !ruby/object:Gem::Dependency
94
129
  name: rake
95
- requirement: &70210721944680 !ruby/object:Gem::Requirement
130
+ requirement: !ruby/object:Gem::Requirement
96
131
  none: false
97
132
  requirements:
98
133
  - - ! '>='
@@ -100,10 +135,15 @@ dependencies:
100
135
  version: '0'
101
136
  type: :development
102
137
  prerelease: false
103
- version_requirements: *70210721944680
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
104
144
  - !ruby/object:Gem::Dependency
105
145
  name: rspec
106
- requirement: &70210721939880 !ruby/object:Gem::Requirement
146
+ requirement: !ruby/object:Gem::Requirement
107
147
  none: false
108
148
  requirements:
109
149
  - - ! '>='
@@ -111,10 +151,15 @@ dependencies:
111
151
  version: '0'
112
152
  type: :development
113
153
  prerelease: false
114
- version_requirements: *70210721939880
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ! '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
115
160
  - !ruby/object:Gem::Dependency
116
161
  name: simplecov
117
- requirement: &70210721937340 !ruby/object:Gem::Requirement
162
+ requirement: !ruby/object:Gem::Requirement
118
163
  none: false
119
164
  requirements:
120
165
  - - ! '>='
@@ -122,10 +167,15 @@ dependencies:
122
167
  version: '0'
123
168
  type: :development
124
169
  prerelease: false
125
- version_requirements: *70210721937340
170
+ version_requirements: !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
126
176
  - !ruby/object:Gem::Dependency
127
177
  name: webmock
128
- requirement: &70210721935680 !ruby/object:Gem::Requirement
178
+ requirement: !ruby/object:Gem::Requirement
129
179
  none: false
130
180
  requirements:
131
181
  - - ! '>='
@@ -133,10 +183,15 @@ dependencies:
133
183
  version: '0'
134
184
  type: :development
135
185
  prerelease: false
136
- version_requirements: *70210721935680
186
+ version_requirements: !ruby/object:Gem::Requirement
187
+ none: false
188
+ requirements:
189
+ - - ! '>='
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
137
192
  - !ruby/object:Gem::Dependency
138
193
  name: yard
139
- requirement: &70210721934980 !ruby/object:Gem::Requirement
194
+ requirement: !ruby/object:Gem::Requirement
140
195
  none: false
141
196
  requirements:
142
197
  - - ! '>='
@@ -144,7 +199,12 @@ dependencies:
144
199
  version: '0'
145
200
  type: :development
146
201
  prerelease: false
147
- version_requirements: *70210721934980
202
+ version_requirements: !ruby/object:Gem::Requirement
203
+ none: false
204
+ requirements:
205
+ - - ! '>='
206
+ - !ruby/object:Gem::Version
207
+ version: '0'
148
208
  description: Simple wrapper for the GitHub v3 API
149
209
  email:
150
210
  - wynn.netherland@gmail.com
@@ -176,6 +236,7 @@ files:
176
236
  - lib/octokit/client/gists.rb
177
237
  - lib/octokit/client/issues.rb
178
238
  - lib/octokit/client/labels.rb
239
+ - lib/octokit/client/markdown.rb
179
240
  - lib/octokit/client/milestones.rb
180
241
  - lib/octokit/client/objects.rb
181
242
  - lib/octokit/client/organizations.rb
@@ -232,6 +293,7 @@ files:
232
293
  - spec/fixtures/v3/labels.json
233
294
  - spec/fixtures/v3/languages.json
234
295
  - spec/fixtures/v3/list_commit_comments.json
296
+ - spec/fixtures/v3/markdown_gfm
235
297
  - spec/fixtures/v3/milestone.json
236
298
  - spec/fixtures/v3/milestones.json
237
299
  - spec/fixtures/v3/not_found.json
@@ -279,6 +341,7 @@ files:
279
341
  - spec/octokit/client/issue_events_spec.rb
280
342
  - spec/octokit/client/issues_spec.rb
281
343
  - spec/octokit/client/labels_spec.rb
344
+ - spec/octokit/client/markdown_spec.rb
282
345
  - spec/octokit/client/milestones_spec.rb
283
346
  - spec/octokit/client/objects_spec.rb
284
347
  - spec/octokit/client/organizations_spec.rb
@@ -312,7 +375,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
312
375
  version: 1.3.6
313
376
  requirements: []
314
377
  rubyforge_project:
315
- rubygems_version: 1.8.10
378
+ rubygems_version: 1.8.23
316
379
  signing_key:
317
380
  specification_version: 3
318
381
  summary: Simple wrapper for the GitHub v3 API
@@ -356,6 +419,7 @@ test_files:
356
419
  - spec/fixtures/v3/labels.json
357
420
  - spec/fixtures/v3/languages.json
358
421
  - spec/fixtures/v3/list_commit_comments.json
422
+ - spec/fixtures/v3/markdown_gfm
359
423
  - spec/fixtures/v3/milestone.json
360
424
  - spec/fixtures/v3/milestones.json
361
425
  - spec/fixtures/v3/not_found.json
@@ -403,6 +467,7 @@ test_files:
403
467
  - spec/octokit/client/issue_events_spec.rb
404
468
  - spec/octokit/client/issues_spec.rb
405
469
  - spec/octokit/client/labels_spec.rb
470
+ - spec/octokit/client/markdown_spec.rb
406
471
  - spec/octokit/client/milestones_spec.rb
407
472
  - spec/octokit/client/objects_spec.rb
408
473
  - spec/octokit/client/organizations_spec.rb