features2cards 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/MIT-LICENSE.txt +20 -0
- data/README.rdoc +30 -0
- data/Rakefile +31 -0
- data/bin/features2cards +5 -0
- data/lib/features2cards.rb +9 -0
- data/lib/features2cards/card.rb +23 -0
- data/lib/features2cards/cli.rb +70 -0
- data/lib/features2cards/prawn.rb +63 -0
- metadata +71 -0
data/History.txt
ADDED
data/MIT-LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Bryan Helmkamp
|
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 NONINFRINGEMENT.
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
= features2cards
|
2
|
+
|
3
|
+
* http://github.com/brynary/features2cards
|
4
|
+
|
5
|
+
== Description
|
6
|
+
|
7
|
+
Create PDF cards from Cucumber features and scenarios for printing. We use it as we kick
|
8
|
+
off our sprints to create index cards for our task board.
|
9
|
+
|
10
|
+
== Usage
|
11
|
+
|
12
|
+
Example:
|
13
|
+
|
14
|
+
features2cards features/scale.feature
|
15
|
+
|
16
|
+
This will generate a file called cards.pdf in the current directory.
|
17
|
+
|
18
|
+
== Install
|
19
|
+
|
20
|
+
sudo gem install features2cards
|
21
|
+
|
22
|
+
== Authors
|
23
|
+
|
24
|
+
- Maintained by {Bryan Helmkamp}[mailto:bryan@brynary.com]
|
25
|
+
- Inspired by Luke Melia (http://www.lukemelia.com/blog/archives/2007/12/29/pdf-storycards-001-released-my-first-gem)
|
26
|
+
|
27
|
+
== License
|
28
|
+
|
29
|
+
Copyright (c) 2008 Bryan Helmkamp.
|
30
|
+
See MIT-LICENSE.txt in this directory.
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require "rake/gempackagetask"
|
3
|
+
require "rake/clean"
|
4
|
+
require './lib/features2cards.rb'
|
5
|
+
|
6
|
+
spec = Gem::Specification.new do |s|
|
7
|
+
s.name = "features2cards"
|
8
|
+
s.version = Features2Cards::VERSION
|
9
|
+
s.author = "Bryan Helmkamp"
|
10
|
+
s.email = "bryan" + "@" + "brynary.com"
|
11
|
+
s.homepage = "http://github.com/brynary/features2cards"
|
12
|
+
s.summary = "features2cards. Generate printable PDF index cards from Cucumber feature files"
|
13
|
+
s.description = s.summary
|
14
|
+
s.executables = "features2cards"
|
15
|
+
s.files = %w[History.txt MIT-LICENSE.txt README.rdoc Rakefile] + Dir["bin/*"] + Dir["lib/**/*"] + Dir["vendor/**/*"]
|
16
|
+
|
17
|
+
s.add_dependency "prawn", ">= 0.1.2"
|
18
|
+
end
|
19
|
+
|
20
|
+
Rake::GemPackageTask.new(spec) do |package|
|
21
|
+
package.gem_spec = spec
|
22
|
+
end
|
23
|
+
|
24
|
+
CLEAN.include ["pkg", "*.gem", "doc", "ri", "coverage"]
|
25
|
+
|
26
|
+
desc 'Install the package as a gem.'
|
27
|
+
task :install_gem => [:clean, :package] do
|
28
|
+
gem = Dir['pkg/*.gem'].first
|
29
|
+
sh "sudo gem install --no-ri --no-rdoc --local #{gem}"
|
30
|
+
end
|
31
|
+
|
data/bin/features2cards
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Features2Cards
|
2
|
+
class Card
|
3
|
+
|
4
|
+
attr_reader :type
|
5
|
+
attr_reader :body
|
6
|
+
attr_reader :footer
|
7
|
+
|
8
|
+
def self.for_feature(feature)
|
9
|
+
new("Feature", feature.header.split("\n").first.gsub(/^\s*Feature:/, '').strip, "")
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.for_scenario(scenario)
|
13
|
+
new("Scenario", scenario.name, scenario.feature.header.split("\n").first)
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(type, body, footer = nil)
|
17
|
+
@type = type
|
18
|
+
@body = body
|
19
|
+
@footer = footer
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "features2cards/card"
|
2
|
+
require "features2cards/prawn"
|
3
|
+
|
4
|
+
module Features2Cards
|
5
|
+
class CLI
|
6
|
+
|
7
|
+
def self.execute
|
8
|
+
load_cucumber
|
9
|
+
new.execute
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.load_cucumber
|
13
|
+
$LOAD_PATH.unshift(File.expand_path("./vendor/plugins/cucumber/lib"))
|
14
|
+
|
15
|
+
require "cucumber"
|
16
|
+
require "cucumber/treetop_parser/feature_en"
|
17
|
+
Cucumber.load_language("en")
|
18
|
+
|
19
|
+
Cucumber::Tree::Feature.class_eval do
|
20
|
+
attr_reader :scenarios
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def execute
|
25
|
+
if files.empty?
|
26
|
+
usage
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
|
30
|
+
generate_pdf(cards)
|
31
|
+
end
|
32
|
+
|
33
|
+
def cards
|
34
|
+
features_to_cards(features)
|
35
|
+
end
|
36
|
+
|
37
|
+
def features
|
38
|
+
files.map do |file|
|
39
|
+
parser.parse_feature(file)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def files
|
44
|
+
ARGV
|
45
|
+
end
|
46
|
+
|
47
|
+
def parser
|
48
|
+
@parser ||= Cucumber::TreetopParser::FeatureParser.new
|
49
|
+
end
|
50
|
+
|
51
|
+
def features_to_cards(features)
|
52
|
+
features.map do |feature|
|
53
|
+
[Card.for_feature(feature)] +
|
54
|
+
feature.scenarios.map do |scenario|
|
55
|
+
Card.for_scenario(scenario)
|
56
|
+
end
|
57
|
+
end.flatten
|
58
|
+
end
|
59
|
+
|
60
|
+
def generate_pdf(cards)
|
61
|
+
Prawn::Document.generate_cards(cards)
|
62
|
+
end
|
63
|
+
|
64
|
+
def usage
|
65
|
+
$stderr.puts "ERROR: No feature files given"
|
66
|
+
$stderr.puts "usage: features2cards <feature files>"
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "prawn"
|
2
|
+
|
3
|
+
class Prawn::Document
|
4
|
+
CARD_WIDTH = 72 * 5 # 5 inches
|
5
|
+
CARD_HEIGHT = 72 * 3 # 3 inches
|
6
|
+
|
7
|
+
def self.generate_cards(cards)
|
8
|
+
generate("cards.pdf", :page_layout => :landscape) do
|
9
|
+
row = 2
|
10
|
+
col = 0
|
11
|
+
|
12
|
+
cards.each do |card|
|
13
|
+
if row == 0
|
14
|
+
start_new_page
|
15
|
+
row = 2
|
16
|
+
col = 0
|
17
|
+
end
|
18
|
+
|
19
|
+
draw_card(card, row, col)
|
20
|
+
|
21
|
+
col += 1
|
22
|
+
|
23
|
+
if col > 1
|
24
|
+
col = 0
|
25
|
+
row -= 1
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def margin_box(margin, &block)
|
32
|
+
bounding_box [bounds.left + margin, bounds.top - margin],
|
33
|
+
:width => bounds.width - (margin * 2), :height => bounds.height - (margin * 2),
|
34
|
+
&block
|
35
|
+
end
|
36
|
+
|
37
|
+
def outline_box
|
38
|
+
stroke_rectangle bounds.top_left, bounds.width, bounds.height
|
39
|
+
end
|
40
|
+
|
41
|
+
def draw_card(card, row, col)
|
42
|
+
bounding_box [CARD_WIDTH * col, CARD_HEIGHT * row + ((bounds.height - (2*CARD_HEIGHT))/2)],
|
43
|
+
:width => CARD_WIDTH, :height => CARD_HEIGHT do
|
44
|
+
|
45
|
+
outline_box
|
46
|
+
|
47
|
+
margin_box 18 do
|
48
|
+
text card.type + ": ", :size => 14
|
49
|
+
|
50
|
+
margin_box 36 do
|
51
|
+
text card.body, :size => 16, :align => :center
|
52
|
+
end
|
53
|
+
|
54
|
+
unless card.footer.nil?
|
55
|
+
bounding_box [bounds.left, bounds.bottom + 18], :width => bounds.width, :height => 18 do
|
56
|
+
text card.footer, :align => :right
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: features2cards
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bryan Helmkamp
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-01-20 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: prawn
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.1.2
|
24
|
+
version:
|
25
|
+
description: features2cards. Generate printable PDF index cards from Cucumber feature files
|
26
|
+
email: bryan@brynary.com
|
27
|
+
executables:
|
28
|
+
- features2cards
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files: []
|
32
|
+
|
33
|
+
files:
|
34
|
+
- History.txt
|
35
|
+
- MIT-LICENSE.txt
|
36
|
+
- README.rdoc
|
37
|
+
- Rakefile
|
38
|
+
- bin/features2cards
|
39
|
+
- lib/features2cards
|
40
|
+
- lib/features2cards/card.rb
|
41
|
+
- lib/features2cards/cli.rb
|
42
|
+
- lib/features2cards/prawn.rb
|
43
|
+
- lib/features2cards.rb
|
44
|
+
has_rdoc: false
|
45
|
+
homepage: http://github.com/brynary/features2cards
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
version:
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.3.1
|
67
|
+
signing_key:
|
68
|
+
specification_version: 2
|
69
|
+
summary: features2cards. Generate printable PDF index cards from Cucumber feature files
|
70
|
+
test_files: []
|
71
|
+
|