pivotal_to_pdf 0.5.2.1 → 0.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ v0.6
2
+ * The points section will be printed only for features. Bugs and Chores don't
3
+ have points
4
+ * Printed a green bounding box for feature, a yellow box for chores and a red
5
+ box for bugs
1
6
  v0.5.2.1 Fixed a manifest problem
2
7
  v0.5.2 Printed labels to the cards
3
8
  v0.5.1 minor improvement over printing estimate, owned by
data/Manifest CHANGED
@@ -10,7 +10,8 @@ lib/pivotal_to_pdf/iteration.rb
10
10
  lib/pivotal_to_pdf/pdf_writer.rb
11
11
  lib/pivotal_to_pdf/pivotal.rb
12
12
  lib/pivotal_to_pdf/story.rb
13
+ pivotal_to_pdf.gemspec
14
+ spec/pivotal_to_pdf/story_spec.rb
13
15
  spec/pivotal_to_pdf_bin_spec.rb
14
16
  spec/spec_helper.rb
15
- spec/story_spec.rb
16
17
  tasks/spec.rb
data/README.md CHANGED
@@ -10,7 +10,7 @@ I steal the part of code from http://ephemera.karmi.cz/post/622136360/create-pri
10
10
  $ [sudo] gem install pivotal_to_pdf
11
11
 
12
12
  ## USAGE
13
- First you need to create a .pivotal.yml under your home directory. No idea how you do this under Windows so no support to Windows yet
13
+ First you need to create a .pivotal.yml under your home directory. On windows, have this file in %HOME%.pivotal.yml
14
14
 
15
15
  a sample .pivotal.yml:
16
16
 
@@ -22,9 +22,12 @@ After install the gem, you can do:
22
22
  * pivotal_to_pdf iteration # print stories for the current iteration into a PDF file
23
23
  * pivotal_to_pdf story STORY_ID # print a single story specifed by ID into a PDF file
24
24
 
25
-
26
25
  The gem will then read the story/stories and print it into a PDF file
27
26
 
27
+ The points section will be printed only for features. Bugs and Chores don't have points
28
+
29
+ Printed a green bounding box for feature, a yellow box for chores and a red box for bugs
30
+
28
31
  The gem assumes that you have https access to the pivotal tracker
29
32
 
30
33
  ##Contributors
data/bin/pivotal_to_pdf CHANGED
@@ -4,14 +4,16 @@ require 'pivotal_to_pdf'
4
4
  require 'thor'
5
5
 
6
6
  class PivotalToPdfApp < Thor
7
- desc "story STORY_ID", "print a single story specifed by ID into a PDF file"
7
+ desc "story STORY_ID", "print a single story specifed by ID into a PDF file. The card will have a color stripe. The color will be green for features, yellow for chores and red for bugs"
8
+ method_option :nocolor, :aliases => "-nc", :desc => "Make the card having no color stripe"
8
9
  def story(story_id)
9
- PivotalToPdf.story story_id
10
+ PivotalToPdf.story story_id, options[:nocolor]
10
11
  end
11
12
 
12
13
  desc "iteration", "print stories for the current iteration into a PDF file"
14
+ method_option :nocolor, :aliases => "-nc", :desc => "Make the card having no color stripe"
13
15
  def iteration(iteration_number = "current")
14
- PivotalToPdf.iteration iteration_number
16
+ PivotalToPdf.iteration iteration_number, options[:nocolor]
15
17
  end
16
18
  end
17
19
 
@@ -6,7 +6,7 @@ require 'rainbow'
6
6
 
7
7
  class PdfWriter
8
8
  attr_reader :story_or_iteration, :stories
9
- def initialize(story_or_iteration)
9
+ def initialize(story_or_iteration, colored_stripe = true)
10
10
  @story_or_iteration = story_or_iteration
11
11
  @stories = story_or_iteration.is_a?(Iteration) ? story_or_iteration.stories : [story_or_iteration]
12
12
  p stories.size
@@ -22,13 +22,13 @@ class PdfWriter
22
22
  # pdf.start_new_page
23
23
 
24
24
  stories.each_with_index do |story, index|
25
- padding = 12
26
- pdf.stroke_color = "666666"
25
+ padding = 10
26
+ pdf.stroke_color = story.story_color
27
27
  pdf.stroke_bounds
28
28
  width = 370
29
29
  # --- Write content
30
30
  pdf.bounding_box [pdf.bounds.left+padding, pdf.bounds.top-padding], :width => width do
31
- pdf.text "#{story.id} - #{story.name}", :size => 14
31
+ pdf.text story.name, :size => 14
32
32
  pdf.fill_color "52D017"
33
33
  pdf.text story.label_text, :size => 8
34
34
  pdf.text "\n", :size => 14
@@ -37,8 +37,7 @@ class PdfWriter
37
37
  pdf.fill_color "000000"
38
38
  end
39
39
 
40
- pdf.text_box "Points: " + (story.respond_to?(:estimate) && !story.estimate.eql?(-1) ? story.estimate.to_s : "Not yet estimated"),
41
- :size => 12, :at => [12, 50], :width => width-18
40
+ pdf.text_box story.points, :size => 12, :at => [12, 50], :width => width-18 unless story.points.nil?
42
41
  pdf.text_box "Owner: " + (story.respond_to?(:owned_by) ? story.owned_by : "None"),
43
42
  :size => 8, :at => [12, 18], :width => width-18
44
43
 
@@ -50,7 +49,7 @@ class PdfWriter
50
49
  pdf.number_pages "<page>/<total>", [pdf.bounds.right-16, -28]
51
50
 
52
51
  puts ">>> Generated PDF file in '#{story_or_iteration.id}.pdf'".foreground(:green)
53
- end
52
+ end
54
53
  rescue Exception
55
54
  puts "[!] There was an error while generating the PDF file... What happened was:".foreground(:red)
56
55
  raise
@@ -3,4 +3,23 @@ class Story < Pivotal
3
3
  return "" if !self.respond_to?(:labels) || self.labels.nil? || self.labels.empty?
4
4
  labels
5
5
  end
6
+
7
+ def points
8
+ return nil unless self.feature?
9
+ "Points: " + (self.respond_to?(:estimate) && !self.estimate.eql?(-1) ? self.estimate.to_s : "Not yet estimated")
10
+ end
11
+
12
+ def story_color
13
+ return "52D017" if feature?
14
+ return "FF0000" if bug?
15
+ return "FFFF00" if chore?
16
+ end
17
+
18
+ private
19
+
20
+ ["feature", "bug", "chore"].each do |type_str|
21
+ define_method "#{type_str}?".to_sym do
22
+ self.story_type == type_str
23
+ end
24
+ end
6
25
  end
@@ -8,14 +8,14 @@ require 'pivotal_to_pdf/story'
8
8
  require 'pivotal_to_pdf/pdf_writer'
9
9
  class PivotalToPdf < Thor
10
10
  class << self
11
- def story(story_id)
11
+ def story(story_id, colored_stripe=true)
12
12
  story = Story.find(story_id)
13
- PdfWriter.new(story).write_to
13
+ PdfWriter.new(story, colored_stripe).write_to
14
14
  end
15
15
 
16
- def iteration(iteration_token)
16
+ def iteration(iteration_token, colored_stripe=true)
17
17
  iteration = Iteration.find(:all, :params => {:group => iteration_token}).first
18
- PdfWriter.new(iteration).write_to
18
+ PdfWriter.new(iteration, colored_stripe).write_to
19
19
  end
20
20
  end
21
21
  end
@@ -2,26 +2,24 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{pivotal_to_pdf}
5
- s.version = "0.5.2.1"
5
+ s.version = "0.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Yi Wen"]
9
- s.date = %q{2010-12-19}
10
- s.default_executable = %q{pivotal_to_pdf}
9
+ s.date = %q{2011-04-26}
11
10
  s.description = %q{Convert Pivotal Tracker Stories to 4x6 PDF for printing so that you can stick the card to your story board}
12
11
  s.email = %q{hayafirst@gmail.com}
13
12
  s.executables = ["pivotal_to_pdf"]
14
13
  s.extra_rdoc_files = ["CHANGELOG", "README.md", "bin/pivotal_to_pdf", "lib/pivotal_to_pdf.rb", "lib/pivotal_to_pdf/iteration.rb", "lib/pivotal_to_pdf/pdf_writer.rb", "lib/pivotal_to_pdf/pivotal.rb", "lib/pivotal_to_pdf/story.rb", "tasks/spec.rb"]
15
- s.files = ["CHANGELOG", "Gemfile", "Gemfile.lock", "Manifest", "README.md", "Rakefile", "bin/pivotal_to_pdf", "lib/pivotal_to_pdf.rb", "lib/pivotal_to_pdf/iteration.rb", "lib/pivotal_to_pdf/pdf_writer.rb", "lib/pivotal_to_pdf/pivotal.rb", "lib/pivotal_to_pdf/story.rb", "spec/pivotal_to_pdf_bin_spec.rb", "spec/spec_helper.rb", "spec/story_spec.rb", "tasks/spec.rb", "pivotal_to_pdf.gemspec"]
14
+ s.files = ["CHANGELOG", "Gemfile", "Gemfile.lock", "Manifest", "README.md", "Rakefile", "bin/pivotal_to_pdf", "lib/pivotal_to_pdf.rb", "lib/pivotal_to_pdf/iteration.rb", "lib/pivotal_to_pdf/pdf_writer.rb", "lib/pivotal_to_pdf/pivotal.rb", "lib/pivotal_to_pdf/story.rb", "pivotal_to_pdf.gemspec", "spec/pivotal_to_pdf/story_spec.rb", "spec/pivotal_to_pdf_bin_spec.rb", "spec/spec_helper.rb", "tasks/spec.rb"]
16
15
  s.homepage = %q{https://github.com/ywen/pivotal_to_pdf}
17
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Pivotal_to_pdf", "--main", "README.md"]
18
17
  s.require_paths = ["lib"]
19
18
  s.rubyforge_project = %q{pivotal_to_pdf}
20
- s.rubygems_version = %q{1.3.7}
19
+ s.rubygems_version = %q{1.7.2}
21
20
  s.summary = %q{Convert Pivotal Tracker Stories to 4x6 PDF for printing}
22
21
 
23
22
  if s.respond_to? :specification_version then
24
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
23
  s.specification_version = 3
26
24
 
27
25
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -0,0 +1,82 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
2
+
3
+ describe Story do
4
+ let(:story){Story.new :labels => [], :story_type => nil}
5
+ describe "#label_text" do
6
+ describe "and there is no label" do
7
+ it "should return blank string" do
8
+ story = Story.new
9
+ story.label_text.should == ""
10
+ end
11
+ end
12
+ describe "and labels is empty" do
13
+ it "should return blank string" do
14
+ story.label_text.should == ""
15
+ end
16
+ end
17
+ describe "and labels is nil" do
18
+ it "should return blank string" do
19
+ story.labels = nil
20
+ story.label_text.should == ""
21
+ end
22
+ end
23
+
24
+ describe "and when there are less than 3 labels" do
25
+ it "should return them in a nice format" do
26
+ story.labels="test1, test2"
27
+ story.label_text.should == "test1, test2"
28
+ end
29
+ end
30
+ end
31
+
32
+ describe "#points" do
33
+ describe "and the story is not a feature" do
34
+ before(:each) do
35
+ story.story_type = "bug"
36
+ end
37
+ it "should return nil" do
38
+ story.points.should be_nil
39
+ end
40
+ end
41
+ describe "and the story is a feature" do
42
+ before(:each) do
43
+ story.story_type = "feature"
44
+ end
45
+ describe "and the story is not respond_to estimate" do
46
+ it "should return Not yet estimated" do
47
+ story.points.should == "Points: Not yet estimated"
48
+ end
49
+ end
50
+
51
+ describe "and the story is respond_to estimate" do
52
+ let(:story) {Story.new :story_type => "feature", :estimate => -1}
53
+ describe "and the estimate is -1" do
54
+ it "should return not yet estimated" do
55
+ story.points.should == "Points: Not yet estimated"
56
+ end
57
+ end
58
+ describe "and the estimate is not -1" do
59
+ it "should return the points" do
60
+ story.estimate = 5
61
+ story.points.should == "Points: 5"
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ describe "#story_color" do
69
+ it "should return green for features" do
70
+ story.story_type = "feature"
71
+ story.story_color.should == "52D017"
72
+ end
73
+ it "should return red for bugs" do
74
+ story.story_type = "bug"
75
+ story.story_color.should == "FF0000"
76
+ end
77
+ it "should return yellow for chores" do
78
+ story.story_type = "chore"
79
+ story.story_color.should == "FFFF00"
80
+ end
81
+ end
82
+ end
@@ -4,19 +4,33 @@ load File.expand_path(File.join(File.dirname(__FILE__), "..", "bin", "pivotal_to
4
4
  describe 'PivotalToPdf Bin' do
5
5
  describe "when pased in story sub command" do
6
6
  it "should call story" do
7
- PivotalToPdf.should_receive(:story).with(123)
7
+ PivotalToPdf.should_receive(:story).with(123, nil)
8
8
  PivotalToPdfApp.start(["story", 123])
9
9
  end
10
10
  it "should not call story when no story id is given" do
11
11
  PivotalToPdf.should_not_receive(:story)
12
12
  PivotalToPdfApp.start(["story"])
13
13
  end
14
+
15
+ describe "and when the nocolor option is defined" do
16
+ it "should pass the option in" do
17
+ PivotalToPdf.should_receive(:story).with(123, "nocolor")
18
+ PivotalToPdfApp.start(["story", 123, "--nocolor"])
19
+ end
20
+ end
14
21
  end
15
22
  describe "when pased in iteration sub command" do
16
23
  it "should call iteration" do
17
- PivotalToPdf.should_receive(:iteration).with(123)
24
+ PivotalToPdf.should_receive(:iteration).with(123, nil)
18
25
  PivotalToPdfApp.start(["iteration", 123])
19
26
  end
27
+
28
+ describe "and when the nocolor option is defined" do
29
+ it "should pass the option in" do
30
+ PivotalToPdf.should_receive(:iteration).with(123, "nocolor")
31
+ PivotalToPdfApp.start(["iteration", 123, "--nocolor"])
32
+ end
33
+ end
20
34
  end
21
35
  end
22
36
 
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pivotal_to_pdf
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 5
8
- - 2
9
- - 1
10
- version: 0.5.2.1
4
+ prerelease:
5
+ version: "0.6"
11
6
  platform: ruby
12
7
  authors:
13
8
  - Yi Wen
@@ -15,8 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2010-12-19 00:00:00 -06:00
19
- default_executable:
13
+ date: 2011-04-26 00:00:00 Z
20
14
  dependencies:
21
15
  - !ruby/object:Gem::Dependency
22
16
  name: activeresource
@@ -26,8 +20,6 @@ dependencies:
26
20
  requirements:
27
21
  - - ">="
28
22
  - !ruby/object:Gem::Version
29
- segments:
30
- - 0
31
23
  version: "0"
32
24
  type: :runtime
33
25
  version_requirements: *id001
@@ -39,8 +31,6 @@ dependencies:
39
31
  requirements:
40
32
  - - ">="
41
33
  - !ruby/object:Gem::Version
42
- segments:
43
- - 0
44
34
  version: "0"
45
35
  type: :runtime
46
36
  version_requirements: *id002
@@ -52,8 +42,6 @@ dependencies:
52
42
  requirements:
53
43
  - - ">="
54
44
  - !ruby/object:Gem::Version
55
- segments:
56
- - 0
57
45
  version: "0"
58
46
  type: :runtime
59
47
  version_requirements: *id003
@@ -65,8 +53,6 @@ dependencies:
65
53
  requirements:
66
54
  - - ">="
67
55
  - !ruby/object:Gem::Version
68
- segments:
69
- - 0
70
56
  version: "0"
71
57
  type: :runtime
72
58
  version_requirements: *id004
@@ -99,12 +85,11 @@ files:
99
85
  - lib/pivotal_to_pdf/pdf_writer.rb
100
86
  - lib/pivotal_to_pdf/pivotal.rb
101
87
  - lib/pivotal_to_pdf/story.rb
88
+ - pivotal_to_pdf.gemspec
89
+ - spec/pivotal_to_pdf/story_spec.rb
102
90
  - spec/pivotal_to_pdf_bin_spec.rb
103
91
  - spec/spec_helper.rb
104
- - spec/story_spec.rb
105
92
  - tasks/spec.rb
106
- - pivotal_to_pdf.gemspec
107
- has_rdoc: true
108
93
  homepage: https://github.com/ywen/pivotal_to_pdf
109
94
  licenses: []
110
95
 
@@ -123,22 +108,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
108
  requirements:
124
109
  - - ">="
125
110
  - !ruby/object:Gem::Version
126
- segments:
127
- - 0
128
111
  version: "0"
129
112
  required_rubygems_version: !ruby/object:Gem::Requirement
130
113
  none: false
131
114
  requirements:
132
115
  - - ">="
133
116
  - !ruby/object:Gem::Version
134
- segments:
135
- - 1
136
- - 2
137
117
  version: "1.2"
138
118
  requirements: []
139
119
 
140
120
  rubyforge_project: pivotal_to_pdf
141
- rubygems_version: 1.3.7
121
+ rubygems_version: 1.7.2
142
122
  signing_key:
143
123
  specification_version: 3
144
124
  summary: Convert Pivotal Tracker Stories to 4x6 PDF for printing
data/spec/story_spec.rb DELETED
@@ -1,31 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
2
-
3
- describe Story do
4
- let(:story){Story.new :labels => []}
5
- describe "when asked for label text" do
6
- describe "and there is no label" do
7
- it "should return blank string" do
8
- story = Story.new
9
- story.label_text.should == ""
10
- end
11
- end
12
- describe "and labels is empty" do
13
- it "should return blank string" do
14
- story.label_text.should == ""
15
- end
16
- end
17
- describe "and labels is nil" do
18
- it "should return blank string" do
19
- story.labels = nil
20
- story.label_text.should == ""
21
- end
22
- end
23
-
24
- describe "and when there are less than 3 labels" do
25
- it "should return them in a nice format" do
26
- story.labels="test1, test2"
27
- story.label_text.should == "test1, test2"
28
- end
29
- end
30
- end
31
- end