pivotal_to_pdf 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.travis.yml CHANGED
@@ -1,3 +1,4 @@
1
1
  script: "cp .pivotal.yml.sample .pivotal.yml; PIVOTAL_TO_PDF_CONFIG_DIR=. bundle exec rake spec"
2
2
  rvm:
3
+ - 1.9.3
3
4
  - ree
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ v1.1.0
2
+ * Add label command for printing stories matching any given label
3
+ v1.0.0
4
+ * Rename iteration command to current_iteration command
5
+ * Add iteration command for printing any given iterations
1
6
  v0.9.1
2
7
  * A bug fix where a nil description or name field will break the PDF generation
3
8
  v0.9
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  pivotal_to_pdf -- print the stories from pivotal tracker to a PDF file
2
2
  ====================================
3
3
 
4
- [![Build Status](http://travis-ci.org/ywen/pivotal_to_pdf.png)](http://travis-ci.org/ywen/pivotal_to_pdf)
4
+ [![Build Status](https://secure.travis-ci.org/ywen/pivotal_to_pdf.png)](http://travis-ci.org/ywen/pivotal_to_pdf)
5
5
 
6
6
  ## DESCRIPTION
7
7
  This is a gem that can read a story from pivotal tracker and print into a 4x6 card so that you can print the card and stick to your physical story board.
@@ -25,7 +25,9 @@ After install the gem, you can do:
25
25
 
26
26
  * pivotal_to_pdf story STORY_ID # print a single story specifed by ID into a PDF file
27
27
 
28
- * pivotal_to_pdf iteration iteration_number # print a single iteration specifed by the number into a PDF file
28
+ * pivotal_to_pdf iteration ITERATION_NUMBER # print a single iteration specifed by the number into a PDF file
29
+
30
+ * pivotal_to_pdf label LABEL_TEXT # print stories matching the specified label into a PDF file
29
31
 
30
32
  Examples:
31
33
 
@@ -36,6 +38,8 @@ pivotal_to_pdf story 159898
36
38
  pivotal_to_pdf current_iteration
37
39
 
38
40
  pivotal_to_pdf iteration 42
41
+
42
+ pivotal_to_pdf label print-these
39
43
  ```
40
44
 
41
45
  Type in
@@ -43,11 +47,7 @@ Type in
43
47
  ```bash
44
48
  pivotal_to_pdf help
45
49
 
46
- pivotal_to_pdf help story
47
-
48
- pivotal_to_pdf help current_iteration
49
-
50
- pivotal_to_pdf help iteration
50
+ pivotal_to_pdf help <command>
51
51
  ```
52
52
 
53
53
  for more usage information
@@ -66,3 +66,4 @@ The gem assumes that you have https access to the pivotal tracker
66
66
  * Kristian Rasmussen
67
67
  * [Alastair Mair](https://github.com/amair)
68
68
  * [John-Mason P. Shackelford](https://github.com/jpshackelford)
69
+ * [mogul](https://github.com/mogul)
data/bin/pivotal_to_pdf CHANGED
@@ -18,6 +18,12 @@ class PivotalToPdfApp < Thor
18
18
  def iteration(iteration_number)
19
19
  PivotalToPdf::Main.iteration iteration_number
20
20
  end
21
+
22
+ desc "label LABEL", "print stories for the label specified into a PDF file"
23
+ def label(label_text)
24
+ PivotalToPdf::Main.label label_text
25
+ end
26
+
21
27
  end
22
28
 
23
29
  PivotalToPdfApp.start
@@ -6,15 +6,15 @@ require 'rainbow'
6
6
 
7
7
  module PivotalToPdf
8
8
  class PdfWriter
9
- attr_reader :story_or_iteration, :stories
10
- def initialize(story_or_iteration, colored_stripe = true)
11
- @story_or_iteration = story_or_iteration
12
- @stories = story_or_iteration.is_a?(Iteration) ? story_or_iteration.stories : [story_or_iteration]
9
+ attr_reader :stories
10
+ private :stories
11
+ def initialize(stories)
12
+ @stories = stories
13
13
  p stories.size
14
14
  end
15
15
 
16
- def write_to
17
- Prawn::Document.generate("#{story_or_iteration.id}.pdf",
16
+ def write_to(destination)
17
+ Prawn::Document.generate("#{destination}.pdf",
18
18
  :page_layout => :landscape,
19
19
  :margin => [25, 25, 50, 25],
20
20
  :page_size => [302, 432]) do |pdf|
@@ -52,7 +52,7 @@ module PivotalToPdf
52
52
  end
53
53
  # pdf.number_pages "<page>/<total>", {:at => [pdf.bounds.right - 16, -28]}
54
54
 
55
- puts ">>> Generated PDF file in '#{story_or_iteration.id}.pdf'".foreground(:green)
55
+ puts ">>> Generated PDF file in '#{destination}.pdf'".foreground(:green)
56
56
  end
57
57
  rescue Exception
58
58
  puts "[!] There was an error while generating the PDF file... What happened was:".foreground(:red)
@@ -0,0 +1,15 @@
1
+ # PivotalTracker has a bug in API v3 that breaks ActiveResource
2
+ # For more info, see http://community.pivotaltracker.com/pivotal/topics/activeresource_client_throws_error
3
+
4
+ class Hash
5
+ class << self
6
+ alias_method :from_xml_original, :from_xml
7
+ def from_xml(xml)
8
+ scrubbed = scrub_attributes(xml)
9
+ from_xml_original(scrubbed)
10
+ end
11
+ def scrub_attributes(xml)
12
+ xml.gsub(/<stories.*>/, "<stories type=\"array\">")
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module PivotalToPdf
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -8,22 +8,33 @@ require 'pivotal_to_pdf/pivotal'
8
8
  require 'pivotal_to_pdf/iteration'
9
9
  require 'pivotal_to_pdf/story'
10
10
  require 'pivotal_to_pdf/pdf_writer'
11
+ require 'pivotal_to_pdf/pt-workarounds'
12
+
13
+ # Uncomment the following to trace the URLs and results generated via ActiveResource
14
+ # require 'logger'
15
+ # ActiveResource::Base.logger = Logger.new(STDERR)
16
+
11
17
  module PivotalToPdf
12
18
  class Main < Thor
13
19
  class << self
14
20
  def story(story_id)
15
21
  story = Story.find(story_id)
16
- PivotalToPdf::PdfWriter.new(story).write_to
22
+ PivotalToPdf::PdfWriter.new([ story ]).write_to(story_id)
17
23
  end
18
24
 
19
25
  def current_iteration
20
26
  iteration = Iteration.find(:all, :params => {:group => "current"}).first
21
- PivotalToPdf::PdfWriter.new(iteration).write_to
27
+ PivotalToPdf::PdfWriter.new(iteration.stories).write_to("current")
22
28
  end
23
29
 
24
30
  def iteration(iteration_number)
25
31
  iteration = Iteration.find(:all, :params => {:offset => iteration_number.to_i - 1, :limit => 1}).first
26
- PivotalToPdf::PdfWriter.new(iteration).write_to
32
+ PivotalToPdf::PdfWriter.new(iteration.stories).write_to(iteration_number)
33
+ end
34
+
35
+ def label(label_text)
36
+ stories = Story.find(:all, :params => {:filter => "label:\"" + label_text + "\""})
37
+ PivotalToPdf::PdfWriter.new(stories).write_to(label_text)
27
38
  end
28
39
  end
29
40
  end
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
2
2
  load File.expand_path(File.join(File.dirname(__FILE__), "..", "bin", "pivotal_to_pdf"))
3
3
 
4
4
  describe 'PivotalToPdf Bin' do
5
- context "when pased in story sub command" do
5
+ context "when passed in story sub command" do
6
6
  it "should call story" do
7
7
  PivotalToPdf::Main.should_receive(:story).with(123)
8
8
  PivotalToPdfApp.start(["story", 123])
@@ -12,13 +12,23 @@ describe 'PivotalToPdf Bin' do
12
12
  PivotalToPdfApp.start(["story"])
13
13
  end
14
14
  end
15
- context "when pased in current_iteration sub command" do
15
+ context "when passed in label sub command" do
16
+ it "should call label" do
17
+ PivotalToPdf::Main.should_receive(:label).with("sometext")
18
+ PivotalToPdfApp.start(["label", "sometext"])
19
+ end
20
+ it "should not call label when no label text is given" do
21
+ PivotalToPdf::Main.should_not_receive(:label)
22
+ PivotalToPdfApp.start(["label"])
23
+ end
24
+ end
25
+ context "when passed in current_iteration sub command" do
16
26
  it "should call current_iteration" do
17
27
  PivotalToPdf::Main.should_receive(:current_iteration)
18
28
  PivotalToPdfApp.start(["current_iteration"])
19
29
  end
20
30
  end
21
- context "when pased in iteration sub command" do
31
+ context "when passed in iteration sub command" do
22
32
  it "should call iteration" do
23
33
  PivotalToPdf::Main.should_receive(:iteration).with("1")
24
34
  PivotalToPdfApp.start(["iteration", "1"])
@@ -16,7 +16,7 @@ module PivotalToPdf
16
16
  end
17
17
 
18
18
  it "build a pdf writer" do
19
- PivotalToPdf::PdfWriter.should_receive(:new).with(story).and_return writer
19
+ PivotalToPdf::PdfWriter.should_receive(:new).with([ story ]).and_return writer
20
20
  Main.story 23
21
21
  end
22
22
 
@@ -26,7 +26,8 @@ module PivotalToPdf
26
26
  end
27
27
  end
28
28
  describe ".current_iteration" do
29
- let(:iteration) {double :iteration}
29
+ let(:stories) {double :stories_from_iteration}
30
+ let(:iteration) {double :iteration, :stories => stories}
30
31
  before(:each) do
31
32
  Iteration.stub(:find).and_return [iteration, double]
32
33
  PivotalToPdf::PdfWriter.stub(:new).and_return writer
@@ -38,7 +39,7 @@ module PivotalToPdf
38
39
  end
39
40
 
40
41
  it "build a pdf writer" do
41
- PivotalToPdf::PdfWriter.should_receive(:new).with(iteration).and_return writer
42
+ PivotalToPdf::PdfWriter.should_receive(:new).with(stories).and_return writer
42
43
  Main.current_iteration
43
44
  end
44
45
 
@@ -49,7 +50,8 @@ module PivotalToPdf
49
50
  end
50
51
 
51
52
  describe ".iteration" do
52
- let(:iteration) {double :iteration}
53
+ let(:stories) {double :stories_from_iteration}
54
+ let(:iteration) {double :iteration, :stories => stories}
53
55
  before(:each) do
54
56
  Iteration.stub(:find).and_return [iteration, double]
55
57
  PivotalToPdf::PdfWriter.stub(:new).and_return writer
@@ -61,7 +63,7 @@ module PivotalToPdf
61
63
  end
62
64
 
63
65
  it "build a pdf writer" do
64
- PivotalToPdf::PdfWriter.should_receive(:new).with(iteration).and_return writer
66
+ PivotalToPdf::PdfWriter.should_receive(:new).with(stories).and_return writer
65
67
  Main.iteration 13
66
68
  end
67
69
 
@@ -69,8 +71,30 @@ module PivotalToPdf
69
71
  writer.should_receive :write_to
70
72
  Main.iteration 13
71
73
  end
74
+ end
75
+
76
+ describe ".label" do
77
+ let(:story) {double :story}
78
+ before(:each) do
79
+ Story.stub(:find).and_return story
80
+ PivotalToPdf::PdfWriter.stub(:new).and_return writer
81
+ end
82
+
83
+ it "initiates a label search" do
84
+ # Kind of a null test here, not sure how else to spec it
85
+ Story.should_receive(:find).with(:all, {:params=>{:filter=>"label:\"testing\""}}).and_return story
86
+ Main.label "testing"
87
+ end
72
88
 
89
+ it "build a pdf writer" do
90
+ PivotalToPdf::PdfWriter.should_receive(:new).with(story).and_return writer
91
+ Main.label "testing"
92
+ end
73
93
 
94
+ it "asks the pdf writer to print it" do
95
+ writer.should_receive :write_to
96
+ Main.label "testing"
97
+ end
74
98
  end
75
99
  end
76
100
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pivotal_to_pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-22 00:00:00.000000000 Z
12
+ date: 2012-02-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activeresource
16
- requirement: &70145969460320 !ruby/object:Gem::Requirement
16
+ requirement: &70227699683300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - =
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.0.9
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70145969460320
24
+ version_requirements: *70227699683300
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: prawn
27
- requirement: &70145969459740 !ruby/object:Gem::Requirement
27
+ requirement: &70227699682460 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - =
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.12.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70145969459740
35
+ version_requirements: *70227699682460
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rainbow
38
- requirement: &70145969459240 !ruby/object:Gem::Requirement
38
+ requirement: &70227699681540 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70145969459240
46
+ version_requirements: *70227699681540
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: thor
49
- requirement: &70145969458700 !ruby/object:Gem::Requirement
49
+ requirement: &70227699680800 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70145969458700
57
+ version_requirements: *70227699680800
58
58
  description: Convert Pivotal Tracker Stories to 4x6 PDF for printing so that you can
59
59
  stick the card to your story board
60
60
  email:
@@ -81,6 +81,7 @@ files:
81
81
  - lib/pivotal_to_pdf/iteration.rb
82
82
  - lib/pivotal_to_pdf/pdf_writer.rb
83
83
  - lib/pivotal_to_pdf/pivotal.rb
84
+ - lib/pivotal_to_pdf/pt-workarounds.rb
84
85
  - lib/pivotal_to_pdf/simple_text_formatter.rb
85
86
  - lib/pivotal_to_pdf/story.rb
86
87
  - lib/pivotal_to_pdf/version.rb
@@ -105,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
106
  version: '0'
106
107
  segments:
107
108
  - 0
108
- hash: 1893678772007316533
109
+ hash: 1429925807640698784
109
110
  required_rubygems_version: !ruby/object:Gem::Requirement
110
111
  none: false
111
112
  requirements: