redminerb 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/redminerb/cli/projects.rb +2 -0
- data/lib/redminerb/client.rb +4 -0
- data/lib/redminerb/projects.rb +15 -4
- data/lib/redminerb/users.rb +1 -1
- data/lib/redminerb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15c9f30f16fc1632e7870c461e94abfaf4cb9aaf
|
4
|
+
data.tar.gz: b7a41abe3ddeebbf1d4629e527a66616f2e0e1d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c9cd6099fbafe3f5c778946480cd2f681ec2efad16866239f4900c81e716531480913f0e8e8a5e6a505f6e0e58c05e4760fac5895c5168ed28dd9905bd1a850
|
7
|
+
data.tar.gz: a32012f49690855eb5634dadd7cf04079a88cda0cae7f4147e255e8acbb5c5d51a80199fcebc46453e506633e93531aded30e94898d3cfb9ec73c9550ade4872
|
data/README.md
CHANGED
@@ -216,7 +216,7 @@ The **projects** command is the wrapper for part of the [Projects resource](http
|
|
216
216
|
|
217
217
|
#### List projects
|
218
218
|
|
219
|
-
$ redminerb projects [list] [-q|--query <FILTER>]
|
219
|
+
$ redminerb projects [list] [-q|--query <FILTER>] [--all]
|
220
220
|
|
221
221
|
The command *projects* will give us the ids of every public and private project where the user have access to.
|
222
222
|
|
data/lib/redminerb/client.rb
CHANGED
@@ -7,11 +7,14 @@ module Redminerb
|
|
7
7
|
class Client
|
8
8
|
class UnprocessableEntity < StandardError; end
|
9
9
|
|
10
|
+
attr_reader :requests
|
11
|
+
|
10
12
|
def initialize(cfg)
|
11
13
|
@connection = Faraday.new(url: cfg.url) do |f|
|
12
14
|
f.adapter Faraday.default_adapter
|
13
15
|
end
|
14
16
|
@connection.basic_auth(cfg.api_key, cfg.api_key)
|
17
|
+
@requests = 0
|
15
18
|
end
|
16
19
|
|
17
20
|
# Uses pagination (limit&offset) params to retreive all the resources of
|
@@ -72,6 +75,7 @@ module Redminerb
|
|
72
75
|
private
|
73
76
|
|
74
77
|
def _get(path, params)
|
78
|
+
@requests += 1
|
75
79
|
@connection.get do |req|
|
76
80
|
req.url path
|
77
81
|
req.headers['Content-Type'] = 'application/json'
|
data/lib/redminerb/projects.rb
CHANGED
@@ -14,10 +14,13 @@ module Redminerb
|
|
14
14
|
# end
|
15
15
|
#
|
16
16
|
def list(params)
|
17
|
-
projects =
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
projects = if params.delete(:all)
|
18
|
+
Redminerb.client.get_collection(:projects, params)
|
19
|
+
elsif (name = params.delete(:name))
|
20
|
+
filter_projects_by_name name, params
|
21
|
+
else
|
22
|
+
Redminerb.client.get_json('/projects.json', params)['projects']
|
23
|
+
end
|
21
24
|
projects.map do |project|
|
22
25
|
OpenStruct.new project
|
23
26
|
end
|
@@ -33,6 +36,14 @@ module Redminerb
|
|
33
36
|
def read(id)
|
34
37
|
RecursiveOpenStruct.new Redminerb.client.get_json("/projects/#{id}.json")['project']
|
35
38
|
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def filter_projects_by_name(name, params)
|
43
|
+
Redminerb.client.get_collection(:projects, params).select do |project|
|
44
|
+
project['name'] =~ /#{name}/i
|
45
|
+
end
|
46
|
+
end
|
36
47
|
end
|
37
48
|
end
|
38
49
|
end
|
data/lib/redminerb/users.rb
CHANGED
@@ -15,7 +15,7 @@ module Redminerb
|
|
15
15
|
#
|
16
16
|
# See lib/reminerb/cli/user.rb code to see other example/s.
|
17
17
|
def list(params)
|
18
|
-
if params.delete(
|
18
|
+
if params.delete(:all)
|
19
19
|
Redminerb.client.get_collection(:users, params)
|
20
20
|
else
|
21
21
|
Redminerb.client.get_json('/users.json', params)['users']
|
data/lib/redminerb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redminerb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fernando Garcia Samblas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|