features2cards 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/.gitignore +3 -0
  2. data/History.txt +11 -0
  3. data/README.rdoc +2 -3
  4. data/Rakefile +26 -2
  5. data/Thorfile +114 -0
  6. data/examples/i18n/.gitignore +1 -0
  7. data/examples/i18n/README.textile +18 -0
  8. data/examples/i18n/Rakefile +30 -0
  9. data/examples/i18n/ar/addition.feature +17 -0
  10. data/examples/i18n/bg/addition.feature +12 -0
  11. data/examples/i18n/bg/consecutive_calculations.feature +19 -0
  12. data/examples/i18n/bg/division.feature +17 -0
  13. data/examples/i18n/cat/suma.feature +17 -0
  14. data/examples/i18n/da/summering.feature +18 -0
  15. data/examples/i18n/de/addition.feature +17 -0
  16. data/examples/i18n/de/division.feature +10 -0
  17. data/examples/i18n/en-lol/stuffing.feature +8 -0
  18. data/examples/i18n/en/addition.feature +17 -0
  19. data/examples/i18n/en/division.feature +10 -0
  20. data/examples/i18n/es/adicion.feature +17 -0
  21. data/examples/i18n/et/jagamine.feature +10 -0
  22. data/examples/i18n/et/liitmine.feature +17 -0
  23. data/examples/i18n/fi/jakolasku.feature +10 -0
  24. data/examples/i18n/fi/yhteenlasku.feature +16 -0
  25. data/examples/i18n/fr/addition.feature +18 -0
  26. data/examples/i18n/he/addition.feature +17 -0
  27. data/examples/i18n/he/division.feature +10 -0
  28. data/examples/i18n/hu/addition.feature +17 -0
  29. data/examples/i18n/hu/division.feature +10 -0
  30. data/examples/i18n/id/addition.feature +17 -0
  31. data/examples/i18n/id/division.feature +10 -0
  32. data/examples/i18n/it/somma.feature +11 -0
  33. data/examples/i18n/ja/addition.feature +17 -0
  34. data/examples/i18n/ja/division.feature +10 -0
  35. data/examples/i18n/ko/addition.feature +17 -0
  36. data/examples/i18n/ko/division.feature +11 -0
  37. data/examples/i18n/lt/addition.feature +17 -0
  38. data/examples/i18n/lt/division.feature +10 -0
  39. data/examples/i18n/lv/addition.feature +17 -0
  40. data/examples/i18n/lv/division.feature +10 -0
  41. data/examples/i18n/no/summering.feature +19 -0
  42. data/examples/i18n/pl/addition.feature +17 -0
  43. data/examples/i18n/pl/division.feature +10 -0
  44. data/examples/i18n/pt/adicao.feature +11 -0
  45. data/examples/i18n/ro/suma.feature +11 -0
  46. data/examples/i18n/ru/addition.feature +11 -0
  47. data/examples/i18n/ru/consecutive_calculations.feature +17 -0
  48. data/examples/i18n/ru/division.feature +16 -0
  49. data/examples/i18n/se/summering.feature +18 -0
  50. data/examples/i18n/sk/addition.feature +17 -0
  51. data/examples/i18n/sk/division.feature +10 -0
  52. data/examples/i18n/zh-CN/addition.feature +18 -0
  53. data/examples/i18n/zh-TW/addition.feature +17 -0
  54. data/examples/i18n/zh-TW/division.feature +11 -0
  55. data/examples/self_test/.gitignore +2 -0
  56. data/examples/self_test/features/features2cards.feature +19 -0
  57. data/features/features2cards_cli.feature +40 -0
  58. data/features/step_definitions/features2cards_steps.rb +41 -0
  59. data/features/support/env.rb +79 -0
  60. data/features2cards.gemspec +118 -0
  61. data/lib/features2cards.rb +2 -8
  62. data/lib/features2cards/card.rb +14 -10
  63. data/lib/features2cards/cli.rb +27 -34
  64. data/lib/features2cards/platform.rb +1 -1
  65. data/lib/features2cards/prawn.rb +13 -13
  66. data/spec/features2cards/card_spec.rb +8 -0
  67. data/spec/features2cards/cli_spec.rb +21 -0
  68. data/spec/features2cards/prawn_spec.rb +5 -0
  69. data/spec/spec.opts +2 -0
  70. data/spec/spec_helper.rb +7 -0
  71. metadata +81 -12
@@ -4,46 +4,42 @@ require "features2cards/prawn"
4
4
 
5
5
  module Features2Cards
6
6
  class CLI
7
-
7
+
8
8
  attr_reader :paths
9
- attr_reader :options
10
-
9
+ attr_reader :options
10
+
11
11
  def self.execute(args)
12
12
  new(args).execute!
13
13
  end
14
-
14
+
15
15
  def initialize(args, out_stream = STDOUT, error_stream = STDERR)
16
- @args = args
16
+ @args = args
17
17
  @out_stream = out_stream
18
18
  @error_stream = error_stream
19
19
  @paths = []
20
- @options = default_options
20
+ @options = default_options
21
21
  end
22
22
 
23
- def execute!
23
+ def execute!
24
24
  parse!(@args)
25
- load_cucumber(@options[:lang])
25
+ load_cucumber
26
26
  if feature_files.empty?
27
27
  usage
28
28
  exit
29
29
  end
30
-
30
+
31
31
  generate_pdf(cards)
32
32
  end
33
-
33
+
34
34
  def parse!(args)
35
35
  @args = args
36
- @args.extend(::OptionParser::Arguable)
36
+ @args.extend(::OptionParser::Arguable)
37
37
  @args.options do |opts|
38
38
  opts.banner = ["Usage: features2cards [options] [ [FILE|DIR] ]+", "",
39
39
  "Examples:",
40
40
  "features2cards features2cards.feature",
41
- "features2cards --language it examples/i18n/it",
41
+ "features2cards examples/i18n/it",
42
42
  ].join("\n")
43
- opts.on("-l [LANG]", "--language [LANG]",
44
- "Specify language for features (Default: #{@options[:lang]})") do |v|
45
- @options[:lang] = v
46
- end
47
43
  opts.on("-o", "--out [FILE]",
48
44
  "Specify pdf output file (Default: #{@options[:pdf_file]}).") do |v|
49
45
  @options[:pdf_file] = v
@@ -55,31 +51,29 @@ module Features2Cards
55
51
  opts.on_tail("-h", "--help", "You're looking at it.") do
56
52
  @out_stream.puts opts.help
57
53
  Kernel.exit
58
- end
54
+ end
59
55
  end.parse!
60
56
 
61
57
  # Whatever is left after option parsing is the FILE arguments
62
58
  @paths += args
63
- end
64
-
65
- def load_cucumber(lang)
66
- Cucumber.load_language(lang)
67
-
59
+ end
60
+
61
+ def load_cucumber
68
62
  Cucumber::Ast::Feature.class_eval do
69
63
  attr_reader :scenarios
70
64
  end
71
65
  end
72
-
66
+
73
67
  def cards
74
68
  features_to_cards(features)
75
69
  end
76
-
70
+
77
71
  def features
78
72
  feature_files.map do |file|
79
- parser.parse_file(file, {})
73
+ Cucumber::FeatureFile.new(file).parse(Cucumber::StepMother.new, {})
80
74
  end
81
75
  end
82
-
76
+
83
77
  def feature_files
84
78
  potential_feature_files = @paths.map do |path|
85
79
  path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
@@ -88,33 +82,32 @@ module Features2Cards
88
82
  end.flatten.uniq
89
83
  potential_feature_files
90
84
  end
91
-
92
-
85
+
86
+
93
87
  def parser
94
88
  @parser ||= Cucumber::Parser::FeatureParser.new
95
89
  end
96
90
 
97
91
  def features_to_cards(features)
98
92
  features.map do |feature|
99
- [Card.for_feature(feature, @options[:lang])]
93
+ [Card.for_feature(feature)]
100
94
  end.flatten
101
95
  end
102
96
 
103
97
  def generate_pdf(cards)
104
98
  Prawn::Document.generate_cards(@options[:pdf_file], cards)
105
99
  end
106
-
100
+
107
101
  def usage
108
102
  @error_stream.puts "ERROR: No feature files given"
109
103
  @error_stream.puts "Type 'features2cards --help' for usage."
110
104
  end
111
-
105
+
112
106
  def default_options
113
107
  {
114
- :lang => "en",
115
108
  :pdf_file => "cards.pdf"
116
109
  }
117
110
  end
118
-
111
+
119
112
  end
120
- end
113
+ end
@@ -11,4 +11,4 @@ module Features2Cards
11
11
  RAILS = defined?(Rails)
12
12
  RUBY_BINARY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
13
13
  RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
14
- end
14
+ end
@@ -3,23 +3,23 @@ require "prawn"
3
3
  class Prawn::Document
4
4
  CARD_WIDTH = 72 * 5 # 5 inches
5
5
  CARD_HEIGHT = 72 * 3 # 3 inches
6
-
6
+
7
7
  def self.generate_cards(outfile, cards)
8
8
  generate(outfile, :page_layout => :landscape) do
9
9
  row = 2
10
10
  col = 0
11
-
11
+
12
12
  cards.each do |card|
13
13
  if row == 0
14
14
  start_new_page
15
15
  row = 2
16
16
  col = 0
17
17
  end
18
-
18
+
19
19
  draw_card(card, row, col)
20
-
20
+
21
21
  col += 1
22
-
22
+
23
23
  if col > 1
24
24
  col = 0
25
25
  row -= 1
@@ -27,13 +27,13 @@ class Prawn::Document
27
27
  end
28
28
  end
29
29
  end
30
-
30
+
31
31
  def margin_box(margin, &block)
32
32
  bounding_box [bounds.left + margin, bounds.top - margin],
33
33
  :width => bounds.width - (margin * 2), :height => bounds.height - (margin * 2),
34
34
  &block
35
35
  end
36
-
36
+
37
37
  def outline_box
38
38
  stroke_rectangle bounds.top_left, bounds.width, bounds.height
39
39
  end
@@ -41,16 +41,16 @@ class Prawn::Document
41
41
  def draw_card(card, row, col)
42
42
  bounding_box [CARD_WIDTH * col, CARD_HEIGHT * row + ((bounds.height - (2*CARD_HEIGHT))/2)],
43
43
  :width => CARD_WIDTH, :height => CARD_HEIGHT do
44
-
44
+
45
45
  outline_box
46
-
46
+
47
47
  margin_box 8 do
48
48
  text card.type, :size => 12
49
-
49
+
50
50
  margin_box 16 do
51
51
  text card.body, :size => 10, :align => :left
52
52
  end
53
-
53
+
54
54
  unless card.footer.nil?
55
55
  bounding_box [bounds.left, bounds.bottom + 10], :width => bounds.width, :height => 10 do
56
56
  text card.footer, :size => 8, :align => :right
@@ -59,5 +59,5 @@ class Prawn::Document
59
59
  end
60
60
  end
61
61
  end
62
-
63
- end
62
+
63
+ end
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'features2cards/card'
3
+
4
+ module Features2Cards
5
+ describe Card do
6
+
7
+ end
8
+ end
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'features2cards/cli'
3
+
4
+ module Features2Cards
5
+ describe CLI do
6
+ it "should parse feature" do
7
+ cli = CLI.execute(%w{examples/self_test/features/features2cards.feature})
8
+ end
9
+
10
+ it "should parse feature in german" do
11
+ cli = CLI.execute(%w{examples/i18n/de})
12
+ end
13
+
14
+ it "should accept --out option" do
15
+ cli = CLI.new(StringIO.new)
16
+ cli.parse!(%w{--out test.pdf})
17
+ cli.options[:pdf_file].should == 'test.pdf'
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,5 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'prawn'
3
+
4
+ describe Prawn::Document do
5
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --diff
@@ -0,0 +1,7 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
2
+ require 'features2cards'
3
+ begin; require 'rubygems'; rescue LoadError; end
4
+ gem 'rspec'
5
+ require 'spec'
6
+ require 'spec/autorun'
7
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: features2cards
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Helmkamp
@@ -9,8 +9,8 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-12 00:00:00 -04:00
13
- default_executable:
12
+ date: 2009-11-09 00:00:00 -05:00
13
+ default_executable: features2cards
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: prawn
@@ -22,25 +22,91 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "0"
24
24
  version:
25
- description: features2cards. Generate printable PDF index cards from Cucumber feature files
25
+ description: |-
26
+ Create PDF cards from Cucumber features and scenarios for printing. We use it as we kick
27
+ off our sprints to create index cards for our task board.
26
28
  email: bryan@brynary.com
27
29
  executables:
28
30
  - features2cards
29
31
  extensions: []
30
32
 
31
- extra_rdoc_files: []
32
-
33
+ extra_rdoc_files:
34
+ - History.txt
35
+ - README.rdoc
36
+ - MIT-LICENSE.txt
33
37
  files:
38
+ - .gitignore
34
39
  - History.txt
35
40
  - MIT-LICENSE.txt
36
41
  - README.rdoc
37
42
  - Rakefile
43
+ - Thorfile
38
44
  - bin/features2cards
45
+ - examples/i18n/.gitignore
46
+ - examples/i18n/README.textile
47
+ - examples/i18n/Rakefile
48
+ - examples/i18n/ar/addition.feature
49
+ - examples/i18n/bg/addition.feature
50
+ - examples/i18n/bg/consecutive_calculations.feature
51
+ - examples/i18n/bg/division.feature
52
+ - examples/i18n/cat/suma.feature
53
+ - examples/i18n/da/summering.feature
54
+ - examples/i18n/de/addition.feature
55
+ - examples/i18n/de/division.feature
56
+ - examples/i18n/en-lol/stuffing.feature
57
+ - examples/i18n/en/addition.feature
58
+ - examples/i18n/en/division.feature
59
+ - examples/i18n/es/adicion.feature
60
+ - examples/i18n/et/jagamine.feature
61
+ - examples/i18n/et/liitmine.feature
62
+ - examples/i18n/fi/jakolasku.feature
63
+ - examples/i18n/fi/yhteenlasku.feature
64
+ - examples/i18n/fr/addition.feature
65
+ - examples/i18n/he/addition.feature
66
+ - examples/i18n/he/division.feature
67
+ - examples/i18n/hu/addition.feature
68
+ - examples/i18n/hu/division.feature
69
+ - examples/i18n/id/addition.feature
70
+ - examples/i18n/id/division.feature
71
+ - examples/i18n/it/somma.feature
72
+ - examples/i18n/ja/addition.feature
73
+ - examples/i18n/ja/division.feature
74
+ - examples/i18n/ko/addition.feature
75
+ - examples/i18n/ko/division.feature
76
+ - examples/i18n/lt/addition.feature
77
+ - examples/i18n/lt/division.feature
78
+ - examples/i18n/lv/addition.feature
79
+ - examples/i18n/lv/division.feature
80
+ - examples/i18n/no/summering.feature
81
+ - examples/i18n/pl/addition.feature
82
+ - examples/i18n/pl/division.feature
83
+ - examples/i18n/pt/adicao.feature
84
+ - examples/i18n/ro/suma.feature
85
+ - examples/i18n/ru/addition.feature
86
+ - examples/i18n/ru/consecutive_calculations.feature
87
+ - examples/i18n/ru/division.feature
88
+ - examples/i18n/se/summering.feature
89
+ - examples/i18n/sk/addition.feature
90
+ - examples/i18n/sk/division.feature
91
+ - examples/i18n/zh-CN/addition.feature
92
+ - examples/i18n/zh-TW/addition.feature
93
+ - examples/i18n/zh-TW/division.feature
94
+ - examples/self_test/.gitignore
95
+ - examples/self_test/features/features2cards.feature
96
+ - features/features2cards_cli.feature
97
+ - features/step_definitions/features2cards_steps.rb
98
+ - features/support/env.rb
99
+ - features2cards.gemspec
100
+ - lib/features2cards.rb
39
101
  - lib/features2cards/card.rb
40
102
  - lib/features2cards/cli.rb
41
103
  - lib/features2cards/platform.rb
42
104
  - lib/features2cards/prawn.rb
43
- - lib/features2cards.rb
105
+ - spec/features2cards/card_spec.rb
106
+ - spec/features2cards/cli_spec.rb
107
+ - spec/features2cards/prawn_spec.rb
108
+ - spec/spec.opts
109
+ - spec/spec_helper.rb
44
110
  has_rdoc: true
45
111
  homepage: http://github.com/brynary/features2cards
46
112
  licenses: []
@@ -64,10 +130,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
130
  version:
65
131
  requirements: []
66
132
 
67
- rubyforge_project:
68
- rubygems_version: 1.3.4
133
+ rubyforge_project: features2cards
134
+ rubygems_version: 1.3.5
69
135
  signing_key:
70
136
  specification_version: 3
71
- summary: features2cards. Generate printable PDF index cards from Cucumber feature files
72
- test_files: []
73
-
137
+ summary: Generate printable PDF index cards from Cucumber feature files
138
+ test_files:
139
+ - spec/features2cards/card_spec.rb
140
+ - spec/features2cards/cli_spec.rb
141
+ - spec/features2cards/prawn_spec.rb
142
+ - spec/spec_helper.rb