commit2jira 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ pkg
2
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source :gemcutter
2
+
3
+ gem "rake"
4
+
5
+ group :development do
6
+ gem "rspec"
7
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ rake (0.9.2)
6
+ rspec (2.7.0)
7
+ rspec-core (~> 2.7.0)
8
+ rspec-expectations (~> 2.7.0)
9
+ rspec-mocks (~> 2.7.0)
10
+ rspec-core (2.7.1)
11
+ rspec-expectations (2.7.0)
12
+ diff-lcs (~> 1.1.2)
13
+ rspec-mocks (2.7.0)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ rake
20
+ rspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2012 Lookout, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,18 @@
1
+ # commit2jira
2
+
3
+
4
+ commit2jira is a simple gem for parsing a commit message for JIRAs referenced
5
+ in the meta-data block of the commit body.
6
+
7
+ A commit that it will parse, for example:
8
+
9
+ commit 54be152b445ecb4ac27ca7b2c06475d27236e2b2
10
+ Author: R. Tyler Croy <rtyler.croy@mylookout.com>
11
+ Date: Fri Apr 6 16:07:23 2012 -0700
12
+
13
+ This is a test commit, and it's awesome.
14
+
15
+ Change-Id: I54be152b445ecb4ac27ca7b2c06475d27236e2b2
16
+ JIRA: TEST-231
17
+
18
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler'
2
+ require 'rspec/core/rake_task'
3
+ Bundler::GemHelper.install_tasks
4
+
5
+ task :default => [:test, :build]
6
+
7
+ RSpec::Core::RakeTask.new('test') do |s|
8
+ s.rspec_opts = '-c'
9
+ end
10
+
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'commit2jira'
6
+ s.version = "0.1.#{ENV['BUILD_NUMBER'] || 'dev'}"
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["R. Tyler Croy"]
9
+ s.email = ["rtyler.croy@mylookout.com"]
10
+ s.homepage = 'https://source.flexilis.local/rcroy/commit2jira'
11
+ s.summary = %q{a gem for parsing jiras from commits}
12
+ s.description = %q{Herpy derpy}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+ end
@@ -0,0 +1,20 @@
1
+
2
+ require 'rubygems'
3
+
4
+ module Commit2Jira
5
+ def from_message(projects, message, &block)
6
+ if message.nil? or message.empty?
7
+ return
8
+ end
9
+ regex = /\b(#{projects.join('|')})-(\d+)\b/i
10
+
11
+ message.scan(regex) do |match|
12
+ project = match[0].upcase
13
+ number = match[1].to_i
14
+
15
+ yield project, number
16
+ end
17
+
18
+ end
19
+ module_function :from_message
20
+ end
@@ -0,0 +1,36 @@
1
+
2
+ require File.dirname(__FILE__) + '/../lib/commit2jira.rb'
3
+
4
+ describe Commit2Jira do
5
+ describe "#from_message" do
6
+ it "should not call the block if there are no JIRAs" do
7
+ Commit2Jira.from_message(['FOO'], 'Foo') do |project, number|
8
+ true.should == false
9
+ end
10
+
11
+ end
12
+
13
+ it "should call the block for one JIRA with the right project" do
14
+ expected_project = 'FOO'
15
+ expected_number = 4779
16
+ message =<<END
17
+ This is a simple commit message
18
+
19
+ JIRA: #{expected_project}-#{expected_number}
20
+ END
21
+ found_project = nil
22
+ found_number = nil
23
+ called = false
24
+ Commit2Jira.from_message(['foo'], message) do |project, number|
25
+ found_project = project
26
+ found_number = number
27
+ called = true
28
+ end
29
+
30
+ called.should == true
31
+
32
+ expected_project.should == found_project
33
+ expected_number.should == found_number
34
+ end
35
+ end
36
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: commit2jira
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 2
10
+ version: 0.1.2
11
+ platform: ruby
12
+ authors:
13
+ - R. Tyler Croy
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-04-18 00:00:00 +00:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Herpy derpy
23
+ email:
24
+ - rtyler.croy@mylookout.com
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - Gemfile.lock
35
+ - LICENSE
36
+ - README.markdown
37
+ - Rakefile
38
+ - commit2jira.gemspec
39
+ - lib/commit2jira.rb
40
+ - spec/commit2jira_spec.rb
41
+ has_rdoc: true
42
+ homepage: https://source.flexilis.local/rcroy/commit2jira
43
+ licenses: []
44
+
45
+ post_install_message:
46
+ rdoc_options: []
47
+
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.6.2
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: a gem for parsing jiras from commits
75
+ test_files:
76
+ - spec/commit2jira_spec.rb