gitmine 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -3,14 +3,16 @@
3
3
  Gitmine displays the last 10 commits of your repo and their associated redmine ticket status.
4
4
 
5
5
  == Install
6
+
6
7
  gem install gitmine
7
8
 
8
9
  == Setup
10
+
9
11
  Put the config file '.gitmine.yml' at the root of your project. Here is a sample file:
10
12
 
11
- host: 'https://redmine.yourcompany.com
12
- # Api key is required for private projects only.
13
- api_key: 'your_api_key'
13
+ host: 'https://redmine.yourcompany.com
14
+ # Api key is required for private projects only.
15
+ api_key: 'your_api_key'
14
16
 
15
17
  Then run gitmine at the root of your project.
16
18
 
@@ -19,6 +21,11 @@ Then run gitmine at the root of your project.
19
21
  * Issues are managed by redmine on http://redmine-gitmine.heroku.com/projects/gitmine
20
22
  * Thanks for reporting issues on http://redmine-gitmine.heroku.com/projects/gitmine/issues/new
21
23
 
24
+ == Contributors
25
+
26
+ * Philippe Creux http://github.com/pcreux
27
+ * Greg Bell http://github.com/gregbell
28
+
22
29
  == Note on Patches/Pull Requests
23
30
 
24
31
  * Fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
data/gitmine.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gitmine}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Philippe Creux"]
12
- s.date = %q{2010-07-27}
12
+ s.date = %q{2010-08-11}
13
13
  s.default_executable = %q{gitmine}
14
14
  s.description = %q{Git log with status of associated redmine tickets}
15
15
  s.email = %q{pcreux@gmail.com}
data/lib/gitmine.rb CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  require 'grit'
4
4
  require 'yaml'
5
- require 'HTTParty'
5
+ require 'httparty'
6
6
 
7
7
  class Gitmine
8
8
  # CLI interface
@@ -24,90 +24,89 @@ class Gitmine
24
24
  Commit.new(c)
25
25
  end
26
26
  end
27
- end
28
-
29
27
 
30
- class Commit
31
- attr_reader :grit_commit
32
28
 
33
- # Initialize a new Commit objects that delegates methods to the Grit::Commit object passed in
34
- def initialize(grit_commit)
35
- @grit_commit = grit_commit
36
- end
29
+ class Commit
30
+ attr_reader :grit_commit
37
31
 
38
- # Issue associated with this commit
39
- # Return nil if teir is no associated issue
40
- def issue
41
- @issue ||= Issue.get_for_commit(message)
42
- end
32
+ # Initialize a new Commit objects that delegates methods to the Grit::Commit object passed in
33
+ def initialize(grit_commit)
34
+ @grit_commit = grit_commit
35
+ end
43
36
 
44
- # Delegate #id to Grit::Commit
45
- def id
46
- @grit_commit.id
47
- end
37
+ # Issue associated with this commit
38
+ # Return nil if their is no associated issue
39
+ def issue
40
+ @issue ||= Issue.get_for_commit(message)
41
+ end
48
42
 
49
- protected
50
- # Delegate methods to Grit::Commit
51
- def method_missing(m, *args, &block)
52
- return @grit_commit.send(m, args, block) if @grit_commit.respond_to? m
53
- super
54
- end
55
- end
43
+ # Delegate #id to Grit::Commit
44
+ def id
45
+ @grit_commit.id
46
+ end
56
47
 
57
- module CommitMsgToIssueId
58
- # Extract the issue_id from a commit message.
59
- # Examples:
60
- # CommitMsgToIssueId.parse("Message for Issue #123.")
61
- # => 123
62
- # CommitMsgToIssueId.parse("#123.")
63
- # => nil
64
- #
65
- def self.parse(msg)
66
- match = msg.match(/Issue #(\d+)/)
67
- match ? match[1] : nil
48
+ protected
49
+ # Delegate methods to Grit::Commit
50
+ def method_missing(m, *args, &block)
51
+ return @grit_commit.send(m, args, block) if @grit_commit.respond_to? m
52
+ super
53
+ end
68
54
  end
69
- end
70
55
 
71
- class Issue
72
- CONFIG_FILE = './.gitmine.yml'
56
+ class Issue
57
+ CONFIG_FILE = './.gitmine.yml'
58
+
59
+ attr_reader :id, :subject, :status
60
+
61
+ # Extract the issue_id from a commit message.
62
+ # Examples:
63
+ # CommitMsgToIssueId.parse("Message for Issue #123.")
64
+ # => 123
65
+ # CommitMsgToIssueId.parse("#123.")
66
+ # => nil
67
+ #
68
+ def self.parse_for_issue_id(msg)
69
+ match = msg.match(/Issue #(\d+)/)
70
+ match ? match[1] : nil
71
+ end
73
72
 
74
- attr_reader :id, :subject, :status
73
+ # Parse the commit_message and get the associated issue if any.
74
+ def self.get_for_commit(commit_message)
75
+ issue_id = parse_for_issue_id(commit_message)
76
+ issue_id ? Issue.get(issue_id) : nil
77
+ end
75
78
 
76
- # Parse the commit_message and get the associated issue if any.
77
- def self.get_for_commit(commit_message)
78
- issue_id = CommitMsgToIssueId.parse(commit_message)
79
- issue_id ? Issue.get(issue_id) : nil
80
- end
79
+ # Get the issue from redmine
80
+ def self.get(issue_id)
81
+ Issue.new.tap { |issue|
82
+ issue.build_via_issue_id(issue_id)
83
+ }
84
+ end
81
85
 
82
- # Get the issue from redmine
83
- def self.get(issue_id)
84
- Issue.new.tap { |issue|
85
- issue.build_via_issue_id(issue_id)
86
- }
87
- end
86
+ # Config from .gitmine.yml
87
+ def config
88
+ @config ||= YAML.load_file(CONFIG_FILE)
89
+ end
88
90
 
89
- # Config from .gitmine.yml
90
- def config
91
- @config ||= YAML.load_file(CONFIG_FILE)
92
- end
91
+ # Get attributes from redmine and set them all
92
+ def build_via_issue_id(issue_id)
93
+ @id = issue_id
94
+ data = get(issue_id).parsed_response['issue']
95
+ @subject = data['subject']
96
+ @status = data['status']['name']
97
+ end
93
98
 
94
- # Get attributes from redmine and set them all
95
- def build_via_issue_id(issue_id)
96
- @id = issue_id
97
- data = get(issue_id).parsed_response['issue']
98
- @subject = data['subject']
99
- @status = data['status']['name']
100
- end
99
+ protected
101
100
 
102
- protected
101
+ # Url to redmine/issues
102
+ def url(id)
103
+ "#{config['host']}/issues/#{id}.xml?key=#{config['api_key']}"
104
+ end
103
105
 
104
- # Url to redmine/issues
105
- def url(id)
106
- "#{config['host']}/issues/#{id}.xml?key=#{config['api_key']}"
106
+ # http_get the issue using HTTParty
107
+ def get(issue_id)
108
+ HTTParty.get(url(issue_id))
109
+ end
107
110
  end
108
111
 
109
- # http_get the issue using HTTParty
110
- def get(issue_id)
111
- HTTParty.get(url(issue_id))
112
- end
113
112
  end
@@ -8,7 +8,7 @@ describe "CommitMsgToIssueId" do
8
8
  ['Add method #yey Commit message Issue #123.', '123']
9
9
  ].each do |msg, id|
10
10
  it "should return #{id} for '#{msg}'" do
11
- CommitMsgToIssueId.parse(msg).should == id
11
+ Gitmine::Issue.parse_for_issue_id(msg).should == id
12
12
  end
13
13
  end
14
14
  end
data/spec/commit_spec.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Commit do
3
+ describe Gitmine::Commit do
4
4
  let(:grit_commit) { Grit::Commit.create(nil, {:message => "Commit message"}) }
5
- let(:commit) { Commit.new(grit_commit) }
6
- let(:issue) { Issue.new }
5
+ let(:commit) { Gitmine::Commit.new(grit_commit) }
6
+ let(:issue) { Gitmine::Issue.new }
7
7
 
8
8
  describe "#new" do
9
9
  it "should take a grit_commit object and store it" do
@@ -24,12 +24,12 @@ describe Commit do
24
24
  end
25
25
 
26
26
  it "should return issue via #Issue.get_for_commit" do
27
- Issue.should_receive(:get_for_commit).with("Commit message") { issue }
27
+ Gitmine::Issue.should_receive(:get_for_commit).with("Commit message") { issue }
28
28
  commit.issue.should == issue
29
29
  end
30
30
 
31
31
  it "should memoize issue" do
32
- Issue.should_receive(:get_for_commit).with("Commit message") { issue }.once
32
+ Gitmine::Issue.should_receive(:get_for_commit).with("Commit message") { issue }.once
33
33
  commit.issue.should == issue
34
34
  commit.issue.should == issue
35
35
  end
data/spec/gitmine_spec.rb CHANGED
@@ -25,7 +25,7 @@ describe Gitmine do
25
25
 
26
26
  describe "#commits" do
27
27
  it "should return Gitmine commits" do
28
- gitmine.commits.first.should be_a Commit
28
+ gitmine.commits.first.should be_a Gitmine::Commit
29
29
  end
30
30
  it "should return commits for the current branch" do
31
31
  repo.should_receive(:commits).with('wip')
data/spec/issue_spec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Issue do
4
- let(:issue) { Issue.new }
3
+ describe Gitmine::Issue do
4
+ let(:issue) { Gitmine::Issue.new }
5
5
  [:id, :subject, :status].each do |a|
6
6
  it "should have an #{a}" do
7
7
  issue.should respond_to a
@@ -25,17 +25,17 @@ describe Issue do
25
25
  describe "#get_for_commit" do
26
26
  it "should parse the commit message to find a commit_id and call #get" do
27
27
  commit_msg = 'A commit msg Issue #123'
28
- CommitMsgToIssueId.should_receive(:parse).with(commit_msg)
29
- Issue.get_for_commit(commit_msg)
28
+ Gitmine::Issue.should_receive(:parse_for_issue_id).with(commit_msg)
29
+ Gitmine::Issue.get_for_commit(commit_msg)
30
30
  end
31
31
  end
32
32
 
33
33
  describe "#get (class method)" do
34
34
  it "should build_via_issue_id" do
35
- issue = Issue.new
36
- Issue.should_receive(:new) { issue }
35
+ issue = Gitmine::Issue.new
36
+ Gitmine::Issue.should_receive(:new) { issue }
37
37
  issue.should_receive(:build_via_issue_id)
38
- Issue.get(123)
38
+ Gitmine::Issue.get(123)
39
39
  end
40
40
  end
41
41
 
data/spec/spec_helper.rb CHANGED
@@ -15,4 +15,4 @@ Rspec.configure do |config|
15
15
  config.mock_with :rspec
16
16
  end
17
17
 
18
- Issue::CONFIG_FILE = File.join(File.dirname(__FILE__), 'config.yml')
18
+ Gitmine::Issue::CONFIG_FILE = File.join(File.dirname(__FILE__), 'config.yml')
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 2
9
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Philippe Creux
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-27 00:00:00 -07:00
17
+ date: 2010-08-11 00:00:00 -07:00
18
18
  default_executable: gitmine
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency