redminerb 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +3 -1
- data/README.md +2 -0
- data/lib/redminerb/cli/projects.rb +3 -1
- data/lib/redminerb/cli/users.rb +10 -1
- data/lib/redminerb/client.rb +17 -0
- data/lib/redminerb/users.rb +6 -3
- 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: d73c75d31889c043847cbfa88509d83971a19dd3
|
4
|
+
data.tar.gz: 757a41cad5019c335107d80a83058db166bd973c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0546f70d8f26ec3ba49c0c12199b938808ba37349b39c1a0f921b8308a7c2446f3427e0828298a3fa8350f872121e71eaac90cc20c598419509d4ea55d9fd23d
|
7
|
+
data.tar.gz: 60eed842cc876d662fb9b4ee73c88ea91b2d0602e3cae0acf44da678cc733c11e89781712ebbf79d2f9e9df490b7d43140f88cec23ae94e28467a39b2c65296d
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -145,6 +145,8 @@ Will return only the ID following by the user's email.
|
|
145
145
|
|
146
146
|
You can see **all the fields available** with `redminerb user me`.
|
147
147
|
|
148
|
+
**To list all the users at the database** you can use the `--all` option. Internally it will make as many HTTP requests to the REST API as needed. Here the `--limit` option let's manage the maximum number of users it will get with each request (to search, if possible, consider using the `--query` option instead).
|
149
|
+
|
148
150
|
#### Show our info in the Redmine server
|
149
151
|
|
150
152
|
$ redminerb user me
|
@@ -26,7 +26,9 @@ module Redminerb
|
|
26
26
|
option :template, aliases: :t
|
27
27
|
def show(project_id)
|
28
28
|
Redminerb.init!
|
29
|
-
puts Redminerb::Template.render(:project,
|
29
|
+
puts Redminerb::Template.render(:project,
|
30
|
+
Redminerb::Projects.read(project_id),
|
31
|
+
options)
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
data/lib/redminerb/cli/users.rb
CHANGED
@@ -12,6 +12,14 @@ module Redminerb
|
|
12
12
|
option :name, aliases: [:q, '--query'], banner: '<FILTER>'
|
13
13
|
option :offset, aliases: :o
|
14
14
|
option :limit, aliases: :l
|
15
|
+
option :all, type: :boolean,
|
16
|
+
desc: "List all the users at the database. Internally it makes\n" + <<-DESC
|
17
|
+
# as many HTTP requests to the REST API as needed (the
|
18
|
+
# --limit option us manage that number setting the maximum
|
19
|
+
# number of users it will get each time). To search consider
|
20
|
+
# using the --query option instead (if possible).
|
21
|
+
DESC
|
22
|
+
|
15
23
|
def list(user_id = nil)
|
16
24
|
if user_id
|
17
25
|
show user_id
|
@@ -42,7 +50,8 @@ module Redminerb
|
|
42
50
|
end
|
43
51
|
initializer_data[:current_command].options.keys.each do |option|
|
44
52
|
next if option == :ask
|
45
|
-
value = ask("#{option.capitalize} [#{options[option]}]:",
|
53
|
+
value = ask("#{option.capitalize} [#{options[option]}]:",
|
54
|
+
Thor::Shell::Color::GREEN)
|
46
55
|
options[option] = value unless value.empty?
|
47
56
|
end
|
48
57
|
break if yes?('Is everything OK? (NO/yes)')
|
data/lib/redminerb/client.rb
CHANGED
@@ -14,6 +14,23 @@ module Redminerb
|
|
14
14
|
@connection.basic_auth(cfg.api_key, cfg.api_key)
|
15
15
|
end
|
16
16
|
|
17
|
+
# Uses pagination (limit&offset) params to retreive all the resources of
|
18
|
+
# the collection "name" using "params" in each request. Returns an array
|
19
|
+
# with all the resources.
|
20
|
+
def get_collection(name, params = { 'limit': 100 })
|
21
|
+
offset = 0
|
22
|
+
limit = params['limit'].to_i
|
23
|
+
[].tap do |resources|
|
24
|
+
loop do
|
25
|
+
params['offset'] = offset
|
26
|
+
response = get_json("/#{name}.json", params)
|
27
|
+
resources << response[name.to_s]
|
28
|
+
offset += limit
|
29
|
+
break unless offset < response['total_count']
|
30
|
+
end
|
31
|
+
end.flatten
|
32
|
+
end
|
33
|
+
|
17
34
|
# Makes a GET request of the given 'path' param and returns the body of the
|
18
35
|
# response parsed as JSON.
|
19
36
|
def get_json(path, params = {})
|
data/lib/redminerb/users.rb
CHANGED
@@ -14,13 +14,16 @@ module Redminerb
|
|
14
14
|
# end
|
15
15
|
#
|
16
16
|
# See lib/reminerb/cli/user.rb code to see other example/s.
|
17
|
-
|
18
17
|
def list(params)
|
19
|
-
|
18
|
+
if params.delete('all')
|
19
|
+
Redminerb.client.get_collection(:users, params)
|
20
|
+
else
|
21
|
+
Redminerb.client.get_json('/users.json', params)['users']
|
22
|
+
end.map do |user|
|
20
23
|
OpenStruct.new user
|
21
24
|
end
|
22
25
|
end
|
23
|
-
|
26
|
+
|
24
27
|
# Creates a brand new user with the given params. In lib/reminerb/cli/user.rb
|
25
28
|
# you can see which ones are required (or running 'redminerb users create'
|
26
29
|
# from the command line).
|
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.1
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|