-
Notifications
You must be signed in to change notification settings - Fork 4
/
cli.rb
60 lines (47 loc) · 1.12 KB
/
cli.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require "features2cards/card"
require "features2cards/prawn"
module Features2Cards
class CLI
def self.execute
load_cucumber
new.execute
end
def self.load_cucumber
$LOAD_PATH.unshift(File.expand_path("./vendor/plugins/cucumber/lib"))
require "cucumber"
require "cucumber/treetop_parser/feature_en"
Cucumber.load_language("en")
Cucumber::Tree::Feature.class_eval do
attr_reader :scenarios
end
end
def execute
generate_pdf(cards)
end
def cards
features_to_cards(features)
end
def features
files.map do |file|
parser.parse_feature(file)
end
end
def files
ARGV
end
def parser
@parser ||= Cucumber::TreetopParser::FeatureParser.new
end
def features_to_cards(features)
features.map do |feature|
[Card.for_feature(feature)] +
feature.scenarios.map do |scenario|
Card.for_scenario(scenario)
end
end.flatten
end
def generate_pdf(cards)
Prawn::Document.generate_cards(cards)
end
end
end