ptb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (8) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README +0 -0
  3. data/README.rdoc +0 -0
  4. data/bin/ptb +12 -0
  5. data/lib/ptb/cli.rb +77 -0
  6. data/lib/ptb.rb +7 -0
  7. data/ptb.gemspec +21 -0
  8. metadata +102 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) <%= Time.now.year %> <%= answers[:author] %>
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 ADDED
File without changes
data/README.rdoc ADDED
File without changes
data/bin/ptb ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/ruby
2
+
3
+ if File.exists?(File.join(File.expand_path('../..', __FILE__), '.git'))
4
+ lib_path = File.expand_path('../../lib', __FILE__)
5
+ $:.unshift(lib_path)
6
+ end
7
+
8
+ require 'rubygems'
9
+ require 'ptb'
10
+ require 'ptb/cli'
11
+
12
+ Ptb::CLI.start
data/lib/ptb/cli.rb ADDED
@@ -0,0 +1,77 @@
1
+ module Ptb
2
+ class CLI < Thor
3
+ def initialize(*)
4
+ super
5
+
6
+ Signal.trap("SIGINT") do
7
+ exit!
8
+ end
9
+ end
10
+
11
+ default_task :branch
12
+
13
+ desc "branch", "List git branches with related PivotalTracker story information."
14
+ def branch
15
+ branches=`git branch`
16
+
17
+ branches.each_line do |line|
18
+ branch = line[2..-2]
19
+ if branch =~ /^[0-9]+$/
20
+ if story = project.stories.find(branch)
21
+ say "#{line.rstrip} [#{story.current_state}] #{story.name} (#{story.url})"
22
+ else
23
+ say line.rstrip
24
+ end
25
+ else
26
+ say line.rstrip
27
+ end
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def choose(prompt, choices, confirm=false)
34
+ selection = nil
35
+ say ""
36
+ choices.each_with_index do |option, index|
37
+ say "#{index}) #{option[0]}"
38
+ end
39
+ until selection do
40
+ say ""
41
+ selection_index = ask(prompt)
42
+ selection = choices[selection_index.to_i]
43
+ if selection and confirm
44
+ say ""
45
+ selection = nil unless yes?("#{selection[0]}? (yn):")
46
+ end
47
+ end
48
+ say ""
49
+ return selection[1]
50
+ end
51
+
52
+ # PivotalTracker::Client.token='3bf308bd729d2d87637a157bc6d2830d'
53
+ def project
54
+ return @project if @project
55
+
56
+ if File.exists?(".ptbrc")
57
+ config = YAML.load(File.read(".ptbrc"))
58
+ PivotalTracker::Client.token=config['token']
59
+ @project = PivotalTracker::Project.find(config['project'])
60
+ else
61
+ config = {}
62
+ PivotalTracker::Client.token = config['token'] = ask("Enter your PivotalTracker API token:")
63
+ @project = choose("Select a project:", PivotalTracker::Project.all.map{|p| [p.name, p]})
64
+ config['project'] = @project.id
65
+ File.open('.ptbrc', 'w') do |file|
66
+ file.write(config.to_yaml)
67
+ end
68
+ end
69
+
70
+ @project
71
+
72
+ rescue
73
+ exit
74
+ end
75
+
76
+ end
77
+ end
data/lib/ptb.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'thor'
2
+ require 'yaml'
3
+ require 'pivotal-tracker'
4
+
5
+ module Ptb
6
+
7
+ end
data/ptb.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ Gem::Specification.new do |s|
2
+ s.platform = Gem::Platform::RUBY
3
+ s.name = "ptb"
4
+ s.version = "0.0.1"
5
+ s.authors = ["Anthony Crumley"]
6
+ s.email = ["anthony.crumley@gmail.com"]
7
+ s.homepage = "http://craftyco.de"
8
+ s.summary = %q{A mash up of PivotalTracker and git that makes a one to one story to branch mapping a lot of fun.}
9
+ s.description = %q{A mash up of PivotalTracker and git that makes a one to one story to branch mapping a lot of fun. It also works nicely with the pt PivotalTracker commandline gem. When branches are named by the PivotalTracker story id ptb will will do a git branch and list each story id branch with status, title and link to the story.}
10
+
11
+ s.rubyforge_project = "ptb"
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
+ s.require_paths = ["lib"]
16
+
17
+ # specify any dependencies here; for example:
18
+ # s.add_development_dependency "rspec"
19
+ s.add_runtime_dependency "pivotal-tracker"
20
+ s.add_runtime_dependency "thor"
21
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ptb
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Anthony Crumley
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-02-19 00:00:00 -06:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: pivotal-tracker
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: thor
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ description: A mash up of PivotalTracker and git that makes a one to one story to branch mapping a lot of fun. It also works nicely with the pt PivotalTracker commandline gem. When branches are named by the PivotalTracker story id ptb will will do a git branch and list each story id branch with status, title and link to the story.
50
+ email:
51
+ - anthony.crumley@gmail.com
52
+ executables:
53
+ - ptb
54
+ extensions: []
55
+
56
+ extra_rdoc_files: []
57
+
58
+ files:
59
+ - MIT-LICENSE
60
+ - README
61
+ - README.rdoc
62
+ - bin/ptb
63
+ - lib/ptb.rb
64
+ - lib/ptb/cli.rb
65
+ - ptb-0.0.1.gem
66
+ - ptb.gemspec
67
+ has_rdoc: true
68
+ homepage: http://craftyco.de
69
+ licenses: []
70
+
71
+ post_install_message:
72
+ rdoc_options: []
73
+
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ hash: 3
82
+ segments:
83
+ - 0
84
+ version: "0"
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ hash: 3
91
+ segments:
92
+ - 0
93
+ version: "0"
94
+ requirements: []
95
+
96
+ rubyforge_project: ptb
97
+ rubygems_version: 1.3.7
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: A mash up of PivotalTracker and git that makes a one to one story to branch mapping a lot of fun.
101
+ test_files: []
102
+