octokit 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/octokit/backports/uri.rb +56 -0
- data/lib/octokit/client/pub_sub_hubbub.rb +11 -4
- data/lib/octokit/client/releases.rb +3 -4
- data/lib/octokit/client/repositories.rb +1 -0
- data/lib/octokit/error.rb +11 -3
- data/lib/octokit/version.rb +1 -1
- data/octokit.gemspec +0 -1
- data/spec/octokit/client/authorizations_spec.rb +13 -16
- data/spec/octokit/client/pub_sub_hubbub_spec.rb +5 -1
- data/spec/octokit/client/releases_spec.rb +2 -1
- metadata +71 -45
- checksums.yaml +0 -7
@@ -0,0 +1,56 @@
|
|
1
|
+
# :stopdoc:
|
2
|
+
|
3
|
+
# Stolen from ruby core's uri/common.rb, with modifications to support 1.8.x
|
4
|
+
#
|
5
|
+
# https://github.com/ruby/ruby/blob/trunk/lib/uri/common.rb
|
6
|
+
#
|
7
|
+
#
|
8
|
+
|
9
|
+
module URI
|
10
|
+
TBLENCWWWCOMP_ = {} # :nodoc:
|
11
|
+
256.times do |i|
|
12
|
+
TBLENCWWWCOMP_[i.chr] = '%%%02X' % i
|
13
|
+
end
|
14
|
+
TBLENCWWWCOMP_[' '] = '+'
|
15
|
+
TBLENCWWWCOMP_.freeze
|
16
|
+
TBLDECWWWCOMP_ = {} # :nodoc:
|
17
|
+
256.times do |i|
|
18
|
+
h, l = i>>4, i&15
|
19
|
+
TBLDECWWWCOMP_['%%%X%X' % [h, l]] = i.chr
|
20
|
+
TBLDECWWWCOMP_['%%%x%X' % [h, l]] = i.chr
|
21
|
+
TBLDECWWWCOMP_['%%%X%x' % [h, l]] = i.chr
|
22
|
+
TBLDECWWWCOMP_['%%%x%x' % [h, l]] = i.chr
|
23
|
+
end
|
24
|
+
TBLDECWWWCOMP_['+'] = ' '
|
25
|
+
TBLDECWWWCOMP_.freeze
|
26
|
+
|
27
|
+
# Encode given +s+ to URL-encoded form data.
|
28
|
+
#
|
29
|
+
# This method doesn't convert *, -, ., 0-9, A-Z, _, a-z, but does convert SP
|
30
|
+
# (ASCII space) to + and converts others to %XX.
|
31
|
+
#
|
32
|
+
# This is an implementation of
|
33
|
+
# http://www.w3.org/TR/html5/forms.html#url-encoded-form-data
|
34
|
+
#
|
35
|
+
# See URI.decode_www_form_component, URI.encode_www_form
|
36
|
+
def self.encode_www_form_component(s)
|
37
|
+
str = s.to_s
|
38
|
+
if RUBY_VERSION < "1.9" && $KCODE =~ /u/i
|
39
|
+
str.gsub(/([^ a-zA-Z0-9_.-]+)/) do
|
40
|
+
'%' + $1.unpack('H2' * Rack::Utils.bytesize($1)).join('%').upcase
|
41
|
+
end.tr(' ', '+')
|
42
|
+
else
|
43
|
+
str.gsub(/[^*\-.0-9A-Z_a-z]/) {|m| TBLENCWWWCOMP_[m]}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Decode given +str+ of URL-encoded form data.
|
48
|
+
#
|
49
|
+
# This decodes + to SP.
|
50
|
+
#
|
51
|
+
# See URI.encode_www_form_component, URI.decode_www_form
|
52
|
+
def self.decode_www_form_component(str, enc=nil)
|
53
|
+
raise ArgumentError, "invalid %-encoding (#{str})" unless /\A(?:%[0-9a-fA-F]{2}|[^%])*\z/ =~ str
|
54
|
+
str.gsub(/\+|%[0-9a-fA-F]{2}/) {|m| TBLDECWWWCOMP_[m]}
|
55
|
+
end
|
56
|
+
end
|
@@ -1,3 +1,10 @@
|
|
1
|
+
major, minor, patch = RUBY_VERSION.split('.').map(&:to_i)
|
2
|
+
|
3
|
+
if (major == 1 && minor < 9) || (major == 1 && minor == 9 && patch < 2)
|
4
|
+
# pull in backports
|
5
|
+
require 'octokit/backports/uri'
|
6
|
+
end
|
7
|
+
|
1
8
|
module Octokit
|
2
9
|
class Client
|
3
10
|
|
@@ -16,9 +23,9 @@ module Octokit
|
|
16
23
|
# client.subscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")
|
17
24
|
def subscribe(topic, callback)
|
18
25
|
options = {
|
26
|
+
:"hub.callback" => callback,
|
19
27
|
:"hub.mode" => "subscribe",
|
20
|
-
:"hub.topic" => topic
|
21
|
-
:"hub.callback" => callback
|
28
|
+
:"hub.topic" => topic
|
22
29
|
}
|
23
30
|
response = pub_sub_hubbub_request(options)
|
24
31
|
|
@@ -35,9 +42,9 @@ module Octokit
|
|
35
42
|
# client.unsubscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")
|
36
43
|
def unsubscribe(topic, callback)
|
37
44
|
options = {
|
45
|
+
:"hub.callback" => callback,
|
38
46
|
:"hub.mode" => "unsubscribe",
|
39
|
-
:"hub.topic" => topic
|
40
|
-
:"hub.callback" => callback
|
47
|
+
:"hub.topic" => topic
|
41
48
|
}
|
42
49
|
response = pub_sub_hubbub_request(options)
|
43
50
|
|
@@ -93,18 +93,17 @@ module Octokit
|
|
93
93
|
# @see http://developer.github.com/v3/repos/releases/#upload-a-release-asset
|
94
94
|
def upload_asset(release_url, path_or_file, options = {})
|
95
95
|
options[:accept] ||= PREVIEW_MEDIA_TYPE
|
96
|
-
file = File.new(path_or_file, "r+b")
|
96
|
+
file = path_or_file.respond_to?(:read) ? path_or_file : File.new(path_or_file, "r+b")
|
97
97
|
options[:content_type] ||= content_type_from_file(file)
|
98
98
|
raise Octokit::MissingContentType.new if options[:content_type].nil?
|
99
99
|
unless name = options[:name]
|
100
|
-
|
101
|
-
name = Pathname.new(file).basename.to_s
|
100
|
+
name = File.basename(file.path)
|
102
101
|
end
|
103
102
|
upload_url = release(release_url).rels[:upload].href_template.expand(:name => name)
|
104
103
|
|
105
104
|
request :post, upload_url, file.read, parse_query_and_convenience_headers(options)
|
106
105
|
ensure
|
107
|
-
file.close
|
106
|
+
file.close if file
|
108
107
|
end
|
109
108
|
|
110
109
|
# Get a single release asset
|
data/lib/octokit/error.rb
CHANGED
@@ -144,18 +144,26 @@ module Octokit
|
|
144
144
|
# and headers include "X-GitHub-OTP"
|
145
145
|
class OneTimePasswordRequired < ClientError
|
146
146
|
#@private
|
147
|
-
|
147
|
+
OTP_DELIVERY_PATTERN = /required; (\w+)/i
|
148
148
|
|
149
149
|
#@private
|
150
150
|
def self.required_header(headers)
|
151
|
-
|
151
|
+
OTP_DELIVERY_PATTERN.match headers['X-GitHub-OTP'].to_s
|
152
152
|
end
|
153
153
|
|
154
154
|
# Delivery method for the user's OTP
|
155
155
|
#
|
156
156
|
# @return [String]
|
157
157
|
def password_delivery
|
158
|
-
@password_delivery ||=
|
158
|
+
@password_delivery ||= delivery_method_from_header
|
159
|
+
end
|
160
|
+
|
161
|
+
private
|
162
|
+
|
163
|
+
def delivery_method_from_header
|
164
|
+
if match = self.class.required_header(@response[:response_headers])
|
165
|
+
match[1]
|
166
|
+
end
|
159
167
|
end
|
160
168
|
end
|
161
169
|
|
data/lib/octokit/version.rb
CHANGED
data/octokit.gemspec
CHANGED
@@ -11,7 +11,6 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.email = ['wynn.netherland@gmail.com', 'sferik@gmail.com', 'clint@ctshryock.com']
|
12
12
|
spec.files = %w(.document CONTRIBUTING.md LICENSE.md README.md Rakefile octokit.gemspec)
|
13
13
|
spec.files += Dir.glob("lib/**/*.rb")
|
14
|
-
spec.files += Dir.glob("spec/**/*")
|
15
14
|
spec.homepage = 'https://github.com/octokit/octokit.rb'
|
16
15
|
spec.licenses = ['MIT']
|
17
16
|
spec.name = 'octokit'
|
@@ -32,28 +32,25 @@ describe Octokit::Client::Authorizations do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
context 'with :idempotent => true' do
|
35
|
-
subject do
|
36
|
-
lambda do |info = {}|
|
37
|
-
@client.create_authorization({
|
38
|
-
:idempotent => true,
|
39
|
-
:client_id => test_github_client_id,
|
40
|
-
:client_secret => test_github_client_secret
|
41
|
-
}.merge(info))
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
35
|
it "creates a new authorization with options" do
|
46
|
-
|
47
|
-
:
|
48
|
-
|
49
|
-
|
36
|
+
authorization = @client.create_authorization \
|
37
|
+
:idempotent => true,
|
38
|
+
:client_id => test_github_client_id,
|
39
|
+
:client_secret => test_github_client_secret,
|
40
|
+
:scopes => %w(gist)
|
50
41
|
expect(authorization.scopes).to be_kind_of Array
|
51
42
|
assert_requested :put, basic_github_url("/authorizations/clients/#{test_github_client_id}")
|
52
43
|
end
|
53
44
|
|
54
45
|
it 'returns an existing API authorization if one already exists' do
|
55
|
-
first_authorization =
|
56
|
-
|
46
|
+
first_authorization = @client.create_authorization \
|
47
|
+
:idempotent => true,
|
48
|
+
:client_id => test_github_client_id,
|
49
|
+
:client_secret => test_github_client_secret
|
50
|
+
second_authorization = @client.create_authorization \
|
51
|
+
:idempotent => true,
|
52
|
+
:client_id => test_github_client_id,
|
53
|
+
:client_secret => test_github_client_secret
|
57
54
|
expect(first_authorization.id).to eql second_authorization.id
|
58
55
|
end
|
59
56
|
end
|
@@ -70,7 +70,11 @@ describe Octokit::Client::PubSubHubbub do
|
|
70
70
|
with(irc_request_body).
|
71
71
|
to_return(:status => 204)
|
72
72
|
expect(@client.subscribe_service_hook("joshk/completeness-fu", "irc", { :server => "chat.freenode.org", :room => "#myproject"})).to eql(true)
|
73
|
-
|
73
|
+
# Since we can't depend upon hash ordering across the Rubies
|
74
|
+
assert_requested :post, "https://api.github.com/hub", :times => 1 do |req|
|
75
|
+
req.body[%r{hub.callback=github%3A%2F%2Firc%3Froom%3D%2523myproject}]
|
76
|
+
req.body[%r{server%3Dchat.freenode.org}]
|
77
|
+
end
|
74
78
|
end
|
75
79
|
end # .subscribe_service_hook
|
76
80
|
|
@@ -79,10 +79,11 @@ describe Octokit::Client::Releases do
|
|
79
79
|
end
|
80
80
|
it "uploads a release asset as file object" do
|
81
81
|
file = File.new("spec/fixtures/upload.png", "r+b")
|
82
|
+
size = File.size(file)
|
82
83
|
name = "upload_by_file.png"
|
83
84
|
asset = @client.upload_asset(@release_url, file, :content_type => "image/png", :name => name)
|
84
85
|
expect(asset.name).to eq(name)
|
85
|
-
expect(asset.size).to eq(
|
86
|
+
expect(asset.size).to eq(size)
|
86
87
|
end
|
87
88
|
it "uploads a release asset with a default name" do
|
88
89
|
path = "spec/fixtures/upload.png"
|
metadata
CHANGED
@@ -1,54 +1,68 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: octokit
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 3
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 2.3.0
|
5
11
|
platform: ruby
|
6
|
-
authors:
|
12
|
+
authors:
|
7
13
|
- Wynn Netherland
|
8
14
|
- Erik Michaels-Ober
|
9
15
|
- Clint Shryock
|
10
16
|
autorequire:
|
11
17
|
bindir: bin
|
12
18
|
cert_chain: []
|
13
|
-
|
14
|
-
|
15
|
-
|
19
|
+
|
20
|
+
date: 2013-10-01 00:00:00 -05:00
|
21
|
+
default_executable:
|
22
|
+
dependencies:
|
23
|
+
- !ruby/object:Gem::Dependency
|
16
24
|
name: bundler
|
17
|
-
requirement: !ruby/object:Gem::Requirement
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '1.0'
|
22
|
-
type: :development
|
23
25
|
prerelease: false
|
24
|
-
|
25
|
-
|
26
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
28
|
+
requirements:
|
26
29
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
hash: 15
|
32
|
+
segments:
|
33
|
+
- 1
|
34
|
+
- 0
|
35
|
+
version: "1.0"
|
36
|
+
type: :development
|
37
|
+
version_requirements: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
30
39
|
name: sawyer
|
31
|
-
requirement: !ruby/object:Gem::Requirement
|
32
|
-
requirements:
|
33
|
-
- - ~>
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: 0.5.1
|
36
|
-
type: :runtime
|
37
40
|
prerelease: false
|
38
|
-
|
39
|
-
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
40
44
|
- - ~>
|
41
|
-
- !ruby/object:Gem::Version
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 9
|
47
|
+
segments:
|
48
|
+
- 0
|
49
|
+
- 5
|
50
|
+
- 1
|
42
51
|
version: 0.5.1
|
52
|
+
type: :runtime
|
53
|
+
version_requirements: *id002
|
43
54
|
description: Simple wrapper for the GitHub API
|
44
|
-
email:
|
55
|
+
email:
|
45
56
|
- wynn.netherland@gmail.com
|
46
57
|
- sferik@gmail.com
|
47
58
|
- clint@ctshryock.com
|
48
59
|
executables: []
|
60
|
+
|
49
61
|
extensions: []
|
62
|
+
|
50
63
|
extra_rdoc_files: []
|
51
|
-
|
64
|
+
|
65
|
+
files:
|
52
66
|
- .document
|
53
67
|
- CONTRIBUTING.md
|
54
68
|
- LICENSE.md
|
@@ -57,6 +71,7 @@ files:
|
|
57
71
|
- octokit.gemspec
|
58
72
|
- lib/octokit/arguments.rb
|
59
73
|
- lib/octokit/authentication.rb
|
74
|
+
- lib/octokit/backports/uri.rb
|
60
75
|
- lib/octokit/client/authorizations.rb
|
61
76
|
- lib/octokit/client/commit_comments.rb
|
62
77
|
- lib/octokit/client/commits.rb
|
@@ -437,31 +452,43 @@ files:
|
|
437
452
|
- spec/octokit/rate_limit_spec.rb
|
438
453
|
- spec/octokit/repository_spec.rb
|
439
454
|
- spec/octokit_spec.rb
|
455
|
+
has_rdoc: true
|
440
456
|
homepage: https://github.com/octokit/octokit.rb
|
441
|
-
licenses:
|
457
|
+
licenses:
|
442
458
|
- MIT
|
443
|
-
metadata: {}
|
444
459
|
post_install_message:
|
445
460
|
rdoc_options: []
|
446
|
-
|
461
|
+
|
462
|
+
require_paths:
|
447
463
|
- lib
|
448
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
464
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
465
|
+
none: false
|
466
|
+
requirements:
|
467
|
+
- - ">="
|
468
|
+
- !ruby/object:Gem::Version
|
469
|
+
hash: 3
|
470
|
+
segments:
|
471
|
+
- 0
|
472
|
+
version: "0"
|
473
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
474
|
+
none: false
|
475
|
+
requirements:
|
476
|
+
- - ">="
|
477
|
+
- !ruby/object:Gem::Version
|
478
|
+
hash: 17
|
479
|
+
segments:
|
480
|
+
- 1
|
481
|
+
- 3
|
482
|
+
- 5
|
457
483
|
version: 1.3.5
|
458
484
|
requirements: []
|
485
|
+
|
459
486
|
rubyforge_project:
|
460
|
-
rubygems_version:
|
487
|
+
rubygems_version: 1.6.2
|
461
488
|
signing_key:
|
462
|
-
specification_version:
|
489
|
+
specification_version: 3
|
463
490
|
summary: Ruby toolkit for working with the GitHub API
|
464
|
-
test_files:
|
491
|
+
test_files:
|
465
492
|
- spec/cassettes/delete_authorization.json
|
466
493
|
- spec/cassettes/Octokit_Client/_get/handles_query_params.json
|
467
494
|
- spec/cassettes/Octokit_Client/_head/handles_query_params.json
|
@@ -801,4 +828,3 @@ test_files:
|
|
801
828
|
- spec/octokit/rate_limit_spec.rb
|
802
829
|
- spec/octokit/repository_spec.rb
|
803
830
|
- spec/octokit_spec.rb
|
804
|
-
has_rdoc:
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 49bd50a2f9430627f5a602916c03e3931299a222
|
4
|
-
data.tar.gz: 7133fd9d3339e1fc94dd480a456948551d88fcc3
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 5ad7ef3547f6c91f21821e0bb69ceb919363b224abe3cc9e494c064c43fa9be3aace48139298aefb2deb938d2b98fcdc7b49626ce5c870eef88ea5ea628c7af8
|
7
|
-
data.tar.gz: 61d8515ae3534f2b5e74954b3ee3a3033dcb976dc526135c26216342eaa09f6f6ac2c5836f5b1a8f6f4abc7a1a59cc8c0909fd44729bff0066a71dee29d43749
|