redcuine 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/redcuine/issue.rb +28 -9
- data/lib/redcuine/optparser.rb +18 -2
- data/test/issue_test.rb +14 -8
- data/test/optparser_test.rb +10 -1
- data/test/test_helper.rb +2 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/lib/redcuine/issue.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
require "tempfile"
|
2
|
+
|
1
3
|
module Redcuine
|
2
4
|
class Issue < Base
|
3
5
|
@@default_param = {}
|
4
6
|
@@issue_attribute_keys = [:subject, :description, :tracker_id, :status_id,
|
5
|
-
:category_id, :assigned_to_id, :
|
7
|
+
:category_id, :assigned_to_id, :priority_id, :fixed_version,
|
6
8
|
:start_date, :due_date, :estimate_date, :done_ratio]
|
7
9
|
|
8
10
|
def self.run
|
@@ -25,10 +27,13 @@ module Redcuine
|
|
25
27
|
def self.post
|
26
28
|
keys = [:project_id] + @@issue_attribute_keys
|
27
29
|
opts = rest_options(keys, @@default_param)
|
30
|
+
opts[:description] = description_by_editor if CONFIG["editor"]
|
28
31
|
issue = Resource::Issue.new(opts)
|
29
|
-
|
30
|
-
puts
|
31
|
-
|
32
|
+
issue.save!
|
33
|
+
puts "Created issue!"
|
34
|
+
CONFIG["id"] = issue.id
|
35
|
+
get
|
36
|
+
return true
|
32
37
|
rescue
|
33
38
|
puts $!.to_s
|
34
39
|
puts $!.backtrace if CONFIG["debug"]
|
@@ -37,13 +42,17 @@ module Redcuine
|
|
37
42
|
end
|
38
43
|
|
39
44
|
def self.put
|
40
|
-
|
41
|
-
opts = rest_options(keys, @@default_param)
|
45
|
+
opts = rest_options(@@issue_attribute_keys, @@default_param)
|
42
46
|
issue = Resource::Issue.find(CONFIG["id"])
|
47
|
+
if CONFIG["editor"]
|
48
|
+
opts[:description] = description_by_editor(issue.description)
|
49
|
+
end
|
43
50
|
issue.load(opts)
|
44
|
-
|
45
|
-
puts
|
46
|
-
|
51
|
+
issue.save!
|
52
|
+
puts "Updated issue!"
|
53
|
+
CONFIG["id"] = issue.id
|
54
|
+
get
|
55
|
+
return true
|
47
56
|
rescue
|
48
57
|
puts $!.to_s
|
49
58
|
puts $!.backtrace if CONFIG["debug"]
|
@@ -113,6 +122,16 @@ module Redcuine
|
|
113
122
|
puts " - #{cf.name}, id:#{cf.id}, value:#{cf.value}"
|
114
123
|
end
|
115
124
|
end
|
125
|
+
puts ""
|
126
|
+
end
|
127
|
+
|
128
|
+
def self.description_by_editor(description="")
|
129
|
+
description = CONFIG['description'] if CONFIG['description']
|
130
|
+
t = Tempfile.new("redissue")
|
131
|
+
t << description
|
132
|
+
t.close
|
133
|
+
system(CONFIG['editor'], t.path)
|
134
|
+
return File.read(t.path)
|
116
135
|
end
|
117
136
|
end
|
118
137
|
end
|
data/lib/redcuine/optparser.rb
CHANGED
@@ -22,6 +22,22 @@ module Redcuine
|
|
22
22
|
CONFIG["rest_type"] = :delete
|
23
23
|
end
|
24
24
|
|
25
|
+
opt.on('-s val', '--subject val', 'Set subject') do |val|
|
26
|
+
CONFIG["subject"] = val
|
27
|
+
end
|
28
|
+
|
29
|
+
opt.on('-m val', '--description val', 'Set description') do |val|
|
30
|
+
CONFIG["description"] = val
|
31
|
+
end
|
32
|
+
|
33
|
+
opt.on('-e [editor]', 'Edit description by editor (default $EDITOR || vi)') do |val|
|
34
|
+
if val
|
35
|
+
CONFIG["editor"] = val
|
36
|
+
else
|
37
|
+
CONFIG["editor"] = ENV['EDITOR'] || "vi"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
25
41
|
opt.on('--debug', 'for debug') do |val|
|
26
42
|
CONFIG["debug"] = true
|
27
43
|
end
|
@@ -31,8 +47,8 @@ module Redcuine
|
|
31
47
|
opt.program_name = 'redissue'
|
32
48
|
|
33
49
|
default_opts(opt)
|
34
|
-
%w(id
|
35
|
-
priority fixed-version start-date due-date estimate-date
|
50
|
+
%w(id tracker-id status-id category-id assigned-to-id
|
51
|
+
priority-id fixed-version start-date due-date estimate-date
|
36
52
|
done-ratio site project-id).each do |k|
|
37
53
|
src = <<-SRC
|
38
54
|
opt.on('--#{k} val', 'Set #{k.gsub("-", " ")}') do |val|
|
data/test/issue_test.rb
CHANGED
@@ -58,19 +58,22 @@ class IssueTest < Test::Unit::TestCase
|
|
58
58
|
stub(Redcuine::Resource::Issue).new do |opt|
|
59
59
|
@opt = opt
|
60
60
|
o = Object.new
|
61
|
-
o.
|
61
|
+
stub(o).save!{ true }
|
62
|
+
stub(o).id{ "1" }
|
62
63
|
o
|
63
64
|
end
|
65
|
+
mock(Redcuine::Issue).get.once
|
64
66
|
Redcuine::CONFIG["rest_type"] = :post
|
65
67
|
Redcuine::CONFIG["project_id"] = "1"
|
66
68
|
keys = [:subject, :description, :tracker_id, :status_id,
|
67
|
-
:category_id, :assigned_to_id, :
|
69
|
+
:category_id, :assigned_to_id, :priority_id, :fixed_version,
|
68
70
|
:start_date, :due_date, :estimate_date, :done_ratio]
|
69
71
|
keys.each do |k|
|
70
72
|
Redcuine::CONFIG[k.to_s] = true
|
71
73
|
end
|
72
74
|
assert_equal true, Redcuine::Issue.run
|
73
75
|
assert_equal([], keys - @opt.keys)
|
76
|
+
assert_equal "1", Redcuine::CONFIG["id"]
|
74
77
|
end
|
75
78
|
|
76
79
|
def test_post_fail
|
@@ -81,22 +84,25 @@ class IssueTest < Test::Unit::TestCase
|
|
81
84
|
def test_put
|
82
85
|
stub(Redcuine::Resource::Issue).find do |id|
|
83
86
|
@id = id
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
@
|
87
|
+
o = Object.new
|
88
|
+
stub(o).save!{ true }
|
89
|
+
stub(o).load{|args| @opt = args }
|
90
|
+
stub(o).id{|args| @id }
|
91
|
+
o
|
88
92
|
end
|
93
|
+
mock(Redcuine::Issue).get.once
|
89
94
|
Redcuine::CONFIG["rest_type"] = :put
|
90
95
|
Redcuine::CONFIG["id"] = "1"
|
91
96
|
keys = [:subject, :description, :tracker_id, :status_id,
|
92
|
-
:category_id, :assigned_to_id, :
|
97
|
+
:category_id, :assigned_to_id, :priority_id, :fixed_version,
|
93
98
|
:start_date, :due_date, :estimate_date, :done_ratio]
|
94
99
|
keys.each do |k|
|
95
100
|
Redcuine::CONFIG[k.to_s] = true
|
96
101
|
end
|
97
102
|
assert_equal true, Redcuine::Issue.run
|
98
103
|
assert_equal("1", @id)
|
99
|
-
assert_equal([], keys - @
|
104
|
+
assert_equal([], keys - @opt.keys)
|
105
|
+
assert_equal "1", Redcuine::CONFIG["id"]
|
100
106
|
end
|
101
107
|
|
102
108
|
def test_put_fail
|
data/test/optparser_test.rb
CHANGED
@@ -22,11 +22,20 @@ class OptParserTest < Test::Unit::TestCase
|
|
22
22
|
|
23
23
|
Redcuine::OptParser.issue_parse!(%w(--debug))
|
24
24
|
assert_equal true, Redcuine::CONFIG["debug"]
|
25
|
+
|
26
|
+
Redcuine::OptParser.issue_parse!(%w(-s subject))
|
27
|
+
assert_equal "subject", Redcuine::CONFIG["subject"]
|
28
|
+
|
29
|
+
Redcuine::OptParser.issue_parse!(%w(-m description))
|
30
|
+
assert_equal "description", Redcuine::CONFIG["description"]
|
31
|
+
|
32
|
+
Redcuine::OptParser.issue_parse!(%w(-e emacs))
|
33
|
+
assert_equal "emacs", Redcuine::CONFIG["editor"]
|
25
34
|
end
|
26
35
|
|
27
36
|
def test_issue_parse
|
28
37
|
opts = %w(id subject description tracker-id status-id
|
29
|
-
category-id assigned-to-id priority fixed-version
|
38
|
+
category-id assigned-to-id priority-id fixed-version
|
30
39
|
start-date due-date estimate-date done-ratio site project-id)
|
31
40
|
args = opts.map{|k| ["--#{k}", k]}.flatten
|
32
41
|
Redcuine::OptParser.issue_parse!(args)
|
data/test/test_helper.rb
CHANGED
@@ -12,6 +12,7 @@ class Test::Unit::TestCase
|
|
12
12
|
def setup
|
13
13
|
super
|
14
14
|
setup_with_clear_config
|
15
|
+
Redcuine::CONFIG["debug"] = true
|
15
16
|
end
|
16
17
|
|
17
18
|
def teardown
|
@@ -23,5 +24,5 @@ class Test::Unit::TestCase
|
|
23
24
|
Redcuine::CONFIG.clear
|
24
25
|
end
|
25
26
|
|
26
|
-
include RR::Adapters::
|
27
|
+
include RR::Adapters::TestUnit
|
27
28
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 3
|
9
|
+
version: 0.1.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Narihiro Nakmaura
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-02-22 00:00:00 +09:00
|
18
18
|
default_executable: redissue
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|