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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b4dd1d4a6a9dc35e5d13d47727879052f86c451
4
- data.tar.gz: b0a9cfe53666b641b03e13d81737c3fa2868db84
3
+ metadata.gz: 15c9f30f16fc1632e7870c461e94abfaf4cb9aaf
4
+ data.tar.gz: b7a41abe3ddeebbf1d4629e527a66616f2e0e1d4
5
5
  SHA512:
6
- metadata.gz: e80b43317154902bcc0dec4470800f13b8414ae72f79b2ae3bd2d0c628ebde9be856445bcb5aac3c71ab4626d2414535d51e02034463e7a6bf15a72ff1c8f14c
7
- data.tar.gz: a56e9c0a30f1e92d916875e907343770dfa29ea277777b45684e43c6cedbb39cddeb750b9d3ccdfa763b3ecd375bcd08ac0f20cc252039ddb024130a98b99bdd
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
 
@@ -11,6 +11,8 @@ module Redminerb
11
11
  option :name, aliases: [:q, '--query'], banner: '<FILTER>'
12
12
  option :offset, aliases: :o
13
13
  option :limit, aliases: :l
14
+ option :all, type: :boolean
15
+
14
16
  def list(project_id = nil)
15
17
  if project_id
16
18
  show(project_id)
@@ -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'
@@ -14,10 +14,13 @@ module Redminerb
14
14
  # end
15
15
  #
16
16
  def list(params)
17
- projects = Redminerb.client.get_json('/projects.json', params)['projects']
18
- if (name = params.delete(:name))
19
- projects = projects.select {|project| project['name'] =~ /#{name}/i}
20
- end
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
@@ -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('all')
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']
@@ -1,4 +1,4 @@
1
1
  # Copyright (c) The Cocktail Experience S.L. (2015)
2
2
  module Redminerb
3
- VERSION = '0.8.2'
3
+ VERSION = '0.8.3'
4
4
  end
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.2
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-23 00:00:00.000000000 Z
11
+ date: 2015-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor