redcuine 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/redcuine.rb +3 -1
- data/lib/redcuine/active_resource_ext.rb +1 -0
- data/lib/redcuine/active_resource_ext/print_rest.rb +9 -0
- data/lib/redcuine/base.rb +1 -1
- data/lib/redcuine/issue.rb +58 -14
- data/lib/redcuine/optparser.rb +5 -1
- data/lib/redcuine/resource.rb +19 -0
- data/redcuine.gemspec +55 -0
- metadata +16 -10
- data/.gitignore +0 -1
data/Rakefile
CHANGED
@@ -7,7 +7,7 @@ begin
|
|
7
7
|
gemspec.homepage = "https://github.com/authorNari/redcuine"
|
8
8
|
gemspec.description = "CUI toolkit for Redmine"
|
9
9
|
gemspec.authors = ["Narihiro Nakmaura"]
|
10
|
-
gemspec.add_dependency("
|
10
|
+
gemspec.add_dependency("active_resource", ">= 3.0.3")
|
11
11
|
end
|
12
12
|
rescue LoadError
|
13
13
|
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.0
|
data/lib/redcuine.rb
CHANGED
@@ -6,12 +6,14 @@ require 'yaml'
|
|
6
6
|
require 'time'
|
7
7
|
require "ostruct"
|
8
8
|
require "optparse"
|
9
|
-
require '
|
9
|
+
require 'active_resource'
|
10
10
|
|
11
11
|
require "redcuine/config_setup"
|
12
12
|
require "redcuine/optparser"
|
13
13
|
require "redcuine/base"
|
14
14
|
require "redcuine/issue"
|
15
|
+
require "redcuine/resource"
|
16
|
+
require "redcuine/active_resource_ext"
|
15
17
|
|
16
18
|
Version = File.read(File.join(File.dirname(__FILE__), '../VERSION')).strip
|
17
19
|
module Redcuine
|
@@ -0,0 +1 @@
|
|
1
|
+
require "redcuine/active_resource_ext/print_rest"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module ActiveResource
|
2
|
+
class Connection
|
3
|
+
def request_with_print(method, path, *arguments)
|
4
|
+
puts "#{method.to_s.upcase} #{site.scheme}://#{site.host}:#{site.port}#{path}"
|
5
|
+
request_without_print(method, path, *arguments)
|
6
|
+
end
|
7
|
+
alias_method_chain :request, :print
|
8
|
+
end
|
9
|
+
end
|
data/lib/redcuine/base.rb
CHANGED
data/lib/redcuine/issue.rb
CHANGED
@@ -17,14 +17,12 @@ module Redcuine
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def get
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
return true
|
20
|
+
CONFIG["id"] ? show(CONFIG["id"]) : index
|
21
|
+
rescue
|
22
|
+
puts $!.to_s
|
23
|
+
puts $!.backtrace if CONFIG["debug"]
|
24
|
+
puts "Fail to get issue."
|
25
|
+
return false
|
28
26
|
end
|
29
27
|
|
30
28
|
def post
|
@@ -32,10 +30,15 @@ module Redcuine
|
|
32
30
|
:category_id, :assigned_to, :priority, :fixed_version,
|
33
31
|
:start_date, :due_date, :estimate_date, :done_ratio]
|
34
32
|
opts = rest_options(keys, @default_param)
|
35
|
-
issue =
|
33
|
+
issue = Resource::Issue.new(opts)
|
36
34
|
res = issue.save
|
37
|
-
puts res ? "
|
35
|
+
puts res ? "Created issue!" : "Fail to create issue."
|
38
36
|
return res
|
37
|
+
rescue
|
38
|
+
puts $!.to_s
|
39
|
+
puts $!.backtrace if CONFIG["debug"]
|
40
|
+
puts "Fail to create issue."
|
41
|
+
return false
|
39
42
|
end
|
40
43
|
|
41
44
|
def put
|
@@ -43,18 +46,28 @@ module Redcuine
|
|
43
46
|
:category_id, :assigned_to, :priority, :fixed_version,
|
44
47
|
:start_date, :due_date, :estimate_date, :done_ratio]
|
45
48
|
opts = rest_options(keys, @default_param)
|
46
|
-
issue =
|
49
|
+
issue = Resource::Issue.find(CONFIG["id"])
|
47
50
|
issue.load(opts)
|
48
51
|
res = issue.save
|
49
|
-
puts res ? "
|
52
|
+
puts res ? "Updated issue!" : "Fail to update issue."
|
50
53
|
return res
|
54
|
+
rescue
|
55
|
+
puts $!.to_s
|
56
|
+
puts $!.backtrace if CONFIG["debug"]
|
57
|
+
puts "Fail to update issue."
|
58
|
+
return false
|
51
59
|
end
|
52
60
|
|
53
61
|
def delete
|
54
|
-
issue =
|
62
|
+
issue = Resource::Issue.find(CONFIG["id"])
|
55
63
|
res = issue.destroy
|
56
|
-
puts res ? "
|
64
|
+
puts res ? "Destroyed issue!" : "Fail to destroy issue."
|
57
65
|
return res
|
66
|
+
rescue
|
67
|
+
puts $!.to_s
|
68
|
+
puts $!.backtrace if CONFIG["debug"]
|
69
|
+
puts "Fail to destroy issue."
|
70
|
+
return false
|
58
71
|
end
|
59
72
|
|
60
73
|
private
|
@@ -75,5 +88,36 @@ module Redcuine
|
|
75
88
|
end
|
76
89
|
return true
|
77
90
|
end
|
91
|
+
|
92
|
+
def show(id)
|
93
|
+
issue = Resource::Issue.find(CONFIG["id"], :params => @default_param)
|
94
|
+
print_get_format(issue)
|
95
|
+
end
|
96
|
+
|
97
|
+
def index
|
98
|
+
opts = rest_options([:project_id, :tracker_id, :assigned_to, :status_id],
|
99
|
+
@default_param)
|
100
|
+
res = Resource::Issue.find(:all, :params => opts)
|
101
|
+
res.each {|issue| print_get_format(issue)}
|
102
|
+
end
|
103
|
+
|
104
|
+
def print_get_format(issue)
|
105
|
+
puts "- id: #{issue.id}"
|
106
|
+
%w(project status priority author assigned_to fixed_version).each do |k|
|
107
|
+
if issue.respond_to?(k)
|
108
|
+
puts " #{k}: #{issue.send(k).name}, id:#{issue.send(k).id}"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
%w(subject description start_date due_date
|
112
|
+
done_ratio estimated_hours created_on updated_on).each do |k|
|
113
|
+
puts " #{k}: #{issue.send(k)}" if issue.respond_to?(k)
|
114
|
+
end
|
115
|
+
if issue.respond_to?(:custom_fields)
|
116
|
+
puts " custom_fields: "
|
117
|
+
issue.custom_fields.each do |cf|
|
118
|
+
puts " - #{cf.name}, id:#{cf.id}, value:#{cf.value}"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
78
122
|
end
|
79
123
|
end
|
data/lib/redcuine/optparser.rb
CHANGED
@@ -21,6 +21,10 @@ module Redcuine
|
|
21
21
|
opt.on('-d', '--delete', 'DELETE by REST API') do |val|
|
22
22
|
CONFIG["rest_type"] = :delete
|
23
23
|
end
|
24
|
+
|
25
|
+
opt.on('--debug', 'for debug') do |val|
|
26
|
+
CONFIG["debug"] = true
|
27
|
+
end
|
24
28
|
end
|
25
29
|
|
26
30
|
@issue_optionparser = OptionParser.new do |opt|
|
@@ -29,7 +33,7 @@ module Redcuine
|
|
29
33
|
default_opts(opt)
|
30
34
|
%w(id subject describe tracker-id status-id category-id assigned-to
|
31
35
|
priority fixed-version start-date due-date estimate-date
|
32
|
-
done-ratio site).each do |k|
|
36
|
+
done-ratio site project-id).each do |k|
|
33
37
|
src = <<-SRC
|
34
38
|
opt.on('--#{k} val', 'Set #{k.gsub("-", " ")}') do |val|
|
35
39
|
CONFIG["#{k.gsub("-", "_")}"] = val
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Redcuine
|
2
|
+
module Resource
|
3
|
+
class Base < ActiveResource::Base
|
4
|
+
def self.setup(&block)
|
5
|
+
instance_eval &block
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.inherited(child)
|
9
|
+
child.headers['X-Redmine-Nometa'] = '1'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Issue < Base
|
14
|
+
end
|
15
|
+
|
16
|
+
class Project < Base
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/redcuine.gemspec
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{redcuine}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Narihiro Nakmaura"]
|
12
|
+
s.date = %q{2011-01-29}
|
13
|
+
s.default_executable = %q{redissue}
|
14
|
+
s.description = %q{CUI toolkit for Redmine}
|
15
|
+
s.email = %q{authornari@gmail.com}
|
16
|
+
s.executables = ["redissue"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
"MIT-LISENCE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"bin/redissue",
|
26
|
+
"lib/redcuine.rb",
|
27
|
+
"lib/redcuine/active_resource_ext.rb",
|
28
|
+
"lib/redcuine/active_resource_ext/print_rest.rb",
|
29
|
+
"lib/redcuine/base.rb",
|
30
|
+
"lib/redcuine/config_setup.rb",
|
31
|
+
"lib/redcuine/config_template.erb",
|
32
|
+
"lib/redcuine/issue.rb",
|
33
|
+
"lib/redcuine/optparser.rb",
|
34
|
+
"lib/redcuine/resource.rb",
|
35
|
+
"redcuine.gemspec"
|
36
|
+
]
|
37
|
+
s.homepage = %q{https://github.com/authorNari/redcuine}
|
38
|
+
s.require_paths = ["lib"]
|
39
|
+
s.rubygems_version = %q{1.3.7}
|
40
|
+
s.summary = %q{CUI toolkit for Redmine}
|
41
|
+
|
42
|
+
if s.respond_to? :specification_version then
|
43
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
44
|
+
s.specification_version = 3
|
45
|
+
|
46
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
|
+
s.add_runtime_dependency(%q<active_resource>, [">= 3.0.3"])
|
48
|
+
else
|
49
|
+
s.add_dependency(%q<active_resource>, [">= 3.0.3"])
|
50
|
+
end
|
51
|
+
else
|
52
|
+
s.add_dependency(%q<active_resource>, [">= 3.0.3"])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
|
9
|
-
version: 0.0.0
|
9
|
+
version: 0.1.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Narihiro Nakmaura
|
@@ -18,17 +18,18 @@ date: 2011-01-29 00:00:00 +09:00
|
|
18
18
|
default_executable: redissue
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
21
|
+
name: active_resource
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
26
27
|
- !ruby/object:Gem::Version
|
27
28
|
segments:
|
29
|
+
- 3
|
28
30
|
- 0
|
29
|
-
-
|
30
|
-
|
31
|
-
version: 0.0.1
|
31
|
+
- 3
|
32
|
+
version: 3.0.3
|
32
33
|
type: :runtime
|
33
34
|
version_requirements: *id001
|
34
35
|
description: CUI toolkit for Redmine
|
@@ -40,28 +41,32 @@ extensions: []
|
|
40
41
|
extra_rdoc_files:
|
41
42
|
- README.rdoc
|
42
43
|
files:
|
43
|
-
- .gitignore
|
44
44
|
- MIT-LISENCE
|
45
45
|
- README.rdoc
|
46
46
|
- Rakefile
|
47
47
|
- VERSION
|
48
48
|
- bin/redissue
|
49
49
|
- lib/redcuine.rb
|
50
|
+
- lib/redcuine/active_resource_ext.rb
|
51
|
+
- lib/redcuine/active_resource_ext/print_rest.rb
|
50
52
|
- lib/redcuine/base.rb
|
51
53
|
- lib/redcuine/config_setup.rb
|
52
54
|
- lib/redcuine/config_template.erb
|
53
55
|
- lib/redcuine/issue.rb
|
54
56
|
- lib/redcuine/optparser.rb
|
57
|
+
- lib/redcuine/resource.rb
|
58
|
+
- redcuine.gemspec
|
55
59
|
has_rdoc: true
|
56
60
|
homepage: https://github.com/authorNari/redcuine
|
57
61
|
licenses: []
|
58
62
|
|
59
63
|
post_install_message:
|
60
|
-
rdoc_options:
|
61
|
-
|
64
|
+
rdoc_options: []
|
65
|
+
|
62
66
|
require_paths:
|
63
67
|
- lib
|
64
68
|
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
65
70
|
requirements:
|
66
71
|
- - ">="
|
67
72
|
- !ruby/object:Gem::Version
|
@@ -69,6 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
74
|
- 0
|
70
75
|
version: "0"
|
71
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
72
78
|
requirements:
|
73
79
|
- - ">="
|
74
80
|
- !ruby/object:Gem::Version
|
@@ -78,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
84
|
requirements: []
|
79
85
|
|
80
86
|
rubyforge_project:
|
81
|
-
rubygems_version: 1.3.
|
87
|
+
rubygems_version: 1.3.7
|
82
88
|
signing_key:
|
83
89
|
specification_version: 3
|
84
90
|
summary: CUI toolkit for Redmine
|
data/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
redcuine.gemspec
|