pra 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b05dfc4974f5278e4d5087b0fab5d2cc908f9610
4
- data.tar.gz: a36c0354adc7ee9d909cb5994a7f50aeba73b7f6
3
+ metadata.gz: 03c59b837ccbcf54d3ac74f7f8a17f4fcbdb9923
4
+ data.tar.gz: 8a131655f65e9c78aeefe47437c535effefe9df9
5
5
  SHA512:
6
- metadata.gz: 30ea96a3f2611358e6aacbe25448ce50c87ea925a0afafe3b722f71ca2855d94ae2b21c8d34505b60672c4b0e17f05b4a36c569ef6498c9509af74b6bae46764
7
- data.tar.gz: bd02aa5874a98fcc7337fccdf6eba273e934dbaf0e44679bf0557cd0b61c5fdb8171746881e108e68c7bc3a5132c76b6cc52738b74ba824094bc6ea5a3daea71
6
+ metadata.gz: df4b092a5dff5a08824616d9e3a5b81abf9a297a322d377ae82dcb34192325d84b8dfe2e9bdc64357ddd48985215fc4528f4404e901b847aaea1da6ec6e682b2
7
+ data.tar.gz: a89c5bb3946700258e83554aaa35822ef61751955fb4b9adf758cd3bef30c32345315c0f65ab926a2a28748d38b859a86607545eb8720dfebfaa31e91d6a3377
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.1.5
data/ChangeLog.md CHANGED
@@ -6,6 +6,8 @@ versions as well as provide a rough history.
6
6
 
7
7
  #### Next Release
8
8
 
9
+ * Switch to using Faraday instead of RestClient.
10
+
9
11
  #### v1.5.1
10
12
 
11
13
  * Fix bug where failed if no `assignee_blacklist` was found in config. Thanks
data/README.md CHANGED
@@ -182,41 +182,36 @@ following:
182
182
  4. Push to the branch (`git push origin my-new-feature`)
183
183
  5. Create new Pull Request
184
184
 
185
- ##### RVM
185
+ ##### RVM/rbenv
186
186
 
187
- We use [RVM](http://rvm.io/) with `pra` to encapsulate the dependency gems in our
188
- development environments. Therefore, we have the `.ruby-version` and
189
- `.ruby-gemset` files in the repository which define the current version of
190
- ruby and the gemset that we are developing with.
187
+ We use [RVM](http://rvm.io/) or [rbenv](https://github.com/sstephenson/rbenv)
188
+ with `pra` to encapsulate the dependency gems in our development environments.
189
+ Therefore, we have the `.ruby-version` file in the repository which define the
190
+ current version of ruby that we are developing with.
191
191
 
192
- You should have [RVM](http://rvm.io) installed of course and when you change
193
- into the project root directory it should switch to the proper ruby version if
194
- you have it intsalled via [RVM](http://rvm.io). It should also create and
195
- switch to the proper gemset.
192
+ You should have [RVM](http://rvm.io) or
193
+ [rbenv](https://github.com/sstephenson/rbenv) installed of course and when you
194
+ change into the project root directory it should switch to the proper ruby
195
+ version if you have it intsalled via [RVM](http://rvm.io) or
196
+ [rbenv](https://github.com/sstephenson/rbenv).
196
197
 
197
- If the proper version of ruby is NOT installed via [RVM](http://rvm.io) you
198
- should first install that version of ruby and then change out of the project
199
- root directory, then change back into it and verify that you are in the
200
- proper ruby version and gemset. This can be done with the following command.
201
-
202
- rvm current
203
-
204
- The above command should have output the following
205
-
206
- ruby-2.0.0-p247@pra
198
+ If the proper version of ruby is NOT installed via [RVM](http://rvm.io) or
199
+ [rbenv](https://github.com/sstephenson/rbenv) you should first install that
200
+ version of ruby and then change out of the project root directory, then change
201
+ back into it and verify that you are in the proper ruby version.
207
202
 
208
203
  ##### Bundler
209
204
 
210
205
  We use [Bundler](http://bundler.io/) to manage the development dependencies of
211
- `pra`. Once you got setup with [RVM](http://rvm.io) as described above you
212
- should be able to install all the development dependencies using the following
213
- command:
206
+ `pra`. Once you are setup with [RVM](http://rvm.io) or
207
+ [rbenv](https://github.com/sstephenson/rbenv) as described above you should be
208
+ able to install all the development dependencies using the following command:
214
209
 
215
210
  bundle
216
211
 
217
212
  ##### Test Driven Development
218
213
 
219
- I eveloped `pra` using the TDD methodology with
214
+ I developed `pra` using the TDD methodology with
220
215
  [RSpec](http://www.relishapp.com/rspec) as the testing tool of choice.
221
216
  Therefore, if you are going to contribute code to `pra` please TDD your code
222
217
  changes using [RSpec](http://www.relishapp.com/rspec). If you do not submit
@@ -225,12 +220,13 @@ you add appropriate test coverage.
225
220
 
226
221
  ##### Run Development Version Manually
227
222
 
228
- If you have setup [RVM](http://rvm.io) as described above and installed the
229
- development dependencies using [Bundler](http://bundler.io/) as described
223
+ If you have setup [RVM](http://rvm.io) or
224
+ [rbenv](https://github.com/sstephenson/rbenv) as described above and installed
225
+ the development dependencies using [Bundler](http://bundler.io/) as described
230
226
  above you should be able to run the development version of `pra` by running
231
227
  the following command:
232
228
 
233
- ./bin/pra
229
+ bundle exec ./bin/pra
234
230
 
235
231
  *Note:* The above of course assumes that you have a `~/.pra.json` file
236
232
  already configured.
@@ -1,7 +1,7 @@
1
1
  require 'pra/pull_source'
2
2
  require 'pra/pull_request'
3
- require 'rest_client'
4
3
  require 'json'
4
+ require 'faraday'
5
5
 
6
6
  module Pra
7
7
  class GithubPullSource < Pra::PullSource
@@ -19,7 +19,7 @@ module Pra
19
19
 
20
20
  def get_repo_pull_requests(repository_config)
21
21
  requests = []
22
- JSON.parse(rest_api_pull_request_resource(repository_config).get).each do |request|
22
+ JSON.parse(rest_api_pull_request_resource(repository_config)).each do |request|
23
23
  requests << Pra::PullRequest.new(title: request["title"], from_reference: request["head"]["label"], to_reference: request["base"]["label"], author: request["user"]["login"], assignee: request["assignee"] ? request["assignee"]["login"] : nil, link: request['html_url'], service_id: 'github', repository: repository_config["repository"])
24
24
  end
25
25
  return requests
@@ -30,7 +30,14 @@ module Pra
30
30
  end
31
31
 
32
32
  def rest_api_pull_request_resource(repository_config)
33
- RestClient::Resource.new(rest_api_pull_request_url(repository_config), user: @config['username'], password: @config['password'], content_type: :json, accept: :json)
33
+ conn = Faraday.new
34
+ conn.basic_auth(@config['username'], @config['password'])
35
+ resp = conn.get do |req|
36
+ req.url rest_api_pull_request_url(repository_config)
37
+ req.headers['Content-Type'] = 'application/json'
38
+ req.headers['Accept'] = 'application/json'
39
+ end
40
+ resp.body
34
41
  end
35
42
  end
36
43
  end
@@ -1,6 +1,6 @@
1
1
  require 'pra/pull_source'
2
2
  require 'pra/pull_request'
3
- require 'rest_client'
3
+ require 'faraday'
4
4
  require 'json'
5
5
 
6
6
  module Pra
@@ -19,7 +19,7 @@ module Pra
19
19
 
20
20
  def get_repo_pull_requests(repository_config)
21
21
  requests = []
22
- JSON.parse(rest_api_pull_request_resource(repository_config).get)["values"].each do |request|
22
+ JSON.parse(rest_api_pull_request_resource(repository_config))["values"].each do |request|
23
23
  requests << Pra::PullRequest.new(title: request["title"], from_reference: request["fromRef"]["id"], to_reference: request["toRef"]["id"], assignee: request["reviewers"].length > 0 ? request["reviewers"].first["user"]["name"] : nil, author: request["author"]["user"]["name"], link: "#{@config['protocol']}://#{@config['host']}#{request['link']['url']}", service_id: 'stash', repository: repository_config["repository_slug"])
24
24
  end
25
25
  return requests
@@ -34,7 +34,14 @@ module Pra
34
34
  end
35
35
 
36
36
  def rest_api_pull_request_resource(repository_config)
37
- RestClient::Resource.new(rest_api_pull_request_url(repository_config), user: @config['username'], password: @config['password'], content_type: :json, accept: :json)
37
+ conn = Faraday.new
38
+ conn.basic_auth(@config['username'], @config['password'])
39
+ resp = conn.get do |req|
40
+ req.url rest_api_pull_request_url(repository_config)
41
+ req.headers['Content-Type'] = 'application/json'
42
+ req.headers['Accept'] = 'application/json'
43
+ end
44
+ resp.body
38
45
  end
39
46
  end
40
47
  end
data/lib/pra/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pra
2
- VERSION = "1.5.1"
2
+ VERSION = "1.6.0"
3
3
  end
data/pra.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rake", "~> 10.1"
23
23
  spec.add_development_dependency "rspec", "~> 2.14"
24
24
 
25
- spec.add_dependency "rest-client", "~> 1.6"
25
+ spec.add_dependency "faraday", "~> 0.9"
26
26
  spec.add_dependency "launchy", "~> 2.4"
27
27
  spec.add_dependency "curses", "~> 1.0"
28
28
  end
@@ -70,9 +70,7 @@ describe Pra::GithubPullSource do
70
70
  ]
71
71
  }
72
72
  pull_source = Pra::GithubPullSource.new(config)
73
- the_resource = double
74
- pull_source.stub(:rest_api_pull_request_resource).with({ "owner" => "reachlocal", "repository" => "snapdragon" }).and_return(the_resource)
75
- the_resource.should_receive(:get).and_return('[]')
73
+ pull_source.stub(:rest_api_pull_request_resource).with({ "owner" => "reachlocal", "repository" => "snapdragon" }).and_return('[]')
76
74
  pull_source.get_repo_pull_requests({ "owner" => "reachlocal", "repository" => "snapdragon" })
77
75
  end
78
76
  end
@@ -113,16 +111,30 @@ describe Pra::GithubPullSource do
113
111
 
114
112
  subject { Pra::GithubPullSource.new(config) }
115
113
 
116
- it "gets the repository url compiled from the config options" do
117
- subject.should_receive(:rest_api_pull_request_url).with(repo_config)
114
+ it "creates a Faraday connection" do
115
+ expect(Faraday).to receive(:new).and_return(double.as_null_object)
118
116
  subject.rest_api_pull_request_resource(repo_config)
119
117
  end
120
118
 
121
- it "builds a restclient resource using the pull request url and user credentials" do
122
- url = "https://my.github.instance/repos/reachlocal/snapdragon/pulls"
123
- subject.stub(:rest_api_pull_request_url).and_return(url)
124
- RestClient::Resource.should_receive(:new).with(url, {user: "foo", password: "bar", content_type: :json, accept: :json})
119
+ it "set the http basic auth credentials" do
120
+ conn = double('faraday connection').as_null_object
121
+ allow(Faraday).to receive(:new).and_return(conn)
122
+ expect(conn).to receive(:basic_auth).with("foo", "bar")
125
123
  subject.rest_api_pull_request_resource(repo_config)
126
124
  end
125
+
126
+ it "makes request using faraday connection" do
127
+ conn = double('faraday connection').as_null_object
128
+ allow(Faraday).to receive(:new).and_return(conn)
129
+ expect(conn).to receive(:get)
130
+ subject.rest_api_pull_request_resource(repo_config)
131
+ end
132
+
133
+ it "returns the responses body" do
134
+ conn = double('faraday connection').as_null_object
135
+ allow(Faraday).to receive(:new).and_return(conn)
136
+ expect(conn).to receive(:get).and_return(double('response', body: 'hoopytbody'))
137
+ expect(subject.rest_api_pull_request_resource(repo_config)).to eq('hoopytbody')
138
+ end
127
139
  end
128
140
  end
@@ -52,7 +52,7 @@ describe Pra::PullRequestService::FetchStatus do
52
52
  subject { Pra::PullRequestService::FetchStatus.new(:success, double) }
53
53
 
54
54
  it 'returns true' do
55
- expect(subject.success?).to be_true
55
+ expect(subject.success?).to be_truthy
56
56
  end
57
57
  end
58
58
 
@@ -60,7 +60,7 @@ describe Pra::PullRequestService::FetchStatus do
60
60
  subject { Pra::PullRequestService::FetchStatus.new(double, double) }
61
61
 
62
62
  it 'returns false' do
63
- expect(subject.success?).to be_false
63
+ expect(subject.success?).to be_falsey
64
64
  end
65
65
  end
66
66
  end
@@ -70,7 +70,7 @@ describe Pra::PullRequestService::FetchStatus do
70
70
  subject { Pra::PullRequestService::FetchStatus.new(:error, double) }
71
71
 
72
72
  it 'returns true' do
73
- expect(subject.error?).to be_true
73
+ expect(subject.error?).to be_truthy
74
74
  end
75
75
  end
76
76
 
@@ -78,7 +78,7 @@ describe Pra::PullRequestService::FetchStatus do
78
78
  subject { Pra::PullRequestService::FetchStatus.new(double, double) }
79
79
 
80
80
  it 'returns false' do
81
- expect(subject.error?).to be_false
81
+ expect(subject.error?).to be_falsey
82
82
  end
83
83
  end
84
84
  end
@@ -124,4 +124,4 @@ describe Pra::PullRequestService::FetchStatus do
124
124
  end
125
125
  end
126
126
  end
127
- end
127
+ end
@@ -70,9 +70,7 @@ describe Pra::StashPullSource do
70
70
  ]
71
71
  }
72
72
  pull_source = Pra::StashPullSource.new(config)
73
- the_resource = double
74
- pull_source.stub(:rest_api_pull_request_resource).with({ "project_slug" => "CAP", "repository_slug" => "capture_api" }).and_return(the_resource)
75
- the_resource.should_receive(:get).and_return('{ "values": [] }')
73
+ pull_source.stub(:rest_api_pull_request_resource).with({ "project_slug" => "CAP", "repository_slug" => "capture_api" }).and_return('{ "values": [] }')
76
74
  pull_source.get_repo_pull_requests({ "project_slug" => "CAP", "repository_slug" => "capture_api" })
77
75
  end
78
76
  end
@@ -134,16 +132,30 @@ describe Pra::StashPullSource do
134
132
 
135
133
  subject { Pra::StashPullSource.new(config) }
136
134
 
137
- it "gets the repository url compiled from the config options" do
138
- subject.should_receive(:rest_api_pull_request_url).with(repo_config)
135
+ it "creates a Faraday connection" do
136
+ expect(Faraday).to receive(:new).and_return(double.as_null_object)
139
137
  subject.rest_api_pull_request_resource(repo_config)
140
138
  end
141
139
 
142
- it "builds a restclient resource using the pull request url and user credentials" do
143
- url = "https://my.stash.instance/rest/api/1.0/projects/CAP/repos/capture_api/pull-requests"
144
- subject.stub(:rest_api_pull_request_url).and_return(url)
145
- RestClient::Resource.should_receive(:new).with(url, {user: "foo", password: "bar", content_type: :json, accept: :json})
140
+ it "set the http basic auth credentials" do
141
+ conn = double('faraday connection').as_null_object
142
+ allow(Faraday).to receive(:new).and_return(conn)
143
+ expect(conn).to receive(:basic_auth).with("foo", "bar")
146
144
  subject.rest_api_pull_request_resource(repo_config)
147
145
  end
146
+
147
+ it "makes request using faraday connection" do
148
+ conn = double('faraday connection').as_null_object
149
+ allow(Faraday).to receive(:new).and_return(conn)
150
+ expect(conn).to receive(:get)
151
+ subject.rest_api_pull_request_resource(repo_config)
152
+ end
153
+
154
+ it "returns the responses body" do
155
+ conn = double('faraday connection').as_null_object
156
+ allow(Faraday).to receive(:new).and_return(conn)
157
+ expect(conn).to receive(:get).and_return(double('response', body: 'hoopytbody'))
158
+ expect(subject.rest_api_pull_request_resource(repo_config)).to eq('hoopytbody')
159
+ end
148
160
  end
149
161
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pra
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew De Ponte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-03 00:00:00.000000000 Z
11
+ date: 2014-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -53,19 +53,19 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.14'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rest-client
56
+ name: faraday
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.6'
61
+ version: '0.9'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.6'
68
+ version: '0.9'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: launchy
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -104,7 +104,6 @@ extensions: []
104
104
  extra_rdoc_files: []
105
105
  files:
106
106
  - ".gitignore"
107
- - ".ruby-gemset"
108
107
  - ".ruby-version"
109
108
  - ChangeLog.md
110
109
  - Gemfile
@@ -164,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
163
  version: '0'
165
164
  requirements: []
166
165
  rubyforge_project:
167
- rubygems_version: 2.2.0
166
+ rubygems_version: 2.2.2
168
167
  signing_key:
169
168
  specification_version: 4
170
169
  summary: CLI tool that shows open pull-requests across systems.
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- pra