pivotal_to_pdf 1.3.1 → 1.3.2

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/.rbenv-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3-p194
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ gem 'rainbow'
3
3
  gem 'activeresource', "3.0.9"
4
4
  gem 'prawn'
5
5
  gem 'thor'
6
- gem "pivotal_to_pdf-formatters"
6
+ gem "pivotal_to_pdf-formatters", ">=0.0.4"
7
7
  group :test do
8
8
  gem 'rspec'
9
9
  gem "guard-spork"
data/Gemfile.lock CHANGED
@@ -26,23 +26,23 @@ GEM
26
26
  guard (>= 0.10.0)
27
27
  spork (>= 0.8.4)
28
28
  i18n (0.5.0)
29
- pdf-reader (1.1.0)
29
+ pdf-reader (1.1.1)
30
30
  Ascii85 (~> 1.0.0)
31
31
  ruby-rc4
32
- pivotal_to_pdf-formatters (0.0.1)
32
+ pivotal_to_pdf-formatters (0.0.4)
33
33
  prawn (0.12.0)
34
34
  pdf-reader (>= 0.9.0)
35
35
  ttfunk (~> 1.0.2)
36
36
  rainbow (1.1.3)
37
37
  rake (0.9.2.2)
38
- rspec (2.9.0)
39
- rspec-core (~> 2.9.0)
40
- rspec-expectations (~> 2.9.0)
41
- rspec-mocks (~> 2.9.0)
42
- rspec-core (2.9.0)
43
- rspec-expectations (2.9.1)
38
+ rspec (2.11.0)
39
+ rspec-core (~> 2.11.0)
40
+ rspec-expectations (~> 2.11.0)
41
+ rspec-mocks (~> 2.11.0)
42
+ rspec-core (2.11.0)
43
+ rspec-expectations (2.11.1)
44
44
  diff-lcs (~> 1.1.3)
45
- rspec-mocks (2.9.0)
45
+ rspec-mocks (2.11.1)
46
46
  ruby-rc4 (0.1.5)
47
47
  spork (0.9.0)
48
48
  thor (0.14.6)
@@ -56,7 +56,7 @@ DEPENDENCIES
56
56
  growl-rspec
57
57
  guard-rspec
58
58
  guard-spork
59
- pivotal_to_pdf-formatters
59
+ pivotal_to_pdf-formatters (>= 0.0.4)
60
60
  prawn
61
61
  rainbow
62
62
  rake
data/README.md CHANGED
@@ -2,6 +2,7 @@ pivotal_to_pdf -- print the stories from pivotal tracker to a PDF file
2
2
  ====================================
3
3
 
4
4
  [![Build Status](https://secure.travis-ci.org/ywen/pivotal_to_pdf.png)](http://travis-ci.org/ywen/pivotal_to_pdf)
5
+ [![Code Quality](https://codeclimate.com/badge.png)](https://codeclimate.com/github/ywen/pivotal_to_pdf)
5
6
 
6
7
  ## DESCRIPTION
7
8
  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.
@@ -19,7 +20,7 @@ a sample .pivotal.yml:
19
20
  ```yaml
20
21
  token: your-api-token-of-pivotal-tracker
21
22
  project_id: your-ptroject-id
22
- formatter: PivotalToPdf::DefaultFormatter
23
+ formatter: PivotalToPdf::Formatters::Default
23
24
  ```
24
25
 
25
26
  The meaning of the ```formatter``` key will be explained in the next section
@@ -6,9 +6,10 @@ require 'active_resource'
6
6
  require "pivotal_to_pdf-formatters"
7
7
  require 'pivotal_to_pdf/configure'
8
8
  require 'pivotal_to_pdf/formatter_factory'
9
- require 'pivotal_to_pdf/simple_text_formatter'
9
+ require 'pivotal_to_pdf/text_formatters/simple_markup'
10
10
  require 'pivotal_to_pdf/pivotal'
11
11
  require 'pivotal_to_pdf/iteration'
12
+ require 'pivotal_to_pdf/text'
12
13
  require 'pivotal_to_pdf/story'
13
14
  require 'pivotal_to_pdf/pt-workarounds'
14
15
 
@@ -1,8 +1,8 @@
1
1
  module PivotalToPdf
2
2
  class Story < Pivotal
3
- def label_text
3
+ def formatted_labels
4
4
  return "" if !self.respond_to?(:labels) || self.labels.nil? || self.labels.empty?
5
- labels
5
+ formatted_output :labels
6
6
  end
7
7
 
8
8
  def points
@@ -28,7 +28,7 @@ module PivotalToPdf
28
28
  private
29
29
 
30
30
  def formatted_output(field)
31
- SimpleTextFormatter.new(send(field)).output
31
+ Text.new(send(field)).to_s
32
32
  end
33
33
 
34
34
  ["feature", "bug", "chore", "release"].each do |type_str|
@@ -0,0 +1,34 @@
1
+ module PivotalToPdf
2
+ class Text
3
+ class << self
4
+ def formatting_classes
5
+ [ TextFormatters::SimpleMarkup ]
6
+ end
7
+ end
8
+
9
+ attr_reader :string
10
+ protected :string
11
+
12
+ def initialize(string)
13
+ @string = string
14
+ end
15
+
16
+ def ==(other)
17
+ string == other.string
18
+ end
19
+
20
+ def hash
21
+ string.hash
22
+ end
23
+
24
+ def to_s
25
+ output = string
26
+ self.class.formatting_classes.each do |klass|
27
+ output = klass.new(output).output
28
+ end
29
+ output
30
+ end
31
+ end
32
+
33
+ end
34
+
@@ -0,0 +1,15 @@
1
+ module PivotalToPdf
2
+ module TextFormatters
3
+ class SimpleMarkup
4
+ attr_reader :string
5
+ private :string
6
+ def initialize(string)
7
+ @string = string.to_s
8
+ end
9
+
10
+ def output
11
+ string.gsub( /\*(.*)\*/,"<b>\\1</b>").gsub(/_(.*)_/, "<i>\\1</i>")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module PivotalToPdf
2
- VERSION = "1.3.1"
2
+ VERSION = "1.3.2"
3
3
  end
@@ -38,7 +38,7 @@ module PivotalToPdf
38
38
  :something_else => "some other my own configs"
39
39
  }.each do |key, value|
40
40
  it "defines #{key} as a method and returns the value: #{value}" do
41
- subject.send(key).should eq(value)
41
+ expect(subject.send(key)).to eq(value)
42
42
  end
43
43
  end
44
44
  end
@@ -10,7 +10,7 @@ module PivotalToPdf
10
10
  context "when the format_class is not defined" do
11
11
  let(:config) { double :config }
12
12
  it "returns the default formatter" do
13
- FormatterFactory.formatter.should eq(PivotalToPdf::Formatters::Default)
13
+ expect(FormatterFactory.formatter).to eq(PivotalToPdf::Formatters::Default)
14
14
  end
15
15
  end
16
16
 
@@ -21,7 +21,7 @@ module PivotalToPdf
21
21
  end
22
22
 
23
23
  it "returns the default formatter" do
24
- FormatterFactory.formatter.should eq(PivotalToPdf::AClass)
24
+ expect(FormatterFactory.formatter).to eq(PivotalToPdf::AClass)
25
25
  end
26
26
  end
27
27
  end
@@ -2,51 +2,35 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
2
2
 
3
3
  module PivotalToPdf
4
4
  describe Story do
5
- subject {Story.new :labels => [], :story_type => nil, :name => "a name"}
5
+ subject {
6
+ Story.new :labels => "test1 test2", :story_type => nil, :name => "a name", :description => "a description"
7
+ }
6
8
  let(:formatter) {double :formatter, :output => nil}
7
- describe "#label_text" do
8
- describe "and there is no label" do
9
+ describe "#formatted_labels" do
10
+ context "and there is no label" do
9
11
  it "should return blank string" do
10
12
  story = Story.new
11
- story.label_text.should == ""
13
+ expect(story.formatted_labels).to eq("")
12
14
  end
13
15
  end
14
- describe "and labels is empty" do
16
+
17
+ context "and labels is empty" do
15
18
  it "should return blank string" do
16
- subject.label_text.should == ""
19
+ subject.labels = ""
20
+ expect(subject.formatted_labels).to eq("")
17
21
  end
18
22
  end
19
- describe "and labels is nil" do
23
+
24
+ context "and labels is nil" do
20
25
  it "should return blank string" do
21
26
  subject.labels = nil
22
- subject.label_text.should == ""
27
+ expect(subject.formatted_labels).to eq("")
23
28
  end
24
29
  end
25
30
 
26
- describe "and when there are less than 3 labels" do
27
- it "should return them in a nice format" do
28
- subject.labels="test1, test2"
29
- subject.label_text.should == "test1, test2"
30
- end
31
- end
32
31
  end
33
32
 
34
- describe "#formatted_name" do
35
- it "should ask the text formatter format the name" do
36
- SimpleTextFormatter.should_receive(:new).with("a name").and_return formatter
37
- formatter.should_receive(:output).and_return "new name"
38
- subject.formatted_name.should == "new name"
39
- end
40
- end
41
-
42
- describe "#formatted_description" do
43
- it "should ask the text formatter format the description" do
44
- subject.description = "a description"
45
- SimpleTextFormatter.should_receive(:new).with("a description").and_return formatter
46
- formatter.should_receive(:output).and_return "new desc"
47
- subject.formatted_description.should == "new desc"
48
- end
49
- end
33
+ it_converts_string_through_text_class_on :name, :description, :labels
50
34
 
51
35
  describe "#points" do
52
36
  describe "and the story is a bug" do
@@ -54,7 +38,7 @@ module PivotalToPdf
54
38
  subject.story_type = "bug"
55
39
  end
56
40
  it "should return nil" do
57
- subject.points.should be_nil
41
+ expect(subject.points).to be_nil
58
42
  end
59
43
  end
60
44
  describe "and the story is a release" do
@@ -62,7 +46,7 @@ module PivotalToPdf
62
46
  subject.story_type = "release"
63
47
  end
64
48
  it "should return nil" do
65
- subject.points.should be_nil
49
+ expect(subject.points).to be_nil
66
50
  end
67
51
  end
68
52
  describe "and the story is a feature" do
@@ -71,7 +55,7 @@ module PivotalToPdf
71
55
  end
72
56
  describe "and the story is not respond_to estimate" do
73
57
  it "should return Not yet estimated" do
74
- subject.points.should == "Points: Not yet estimated"
58
+ expect(subject.points).to eq("Points: Not yet estimated")
75
59
  end
76
60
  end
77
61
 
@@ -79,13 +63,13 @@ module PivotalToPdf
79
63
  let(:story) {Story.new :story_type => "feature", :estimate => -1}
80
64
  describe "and the estimate is -1" do
81
65
  it "should return not yet estimated" do
82
- subject.points.should == "Points: Not yet estimated"
66
+ expect(subject.points).to eq("Points: Not yet estimated")
83
67
  end
84
68
  end
85
69
  describe "and the estimate is not -1" do
86
70
  it "should return the points" do
87
71
  subject.estimate = 5
88
- subject.points.should == "Points: 5"
72
+ expect(subject.points).to eq("Points: 5")
89
73
  end
90
74
  end
91
75
  end
@@ -95,19 +79,19 @@ module PivotalToPdf
95
79
  describe "#story_color" do
96
80
  it "should return green for features" do
97
81
  subject.story_type = "feature"
98
- subject.story_color.should == "52D017"
82
+ expect(subject.story_color).to eq("52D017")
99
83
  end
100
84
  it "should return red for bugs" do
101
85
  subject.story_type = "bug"
102
- subject.story_color.should == "FF0000"
86
+ expect(subject.story_color).to eq("FF0000")
103
87
  end
104
88
  it "should return yellow for chores" do
105
89
  subject.story_type = "chore"
106
- subject.story_color.should == "FFFF00"
90
+ expect(subject.story_color).to eq("FFFF00")
107
91
  end
108
92
  it "should return black for releases" do
109
93
  subject.story_type = "release"
110
- subject.story_color.should == "000000"
94
+ expect(subject.story_color).to eq("000000")
111
95
  end
112
96
  end
113
97
  end
@@ -0,0 +1,34 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
2
+
3
+ module PivotalToPdf
4
+ module TextFormatters
5
+ describe SimpleMarkup do
6
+ describe "#output" do
7
+ let(:formatter) {described_class.new "a text"}
8
+ context "when there is no special formatting" do
9
+ it "should return the string" do
10
+ expect(formatter.output).to eq("a text")
11
+ end
12
+ end
13
+ context "when there is bold special formatting" do
14
+ let(:formatter) {described_class.new "a *special test* text"}
15
+ it "should return the string converted" do
16
+ expect(formatter.output).to eq("a <b>special test</b> text")
17
+ end
18
+ end
19
+ context "when there is italic special formatting" do
20
+ let(:formatter) {described_class.new "a _special test_ text"}
21
+ it "should return the string converted" do
22
+ expect(formatter.output).to eq("a <i>special test</i> text")
23
+ end
24
+ end
25
+ context "when the text to format is nil" do
26
+ let(:formatter) {described_class.new nil}
27
+ it "should convert to an empty string" do
28
+ expect(formatter.output).to be_empty
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ module PivotalToPdf
4
+ describe Text do
5
+ subject { Text.new "text" }
6
+
7
+ describe ".formatting_classes" do
8
+ it "returns formatting classes" do
9
+ expect(Text.formatting_classes).to eq(
10
+ [ TextFormatters::SimpleMarkup ]
11
+ )
12
+ end
13
+ end
14
+
15
+ describe "#==" do
16
+ context "when another text's string matches" do
17
+ it "is equal to the other" do
18
+ expect(subject).to eq(Text.new("text"))
19
+ end
20
+ end
21
+
22
+ context "when another text's string doesn't " do
23
+ it "is not equal to the other" do
24
+ expect(subject).not_to eq(Text.new("text2"))
25
+ end
26
+ end
27
+ end
28
+
29
+ describe "#hash" do
30
+ it "returns strig's hash value" do
31
+ expect(subject.hash).to eq("text".hash)
32
+ end
33
+ end
34
+
35
+ describe "#to_s" do
36
+ let(:formatter1) { double :formatter1, :output => "text2"}
37
+ let(:formatter2) { double :formatter2, :output => "text3"}
38
+ let(:klass1) { double :format_class1, :new => formatter1 }
39
+ let(:klass2) { double :format_class2, :new => formatter2 }
40
+
41
+ before(:each) do
42
+ Text.stub(:formatting_classes).and_return [klass1, klass2]
43
+ end
44
+
45
+ it "asks each formatting class's output in order" do
46
+ klass1.should_receive(:new).with("text").and_return formatter1
47
+ klass2.should_receive(:new).with("text2").and_return formatter2
48
+ expect(subject.to_s).to eq("text3")
49
+ end
50
+ end
51
+ end
52
+ end
data/spec/spec_helper.rb CHANGED
@@ -3,23 +3,13 @@ require 'spork'
3
3
  require 'rspec/core'
4
4
 
5
5
  Spork.prefork do
6
-
6
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
7
7
  RSpec.configure do |config|
8
- # == Mock Framework
9
- #
10
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
11
- #
12
- # config.mock_with :mocha
13
- # config.mock_with :flexmock
14
- # config.mock_with :rr
8
+ config.expect_with :rspec do |c|
9
+ c.syntax = :expect
10
+ end
15
11
  config.mock_with :rspec
16
- # out = ENV['CC_BUILD_ARTIFACTS'] || "#{Rails.root}"
17
- # config.output_stream = File.open("#{out}/UnitTests/index.html", "w") if config.formatter_class.name =~ /HtmlFormatter/
18
-
19
-
20
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
21
- # examples within a transaction, comment the following line or assign false
22
- # instead of true.
12
+ config.extend Macros
23
13
  end
24
14
 
25
15
  end
@@ -27,7 +17,6 @@ end
27
17
  Spork.each_run do
28
18
  # Requires supporting files with custom matchers and macros, etc,
29
19
  # in ./support/ and its subdirectories.
30
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
31
20
  require "#{File.dirname(__FILE__)}/../lib/pivotal_to_pdf"
32
21
  Dir["#{File.dirname(__FILE__)}/../lib/**/*.rb"].each {|f| require f}
33
22
  end
@@ -0,0 +1,22 @@
1
+ module Macros
2
+ def it_converts_string_through_text_class_on(*fields)
3
+ fields.each do |field|
4
+ describe "#formatted_#{field}" do
5
+ let(:text) { double :text, :to_s => "formatedd #{field}"}
6
+ before(:each) do
7
+ PivotalToPdf::Text.stub(:new).and_return text
8
+ end
9
+
10
+ it "sends the string to Text class" do
11
+ PivotalToPdf::Text.should_receive(:new).with(subject.send(field)).and_return text
12
+ subject.send("formatted_#{field}")
13
+ end
14
+
15
+ it "returns Text.to_s" do
16
+ text.should_receive(:to_s).and_return "formatted #{field}"
17
+ expect(subject.send("formatted_#{field}")).to eq("formatted #{field}")
18
+ end
19
+ end
20
+ end
21
+ end
22
+ 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.3.1
4
+ version: 1.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-23 00:00:00.000000000 Z
12
+ date: 2012-07-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pivotal_to_pdf-formatters
@@ -119,6 +119,7 @@ files:
119
119
  - .bundle/config
120
120
  - .gitignore
121
121
  - .pivotal.yml.sample
122
+ - .rbenv-version
122
123
  - .rspec
123
124
  - .rvmrc
124
125
  - .travis.yml
@@ -136,17 +137,20 @@ files:
136
137
  - lib/pivotal_to_pdf/iteration.rb
137
138
  - lib/pivotal_to_pdf/pivotal.rb
138
139
  - lib/pivotal_to_pdf/pt-workarounds.rb
139
- - lib/pivotal_to_pdf/simple_text_formatter.rb
140
140
  - lib/pivotal_to_pdf/story.rb
141
+ - lib/pivotal_to_pdf/text.rb
142
+ - lib/pivotal_to_pdf/text_formatters/simple_markup.rb
141
143
  - lib/pivotal_to_pdf/version.rb
142
144
  - pivotal_to_pdf.gemspec
143
145
  - spec/pivotal_to_pdf/configure_spec.rb
144
146
  - spec/pivotal_to_pdf/formatter_factory_spec.rb
145
- - spec/pivotal_to_pdf/simple_text_formatter_spec.rb
146
147
  - spec/pivotal_to_pdf/story_spec.rb
148
+ - spec/pivotal_to_pdf/text_formatters/simple_markup_spec.rb
149
+ - spec/pivotal_to_pdf/text_spec.rb
147
150
  - spec/pivotal_to_pdf_bin_spec.rb
148
151
  - spec/pivotal_to_pdf_spec.rb
149
152
  - spec/spec_helper.rb
153
+ - spec/support/macros/it_converts_string_through_text_class_on.rb
150
154
  - tasks/spec.rb
151
155
  homepage: https://github.com/ywen/pivotal_to_pdf
152
156
  licenses: []
@@ -175,8 +179,11 @@ summary: Convert Pivotal Tracker Stories to 4x6 PDF cards
175
179
  test_files:
176
180
  - spec/pivotal_to_pdf/configure_spec.rb
177
181
  - spec/pivotal_to_pdf/formatter_factory_spec.rb
178
- - spec/pivotal_to_pdf/simple_text_formatter_spec.rb
179
182
  - spec/pivotal_to_pdf/story_spec.rb
183
+ - spec/pivotal_to_pdf/text_formatters/simple_markup_spec.rb
184
+ - spec/pivotal_to_pdf/text_spec.rb
180
185
  - spec/pivotal_to_pdf_bin_spec.rb
181
186
  - spec/pivotal_to_pdf_spec.rb
182
187
  - spec/spec_helper.rb
188
+ - spec/support/macros/it_converts_string_through_text_class_on.rb
189
+ has_rdoc:
@@ -1,13 +0,0 @@
1
- module PivotalToPdf
2
- class SimpleTextFormatter
3
- attr_reader :string
4
- private :string
5
- def initialize(string)
6
- @string = string.to_s
7
- end
8
-
9
- def output
10
- string.gsub( /\*(.*)\*/,"<b>\\1</b>").gsub(/_(.*)_/, "<i>\\1</i>")
11
- end
12
- end
13
- end
@@ -1,32 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
2
-
3
- module PivotalToPdf
4
- describe SimpleTextFormatter do
5
- describe "#output" do
6
- let(:formatter) {SimpleTextFormatter.new "a text"}
7
- context "when there is no special formatting" do
8
- it "should return the string" do
9
- formatter.output.should == "a text"
10
- end
11
- end
12
- context "when there is bold special formatting" do
13
- let(:formatter) {SimpleTextFormatter.new "a *special test* text"}
14
- it "should return the string converted" do
15
- formatter.output.should == "a <b>special test</b> text"
16
- end
17
- end
18
- context "when there is italic special formatting" do
19
- let(:formatter) {SimpleTextFormatter.new "a _special test_ text"}
20
- it "should return the string converted" do
21
- formatter.output.should == "a <i>special test</i> text"
22
- end
23
- end
24
- context "when the text to format is nil" do
25
- let(:formatter) {SimpleTextFormatter.new nil}
26
- it "should convert to an empty string" do
27
- formatter.output.should be_empty
28
- end
29
- end
30
- end
31
- end
32
- end