redmine-cli 0.1.5 → 0.1.6
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/lib/redmine-cli/cli.rb +41 -28
- data/lib/redmine-cli/config.rb +4 -1
- data/lib/redmine-cli/resources.rb +33 -29
- data/lib/redmine-cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA512:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4715cd84be2f4f9adfe2b9a598221eee36cdf4ef16414006319902bf79eb25c6e6a52fbe9a213d098803036567c0c49afa3e3fe2ea11c448d9b31a2de63f36f5
|
4
|
+
data.tar.gz: 7a03c0dd6effd5b996e82defbc26aa414894caf227e61d846dc364e695dd1852def7cb06f1daaec287e2acd65247d386058a4baea0e73d7bfc79b75d018410c9
|
5
5
|
SHA1:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ca6c9816ff3f2553537df71a283c5f41572bfaa
|
7
|
+
data.tar.gz: 347e907bd37c2cd28c97d9abfa0e7dbc7e94e3d6
|
data/lib/redmine-cli/cli.rb
CHANGED
@@ -4,6 +4,7 @@ require 'redmine-cli/config'
|
|
4
4
|
require 'redmine-cli/resources'
|
5
5
|
require 'redmine-cli/generators/install'
|
6
6
|
require 'rubygems'
|
7
|
+
require 'ruby-debug'
|
7
8
|
require 'interactive_editor'
|
8
9
|
require 'yaml'
|
9
10
|
require 'pp'
|
@@ -43,39 +44,51 @@ module Redmine
|
|
43
44
|
collection.sort! {|i,j| i.priority.id <=> j.priority.id }
|
44
45
|
|
45
46
|
# Retrieve the list of issue fields in selected_fields
|
46
|
-
issues = collection.collect { |issue|
|
47
|
+
issues = collection.collect { |issue|
|
48
|
+
selected_fields.collect {|key|
|
47
49
|
|
48
|
-
|
49
|
-
|
50
|
-
|
50
|
+
assignee = ""
|
51
|
+
assignee = issue.assigned_to.name if issue.respond_to?(:assigned_to)
|
52
|
+
version = issue.fixed_version.name if issue.respond_to?(:fixed_version)
|
53
|
+
|
54
|
+
# Hack, because I don't feel like spending much time on this
|
55
|
+
if options.version
|
56
|
+
next unless version == options.version
|
57
|
+
end
|
51
58
|
|
52
|
-
|
53
|
-
|
59
|
+
# This section tries to fill in the field using various methods. First, we try to reference it as a built-in field for which we have a title, ref, and display method.
|
60
|
+
# If we don't have that, then we try to reference it as an attribute of the issue object.
|
61
|
+
# If at any point we try to reference something that gives us an IndexError, we assume that that is not a native field, and we try to look through the custom fields to find it.
|
62
|
+
# Finally, if that fails, we let the value simply be "".
|
63
|
+
#
|
64
|
+
val = ""
|
65
|
+
|
66
|
+
begin
|
67
|
+
# If this is a built-in field for which we have a title, ref, and display method, use that.
|
68
|
+
field = fields.fetch(key)
|
69
|
+
if field.display
|
70
|
+
value = issue.attributes.fetch(field.ref)
|
71
|
+
val = field.display.call(value)
|
72
|
+
else
|
73
|
+
f = fields.fetch(key).ref
|
74
|
+
val = issue.attributes.fetch(f)
|
75
|
+
end
|
76
|
+
rescue IndexError
|
77
|
+
# Otherwise, let's look for a custom field by that name.
|
78
|
+
if issue.attributes[:custom_fields].present?
|
79
|
+
issue.attributes[:custom_fields].collect { | field |
|
80
|
+
if field.attributes.fetch("name") == key
|
81
|
+
val = field.attributes.fetch("value")
|
82
|
+
end
|
83
|
+
}
|
84
|
+
end
|
85
|
+
""
|
54
86
|
|
55
|
-
begin
|
56
|
-
# If this is a built-in field for which we have a title, ref, and display method, use that.
|
57
|
-
field = fields.fetch(key)
|
58
|
-
if field.display
|
59
|
-
value = issue.attributes.fetch(field.ref)
|
60
|
-
field.display.call(value)
|
61
|
-
else
|
62
|
-
f = fields.fetch(key).ref
|
63
|
-
issue.attributes.fetch(f)
|
64
|
-
end
|
65
|
-
rescue IndexError
|
66
|
-
# Otherwise, let's look for a custom field by that name.
|
67
|
-
if issue.attributes[:custom_fields].present?
|
68
|
-
issue.attributes[:custom_fields].collect { | field |
|
69
|
-
if field.attributes.fetch("name") == key
|
70
|
-
field.attributes.fetch("value")
|
71
|
-
end
|
72
|
-
}
|
73
87
|
end
|
74
|
-
""
|
75
|
-
#TODO: If the custom field doesn't exist, then we end up returning a blank value (not an error). I guess that's OK?
|
76
|
-
end
|
77
88
|
|
78
|
-
|
89
|
+
val
|
90
|
+
}
|
91
|
+
}
|
79
92
|
|
80
93
|
if issues.any?
|
81
94
|
issues.insert(0, selected_fields.collect {| key |
|
data/lib/redmine-cli/config.rb
CHANGED
@@ -3,13 +3,16 @@ require 'yaml'
|
|
3
3
|
|
4
4
|
module Redmine
|
5
5
|
module Cli
|
6
|
+
class NoConfigFileError < StandardError
|
7
|
+
end
|
8
|
+
|
6
9
|
class << self
|
7
10
|
|
8
11
|
def config
|
9
12
|
begin
|
10
13
|
generic_conf '.redmine'
|
11
14
|
rescue Errno::ENOENT
|
12
|
-
|
15
|
+
raise NoConfigFileError
|
13
16
|
exit 1
|
14
17
|
end
|
15
18
|
end
|
@@ -7,38 +7,42 @@ require 'pp'
|
|
7
7
|
module Redmine
|
8
8
|
module Cli
|
9
9
|
class BaseResource < ActiveResource::Base
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
10
|
+
begin
|
11
|
+
self.site = Redmine::Cli::config.url
|
12
|
+
self.user = Redmine::Cli::config.username
|
13
|
+
self.password = Redmine::Cli::config.password
|
14
|
+
|
15
|
+
class << self
|
16
|
+
# HACK: Redmine API isn't ActiveResource-friendly out of the box, so
|
17
|
+
# we need to pass nometa=1 to all requests since we don't care about
|
18
|
+
# the metadata that gets passed back in the top level attributes.
|
19
|
+
def find(*arguments)
|
20
|
+
arguments[1] = arguments[1] || {}
|
21
|
+
arguments[1][:params] = arguments[1][:params] || {}
|
22
|
+
arguments[1][:params][:nometa] = 1
|
23
|
+
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
def fetch_all(params = {})
|
28
|
+
limit = 100
|
29
|
+
offset = 0
|
30
|
+
|
31
|
+
resources = []
|
32
|
+
|
33
|
+
while((fetched_resources = self.all(:params => params.merge({:limit => limit, :offset => offset}))).any?)
|
34
|
+
resources += fetched_resources
|
35
|
+
offset += limit
|
36
|
+
if fetched_resources.length < limit then
|
37
|
+
break
|
38
|
+
end
|
37
39
|
end
|
40
|
+
|
41
|
+
resources
|
38
42
|
end
|
39
|
-
|
40
|
-
resources
|
41
43
|
end
|
44
|
+
rescue NoConfigFileError
|
45
|
+
puts "Warning: No .redmine file was found in your home directory. Use \"redmine install\" to create one."
|
42
46
|
end
|
43
47
|
end
|
44
48
|
|
data/lib/redmine-cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redmine-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jorge Dias
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2015-04-
|
12
|
+
date: 2015-04-27 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activeresource
|