jira 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 chrislo
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.
@@ -0,0 +1,29 @@
1
+ = jira
2
+
3
+ A command line interface to the Jira issue tracking system.
4
+
5
+ To use, create a '.jira' YAML file in your home directory. For example:
6
+
7
+ :jira_base: https://jira.your.domain
8
+ :pem: ~/yourcert.pem
9
+
10
+ The 'pem' parameter is optional, but required if your jira
11
+ installation uses SSL authentication. If you connect to Jira through a
12
+ proxy set the HTTP_PROXY environment variable.
13
+
14
+ To get a list of unopened tickets assigned to you:
15
+
16
+ $ jira list
17
+
18
+ == Note on Patches/Pull Requests
19
+
20
+ * Fork the project.
21
+ * Make your feature addition or bug fix.
22
+ * Add tests for it. This is important so I don't break it in a
23
+ future version unintentionally.
24
+ * Commit, do not mess with rakefile, version, or history.
25
+ * Send me a pull request. Bonus points for topic branches.
26
+
27
+ == Copyright
28
+
29
+ Copyright (c) 2009 chrislo. See LICENSE for details.
@@ -0,0 +1,47 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "jira"
8
+ gem.summary = %Q{A command line interface to the JIRA issue tracking system}
9
+ gem.description = %Q{A command line interface to the JIRA issue tracking system}
10
+ gem.email = "chris.lowis@gmail.com"
11
+ gem.homepage = "http://github.com/chrislo/jira"
12
+ gem.authors = ["chrislo"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.add_development_dependency "fakeweb", ">= 1.2.7"
15
+ gem.add_dependency "rest-client", ">= 1.0.3"
16
+ gem.add_dependency "xml-simple", ">= 1.0.12"
17
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
+ end
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
21
+ end
22
+
23
+ require 'spec/rake/spectask'
24
+ Spec::Rake::SpecTask.new(:spec) do |spec|
25
+ spec.libs << 'lib' << 'spec'
26
+ spec.spec_files = FileList['spec/**/*_spec.rb']
27
+ end
28
+
29
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
30
+ spec.libs << 'lib' << 'spec'
31
+ spec.pattern = 'spec/**/*_spec.rb'
32
+ spec.rcov = true
33
+ end
34
+
35
+ task :spec => :check_dependencies
36
+
37
+ task :default => :spec
38
+
39
+ require 'rake/rdoctask'
40
+ Rake::RDocTask.new do |rdoc|
41
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
42
+
43
+ rdoc.rdoc_dir = 'rdoc'
44
+ rdoc.title = "jira #{version}"
45
+ rdoc.rdoc_files.include('README*')
46
+ rdoc.rdoc_files.include('lib/**/*.rb')
47
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ # require 'jira'
6
+ require File.dirname(__FILE__) + '/../lib/jira'
7
+
8
+ Jira::CLI.execute
@@ -0,0 +1,53 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{jira}
8
+ s.version = ""
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["chrislo"]
12
+ s.date = %q{2009-11-16}
13
+ s.description = %q{TODO: longer description of your gem}
14
+ s.email = %q{chris.lowis@bbc.co.uk}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "lib/jira.rb",
26
+ "spec/jira_spec.rb",
27
+ "spec/spec.opts",
28
+ "spec/spec_helper.rb"
29
+ ]
30
+ s.homepage = %q{http://github.com/chrislo/jira}
31
+ s.rdoc_options = ["--charset=UTF-8"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = %q{1.3.5}
34
+ s.summary = %q{TODO: one-line summary of your gem}
35
+ s.test_files = [
36
+ "spec/jira_spec.rb",
37
+ "spec/spec_helper.rb"
38
+ ]
39
+
40
+ if s.respond_to? :specification_version then
41
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42
+ s.specification_version = 3
43
+
44
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
45
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
46
+ else
47
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
48
+ end
49
+ else
50
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
51
+ end
52
+ end
53
+
@@ -0,0 +1,5 @@
1
+ require 'pathname'
2
+ dir = Pathname(__FILE__).dirname.expand_path
3
+
4
+ require dir + 'jira/issue'
5
+ require dir + 'jira/cli'
@@ -0,0 +1,65 @@
1
+ require 'optparse'
2
+
3
+ module Jira
4
+ class CLI
5
+ attr_reader :action, :options, :args
6
+
7
+ def self.execute
8
+ parse(ARGV).execute!
9
+ end
10
+
11
+ def self.parse(args)
12
+ cli = new(args)
13
+ cli.parse_options!
14
+ cli.load_options_from_file
15
+ cli
16
+ end
17
+
18
+ def initialize(args)
19
+ @args = args.dup
20
+ end
21
+
22
+ def execute!
23
+ case action
24
+ when 'list':
25
+ handle_ticket_list
26
+ else
27
+ puts 'not a command'
28
+ end
29
+ end
30
+
31
+ def handle_ticket_list
32
+ issues = Jira::Issue.new(@options).list_all_open_assigned_issues
33
+ puts issues
34
+ end
35
+
36
+ def parse_options!
37
+ if args.empty?
38
+ warn "Please specify at least one action to execute."
39
+ puts " list"
40
+ exit
41
+ end
42
+
43
+ @action = args.first
44
+ end
45
+
46
+ def load_options_from_file
47
+ options_file = File.join(ENV['HOME'],'.jira')
48
+ if File.exists?(options_file)
49
+ loaded_options = YAML.load_file(File.join(ENV['HOME'],'.jira'))
50
+ else
51
+ abort "You need a ~/.jira"
52
+ end
53
+
54
+ @options = {}
55
+ @options[:jira_base] = loaded_options[:jira_base]
56
+
57
+ if loaded_options.has_key? :pem
58
+ pem_contents = File.read(File.expand_path(loaded_options[:pem]))
59
+ @options[:ssl_client_cert] = OpenSSL::X509::Certificate.new(pem_contents)
60
+ @options[:ssl_client_key] = OpenSSL::PKey::RSA.new(pem_contents)
61
+ @options[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,29 @@
1
+ require 'rubygems'
2
+ require 'rest_client'
3
+ require 'xmlsimple'
4
+ require 'ostruct'
5
+
6
+ module Jira
7
+ class Issue
8
+ def initialize(options = nil)
9
+ @resource = rest_resource(options)
10
+ end
11
+
12
+ def rest_resource(options)
13
+ RestClient.proxy = ENV['http_proxy']
14
+ @resource = RestClient::Resource.new(options[:jira_base], options)
15
+ end
16
+
17
+ def find_all_open_assigned_issues
18
+ res = @resource['sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?resolution=-1&assigneeSelect=issue_current_user'].get
19
+ doc = XmlSimple.xml_in res.to_s
20
+ open_issues = doc['channel'].first['item']
21
+ issues = open_issues.map {|i| OpenStruct.new(i)}
22
+ end
23
+
24
+ def list_all_open_assigned_issues
25
+ issues = find_all_open_assigned_issues
26
+ issues.map{|i| "* #{i.title}"}.join("\n")
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,155 @@
1
+ <!-- RSS generated by JIRA (Enterprise Edition, Version: 3.13-#330) at Wed Nov 18 23:15:44 GMT 2009 -->
2
+ <!-- If you wish to do custom client-side styling of RSS, uncomment this:
3
+ <?xml-stylesheet href="https://jira.your.domain:443/styles/jiraxml2html.xsl" type="text/xsl"?>
4
+ -->
5
+ <rss version="0.92" >
6
+ <channel>
7
+ <title>Your JIRA</title>
8
+ <link>https://jira.your.domain:443/secure/IssueNavigator.jspa?reset=true&amp;resolution=-1&amp;assigneeSelect=issue_current_user&amp;sorter/field=priority&amp;sorter/order=DESC</link>
9
+ <description>An XML representation of a search request</description>
10
+
11
+ <language>en-gb</language> <issue start="0" end="2" total="2" /> <build-info>
12
+ <version>3.13</version>
13
+ <build-number>330</build-number>
14
+ <build-date>27-08-2008</build-date>
15
+ <edition>Enterprise</edition>
16
+
17
+ </build-info>
18
+
19
+ <item>
20
+ <title>[TST-14301] Test</title>
21
+ <link>https://jira.your.domain:443/browse/TST-14301</link>
22
+
23
+ <description></description>
24
+ <environment></environment>
25
+ <key id="48203">TST-14301</key>
26
+ <summary>Test</summary>
27
+
28
+ <type id="18" iconUrl="https://jira.your.domain:443https://confluence.your.domain/download/attachments/6162113/application_go.png">Change</type>
29
+
30
+ <priority id="5" iconUrl="https://jira.your.domain:443https://confluence.your.domain/download/attachments/6162113/error.png">Unknown</priority>
31
+ <status id="1" iconUrl="https://jira.your.domain:443/images/icons/status_open.gif">Open</status>
32
+ <resolution id="-1">Unresolved</resolution>
33
+
34
+
35
+ <assignee username="chris.lowis">Chris Lowis</assignee>
36
+
37
+ <reporter username="chris.lowis">Chris Lowis</reporter>
38
+
39
+
40
+ <created>Wed, 18 Nov 2009 20:57:09 +0000 (GMT)</created>
41
+ <updated>Wed, 18 Nov 2009 20:57:15 +0000 (GMT)</updated>
42
+
43
+
44
+
45
+
46
+ <due></due>
47
+
48
+ <votes>0</votes>
49
+
50
+
51
+
52
+
53
+ <attachments>
54
+ </attachments>
55
+
56
+ <subtasks>
57
+ </subtasks>
58
+
59
+ <customfields>
60
+ <customfield id="customfield_10310" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
61
+ <customfieldname>Group assignee</customfieldname>
62
+ <customfieldvalues>
63
+ <customfieldvalue><![CDATA[Not assigned]]></customfieldvalue>
64
+
65
+ </customfieldvalues>
66
+
67
+ </customfield>
68
+ <customfield id="customfield_10272" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
69
+ <customfieldname>Change Type</customfieldname>
70
+ <customfieldvalues>
71
+ <customfieldvalue><![CDATA[Managed]]></customfieldvalue>
72
+
73
+ </customfieldvalues>
74
+ </customfield>
75
+ <customfield id="customfield_10297" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
76
+
77
+ <customfieldname>Tech kick-off</customfieldname>
78
+ <customfieldvalues>
79
+ <customfieldvalue><![CDATA[No]]></customfieldvalue>
80
+
81
+ </customfieldvalues>
82
+ </customfield>
83
+ </customfields>
84
+
85
+ </item>
86
+
87
+ <item>
88
+ <title>[TST-14302] another ticket</title>
89
+ <link>https://jira.your.domain:443/browse/TST-14302</link>
90
+
91
+ <description></description>
92
+ <environment></environment>
93
+ <key id="48206">TST-14302</key>
94
+ <summary>another ticket</summary>
95
+ <type id="18" iconUrl="https://jira.your.domain:443https://confluence.your.domain/download/attachments/6162113/application_go.png">Change</type>
96
+
97
+
98
+ <priority id="5" iconUrl="https://jira.your.domain:443https://confluence.your.domain/download/attachments/6162113/error.png">Unknown</priority>
99
+ <status id="1" iconUrl="https://jira.your.domain:443/images/icons/status_open.gif">Open</status>
100
+ <resolution id="-1">Unresolved</resolution>
101
+
102
+
103
+ <assignee username="chris.lowis">Chris Lowis</assignee>
104
+
105
+ <reporter username="chris.lowis">Chris Lowis</reporter>
106
+
107
+ <created>Wed, 18 Nov 2009 23:14:54 +0000 (GMT)</created>
108
+
109
+ <updated>Wed, 18 Nov 2009 23:15:00 +0000 (GMT)</updated>
110
+
111
+
112
+
113
+
114
+ <due></due>
115
+
116
+ <votes>0</votes>
117
+
118
+
119
+
120
+
121
+ <attachments>
122
+ </attachments>
123
+
124
+ <subtasks>
125
+ </subtasks>
126
+
127
+ <customfields>
128
+ <customfield id="customfield_10310" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
129
+ <customfieldname>Group assignee</customfieldname>
130
+ <customfieldvalues>
131
+ <customfieldvalue><![CDATA[Not assigned]]></customfieldvalue>
132
+
133
+ </customfieldvalues>
134
+ </customfield>
135
+ <customfield id="customfield_10272" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
136
+
137
+ <customfieldname>Change Type</customfieldname>
138
+ <customfieldvalues>
139
+ <customfieldvalue><![CDATA[Managed]]></customfieldvalue>
140
+
141
+ </customfieldvalues>
142
+ </customfield>
143
+ <customfield id="customfield_10297" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
144
+ <customfieldname>Tech kick-off</customfieldname>
145
+
146
+ <customfieldvalues>
147
+ <customfieldvalue><![CDATA[No]]></customfieldvalue>
148
+
149
+ </customfieldvalues>
150
+ </customfield>
151
+ </customfields>
152
+
153
+ </item>
154
+ </channel>
155
+ </rss>
@@ -0,0 +1,32 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
+
3
+ module Jira
4
+ describe Issue do
5
+ before(:each) do
6
+ options[:jira_base] = 'https://my.jira'
7
+ FakeWeb.allow_net_connect = false
8
+ FakeWeb.register_uri(:get,
9
+ "#{options[:jira_base]}/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?resolution=-1&assigneeSelect=issue_current_user",
10
+ :body => File.read(File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures', 'issues.xml'))))
11
+ @ji = Jira::Issue.new(options)
12
+ end
13
+
14
+ describe "initialize" do
15
+ end
16
+
17
+ describe "find_all_open_assigned_issues" do
18
+ it "should return a list of open issues" do
19
+ issues = @ji.find_all_open_assigned_issues
20
+ issues.map {|i| i.title}.flatten.should include('[TST-14301] Test')
21
+ end
22
+ end
23
+
24
+ describe "list all open assigned issues" do
25
+ it "should give a formated list of issue titles" do
26
+ @ji.stub!(:find_all_open_assigned_issues).
27
+ and_return([OpenStruct.new(:title => "An issue"),OpenStruct.new(:title => "A second issue")])
28
+ @ji.list_all_open_assigned_issues.should == "* An issue\n* A second issue"
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,13 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ require 'jira'
8
+
9
+ require 'rubygems'
10
+ require 'fakeweb'
11
+
12
+ Spec::Runner.configure do |config|
13
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jira
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - chrislo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-06 00:00:00 +00:00
13
+ default_executable: jira
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.9
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: fakeweb
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.7
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: rest-client
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.3
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: xml-simple
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.0.12
54
+ version:
55
+ description: A command line interface to the JIRA issue tracking system
56
+ email: chris.lowis@gmail.com
57
+ executables:
58
+ - jira
59
+ extensions: []
60
+
61
+ extra_rdoc_files:
62
+ - LICENSE
63
+ - README.rdoc
64
+ files:
65
+ - .document
66
+ - .gitignore
67
+ - LICENSE
68
+ - README.rdoc
69
+ - Rakefile
70
+ - VERSION
71
+ - bin/jira
72
+ - jira.gemspec
73
+ - lib/jira.rb
74
+ - lib/jira/cli.rb
75
+ - lib/jira/issue.rb
76
+ - spec/fixtures/issues.xml
77
+ - spec/jira/issue_spec.rb
78
+ - spec/spec.opts
79
+ - spec/spec_helper.rb
80
+ has_rdoc: true
81
+ homepage: http://github.com/chrislo/jira
82
+ licenses: []
83
+
84
+ post_install_message:
85
+ rdoc_options:
86
+ - --charset=UTF-8
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: "0"
94
+ version:
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: "0"
100
+ version:
101
+ requirements: []
102
+
103
+ rubyforge_project:
104
+ rubygems_version: 1.3.5
105
+ signing_key:
106
+ specification_version: 3
107
+ summary: A command line interface to the JIRA issue tracking system
108
+ test_files:
109
+ - spec/jira/issue_spec.rb
110
+ - spec/spec_helper.rb