jira4nix 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +48 -0
- data/VERSION +1 -0
- data/bin/jira +138 -0
- data/lib/jira.rb +0 -0
- data/spec/jira_spec.rb +7 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +9 -0
- metadata +124 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Kyle Maxwell
|
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,17 @@
|
|
1
|
+
= jira
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Kyle Maxwell. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "jira4nix"
|
8
|
+
gem.summary = %Q{CLI for jira}
|
9
|
+
gem.description = %Q{Work in progress}
|
10
|
+
gem.email = "kmaxwell@twitter.com"
|
11
|
+
gem.homepage = "http://github.com/fizx/jira"
|
12
|
+
gem.authors = ["Kyle Maxwell"]
|
13
|
+
gem.add_dependency "jira4r", "0.3"
|
14
|
+
gem.add_dependency "plain_option_parser"
|
15
|
+
gem.add_dependency "highline"
|
16
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
17
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
|
+
end
|
19
|
+
Jeweler::GemcutterTasks.new
|
20
|
+
rescue LoadError
|
21
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'spec/rake/spectask'
|
25
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
26
|
+
spec.libs << 'lib' << 'spec'
|
27
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
28
|
+
end
|
29
|
+
|
30
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
31
|
+
spec.libs << 'lib' << 'spec'
|
32
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
33
|
+
spec.rcov = true
|
34
|
+
end
|
35
|
+
|
36
|
+
task :spec => :check_dependencies
|
37
|
+
|
38
|
+
task :default => :spec
|
39
|
+
|
40
|
+
require 'rake/rdoctask'
|
41
|
+
Rake::RDocTask.new do |rdoc|
|
42
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
43
|
+
|
44
|
+
rdoc.rdoc_dir = 'rdoc'
|
45
|
+
rdoc.title = "jira #{version}"
|
46
|
+
rdoc.rdoc_files.include('README*')
|
47
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
48
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/jira
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "rubygems"
|
3
|
+
require "plain_option_parser"
|
4
|
+
require "highline/import"
|
5
|
+
require "jira4r"
|
6
|
+
require "yaml"
|
7
|
+
|
8
|
+
$config_file = File.join(ENV["HOME"], ".jira.yml")
|
9
|
+
$config = File.exists?($config_file) ? YAML.load(File.open($config_file)) : {}
|
10
|
+
|
11
|
+
def input(prompt, key, default = nil, &validation)
|
12
|
+
key = key.to_s
|
13
|
+
@original = $config[key]
|
14
|
+
input = ask("#{prompt} [#{$config[key] || default}]")
|
15
|
+
$config[key] = input unless input.empty?
|
16
|
+
$config[key] ||= default
|
17
|
+
validation.call if validation
|
18
|
+
save $config
|
19
|
+
rescue
|
20
|
+
$config[key] = @original
|
21
|
+
raise
|
22
|
+
end
|
23
|
+
|
24
|
+
def save
|
25
|
+
File.open($config_file, "w") do |f|
|
26
|
+
YAML.dump($config, f)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def password
|
31
|
+
password = ask("Enter password: ") { |q| q.echo = false }
|
32
|
+
init
|
33
|
+
$config["token"] = $jira.login($config["user"], password)
|
34
|
+
save
|
35
|
+
login
|
36
|
+
end
|
37
|
+
|
38
|
+
def init
|
39
|
+
$jira = Jira4R::JiraTool.new(2, $config["location"])
|
40
|
+
logger = Logger.new(STDERR)
|
41
|
+
logger.level = Logger::WARN
|
42
|
+
$jira.logger = logger
|
43
|
+
end
|
44
|
+
|
45
|
+
def login
|
46
|
+
init
|
47
|
+
$jira.instance_variable_set("@token", $config["token"])
|
48
|
+
end
|
49
|
+
|
50
|
+
def create_ticket(summary, description, user, group, component, reviewboard = nil, git_repo = nil, branch = nil)
|
51
|
+
issue = Jira4R::V2::RemoteIssue.new
|
52
|
+
issue.summary = summary
|
53
|
+
issue.description = description
|
54
|
+
issue.type = 2
|
55
|
+
issue.assignee = user
|
56
|
+
issue.reporter = user
|
57
|
+
issue.project = group
|
58
|
+
|
59
|
+
issue.components = $jira.getComponents(group).select{|c| c.name == component }
|
60
|
+
|
61
|
+
issue.customFieldValues = []
|
62
|
+
if reviewboard
|
63
|
+
# reviewboard custom field
|
64
|
+
rb = Jira4R::V2::RemoteCustomFieldValue.new
|
65
|
+
rb.customfieldId = "customfield_10000"
|
66
|
+
rb.values = reviewboard
|
67
|
+
issue.customFieldValues << rb
|
68
|
+
end
|
69
|
+
|
70
|
+
if branch
|
71
|
+
# branch custom field
|
72
|
+
b = Jira4R::V2::RemoteCustomFieldValue.new
|
73
|
+
b.customfieldId = "customfield_10022"
|
74
|
+
b.values = branch
|
75
|
+
issue.customFieldValues << b
|
76
|
+
end
|
77
|
+
|
78
|
+
if git_repo
|
79
|
+
# 'git repository' custom field
|
80
|
+
gr = Jira4R::V2::RemoteCustomFieldValue.new
|
81
|
+
gr.customfieldId = "customfield_10052"
|
82
|
+
gr.values = git_repo
|
83
|
+
issue.customFieldValues << gr
|
84
|
+
end
|
85
|
+
|
86
|
+
puts issue.inspect
|
87
|
+
|
88
|
+
issue = $jira.createIssue(issue)
|
89
|
+
rescue SOAP::FaultError => e
|
90
|
+
if e.message =~ /auth/
|
91
|
+
password
|
92
|
+
retry
|
93
|
+
else
|
94
|
+
raise
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
PlainOptionParser.new do
|
99
|
+
desc "Setup your global JIRA settings"
|
100
|
+
cmd "setup" do
|
101
|
+
input "JIRA location", :location
|
102
|
+
input "JIRA user", :user, ENV["USER"]
|
103
|
+
password
|
104
|
+
end
|
105
|
+
|
106
|
+
desc "Make a context"
|
107
|
+
cmd "configure" do
|
108
|
+
login
|
109
|
+
begin
|
110
|
+
input "Project", :project do
|
111
|
+
$project = $jira.getProjectByKey($config["project"])
|
112
|
+
end
|
113
|
+
rescue
|
114
|
+
puts "Invalid project name!"
|
115
|
+
retry
|
116
|
+
end
|
117
|
+
|
118
|
+
begin
|
119
|
+
input "Component", :component do
|
120
|
+
$jira.getComponents($config["project"]).any?{|c| c.name == $config["component"]} or raise
|
121
|
+
end
|
122
|
+
rescue
|
123
|
+
puts "Invalid component name!"
|
124
|
+
retry
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# summary, description, reviewboard, git_repo, branch, user, group
|
129
|
+
|
130
|
+
cmd "new feature" do
|
131
|
+
login
|
132
|
+
title = ask("Title")
|
133
|
+
description = ask("Description")
|
134
|
+
create_ticket(title, description, $config["user"], $config["project"], $config["component"])
|
135
|
+
# (summary, description, user, group, reviewboard = nil, git_repo = nil, branch = nil)
|
136
|
+
end
|
137
|
+
|
138
|
+
end.start(ARGV)
|
data/lib/jira.rb
ADDED
File without changes
|
data/spec/jira_spec.rb
ADDED
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jira4nix
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Kyle Maxwell
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-02-18 00:00:00 -08:00
|
18
|
+
default_executable: jira
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: jira4r
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 3
|
30
|
+
version: "0.3"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: plain_option_parser
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 0
|
42
|
+
version: "0"
|
43
|
+
type: :runtime
|
44
|
+
version_requirements: *id002
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: highline
|
47
|
+
prerelease: false
|
48
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
segments:
|
53
|
+
- 0
|
54
|
+
version: "0"
|
55
|
+
type: :runtime
|
56
|
+
version_requirements: *id003
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rspec
|
59
|
+
prerelease: false
|
60
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
segments:
|
65
|
+
- 1
|
66
|
+
- 2
|
67
|
+
- 9
|
68
|
+
version: 1.2.9
|
69
|
+
type: :development
|
70
|
+
version_requirements: *id004
|
71
|
+
description: Work in progress
|
72
|
+
email: kmaxwell@twitter.com
|
73
|
+
executables:
|
74
|
+
- jira
|
75
|
+
extensions: []
|
76
|
+
|
77
|
+
extra_rdoc_files:
|
78
|
+
- LICENSE
|
79
|
+
- README.rdoc
|
80
|
+
files:
|
81
|
+
- .document
|
82
|
+
- .gitignore
|
83
|
+
- LICENSE
|
84
|
+
- README.rdoc
|
85
|
+
- Rakefile
|
86
|
+
- VERSION
|
87
|
+
- bin/jira
|
88
|
+
- lib/jira.rb
|
89
|
+
- spec/jira_spec.rb
|
90
|
+
- spec/spec.opts
|
91
|
+
- spec/spec_helper.rb
|
92
|
+
has_rdoc: true
|
93
|
+
homepage: http://github.com/fizx/jira
|
94
|
+
licenses: []
|
95
|
+
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options:
|
98
|
+
- --charset=UTF-8
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
version: "0"
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
segments:
|
113
|
+
- 0
|
114
|
+
version: "0"
|
115
|
+
requirements: []
|
116
|
+
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 1.3.6
|
119
|
+
signing_key:
|
120
|
+
specification_version: 3
|
121
|
+
summary: CLI for jira
|
122
|
+
test_files:
|
123
|
+
- spec/jira_spec.rb
|
124
|
+
- spec/spec_helper.rb
|