redcuine 0.0.0
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.
- data/.gitignore +1 -0
- data/MIT-LISENCE +20 -0
- data/README.rdoc +26 -0
- data/Rakefile +14 -0
- data/VERSION +1 -0
- data/bin/redissue +15 -0
- data/lib/redcuine/base.rb +35 -0
- data/lib/redcuine/config_setup.rb +23 -0
- data/lib/redcuine/config_template.erb +9 -0
- data/lib/redcuine/issue.rb +79 -0
- data/lib/redcuine/optparser.rb +42 -0
- data/lib/redcuine.rb +27 -0
- metadata +86 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
redcuine.gemspec
|
data/MIT-LISENCE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Narihiro Nakamura
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
= redcuine
|
2
|
+
|
3
|
+
Welcome to the CUI world from Redmine.
|
4
|
+
redcuine is CUI toolkit for Redmine.
|
5
|
+
|
6
|
+
== Usage
|
7
|
+
|
8
|
+
redcuine use {REST API in Redmine}[http://www.redmine.org/projects/redmine/wiki/Rest_api].
|
9
|
+
|
10
|
+
=== Treat issues
|
11
|
+
|
12
|
+
Use redissue.
|
13
|
+
|
14
|
+
$ redissue -g # GET
|
15
|
+
$ redissue -p --subject test # POST
|
16
|
+
$ redissue -u --id 1 --subject test # PUT
|
17
|
+
$ redissue -d --id 1 # DELETE
|
18
|
+
|
19
|
+
=== Treat projects
|
20
|
+
|
21
|
+
TODO:
|
22
|
+
|
23
|
+
== Author
|
24
|
+
|
25
|
+
Copyright (c) 2011 {Narihiro Nakamura}[http://www.narihir.info],
|
26
|
+
released under the MIT license.
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gemspec|
|
4
|
+
gemspec.name = "redcuine"
|
5
|
+
gemspec.summary = "CUI toolkit for Redmine"
|
6
|
+
gemspec.email = "authornari@gmail.com"
|
7
|
+
gemspec.homepage = "https://github.com/authorNari/redcuine"
|
8
|
+
gemspec.description = "CUI toolkit for Redmine"
|
9
|
+
gemspec.authors = ["Narihiro Nakmaura"]
|
10
|
+
gemspec.add_dependency("redmine_client", ">= 0.0.1")
|
11
|
+
end
|
12
|
+
rescue LoadError
|
13
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
14
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
data/bin/redissue
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
self_file =
|
5
|
+
if File.symlink?(__FILE__)
|
6
|
+
require 'pathname'
|
7
|
+
Pathname.new(__FILE__).realpath
|
8
|
+
else
|
9
|
+
__FILE__
|
10
|
+
end
|
11
|
+
$:.unshift(File.dirname(self_file) + "/../lib")
|
12
|
+
|
13
|
+
require 'redcuine'
|
14
|
+
Redcuine::OptParser.issue_parse!(ARGV)
|
15
|
+
Redcuine::Issue.run
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Redcuine
|
2
|
+
class Base
|
3
|
+
def self.run
|
4
|
+
if res = check_args
|
5
|
+
RedmineClient::Base.configure do
|
6
|
+
self.site = CONFIG["site"]
|
7
|
+
if CONFIG["user"] && CONFIG["password"]
|
8
|
+
self.user = CONFIG["user"]
|
9
|
+
self.password = CONFIG["password"]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
return res
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
def rest_options(keys, default={})
|
18
|
+
params = {}
|
19
|
+
keys.each do |k|
|
20
|
+
params[k] = CONFIG[k.to_s]
|
21
|
+
end
|
22
|
+
params = default.merge(params)
|
23
|
+
params.delete_if{|_, v| v.nil?}
|
24
|
+
return params
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.check_args
|
28
|
+
unless CONFIG["site"]
|
29
|
+
puts "Please set --site."
|
30
|
+
return false
|
31
|
+
end
|
32
|
+
return true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
module Redcuine
|
5
|
+
module ConfigSetup
|
6
|
+
module_function
|
7
|
+
|
8
|
+
def run
|
9
|
+
unless File.exists?(CONF_DIR)
|
10
|
+
template = open(File.dirname(__FILE__) + '/config_template.erb').read
|
11
|
+
config = ERB.new(template, nil, '-').result(binding)
|
12
|
+
Dir.mkdir(CONF_DIR)
|
13
|
+
File.open(CONF_FILE, 'w', 0600) {|io|
|
14
|
+
io << config
|
15
|
+
}
|
16
|
+
|
17
|
+
puts "generated: ~/.redcuine/config.yml"
|
18
|
+
puts "Please setup it."
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Redcuine
|
2
|
+
class Issue < Base
|
3
|
+
def self.run
|
4
|
+
if super
|
5
|
+
issue = self.new
|
6
|
+
return issue.send(CONFIG['rest_type'])
|
7
|
+
end
|
8
|
+
return false
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
if CONFIG["enable_api_key"]
|
13
|
+
@default_param = {:key => CONFIG["api_key"]}
|
14
|
+
else
|
15
|
+
@default_param = {}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def get
|
20
|
+
if CONFIG["id"]
|
21
|
+
puts RedmineClient::Issue.find(CONFIG["id"], :params => @default_param).to_yaml
|
22
|
+
else
|
23
|
+
opts = rest_options([:project_id, :tracker_id, :assigned_to, :status_id],
|
24
|
+
@default_param)
|
25
|
+
puts RedmineClient::Issue.find(:all, :params => opts).to_yaml
|
26
|
+
end
|
27
|
+
return true
|
28
|
+
end
|
29
|
+
|
30
|
+
def post
|
31
|
+
keys = [:project_id, :subject, :describe, :tracker_id, :status_id,
|
32
|
+
:category_id, :assigned_to, :priority, :fixed_version,
|
33
|
+
:start_date, :due_date, :estimate_date, :done_ratio]
|
34
|
+
opts = rest_options(keys, @default_param)
|
35
|
+
issue = RedmineClient::Issue.new(opts)
|
36
|
+
res = issue.save
|
37
|
+
puts res ? "Issue created!" : "Issue fail to create."
|
38
|
+
return res
|
39
|
+
end
|
40
|
+
|
41
|
+
def put
|
42
|
+
keys = [:subject, :describe, :tracker_id, :status_id,
|
43
|
+
:category_id, :assigned_to, :priority, :fixed_version,
|
44
|
+
:start_date, :due_date, :estimate_date, :done_ratio]
|
45
|
+
opts = rest_options(keys, @default_param)
|
46
|
+
issue = RedmineClient::Issue.find(CONFIG["id"])
|
47
|
+
issue.load(opts)
|
48
|
+
res = issue.save
|
49
|
+
puts res ? "Issue updated!" : "Issue fail to update."
|
50
|
+
return res
|
51
|
+
end
|
52
|
+
|
53
|
+
def delete
|
54
|
+
issue = RedmineClient::Issue.find(CONFIG["id"])
|
55
|
+
res = issue.destroy
|
56
|
+
puts res ? "Issue destroyed!" : "Issue fail to destroy."
|
57
|
+
return res
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
def self.check_args
|
62
|
+
return false unless super
|
63
|
+
unless CONFIG['rest_type']
|
64
|
+
puts "Please input -g or -u or -p -or -d."
|
65
|
+
return false
|
66
|
+
end
|
67
|
+
if (CONFIG['rest_type'] == :put || CONFIG['rest_type'] == :delete) &&
|
68
|
+
!CONFIG['id']
|
69
|
+
puts "Please input --id."
|
70
|
+
return false
|
71
|
+
end
|
72
|
+
if CONFIG['rest_type'] == :post && CONFIG['project_id']
|
73
|
+
puts "Please input --project-id."
|
74
|
+
return false
|
75
|
+
end
|
76
|
+
return true
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Redcuine
|
2
|
+
module OptParser
|
3
|
+
def self.issue_parse!(argv)
|
4
|
+
@issue_optionparser.parse!(argv)
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
def self.default_opts(opt)
|
9
|
+
opt.on('-p', '--post', 'POST by REST API') do
|
10
|
+
CONFIG["rest_type"] = :post
|
11
|
+
end
|
12
|
+
|
13
|
+
opt.on('-g', '--get', 'GET by REST API') do |val|
|
14
|
+
CONFIG["rest_type"] = :get
|
15
|
+
end
|
16
|
+
|
17
|
+
opt.on('-u', '--put', 'PUT by REST API') do |val|
|
18
|
+
CONFIG["rest_type"] = :put
|
19
|
+
end
|
20
|
+
|
21
|
+
opt.on('-d', '--delete', 'DELETE by REST API') do |val|
|
22
|
+
CONFIG["rest_type"] = :delete
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
@issue_optionparser = OptionParser.new do |opt|
|
27
|
+
opt.program_name = 'redissue'
|
28
|
+
|
29
|
+
default_opts(opt)
|
30
|
+
%w(id subject describe tracker-id status-id category-id assigned-to
|
31
|
+
priority fixed-version start-date due-date estimate-date
|
32
|
+
done-ratio site).each do |k|
|
33
|
+
src = <<-SRC
|
34
|
+
opt.on('--#{k} val', 'Set #{k.gsub("-", " ")}') do |val|
|
35
|
+
CONFIG["#{k.gsub("-", "_")}"] = val
|
36
|
+
end
|
37
|
+
SRC
|
38
|
+
eval(src)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/redcuine.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) ||
|
3
|
+
$:.include?(File.expand_path(File.dirname(__FILE__)))
|
4
|
+
|
5
|
+
require 'yaml'
|
6
|
+
require 'time'
|
7
|
+
require "ostruct"
|
8
|
+
require "optparse"
|
9
|
+
require 'redmine_client'
|
10
|
+
|
11
|
+
require "redcuine/config_setup"
|
12
|
+
require "redcuine/optparser"
|
13
|
+
require "redcuine/base"
|
14
|
+
require "redcuine/issue"
|
15
|
+
|
16
|
+
Version = File.read(File.join(File.dirname(__FILE__), '../VERSION')).strip
|
17
|
+
module Redcuine
|
18
|
+
CONFIG = {}
|
19
|
+
CONF_DIR = File.expand_path('~/.redcuine') unless defined? CONF_DIR
|
20
|
+
CONF_FILE = File.join(Redcuine::CONF_DIR, 'config.yml') unless defined? CONF_FILE
|
21
|
+
|
22
|
+
def self.load_config!
|
23
|
+
ConfigSetup.run
|
24
|
+
CONFIG.replace(YAML.load(IO.read(CONF_FILE)))
|
25
|
+
end
|
26
|
+
load_config!
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: redcuine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 0.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Narihiro Nakmaura
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-01-29 00:00:00 +09:00
|
18
|
+
default_executable: redissue
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: redmine_client
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 0
|
30
|
+
- 1
|
31
|
+
version: 0.0.1
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
description: CUI toolkit for Redmine
|
35
|
+
email: authornari@gmail.com
|
36
|
+
executables:
|
37
|
+
- redissue
|
38
|
+
extensions: []
|
39
|
+
|
40
|
+
extra_rdoc_files:
|
41
|
+
- README.rdoc
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- MIT-LISENCE
|
45
|
+
- README.rdoc
|
46
|
+
- Rakefile
|
47
|
+
- VERSION
|
48
|
+
- bin/redissue
|
49
|
+
- lib/redcuine.rb
|
50
|
+
- lib/redcuine/base.rb
|
51
|
+
- lib/redcuine/config_setup.rb
|
52
|
+
- lib/redcuine/config_template.erb
|
53
|
+
- lib/redcuine/issue.rb
|
54
|
+
- lib/redcuine/optparser.rb
|
55
|
+
has_rdoc: true
|
56
|
+
homepage: https://github.com/authorNari/redcuine
|
57
|
+
licenses: []
|
58
|
+
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options:
|
61
|
+
- --charset=UTF-8
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.3.6
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: CUI toolkit for Redmine
|
85
|
+
test_files: []
|
86
|
+
|