bitbucket_rest_api 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bitbucket_rest_api/api.rb +0 -1
- data/lib/bitbucket_rest_api/authorization.rb +0 -15
- data/lib/bitbucket_rest_api/connection.rb +5 -6
- data/lib/bitbucket_rest_api/issues.rb +15 -20
- data/lib/bitbucket_rest_api/repos.rb +4 -4
- data/lib/bitbucket_rest_api/request/oauth.rb +9 -7
- data/lib/bitbucket_rest_api/version.rb +1 -1
- metadata +48 -37
@@ -3,21 +3,6 @@
|
|
3
3
|
module BitBucket
|
4
4
|
module Authorization
|
5
5
|
|
6
|
-
# Setup OAuth instance
|
7
|
-
def client
|
8
|
-
@client ||= ::OAuth::Consumer.new(client_id, client_secret,
|
9
|
-
{:signature_method=>"HMAC-SHA1",
|
10
|
-
:request_token_path=>"/1.0/oauth/request_token",
|
11
|
-
:authorize_path=>"/1.0/oauth/authenticate",
|
12
|
-
:access_token_path=>"/1.0/oauth/access_token",
|
13
|
-
:proxy=>nil,
|
14
|
-
:scheme=>:header,
|
15
|
-
:http_method=>:post,
|
16
|
-
:oauth_version=>"1.0",
|
17
|
-
:site=>"https://api.bitbucket.org"}
|
18
|
-
)
|
19
|
-
end
|
20
|
-
|
21
6
|
# Check whether authentication credentials are present
|
22
7
|
def authenticated?
|
23
8
|
basic_authed? || oauth_token?
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'faraday'
|
4
|
+
require 'faraday_middleware'
|
4
5
|
require 'bitbucket_rest_api/response'
|
5
6
|
require 'bitbucket_rest_api/response/mashify'
|
6
7
|
require 'bitbucket_rest_api/response/jsonize'
|
@@ -26,10 +27,7 @@ module BitBucket
|
|
26
27
|
def default_options(options={})
|
27
28
|
{
|
28
29
|
:headers => {
|
29
|
-
|
30
|
-
ACCEPT_CHARSET => "utf-8",
|
31
|
-
USER_AGENT => user_agent,
|
32
|
-
CONTENT_TYPE => 'application/json'
|
30
|
+
USER_AGENT => user_agent
|
33
31
|
},
|
34
32
|
:ssl => { :verify => false },
|
35
33
|
:url => options.fetch(:endpoint) { BitBucket.endpoint }
|
@@ -41,11 +39,12 @@ module BitBucket
|
|
41
39
|
#
|
42
40
|
def default_middleware(options={})
|
43
41
|
Proc.new do |builder|
|
44
|
-
builder.use BitBucket::Request::Jsonize
|
42
|
+
#builder.use BitBucket::Request::Jsonize
|
45
43
|
builder.use Faraday::Request::Multipart
|
46
44
|
builder.use Faraday::Request::UrlEncoded
|
47
|
-
builder.use
|
45
|
+
builder.use FaradayMiddleware::OAuth, {:consumer_key => client_id, :consumer_secret => client_secret, :token => oauth_token, :token_secret => oauth_secret} if oauth_token? and oauth_secret?
|
48
46
|
builder.use BitBucket::Request::BasicAuth, authentication if basic_authed?
|
47
|
+
builder.use FaradayMiddleware::EncodeJson
|
49
48
|
|
50
49
|
builder.use Faraday::Response::Logger if ENV['DEBUG']
|
51
50
|
builder.use BitBucket::Response::Helpers
|
@@ -10,27 +10,21 @@ module BitBucket
|
|
10
10
|
:Milestones => 'milestones'
|
11
11
|
|
12
12
|
VALID_ISSUE_PARAM_NAMES = %w[
|
13
|
-
filter
|
14
|
-
state
|
15
|
-
labels
|
16
|
-
sort
|
17
|
-
direction
|
18
|
-
since
|
19
|
-
milestone
|
20
|
-
assignee
|
21
|
-
mentioned
|
22
13
|
title
|
23
|
-
|
24
|
-
|
25
|
-
|
14
|
+
content
|
15
|
+
component
|
16
|
+
milestone
|
17
|
+
version
|
18
|
+
responsible
|
19
|
+
priority
|
20
|
+
status
|
21
|
+
kind
|
26
22
|
].freeze
|
27
23
|
|
28
24
|
VALID_ISSUE_PARAM_VALUES = {
|
29
|
-
'
|
30
|
-
'
|
31
|
-
'
|
32
|
-
'direction' => %w[ desc asc ],
|
33
|
-
'since' => %r{\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z}
|
25
|
+
'priority' => %w[ trivial minor major critical blocker ],
|
26
|
+
'status' => ['new', 'open', 'resolved', 'on hold', 'invalid', 'duplicate', 'wontfix'],
|
27
|
+
'kind' => %w[ bug enhancement proposal task ]
|
34
28
|
}
|
35
29
|
|
36
30
|
# Creates new Issues API
|
@@ -72,8 +66,8 @@ module BitBucket
|
|
72
66
|
assert_valid_values(VALID_ISSUE_PARAM_VALUES, params)
|
73
67
|
|
74
68
|
response = get_request("/repositories/#{user}/#{repo}/issues", params)
|
75
|
-
return response unless block_given?
|
76
|
-
response.each { |el| yield el }
|
69
|
+
return response.issues unless block_given?
|
70
|
+
response.issues.each { |el| yield el }
|
77
71
|
end
|
78
72
|
|
79
73
|
alias :list_repository :list_repo
|
@@ -140,11 +134,12 @@ module BitBucket
|
|
140
134
|
_validate_user_repo_params(user, repo) unless user? && repo?
|
141
135
|
|
142
136
|
normalize! params
|
137
|
+
_merge_user_into_params!(params) unless params.has_key?('user')
|
143
138
|
# _merge_mime_type(:issue, params)
|
144
139
|
filter! VALID_ISSUE_PARAM_NAMES, params
|
145
140
|
assert_required_keys(%w[ title ], params)
|
146
141
|
|
147
|
-
post_request("/repositories/#{user}/#{repo}/issues", params)
|
142
|
+
post_request("/repositories/#{user}/#{repo}/issues/", params)
|
148
143
|
end
|
149
144
|
|
150
145
|
# Edit an issue
|
@@ -176,12 +176,12 @@ module BitBucket
|
|
176
176
|
_merge_user_into_params!(params) unless params.has_key?('user')
|
177
177
|
filter! %w[ user type ], params
|
178
178
|
|
179
|
-
response = if (user_name = params.delete("user"))
|
180
|
-
|
181
|
-
else
|
179
|
+
response = #if (user_name = params.delete("user"))
|
180
|
+
# get_request("/users/#{user_name}", params)
|
181
|
+
#else
|
182
182
|
# For authenticated user
|
183
183
|
get_request("/user/repositories", params)
|
184
|
-
end
|
184
|
+
#end
|
185
185
|
return response unless block_given?
|
186
186
|
response.each { |el| yield el }
|
187
187
|
end
|
@@ -7,24 +7,26 @@ module BitBucket
|
|
7
7
|
class OAuth < Faraday::Middleware
|
8
8
|
include BitBucket::Utils::Url
|
9
9
|
|
10
|
-
ACCESS_TOKEN = 'access_token'.freeze
|
11
10
|
AUTH_HEADER = 'Authorization'.freeze
|
12
11
|
|
13
|
-
dependency '
|
12
|
+
dependency 'simple_oauth'
|
14
13
|
|
15
14
|
def call(env)
|
16
15
|
# Extract parameters from the query
|
17
16
|
params = { }.update query_params(env[:url])
|
18
17
|
|
19
18
|
if (@token and @secret) and (!@token.empty? and !@secret.empty?)
|
20
|
-
env[:url].query = build_query params
|
21
|
-
|
22
19
|
access_token = ::OAuth::AccessToken.new(@consumer, @token, @secret)
|
23
|
-
|
24
|
-
|
25
|
-
oauth_helper
|
20
|
+
env[:url].query = build_query params
|
21
|
+
|
22
|
+
puts oauth_helper.header
|
23
|
+
puts oauth_helper.header.class
|
26
24
|
env[:request_headers].merge!(AUTH_HEADER => oauth_helper.header)
|
27
25
|
end
|
26
|
+
|
27
|
+
env[:url].query = build_query params
|
28
|
+
|
29
|
+
|
28
30
|
|
29
31
|
@app.call env
|
30
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitbucket_rest_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-06 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hashie
|
16
|
-
requirement: &
|
16
|
+
requirement: &70111273293220 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70111273293220
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: faraday
|
27
|
-
requirement: &
|
27
|
+
requirement: &70111273292600 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.8.1
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70111273292600
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: multi_json
|
38
|
-
requirement: &
|
38
|
+
requirement: &70111273292020 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,21 +43,21 @@ dependencies:
|
|
43
43
|
version: '1.3'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70111273292020
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
49
|
-
requirement: &
|
48
|
+
name: faraday_middleware
|
49
|
+
requirement: &70111273291360 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.8.1
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70111273291360
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: nokogiri
|
60
|
-
requirement: &
|
60
|
+
requirement: &70111273290740 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,21 @@ dependencies:
|
|
65
65
|
version: 1.5.2
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70111273290740
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simple_oauth
|
71
|
+
requirement: &70111273290120 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70111273290120
|
69
80
|
- !ruby/object:Gem::Dependency
|
70
81
|
name: rspec
|
71
|
-
requirement: &
|
82
|
+
requirement: &70111273288880 !ruby/object:Gem::Requirement
|
72
83
|
none: false
|
73
84
|
requirements:
|
74
85
|
- - ! '>='
|
@@ -76,10 +87,10 @@ dependencies:
|
|
76
87
|
version: '0'
|
77
88
|
type: :development
|
78
89
|
prerelease: false
|
79
|
-
version_requirements: *
|
90
|
+
version_requirements: *70111273288880
|
80
91
|
- !ruby/object:Gem::Dependency
|
81
92
|
name: cucumber
|
82
|
-
requirement: &
|
93
|
+
requirement: &70111273288020 !ruby/object:Gem::Requirement
|
83
94
|
none: false
|
84
95
|
requirements:
|
85
96
|
- - ! '>='
|
@@ -87,10 +98,10 @@ dependencies:
|
|
87
98
|
version: '0'
|
88
99
|
type: :development
|
89
100
|
prerelease: false
|
90
|
-
version_requirements: *
|
101
|
+
version_requirements: *70111273288020
|
91
102
|
- !ruby/object:Gem::Dependency
|
92
103
|
name: webmock
|
93
|
-
requirement: &
|
104
|
+
requirement: &70111273269300 !ruby/object:Gem::Requirement
|
94
105
|
none: false
|
95
106
|
requirements:
|
96
107
|
- - ~>
|
@@ -98,10 +109,10 @@ dependencies:
|
|
98
109
|
version: 1.8.0
|
99
110
|
type: :development
|
100
111
|
prerelease: false
|
101
|
-
version_requirements: *
|
112
|
+
version_requirements: *70111273269300
|
102
113
|
- !ruby/object:Gem::Dependency
|
103
114
|
name: vcr
|
104
|
-
requirement: &
|
115
|
+
requirement: &70111273268560 !ruby/object:Gem::Requirement
|
105
116
|
none: false
|
106
117
|
requirements:
|
107
118
|
- - ~>
|
@@ -109,10 +120,10 @@ dependencies:
|
|
109
120
|
version: 2.2.0
|
110
121
|
type: :development
|
111
122
|
prerelease: false
|
112
|
-
version_requirements: *
|
123
|
+
version_requirements: *70111273268560
|
113
124
|
- !ruby/object:Gem::Dependency
|
114
125
|
name: simplecov
|
115
|
-
requirement: &
|
126
|
+
requirement: &70111273267400 !ruby/object:Gem::Requirement
|
116
127
|
none: false
|
117
128
|
requirements:
|
118
129
|
- - ~>
|
@@ -120,10 +131,10 @@ dependencies:
|
|
120
131
|
version: 0.6.1
|
121
132
|
type: :development
|
122
133
|
prerelease: false
|
123
|
-
version_requirements: *
|
134
|
+
version_requirements: *70111273267400
|
124
135
|
- !ruby/object:Gem::Dependency
|
125
136
|
name: guard
|
126
|
-
requirement: &
|
137
|
+
requirement: &70111273266280 !ruby/object:Gem::Requirement
|
127
138
|
none: false
|
128
139
|
requirements:
|
129
140
|
- - ! '>='
|
@@ -131,10 +142,10 @@ dependencies:
|
|
131
142
|
version: '0'
|
132
143
|
type: :development
|
133
144
|
prerelease: false
|
134
|
-
version_requirements: *
|
145
|
+
version_requirements: *70111273266280
|
135
146
|
- !ruby/object:Gem::Dependency
|
136
147
|
name: guard-rspec
|
137
|
-
requirement: &
|
148
|
+
requirement: &70111273265240 !ruby/object:Gem::Requirement
|
138
149
|
none: false
|
139
150
|
requirements:
|
140
151
|
- - ! '>='
|
@@ -142,10 +153,10 @@ dependencies:
|
|
142
153
|
version: '0'
|
143
154
|
type: :development
|
144
155
|
prerelease: false
|
145
|
-
version_requirements: *
|
156
|
+
version_requirements: *70111273265240
|
146
157
|
- !ruby/object:Gem::Dependency
|
147
158
|
name: guard-cucumber
|
148
|
-
requirement: &
|
159
|
+
requirement: &70111273264600 !ruby/object:Gem::Requirement
|
149
160
|
none: false
|
150
161
|
requirements:
|
151
162
|
- - ! '>='
|
@@ -153,10 +164,10 @@ dependencies:
|
|
153
164
|
version: '0'
|
154
165
|
type: :development
|
155
166
|
prerelease: false
|
156
|
-
version_requirements: *
|
167
|
+
version_requirements: *70111273264600
|
157
168
|
- !ruby/object:Gem::Dependency
|
158
169
|
name: rake
|
159
|
-
requirement: &
|
170
|
+
requirement: &70111273263720 !ruby/object:Gem::Requirement
|
160
171
|
none: false
|
161
172
|
requirements:
|
162
173
|
- - ! '>='
|
@@ -164,10 +175,10 @@ dependencies:
|
|
164
175
|
version: '0'
|
165
176
|
type: :development
|
166
177
|
prerelease: false
|
167
|
-
version_requirements: *
|
178
|
+
version_requirements: *70111273263720
|
168
179
|
- !ruby/object:Gem::Dependency
|
169
180
|
name: bundler
|
170
|
-
requirement: &
|
181
|
+
requirement: &70111273262820 !ruby/object:Gem::Requirement
|
171
182
|
none: false
|
172
183
|
requirements:
|
173
184
|
- - ! '>='
|
@@ -175,8 +186,8 @@ dependencies:
|
|
175
186
|
version: '0'
|
176
187
|
type: :development
|
177
188
|
prerelease: false
|
178
|
-
version_requirements: *
|
179
|
-
description: ! ' Ruby wrapper for the BitBucket API '
|
189
|
+
version_requirements: *70111273262820
|
190
|
+
description: ! ' Ruby wrapper for the BitBucket API supporting OAuth and Basic Authentication '
|
180
191
|
email: mcochran@linux.com
|
181
192
|
executables: []
|
182
193
|
extensions: []
|
@@ -262,5 +273,5 @@ rubyforge_project:
|
|
262
273
|
rubygems_version: 1.8.10
|
263
274
|
signing_key:
|
264
275
|
specification_version: 3
|
265
|
-
summary: Ruby wrapper for the BitBucket API
|
276
|
+
summary: Ruby wrapper for the BitBucket API supporting OAuth and Basic Authentication
|
266
277
|
test_files: []
|