redminerb 0.7.1 → 0.7.2

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: c0eaa8da3e11151f1a2699b28ef9d1cdb1f5444f
4
- data.tar.gz: 48d69b47bb1d62359ceb1c8561eaf725303af1ff
3
+ metadata.gz: 4ffa75b08fce4f5b9002a23c8390cf6bd82a9efe
4
+ data.tar.gz: b8aa4a4d89f7cd543e94026d5536cd4d0205998f
5
5
  SHA512:
6
- metadata.gz: 5171b97f91535076e8329bdbe5a87ccb88e94cb5951670e8dc1447a1788efbc659b2036d6dffc17ff96b2b1db960c06338b8da30b0b6670e0c0c0fdb967f365f
7
- data.tar.gz: e1ca1b8a22384bc489850c2dcec3671bb5792c4239399d1236ada750f73ad39e87f5354de4a7607f3daae1d4c50dd8922828b39a22b5d588691a8099083aa091
6
+ metadata.gz: 4f089f4606de00bfbf4da4df880b45c7c59dc982faf880f84c3ff7faf0995ee985217fa289bc8f4f0b5326388249621ab52e1c7dd7392589a611d95403b2209e
7
+ data.tar.gz: 58c101d78ccaf6f156fb4ea0155ac5422795aeb2c80daf9bf002464701aff3409aa12d9735ddff579f13f6ab01fb50f7da44ef36a22c5f8a7f7e61633b2bb7b8
data/README.md CHANGED
@@ -127,13 +127,13 @@ The **users** command is the wrapper for part of the [Users resource](http://www
127
127
 
128
128
  $ redminerb users # i.e. 'redminerb users list'
129
129
 
130
- That should give you the current users on your Redmine server, one per line.
130
+ That should give you the current users on your Redmine server, one per line. It will return a 403 error if our API key's user doesn't have permission to list users.
131
131
 
132
- You can use the `--name` option to list users as described by the *name* filter of the API resource. The `-q` and `--query` are aliases for this option. For example:
132
+ You can use the `--name` option to list users as described by the *name* filter of the API resource (see the link above). The `-q` and `--query` are aliases for this option. For example:
133
133
 
134
134
  $ redminerb users -q red # i.e. 'redminerb users list --name=red'
135
135
 
136
- Will show us the users which login, first name, last name or email contains the 'red' word.
136
+ Will show us the **users whose login, first name, last name or email** contains the **'red'** word.
137
137
 
138
138
  By omission *users list* gives you the ID, the login and the e-mail of the user. You can
139
139
  change that using the *--fields (-f)* option, that let you specify others separated
@@ -197,6 +197,19 @@ For example, to see the info of the issue #12539 we'd launch:
197
197
 
198
198
  $ redminerb issue 12539
199
199
 
200
+
201
+ ### Projects
202
+
203
+ The **projects** command is the wrapper for part of the [Projects resource](http://www.redmine.org/projects/redmine/wiki/Rest_Projects) of the Redmine REST API.
204
+
205
+ #### List projects
206
+
207
+ $ redminerb projects [list] [-q|--query <FILTER>]
208
+
209
+ The command *projects* will give us the ids of every public and private project where the user have access to.
210
+
211
+ The results can be **filtered** through a **case unsensitive match** using the *--query (-q, --name)* option. For example, the order `redminerb projects -q iber` will show us all projects whose names match **"IBER"**.
212
+
200
213
  ## Development
201
214
 
202
215
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -0,0 +1,37 @@
1
+ # Copyright (c) The Cocktail Experience S.L. (2015)
2
+ require_relative '../projects'
3
+
4
+ module Redminerb
5
+ module Cli
6
+ # Thor's 'projects' subcommand definition
7
+ class Projects < Thor
8
+ default_command :list
9
+
10
+ desc 'list', 'Shows open projects in our Redmine'
11
+ option :name, aliases: [:q, '--query'], banner: '<FILTER>'
12
+ option :offset, aliases: :o
13
+ option :limit, aliases: :l
14
+ def list(project_id = nil)
15
+ if project_id
16
+ show(project_id)
17
+ else
18
+ Redminerb.init!
19
+ name = options.delete(:name)
20
+ Redminerb::Projects.list(options).each do |project|
21
+ if name.nil? || project.name =~ /#{name}/i
22
+ puts "#{project.id}\t".green +
23
+ project.name.split.map { |i| i.capitalize }.join(' ').green
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ desc 'show <number>', 'Shows an project (SHORTCUT: "redminerb projects <number>")'
30
+ option :template, aliases: :t
31
+ def show(project_id)
32
+ Redminerb.init!
33
+ puts Redminerb::Template.render(:project, Redminerb::Projects.read(project_id), options)
34
+ end
35
+ end
36
+ end
37
+ end
data/lib/redminerb/cli.rb CHANGED
@@ -4,6 +4,7 @@ require 'colorize'
4
4
  require_relative '../redminerb'
5
5
  require_relative 'cli/users'
6
6
  require_relative 'cli/issues'
7
+ require_relative 'cli/projects'
7
8
 
8
9
  module Redminerb
9
10
  # Thor's command class
@@ -19,9 +20,11 @@ module Redminerb
19
20
  end
20
21
 
21
22
  # The subcommad's classes are defined in lib/redminerb/cli
22
- desc 'users [list]', "Manage Redmine's users"
23
+ desc 'users [list|<id>]', "Manage Redmine's users"
23
24
  subcommand 'users', Cli::Users
24
- desc 'issues [show] <id>', "Manage Redmine's issues"
25
+ desc 'issues [list|<id>]', "Manage Redmine's issues"
25
26
  subcommand 'issues', Cli::Issues
27
+ desc 'projects [list|<id>]', "Manage Redmine's projects"
28
+ subcommand 'projects', Cli::Projects
26
29
  end
27
30
  end
@@ -0,0 +1,35 @@
1
+ # Copyright (c) The Cocktail Experience S.L. (2015)
2
+ require 'recursive-open-struct'
3
+
4
+ module Redminerb
5
+ # Projects resource wrapper
6
+ class Projects
7
+ class << self
8
+ # Get Redmine's projects as OpenStruct objects.
9
+ #
10
+ # Example:
11
+ # Redminerb.init!
12
+ # Redminerb::Projects.list.each do |project|
13
+ # puts "#{project.id}: #{project.name}"
14
+ # end
15
+ #
16
+
17
+ def list(params)
18
+ Redminerb.client.get_json('/projects.json', params)['projects'].map do |project|
19
+ OpenStruct.new project
20
+ end
21
+ end
22
+
23
+ # Get an project's info as an OpenStruct object.
24
+ #
25
+ # Example:
26
+ # Redminerb.init!
27
+ # project = Redminerb::Projects.read(34)
28
+ # puts "#{project.id}: #{project.name}"
29
+ #
30
+ def read(id)
31
+ RecursiveOpenStruct.new Redminerb.client.get_json("/projects/#{id}.json")['project']
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,4 +1,4 @@
1
1
  # Copyright (c) The Cocktail Experience S.L. (2015)
2
2
  module Redminerb
3
- VERSION = '0.7.1'
3
+ VERSION = '0.7.2'
4
4
  end
data/lib/redminerb.rb CHANGED
@@ -39,7 +39,7 @@ module Redminerb
39
39
  end
40
40
 
41
41
  def init_required!
42
- fail(UninitializedError, 'Call Redminerb.init! first') unless @initialized
42
+ fail(UninitializedError, 'call Redminerb.init! first') unless @initialized
43
43
  end
44
44
 
45
45
  def config
data/templates/issue.erb CHANGED
@@ -1,12 +1,12 @@
1
1
  <%= Redminerb.separator.green %>
2
- <%= "[#{issue.tracker.name}]".blue + "[#{issue.project.name}:##{issue.id}]".green %> <%= issue.subject %>
2
+ <%= "[#{issue.tracker.name}]".blue + "[#{issue.project.name}##{issue.id}]".green %> <%= issue.subject %>
3
3
  <%= Redminerb.separator.green %>
4
- Author: <%= issue.author.name.red %>
5
- Assigned to: <%= issue.assigned_to.name.red %>
6
- Status: <%= issue.status.name.red %>
7
- Priority: <%= issue.priority.name.red %>
4
+ Author: <%= issue.author.name.red %>
5
+ Assigned to: <%= issue.assigned_to.name.red %>
6
+ Status: <%= issue.status.name.red %>
7
+ Priority: <%= issue.priority.name.red %>
8
8
  <%= Redminerb.separator.green %>
9
- <%= issue.description %>
9
+ <%= issue.description %>
10
10
  <%= Redminerb.separator.green %>
11
- <%= Redminerb.config.url + "issues/#{issue.id}" %>
11
+ <%= (Redminerb.config.url + "issues/#{issue.id}").red %>
12
12
  <%= Redminerb.separator.green %>
@@ -0,0 +1,14 @@
1
+ <%= Redminerb.separator.green %>
2
+ <%= project.name.split.map { |i| i.capitalize }.join(' ').blue %> (#<%= project.id %>)
3
+ <%= Redminerb.separator.green %>
4
+ <% if project.parent %>Parent: <%= project.parent.name.capitalize.red %> (#<%= project.parent.id %>)<% end %>
5
+ Identifier: <%= project.identifier.red %>
6
+ Homepage: <%= project.homepage.red %>
7
+ Created date: <%= project.created_on.red %>
8
+ Updated: <%= project.created_on.red %>
9
+ Status: <%= project.status.to_s.red %>
10
+ <%= Redminerb.separator.green %>
11
+ Description: <%= project.description.gsub("\n", "\n ") %>
12
+ <%= Redminerb.separator.green %>
13
+ <%= (Redminerb.config.url + "projects/#{project.id}").red %>
14
+ <%= Redminerb.separator.green %>
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.7.1
4
+ version: 0.7.2
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-05 00:00:00.000000000 Z
11
+ date: 2015-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -217,16 +217,19 @@ files:
217
217
  - lib/redminerb.rb
218
218
  - lib/redminerb/cli.rb
219
219
  - lib/redminerb/cli/issues.rb
220
+ - lib/redminerb/cli/projects.rb
220
221
  - lib/redminerb/cli/users.rb
221
222
  - lib/redminerb/client.rb
222
223
  - lib/redminerb/config.rb
223
224
  - lib/redminerb/issues.rb
225
+ - lib/redminerb/projects.rb
224
226
  - lib/redminerb/template.rb
225
227
  - lib/redminerb/users.rb
226
228
  - lib/redminerb/version.rb
227
229
  - redminerb.gemspec
228
230
  - templates/issue.erb
229
231
  - templates/issue_boxie.erb
232
+ - templates/project.erb
230
233
  - templates/user.erb
231
234
  - templates/user_in_a_box.erb
232
235
  homepage: http://github.com/nando/redminerb