pivotal_to_pdf-formatters 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .rvmrc
19
+ test_reports
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format documentation
data/.rvmrc.template ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.3@pivotal_to_pdf-formatters
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pivotal_to_pdf-formatters.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,11 @@
1
+ guard 'spork' do
2
+ watch('Gemfile')
3
+ watch('Gemfile.lock')
4
+ watch('spec/spec_helper.rb') { :rspec }
5
+ end
6
+
7
+ guard 'rspec', :all_after_pass => false, :cli => "--color --format documentation --drb" do
8
+ watch(%r{^spec/.+_spec\.rb$})
9
+ watch(%r{^lib/(.+)/(.+)\.rb$}) { |m| [ "lib/#{m[1]}/#{m[2]}.rb", "spec/#{m[1]}/#{m[2]}_spec.rb" ] }
10
+ watch('spec/spec_helper.rb') { "spec" }
11
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Yi Wen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # PivotalToPdf::Formatters
2
+
3
+ The gem provides the formatters for the pivotal_to_pdf gem.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'pivotal_to_pdf-formatters'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install pivotal_to_pdf-formatters
18
+
19
+ ## Usage
20
+
21
+ The gem needs to use with pivotal_to_pdf gem. It provides the formatters for the pivotal_to_pdf.
22
+
23
+ To use an existing formatter, Please see the [pivotal_to_pdf README](https://github.com/ywen/pivotal_to_pdf) **Formatters** section.
24
+
25
+ To add a formatter, please fork this project, add you own formatter, submit a PR, and I will merge it if I decide no harm can be done and update the version. Once the new version of this gem is released, you can update the gem and your formatter should be ready for use.
26
+
27
+ ### Coding standard
28
+
29
+ A formatter must have 2 public interfaces for it to work:
30
+
31
+ - ```initialize``` takes an array of stories
32
+ - ```write_to``` method writes to the your chosen output (PDF, HTML, etc.) in your style.
33
+
34
+ Your formatter can extends from ```PivotalToPdf::Formatters::Base``` to have ```initialize``` method available.
35
+
36
+ The ```Default``` formatter is a bad example on how to write code. I expect some tests along with your formatter.
37
+ Design it good, do not afraid adding more help classes when needed.
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ Dir["#{File.dirname(__FILE__)}/tasks/**/*.rb"].each {|f| require f}
@@ -0,0 +1,12 @@
1
+ module PivotalToPdf
2
+ module Formatters
3
+ class Base
4
+ attr_reader :stories
5
+ private :stories
6
+ def initialize(stories)
7
+ @stories = stories
8
+ p stories.size
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'prawn'
5
+ require 'rainbow'
6
+
7
+ module PivotalToPdf
8
+ module Formatters
9
+ class Default < Base
10
+ def write_to(destination)
11
+ Prawn::Document.generate("#{destination}.pdf",
12
+ :page_layout => :landscape,
13
+ :margin => [25, 25, 50, 25],
14
+ :page_size => [302, 432]) do |pdf|
15
+
16
+ # pdf.font "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"
17
+ # pdf.start_new_page
18
+
19
+ stories.each_with_index do |story, index|
20
+ padding = 10
21
+ pdf.stroke_color = story.story_color
22
+ pdf.stroke_bounds
23
+ width = 370
24
+ pdf.line_width=6
25
+ # --- Write content
26
+ pdf.bounding_box [pdf.bounds.left+padding, pdf.bounds.top-padding], :width => width do
27
+ pdf.text story.formatted_name, :size => 14, :inline_format => true
28
+ pdf.fill_color "52D017"
29
+ pdf.text story.label_text, :size => 8
30
+ pdf.text "\n", :size => 14
31
+ pdf.fill_color "444444"
32
+ pdf.text story.formatted_description || "", :size => 10, :inline_format => true
33
+ pdf.fill_color "000000"
34
+ end
35
+ pdf.line(pdf.bounds.bottom_left, pdf.bounds.bottom_right)
36
+ pdf.stroke_bounds
37
+
38
+ pdf.text_box story.points, :size => 12, :at => [12, 50], :width => width-18 unless story.points.nil?
39
+ pdf.text_box "Owner: " + (story.respond_to?(:owned_by) ? story.owned_by : "None"),
40
+ :size => 8, :at => [12, 18], :width => width-18
41
+
42
+ pdf.fill_color "999999"
43
+ pdf.text_box story.story_type.capitalize, :size => 8, :align => :right, :at => [12, 18], :width => width-18
44
+ pdf.fill_color "000000"
45
+ pdf.start_new_page unless index == stories.size - 1
46
+ end
47
+ # pdf.number_pages "<page>/<total>", {:at => [pdf.bounds.right - 16, -28]}
48
+
49
+ puts ">>> Generated PDF file in '#{destination}.pdf'".foreground(:green)
50
+ end
51
+ rescue Exception
52
+ puts "[!] There was an error while generating the PDF file... What happened was:".foreground(:red)
53
+ raise
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,5 @@
1
+ module PivotalToPdf
2
+ module Formatters
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ require 'pivotal_to_pdf-formatters/base'
2
+ Dir["#{File.dirname(__FILE__)}/pivotal_to_pdf-formatters/**/*.rb"].each do |f|
3
+ require f
4
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/pivotal_to_pdf-formatters/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Yi Wen"]
6
+ gem.email = ["hayafirst@gmail.com"]
7
+ gem.description = %q{The gem is a collection of possible formatters for the pivotal_to_pdf gem}
8
+ gem.summary = %q{The gem is a collection of possible formatters for the pivotal_to_pdf gem}
9
+ gem.homepage = "https://github.com/ywen/pivotal_to_pdf-formatters"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "pivotal_to_pdf-formatters"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = PivotalToPdf::Formatters::VERSION
17
+ gem.add_development_dependency(%q<rspec>)
18
+ gem.add_development_dependency(%q<rake>)
19
+ gem.add_development_dependency(%q<guard-spork>)
20
+ gem.add_development_dependency(%q<guard-rspec>)
21
+ gem.add_development_dependency(%q<tailor>, "0.1.5")
22
+ gem.add_development_dependency(%q<cane>)
23
+ gem.add_development_dependency(%q<simplecov>)
24
+ gem.add_development_dependency(%q<growl-rspec>)
25
+ end
@@ -0,0 +1,30 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ SimpleCov.at_exit do
4
+ threshold = 100
5
+ SimpleCov.result.format!
6
+ if SimpleCov.result.covered_percent != threshold
7
+ actual_coverage = SimpleCov.result.covered_percent
8
+ puts "The coverage is #{actual_coverage}%. It has to be 100%"
9
+ exit 1
10
+ end
11
+ end
12
+ end
13
+ require 'spork'
14
+ require 'guard/spork'
15
+
16
+ Spork.prefork do
17
+ require 'rspec/core'
18
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
19
+ require "#{File.dirname(__FILE__)}/../lib/pivotal_to_pdf-formatters"
20
+
21
+ RSpec.configure do |config|
22
+ config.mock_with :rspec
23
+ end
24
+ end
25
+
26
+ Spork.each_run do
27
+ load "#{File.dirname(__FILE__)}/../lib/pivotal_to_pdf-formatters.rb"
28
+ Dir["#{File.dirname(__FILE__)}/../lib/pivotal_to_pdf-formatters/*.rb"].each {|f| load f}
29
+ end
30
+
data/tasks/ci.rb ADDED
@@ -0,0 +1,24 @@
1
+ begin
2
+ require 'rspec/core'
3
+ require 'rspec/core/rake_task'
4
+
5
+ require 'cane/rake_task'
6
+ task :ci => [
7
+ 'cruise_spec',
8
+ 'quality'
9
+ ]
10
+
11
+ desc "Run cane to check quality metrics"
12
+ Cane::RakeTask.new(:quality) do |cane|
13
+ cane.abc_max = 10
14
+ cane.no_doc = true
15
+ end
16
+ desc "Run all specs in spec directory (excluding plugin specs)"
17
+ RSpec::Core::RakeTask.new(:cruise_spec) do |t|
18
+ out = File.join(File.expand_path(File.dirname(__FILE__)), "..","test_reports/Rspec.html")
19
+ t.rspec_opts = ["--format", "html", "-o", out, "--format", "progress"]
20
+ excluded_paths = ['bundle', 'spec', 'config/boot.rb', '/var/', '/usr']
21
+ t.pattern = "spec/**/*_spec.rb"
22
+ end
23
+ rescue LoadError => e
24
+ end
data/tasks/rspec.rb ADDED
@@ -0,0 +1,17 @@
1
+ begin
2
+ require 'rspec/core'
3
+ require 'rspec/core/rake_task'
4
+
5
+ spec_prereq = :noop
6
+ task :noop do
7
+ end
8
+
9
+ desc "Run all specs in spec directory (excluding plugin specs)"
10
+ RSpec::Core::RakeTask.new(:spec => spec_prereq) do |t|
11
+ t.rspec_opts = ["--format", "documentation"]
12
+ t.pattern = "spec/**/*_spec.rb"
13
+ end
14
+
15
+ rescue LoadError => e
16
+ p e
17
+ end
metadata ADDED
@@ -0,0 +1,191 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pivotal_to_pdf-formatters
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Yi Wen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: guard-spork
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: guard-rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: tailor
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - '='
84
+ - !ruby/object:Gem::Version
85
+ version: 0.1.5
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - '='
92
+ - !ruby/object:Gem::Version
93
+ version: 0.1.5
94
+ - !ruby/object:Gem::Dependency
95
+ name: cane
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: simplecov
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: growl-rspec
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ description: The gem is a collection of possible formatters for the pivotal_to_pdf
143
+ gem
144
+ email:
145
+ - hayafirst@gmail.com
146
+ executables: []
147
+ extensions: []
148
+ extra_rdoc_files: []
149
+ files:
150
+ - .gitignore
151
+ - .rspec
152
+ - .rvmrc.template
153
+ - Gemfile
154
+ - Guardfile
155
+ - LICENSE
156
+ - README.md
157
+ - Rakefile
158
+ - lib/pivotal_to_pdf-formatters.rb
159
+ - lib/pivotal_to_pdf-formatters/base.rb
160
+ - lib/pivotal_to_pdf-formatters/default.rb
161
+ - lib/pivotal_to_pdf-formatters/version.rb
162
+ - pivotal_to_pdf-formatters.gemspec
163
+ - spec/spec_helper.rb
164
+ - tasks/ci.rb
165
+ - tasks/rspec.rb
166
+ homepage: https://github.com/ywen/pivotal_to_pdf-formatters
167
+ licenses: []
168
+ post_install_message:
169
+ rdoc_options: []
170
+ require_paths:
171
+ - lib
172
+ required_ruby_version: !ruby/object:Gem::Requirement
173
+ none: false
174
+ requirements:
175
+ - - ! '>='
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ none: false
180
+ requirements:
181
+ - - ! '>='
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ requirements: []
185
+ rubyforge_project:
186
+ rubygems_version: 1.8.23
187
+ signing_key:
188
+ specification_version: 3
189
+ summary: The gem is a collection of possible formatters for the pivotal_to_pdf gem
190
+ test_files:
191
+ - spec/spec_helper.rb