kosmas58-features2cards 0.3.92

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/History.txt ADDED
@@ -0,0 +1,17 @@
1
+ === 0.3.1 / 2009-06-12
2
+
3
+ The Kosmas Schütz Release.
4
+
5
+ * 4 major enhancements
6
+
7
+ * Upgraded to Cucumber > 0.3.x (Kosmas Schütz)
8
+ * Added language option to use the different languages cucumber supports. (Kosmas Schütz)
9
+ * Added out option to specify pdf file name. (Kosmas Schütz)
10
+ * Can handle directories and files (Kosmas Schütz)
11
+
12
+ === 0.1.0 / 2008-10-26
13
+
14
+ * 1 major enhancement
15
+
16
+ * Birthday!
17
+
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,36 @@
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
+ features2cards [options] [ [FILE|DIR] ]
13
+
14
+ Examples:
15
+ features2cards features2cards.feature
16
+ features2cards --out italian.pdf examples/i18n/it
17
+
18
+ === Options
19
+
20
+ -o, --out [FILE] Specify pdf output file (Default: cards.pdf).
21
+ --version Show version
22
+ -h, --help Show help
23
+
24
+ == Install
25
+
26
+ sudo gem install features2cards
27
+
28
+ == Authors
29
+
30
+ - Maintained by {Bryan Helmkamp}[mailto:bryan@brynary.com]
31
+ - Inspired by Luke Melia (http://www.lukemelia.com/blog/archives/2007/12/29/pdf-storycards-001-released-my-first-gem)
32
+
33
+ == License
34
+
35
+ Copyright (c) 2008-2009 Bryan Helmkamp.
36
+ See MIT-LICENSE.txt in this directory.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require "rake/gempackagetask"
3
+ require "rake/clean"
4
+ require './lib/features2cards.rb'
5
+
6
+ Dir['rake_tasks/**/*.rake'].each { |rake| load rake }
7
+
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/features2cards")
4
+
5
+ Features2Cards::CLI.execute(ARGV.dup)
@@ -0,0 +1,21 @@
1
+ require "rubygems"
2
+
3
+ unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
4
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
5
+ end
6
+
7
+ require "features2cards/platform"
8
+ require "features2cards/cli"
9
+
10
+ module Features2Cards#:nodoc:
11
+ class VERSION #:nodoc:
12
+ MAJOR = 0
13
+ MINOR = 3
14
+ TINY = 92
15
+ PATCH = nil # Set to nil for official release
16
+
17
+ STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
18
+ STABLE_STRING = [MAJOR, MINOR, TINY].join('.')
19
+ end
20
+ end
21
+
@@ -0,0 +1,53 @@
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
+ actual_feature = feature.to_sexp()
10
+ actual_feature.shift
11
+ actual_feature.shift
12
+ title = actual_feature[0].split("\n").first
13
+ footer = title
14
+ body = actual_feature[0].gsub(/^\s*#{title}\n/, '')
15
+ card = [new(title, body, "")]
16
+ footer = title
17
+
18
+ actual_feature.shift
19
+ scenarios = actual_feature
20
+
21
+ scenarios.map do |scenario|
22
+ case(scenario[0])
23
+ when :scenario_outline
24
+ scenario.shift
25
+ when :scenario
26
+ scenario.shift
27
+ scenario.shift
28
+ when :tag
29
+ next
30
+ when :comment
31
+ next
32
+ end
33
+ title = scenario[0] + " " + scenario[1]
34
+ scenario.shift
35
+ scenario.shift
36
+ body = ""
37
+ scenario.map do |step|
38
+ body += step[2] + " " + step[3] + "\n" if step[0] == :step or step[0] == :step_invocation
39
+ end
40
+ card.push(new(title, body, footer))
41
+ end
42
+
43
+ return card
44
+ end
45
+
46
+ def initialize(type, body, footer = nil)
47
+ @type = type
48
+ @body = body
49
+ @footer = footer
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,113 @@
1
+ require "cucumber"
2
+ require "features2cards/card"
3
+ require "features2cards/prawn"
4
+
5
+ module Features2Cards
6
+ class CLI
7
+
8
+ attr_reader :paths
9
+ attr_reader :options
10
+
11
+ def self.execute(args)
12
+ new(args).execute!
13
+ end
14
+
15
+ def initialize(args, out_stream = STDOUT, error_stream = STDERR)
16
+ @args = args
17
+ @out_stream = out_stream
18
+ @error_stream = error_stream
19
+ @paths = []
20
+ @options = default_options
21
+ end
22
+
23
+ def execute!
24
+ parse!(@args)
25
+ load_cucumber
26
+ if feature_files.empty?
27
+ usage
28
+ exit
29
+ end
30
+
31
+ generate_pdf(cards)
32
+ end
33
+
34
+ def parse!(args)
35
+ @args = args
36
+ @args.extend(::OptionParser::Arguable)
37
+ @args.options do |opts|
38
+ opts.banner = ["Usage: features2cards [options] [ [FILE|DIR] ]+", "",
39
+ "Examples:",
40
+ "features2cards features2cards.feature",
41
+ "features2cards examples/i18n/it",
42
+ ].join("\n")
43
+ opts.on("-o", "--out [FILE]",
44
+ "Specify pdf output file (Default: #{@options[:pdf_file]}).") do |v|
45
+ @options[:pdf_file] = v
46
+ end
47
+ opts.on_tail("--version", "Show version.") do
48
+ @out_stream.puts VERSION::STRING
49
+ Kernel.exit
50
+ end
51
+ opts.on_tail("-h", "--help", "You're looking at it.") do
52
+ @out_stream.puts opts.help
53
+ Kernel.exit
54
+ end
55
+ end.parse!
56
+
57
+ # Whatever is left after option parsing is the FILE arguments
58
+ @paths += args
59
+ end
60
+
61
+ def load_cucumber
62
+ Cucumber::Ast::Feature.class_eval do
63
+ attr_reader :scenarios
64
+ end
65
+ end
66
+
67
+ def cards
68
+ features_to_cards(features)
69
+ end
70
+
71
+ def features
72
+ feature_files.map do |file|
73
+ Cucumber::FeatureFile.new(file).parse({})
74
+ end
75
+ end
76
+
77
+ def feature_files
78
+ potential_feature_files = @paths.map do |path|
79
+ path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
80
+ path = path.chomp('/')
81
+ File.directory?(path) ? Dir["#{path}/**/*.feature"] : path
82
+ end.flatten.uniq
83
+ potential_feature_files
84
+ end
85
+
86
+
87
+ def parser
88
+ @parser ||= Cucumber::Parser::FeatureParser.new
89
+ end
90
+
91
+ def features_to_cards(features)
92
+ features.map do |feature|
93
+ [Card.for_feature(feature)]
94
+ end.flatten
95
+ end
96
+
97
+ def generate_pdf(cards)
98
+ Prawn::Document.generate_cards(@options[:pdf_file], cards)
99
+ end
100
+
101
+ def usage
102
+ @error_stream.puts "ERROR: No feature files given"
103
+ @error_stream.puts "Type 'features2cards --help' for usage."
104
+ end
105
+
106
+ def default_options
107
+ {
108
+ :pdf_file => "cards.pdf"
109
+ }
110
+ end
111
+
112
+ end
113
+ end
@@ -0,0 +1,14 @@
1
+ # Detect the platform we're running on so we can tweak behaviour
2
+ # in various places.
3
+ require 'rbconfig'
4
+
5
+ module Features2Cards
6
+ BINARY = File.expand_path(File.dirname(__FILE__) + '/../../bin/features2cards')
7
+ JRUBY = defined?(JRUBY_VERSION)
8
+ IRONRUBY = Config::CONFIG['sitedir'] =~ /IronRuby/
9
+ WINDOWS = Config::CONFIG['host_os'] =~ /mswin|mingw/
10
+ WINDOWS_MRI = WINDOWS && !JRUBY && !IRONRUBY
11
+ RAILS = defined?(Rails)
12
+ RUBY_BINARY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
13
+ RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
14
+ 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(outfile, cards)
8
+ generate(outfile, :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 8 do
48
+ text card.type, :size => 12
49
+
50
+ margin_box 16 do
51
+ text card.body, :size => 10, :align => :left
52
+ end
53
+
54
+ unless card.footer.nil?
55
+ bounding_box [bounds.left, bounds.bottom + 10], :width => bounds.width, :height => 10 do
56
+ text card.footer, :size => 8, :align => :right
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kosmas58-features2cards
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.92
5
+ platform: ruby
6
+ authors:
7
+ - Bryan Helmkamp
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-22 00:00:00 -07:00
13
+ default_executable: features2cards
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"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: cucumber
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.92
34
+ version:
35
+ description: features2cards. Generate printable PDF index cards from Cucumber feature files
36
+ email: bryan@brynary.com
37
+ executables:
38
+ - features2cards
39
+ extensions: []
40
+
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - History.txt
45
+ - MIT-LICENSE.txt
46
+ - README.rdoc
47
+ - Rakefile
48
+ - bin/features2cards
49
+ - lib/features2cards
50
+ - lib/features2cards/card.rb
51
+ - lib/features2cards/cli.rb
52
+ - lib/features2cards/platform.rb
53
+ - lib/features2cards/prawn.rb
54
+ - lib/features2cards.rb
55
+ has_rdoc: false
56
+ homepage: http://github.com/brynary/features2cards
57
+ licenses:
58
+ post_install_message:
59
+ rdoc_options: []
60
+
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ version:
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
75
+ requirements: []
76
+
77
+ rubyforge_project:
78
+ rubygems_version: 1.3.5
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: features2cards. Generate printable PDF index cards from Cucumber feature files
82
+ test_files: []
83
+