git-pivotal 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  pkg
2
+ coverage
2
3
  *.gem
data/Rakefile CHANGED
@@ -20,6 +20,7 @@ begin
20
20
  gemspec.add_dependency "rest-client"
21
21
 
22
22
  gemspec.add_development_dependency "rspec"
23
+ gemspec.add_development_dependency "mocha"
23
24
  end
24
25
 
25
26
  Jeweler::GemcutterTasks.new
@@ -29,4 +30,6 @@ end
29
30
 
30
31
  Spec::Rake::SpecTask.new do |t|
31
32
  t.warning = true
33
+ t.rcov = true
34
+ t.rcov_opts = ['--exclude', 'gems']
32
35
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/git-pivotal.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{git-pivotal}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeff Tucker"]
12
- s.date = %q{2010-01-27}
12
+ s.date = %q{2010-01-29}
13
13
  s.default_executable = %q{git-pick}
14
14
  s.description = %q{A collection of git utilities to ease integration with Pivotal Tracker}
15
15
  s.email = %q{jeff@trydionel.com}
@@ -66,15 +66,18 @@ Gem::Specification.new do |s|
66
66
  s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
67
67
  s.add_runtime_dependency(%q<rest-client>, [">= 0"])
68
68
  s.add_development_dependency(%q<rspec>, [">= 0"])
69
+ s.add_development_dependency(%q<mocha>, [">= 0"])
69
70
  else
70
71
  s.add_dependency(%q<nokogiri>, [">= 0"])
71
72
  s.add_dependency(%q<rest-client>, [">= 0"])
72
73
  s.add_dependency(%q<rspec>, [">= 0"])
74
+ s.add_dependency(%q<mocha>, [">= 0"])
73
75
  end
74
76
  else
75
77
  s.add_dependency(%q<nokogiri>, [">= 0"])
76
78
  s.add_dependency(%q<rest-client>, [">= 0"])
77
79
  s.add_dependency(%q<rspec>, [">= 0"])
80
+ s.add_dependency(%q<mocha>, [">= 0"])
78
81
  end
79
82
  end
80
83
 
data/lib/commands/pick.rb CHANGED
@@ -33,9 +33,11 @@ private
33
33
  def parse_gitconfig
34
34
  token = get("git config --get pivotal.api-token").strip
35
35
  id = get("git config --get pivotal.project-id").strip
36
+ name = get("git config --get pivotal.full-name").strip
36
37
 
37
38
  @options[:api_token] = token if token
38
39
  @options[:project_id] = id if id
40
+ @options[:full_name] = name if name
39
41
  end
40
42
 
41
43
  def parse_argv(*args)
@@ -43,6 +45,7 @@ private
43
45
  opts.banner = "Usage: git pick [options]"
44
46
  opts.on("-k", "--api-key=", "Pivotal Tracker API key") { |k| @options[:api_token] = k }
45
47
  opts.on("-p", "--project-id=", "Pivotal Trakcer project id") { |p| @options[:project_id] = p }
48
+ opts.on("-n", "--full-name=", "Pivotal Trakcer full name") { |n| @options[:full_name] = n }
46
49
  opts.on("-q", "--quiet", "Quiet, no-interaction mode") { |q| @options[:quiet] = q }
47
50
  opts.on("-v", "--[no-]verbose", "Run verbosely") { |v| @options[:verbose] = v }
48
51
  opts.on_tail("-h", "--help", "This usage guide") { puts opts; exit 0 }
@@ -110,7 +113,7 @@ private
110
113
 
111
114
  def start_story(story)
112
115
  puts "Updating story status in Pivotal Tracker..."
113
- story.start!
116
+ story.start!(:owned_by => @options[:full_name])
114
117
  end
115
118
 
116
119
  end
data/lib/pivotal/base.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'rest_client'
3
3
  require 'nokogiri'
4
+ require 'builder'
4
5
 
5
6
  module Pivotal
6
7
  class Base
@@ -27,9 +28,36 @@ module Pivotal
27
28
  parsed_resource.css(method.to_s).text
28
29
  end
29
30
 
31
+ def update_attributes(options = {})
32
+ @xml = resource.put generate_xml(options)
33
+ end
34
+
30
35
  class << self
36
+ def name_as_xml_attribute
37
+ self.name.gsub(/.+\:\:/, '').downcase
38
+ end
39
+
31
40
  def xpath
32
- '//' + self.name.gsub(/.+\:\:/, '').downcase
41
+ '//' + self.name_as_xml_attribute
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ def generate_xml(options = {})
48
+ builder = Builder::XmlMarkup.new
49
+ allowed_keys(options).each do |key, value|
50
+ builder.key(value.to_s)
51
+ end
52
+
53
+ builder
54
+ end
55
+
56
+ def allowed_keys(options = {})
57
+ options.reject do |key, _|
58
+ !%w[id story_type url estimate current_state
59
+ description name requested_by owned_by
60
+ created_at accepted_at labels].include? key.to_s
33
61
  end
34
62
  end
35
63
 
data/lib/pivotal/story.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Pivotal
2
2
  class Story < Base
3
3
 
4
- def start!
5
- resource.put "<story><current_state>started</current_state></story>"
4
+ def start!(options = {})
5
+ update_attributes(options.merge(:current_state => :started))
6
6
  end
7
7
 
8
8
  end
data/readme.markdown CHANGED
@@ -1,10 +1,10 @@
1
1
  #Git Pivotal
2
2
 
3
3
  ##Prelude
4
- You might want to have [this song]("http://www.dailymotion.com/video/x9vzh0_olivia-newton-john-lets-get-physica_music") running in the background while you read this.
4
+ You might want to have [this song](http://www.dailymotion.com/video/x9vzh0_olivia-newton-john-lets-get-physica_music) running in the background while you read this.
5
5
 
6
6
  ##Let's Git Pivotal
7
- Inspired by [Hashrocket's blend of git and Pivotal Tracker]("http://reinh.com/blog/2009/03/02/a-git-workflow-for-agile-teams.html"), I set off to create a set of utilities to simplify the workflow between the two.
7
+ Inspired by [Hashrocket's blend of git and Pivotal Tracker](http://reinh.com/blog/2009/03/02/a-git-workflow-for-agile-teams.html) and [a popular article on effective git workflows](http://nvie.com/archives/323), I set off to create a set of utilities to simplify the workflow between the two.
8
8
 
9
9
  ###Git Pick
10
10
  This selects the top-most available feature from your Pivotal Tracker, and offers to create a feature branch.
@@ -21,13 +21,27 @@ This selects the top-most available feature from your Pivotal Tracker, and offer
21
21
  2 git-pick:feature-1234567 %
22
22
 
23
23
  ##Installation
24
- Some long process to actually install it. Working on that.
25
- Once installed, git pivotal needs two bits of info: your Pivotal Tracker API Token and your Pivotal Tracker project id. The former is best set as a global git config option:
24
+ To install git-pivotal, simply run
25
+
26
+ [sudo] gem install git-pivotal
27
+
28
+ <h2 id="config">Configuration</h2>
29
+ Once installed, git pivotal needs three bits of info: your Pivotal Tracker API Token, your name as it appears in Pivotal Tracker and your Pivotal Tracker project id. The former two are best set as a global git config options:
26
30
 
27
31
  git config --global pivotal.api-token 9a9a9a9a9a9a9a9a9a9a
32
+ git config --global pivotal.full-name "Jeff Tucker"
28
33
 
29
34
  The project id is best placed within your project's git config:
30
35
 
31
36
  git config -f .git/config pivotal.project-id 88888
32
37
 
33
- If you're not interested in storing these options in git, you can pass them into git pivotal as command line arguments. See the usage guides for more details.
38
+ If you're not interested in storing these options in git, you can pass them into git pivotal as command line arguments. See the usage guides for more details.
39
+
40
+ ##TODO
41
+ This is <del>some seriously</del> alpha software. Several things on the ol' todo list:
42
+
43
+ * <del>Create a general Pivotal::Base#update_attributes method</del>
44
+ * <del>`git pick` doesn't update the story to indicate who claimed it</del>
45
+ * Add command to close/finish currently 'picked' feature
46
+ * Reduce verbosity of `git pick`
47
+ * More that I can't recall at the moment
@@ -33,4 +33,31 @@ describe Pivotal::Base do
33
33
  @base.class.should include(Pivotal::Associations)
34
34
  end
35
35
 
36
+ describe "updating the remote resource" do
37
+
38
+ before(:each) do
39
+ @xml = "<story><current_state>started</current_state></story>"
40
+ @base.resource.expects(:put).with(@xml).returns(@xml)
41
+ end
42
+
43
+ it "should be able to update the remote resource with a hash of string values" do
44
+ @base.update_attributes(:current_state => "started")
45
+ end
46
+
47
+ it "should be able to update the remote resource with a hash of symbol values" do
48
+ @base.update_attributes(:current_state => :started)
49
+ end
50
+
51
+ it "should not update attributes which don't exist on the remote model" do
52
+ @base.update_attributes(:unknown_attribute => true)
53
+ end
54
+
55
+ it "should update the stored xml with the new remote model" do
56
+ lambda {
57
+ @base.update_attributes(:current_state => "started")
58
+ }.should change(@base, :xml).to(@xml)
59
+ end
60
+
61
+ end
62
+
36
63
  end
@@ -12,4 +12,18 @@ describe Pivotal::Story do
12
12
  @story.resource.url.should == "https://www.pivotaltracker.com/services/v3/projects/1/stories/1"
13
13
  end
14
14
 
15
+ it "should be able to mark the story as started" do
16
+ @xml = "<story><current_state>started</current_state></story>"
17
+ @story.resource.expects(:put).with(@xml)
18
+
19
+ @story.start!
20
+ end
21
+
22
+ it "should be able to update other attributes when marking the story as started" do
23
+ @xml = "<story><current_state>started</current_state><owned_by>Jeff Tucker</owned_by></story>"
24
+ @story.resource.expects(:put).with(@xml)
25
+
26
+ @story.start!(:owned_by => "Jeff Tucker")
27
+ end
28
+
15
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-pivotal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Tucker
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-27 00:00:00 -05:00
12
+ date: 2010-01-29 00:00:00 -05:00
13
13
  default_executable: git-pick
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,6 +42,16 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: "0"
44
44
  version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: mocha
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
45
55
  description: A collection of git utilities to ease integration with Pivotal Tracker
46
56
  email: jeff@trydionel.com
47
57
  executables: