cukedep 0.1.11 → 0.2.00
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.
- checksums.yaml +6 -14
- data/.ruby-version +1 -1
- data/.travis.yml +10 -10
- data/CHANGELOG.md +6 -0
- data/Gemfile +5 -5
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/Rakefile +30 -30
- data/bin/cukedep +15 -15
- data/lib/cukedep/application.rb +105 -112
- data/lib/cukedep/cli/cmd-line.rb +11 -13
- data/lib/cukedep/config.rb +85 -89
- data/lib/cukedep/constants.rb +5 -5
- data/lib/cukedep/cuke-runner.rb +191 -198
- data/lib/cukedep/customization.rb +30 -30
- data/lib/cukedep/feature-model.rb +43 -46
- data/lib/cukedep/feature-rep.rb +9 -11
- data/lib/cukedep/file-action.rb +11 -18
- data/lib/cukedep/gherkin-facade.rb +11 -6
- data/lib/cukedep/gherkin-listener.rb +12 -42
- data/lib/cukedep/hook-dsl.rb +78 -78
- data/lib/cukedep/sandbox.rb +15 -16
- data/lib/cukedep.rb +1 -2
- data/sample/features/step_definitions/steps.rb +2 -2
- data/sample/model/model.rb +19 -20
- data/spec/cukedep/application_spec.rb +80 -80
- data/spec/cukedep/cli/cmd-line_spec.rb +88 -88
- data/spec/cukedep/cuke-runner_spec.rb +74 -74
- data/spec/cukedep/customization_spec.rb +31 -31
- data/spec/cukedep/debug-file-action.rb +29 -29
- data/spec/cukedep/feature-model_spec.rb +100 -100
- data/spec/cukedep/feature-rep_spec.rb +2 -1
- data/spec/cukedep/file-action_spec.rb +365 -366
- data/spec/cukedep/file-parsing.rb +39 -41
- data/spec/cukedep/gherkin-facade_spec.rb +48 -49
- data/spec/cukedep/gherkin-listener_spec.rb +55 -57
- data/spec/cukedep/hook-dsl_spec.rb +182 -182
- data/spec/cukedep/sample_features/cukedep_hooks.rb +30 -30
- data/spec/cukedep/sample_features/standalone.feature +1 -1
- data/templates/rake.erb +12 -21
- metadata +80 -58
- data/sample/result.html +0 -472
- data/spec/cukedep/sample_features/cukedep.rake +0 -215
- data/spec/cukedep/sample_features/dependencies.dot +0 -38
- data/spec/cukedep/sample_features/feature2id.csv +0 -7
checksums.yaml
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
metadata.gz: !binary |-
|
|
9
|
-
YWQ5MTk1ZjU4MGI0NmVmOTBiMzA3Yjk1MjBlYTM5MzZmMTM3NGU0YTdhMWY0
|
|
10
|
-
MjcxMDY3NzM2MWFlMTY1MjYwNTE5N2Y0N2YxMmYyNjU1YjUyYjBjYmUzYmFk
|
|
11
|
-
OTU3ZWUyMTRkYjc0NDVhOGYxOTNiOWRiNWI0NzBiNDVkYWFmOTU=
|
|
12
|
-
data.tar.gz: !binary |-
|
|
13
|
-
ZjFlODk3YmFjYTdmZjhmZmI4ODFkZjlhMjE2ODYzNzliYzljNzU0YTFhMzZi
|
|
14
|
-
ZWNhOTU2MmQ4MWY3MzExZjYzNDc0MWIwYWU5MzgwY2MxZWNiMjFmNDNmNDgz
|
|
15
|
-
ODBjOGQzMzU2MzE5NzA1ZWNiYTk1YTE2MzYyNjI0YTc5OWFlN2M=
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 1813f9ae8e497b82bfc4926b223a5ec8ab77924b
|
|
4
|
+
data.tar.gz: b23e1ee17b0487827f416950d0f647ad94818679
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 2d74c075fd475de69fe58b0ef0640449aae3a61c620f23e20e82ecfd650f5cd467130839ec74aab8a7d4c6d9c24aa2902c3c86e38ae42f937b00ea50dc6a6848
|
|
7
|
+
data.tar.gz: 09f150a25d72717c1d3f2be7e3245898605d89c6547ce3c4b78a99a7109f5dff84bd411e48d1cf53067286df59b8c3b0d4276db7c01928a340563e098c1dd1ec
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
2.2.0
|
data/.travis.yml
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
language: ruby
|
|
2
2
|
rvm:
|
|
3
|
-
-
|
|
4
|
-
- 2.2
|
|
5
|
-
- 2.
|
|
6
|
-
- 2.
|
|
7
|
-
- 1.9.3
|
|
3
|
+
- 2.5.0
|
|
4
|
+
- 2.4.2
|
|
5
|
+
- 2.3.5
|
|
6
|
+
- 2.2.8
|
|
8
7
|
- jruby-head
|
|
9
|
-
- jruby-
|
|
10
|
-
|
|
8
|
+
- jruby-9.1.9.0
|
|
9
|
+
- ruby-head
|
|
10
|
+
|
|
11
11
|
matrix:
|
|
12
12
|
allow_failures:
|
|
13
13
|
- rvm: jruby-head
|
|
14
14
|
- rvm: ruby-head
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
gemfile:
|
|
17
17
|
- Gemfile
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
# whitelist
|
|
20
|
-
branches:
|
|
20
|
+
branches:
|
|
21
21
|
only:
|
|
22
22
|
- master
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
### 0.2.00 / 2018-05-21
|
|
2
|
+
Version number bumped.
|
|
3
|
+
* [CHANGE] Version numbers in dependencies
|
|
4
|
+
* [CHANGE] Code re-formatted to please Rubocop 0.55.0
|
|
5
|
+
* [FIX] Fixed code breaking changes caused by 'gherkin 4.+'
|
|
6
|
+
|
|
1
7
|
### 0.1.11 / 2015-06-18
|
|
2
8
|
* [CHANGE] Code re-formatted to please Rubocop 0.32.0
|
|
3
9
|
* [FIX] File `.rubocop.yml`: disable some cop settings that were too loud.
|
data/Gemfile
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
# Prevent Bundler to load the dependencies from our .gemspec file
|
|
3
3
|
|
|
4
|
-
gem '
|
|
5
|
-
gem '
|
|
6
|
-
gem 'rake', ['>= 0.
|
|
4
|
+
gem 'cucumber', ['>= 3.1.0']
|
|
5
|
+
gem 'gherkin', ['>=5.0.0']
|
|
6
|
+
gem 'rake', ['>= 11.0.0']
|
|
7
7
|
|
|
8
8
|
group :development do
|
|
9
|
-
gem 'rspec', '>= 3.
|
|
10
|
-
gem 'simplecov', '>= 0.
|
|
9
|
+
gem 'rspec', '>= 3.6.0'
|
|
10
|
+
gem 'simplecov', '>= 0.10.0'
|
|
11
11
|
end
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -125,5 +125,5 @@ While feature `bar` may start like this:
|
|
|
125
125
|
|
|
126
126
|
Copyright
|
|
127
127
|
---------
|
|
128
|
-
Copyright (c) 2013,
|
|
128
|
+
Copyright (c) 2013-2018, Dimitri Geshef.
|
|
129
129
|
__Cukedep__ is released under the MIT License see [LICENSE.txt](https://github.com/famished-tiger/Cukedep/blob/master/LICENSE.txt) for details.
|
data/Rakefile
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
require 'rubygems'
|
|
2
|
-
require_relative './lib/cukedep/constants'
|
|
3
|
-
|
|
4
|
-
namespace :gem do
|
|
5
|
-
desc 'Push the gem to rubygems.org'
|
|
6
|
-
task :push do
|
|
7
|
-
system("gem push cukedep-#{Cukedep::Version}.gem")
|
|
8
|
-
end
|
|
9
|
-
end # namespace
|
|
10
|
-
|
|
11
|
-
# Testing-specific tasks
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# RSpec as testing tool
|
|
15
|
-
require 'rspec/core/rake_task'
|
|
16
|
-
desc 'Run RSpec'
|
|
17
|
-
RSpec::Core::RakeTask.new do |spec|
|
|
18
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# Combine RSpec tests
|
|
23
|
-
desc 'Run tests, with RSpec'
|
|
24
|
-
task test: [:spec]
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
# Default rake task
|
|
28
|
-
task default: :test
|
|
29
|
-
|
|
30
|
-
# End of file
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require_relative './lib/cukedep/constants'
|
|
3
|
+
|
|
4
|
+
namespace :gem do
|
|
5
|
+
desc 'Push the gem to rubygems.org'
|
|
6
|
+
task :push do
|
|
7
|
+
system("gem push cukedep-#{Cukedep::Version}.gem")
|
|
8
|
+
end
|
|
9
|
+
end # namespace
|
|
10
|
+
|
|
11
|
+
# Testing-specific tasks
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# RSpec as testing tool
|
|
15
|
+
require 'rspec/core/rake_task'
|
|
16
|
+
desc 'Run RSpec'
|
|
17
|
+
RSpec::Core::RakeTask.new do |spec|
|
|
18
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# Combine RSpec tests
|
|
23
|
+
desc 'Run tests, with RSpec'
|
|
24
|
+
task test: [:spec]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# Default rake task
|
|
28
|
+
task default: :test
|
|
29
|
+
|
|
30
|
+
# End of file
|
data/bin/cukedep
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# File: cukedep
|
|
3
|
-
# The 'executable' of the Cukedep utility.
|
|
4
|
-
|
|
5
|
-
mydir = File.dirname(__FILE__)
|
|
6
|
-
lib_dir = mydir + '/../lib'
|
|
7
|
-
$LOAD_PATH.unshift lib_dir unless $LOAD_PATH.include?(lib_dir)
|
|
8
|
-
|
|
9
|
-
require 'cukedep' # Load the Cukedep::Application class
|
|
10
|
-
|
|
11
|
-
# The application's entry point
|
|
12
|
-
app = Cukedep::Application.new
|
|
13
|
-
app.run!(ARGV)
|
|
14
|
-
|
|
15
|
-
# End of file
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# File: cukedep
|
|
3
|
+
# The 'executable' of the Cukedep utility.
|
|
4
|
+
|
|
5
|
+
mydir = File.dirname(__FILE__)
|
|
6
|
+
lib_dir = mydir + '/../lib'
|
|
7
|
+
$LOAD_PATH.unshift lib_dir unless $LOAD_PATH.include?(lib_dir)
|
|
8
|
+
|
|
9
|
+
require 'cukedep' # Load the Cukedep::Application class
|
|
10
|
+
|
|
11
|
+
# The application's entry point
|
|
12
|
+
app = Cukedep::Application.new
|
|
13
|
+
app.run!(ARGV)
|
|
14
|
+
|
|
15
|
+
# End of file
|
data/lib/cukedep/application.rb
CHANGED
|
@@ -1,112 +1,105 @@
|
|
|
1
|
-
# File: application.rb
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
require_relative '
|
|
5
|
-
require_relative '
|
|
6
|
-
require_relative 'gherkin-
|
|
7
|
-
require_relative '
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
config
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
#
|
|
73
|
-
|
|
74
|
-
#
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
#
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
aModel.draw_dependency_graph(aConfig.graph_file.name, true)
|
|
107
|
-
aModel.generate_rake_tasks(aConfig.rake_file, proj_dir)
|
|
108
|
-
end
|
|
109
|
-
end # class
|
|
110
|
-
end # module
|
|
111
|
-
|
|
112
|
-
# End of file
|
|
1
|
+
# File: application.rb
|
|
2
|
+
|
|
3
|
+
require_relative 'cli/cmd-line'
|
|
4
|
+
require_relative 'config'
|
|
5
|
+
require_relative 'gherkin-listener'
|
|
6
|
+
require_relative 'gherkin-facade'
|
|
7
|
+
require_relative 'feature-model'
|
|
8
|
+
|
|
9
|
+
module Cukedep # Module used as a namespace
|
|
10
|
+
# Runner for the Cukedep application.
|
|
11
|
+
class Application
|
|
12
|
+
attr_reader(:proj_dir)
|
|
13
|
+
|
|
14
|
+
# Entry point for the application object.
|
|
15
|
+
def run!(theCmdLineArgs)
|
|
16
|
+
options = options_from(theCmdLineArgs)
|
|
17
|
+
create_default_cfg if options[:setup]
|
|
18
|
+
config = Config.load_cfg(Cukedep::YMLFilename)
|
|
19
|
+
|
|
20
|
+
# Complain if no project dir is specified
|
|
21
|
+
if config.proj_dir.nil? || config.proj_dir.empty?
|
|
22
|
+
if options[:project]
|
|
23
|
+
@proj_dir = options[:project]
|
|
24
|
+
else
|
|
25
|
+
msg_p1 = "No project dir specified in '#{Cukedep::YMLFilename}'"
|
|
26
|
+
msg_p2 = ' nor via --project option.'
|
|
27
|
+
raise StandardError, msg_p1 + msg_p2
|
|
28
|
+
end
|
|
29
|
+
else
|
|
30
|
+
@proj_dir = config.proj_dir
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
feature_files = parse_features(config.feature_encoding)
|
|
34
|
+
|
|
35
|
+
model = FeatureModel.new(feature_files)
|
|
36
|
+
generate_files(model, config)
|
|
37
|
+
|
|
38
|
+
return if options[:dryrun]
|
|
39
|
+
rake_cmd = 'rake -f cukedep.rake'
|
|
40
|
+
system(rake_cmd)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
protected
|
|
44
|
+
|
|
45
|
+
# Retrieve the user-entered command-line options
|
|
46
|
+
def options_from(theCmdLineArgs)
|
|
47
|
+
cli = CLI::CmdLine.new
|
|
48
|
+
cli.parse!(theCmdLineArgs.dup)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Create a local copy of the .cukedep.yml file, then
|
|
52
|
+
# stop the application.
|
|
53
|
+
def create_default_cfg
|
|
54
|
+
if File.exist?(Cukedep::YMLFilename)
|
|
55
|
+
puts "OK to overwrite file #{Cukedep::YMLFilename}."
|
|
56
|
+
puts '(Y/N)?'
|
|
57
|
+
answer = $stdin.gets
|
|
58
|
+
exit if answer =~ /^\s*[Nn]\s*$/
|
|
59
|
+
end
|
|
60
|
+
Config.default.write(Cukedep::YMLFilename)
|
|
61
|
+
|
|
62
|
+
exit
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# # Read the .cukedep.yml file in the current working directory
|
|
66
|
+
# def load_cfg()
|
|
67
|
+
# if File.exist?(Cukedep::YMLFilename)
|
|
68
|
+
# YAML.load_file(Cukedep::YMLFilename)
|
|
69
|
+
# else
|
|
70
|
+
# Config.default
|
|
71
|
+
# end
|
|
72
|
+
# end
|
|
73
|
+
|
|
74
|
+
# Parse the feature files (with the specified external encoding)
|
|
75
|
+
def parse_features(external_encoding)
|
|
76
|
+
# Create a Gherkin listener
|
|
77
|
+
listener = Cukedep::GherkinListener.new
|
|
78
|
+
|
|
79
|
+
# Parse the feature files in work directory
|
|
80
|
+
is_verbose = true
|
|
81
|
+
gherkin_facade = GherkinFacade.new(is_verbose, external_encoding)
|
|
82
|
+
gherkin_facade.parse_features(listener, ['*.feature'])
|
|
83
|
+
|
|
84
|
+
return listener.feature_files
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def generate_files(aModel, aConfig)
|
|
88
|
+
# Sort the feature files by dependency order.
|
|
89
|
+
aModel.sort_features_by_dep
|
|
90
|
+
|
|
91
|
+
puts "\nGenerating:"
|
|
92
|
+
|
|
93
|
+
# Generate CSV files detailing the feature to identifier mapping
|
|
94
|
+
# and vise versa
|
|
95
|
+
# TODO: replace hard-coded names by value from config
|
|
96
|
+
feature2id_report = aConfig.feature2id.name
|
|
97
|
+
id2feature_report = aConfig.id2feature.name
|
|
98
|
+
aModel.mapping_reports(feature2id_report, id2feature_report, true)
|
|
99
|
+
aModel.draw_dependency_graph(aConfig.graph_file.name, true)
|
|
100
|
+
aModel.generate_rake_tasks(aConfig.rake_file, proj_dir)
|
|
101
|
+
end
|
|
102
|
+
end # class
|
|
103
|
+
end # module
|
|
104
|
+
|
|
105
|
+
# End of file
|
data/lib/cukedep/cli/cmd-line.rb
CHANGED
|
@@ -22,14 +22,14 @@ class CmdLine
|
|
|
22
22
|
attr_reader(:parser)
|
|
23
23
|
|
|
24
24
|
# Constructor.
|
|
25
|
-
def initialize
|
|
25
|
+
def initialize
|
|
26
26
|
@options = {}
|
|
27
27
|
|
|
28
28
|
@parser = OptionParser.new do |opts|
|
|
29
|
-
opts.banner = <<-
|
|
29
|
+
opts.banner = <<-HELP
|
|
30
30
|
Usage: cukedep [options]
|
|
31
31
|
The command-line options are:
|
|
32
|
-
|
|
32
|
+
HELP
|
|
33
33
|
|
|
34
34
|
# No argument. Check
|
|
35
35
|
dry_txt1 = 'Check the feature file dependencies'
|
|
@@ -64,34 +64,32 @@ EOS
|
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
public
|
|
68
|
-
|
|
69
67
|
# Perform the command-line parsing
|
|
70
68
|
def parse!(theCmdLineArgs)
|
|
71
69
|
begin
|
|
72
|
-
parser.parse!(theCmdLineArgs)
|
|
70
|
+
parser.parse!(theCmdLineArgs)
|
|
73
71
|
rescue OptionParser::MissingArgument => exc
|
|
74
72
|
err_msg = ''
|
|
75
73
|
exc.args.each do |arg|
|
|
76
74
|
err_msg << "No argument provided with command line option: #{arg}\n"
|
|
77
75
|
end
|
|
78
76
|
err_msg << 'To see the command-line syntax, do:\ncukedep --help'
|
|
79
|
-
raise
|
|
77
|
+
raise StandardError, err_msg
|
|
80
78
|
end
|
|
81
79
|
|
|
82
80
|
# Some options stop the application
|
|
83
81
|
exit if options[:version] || options[:help]
|
|
84
|
-
|
|
82
|
+
|
|
85
83
|
return options
|
|
86
84
|
end
|
|
87
85
|
|
|
88
86
|
private
|
|
89
|
-
|
|
87
|
+
|
|
90
88
|
def validated_project(theProjectPath)
|
|
91
89
|
unless Dir.exist?(theProjectPath)
|
|
92
|
-
|
|
90
|
+
raise StandardError, "Cannot find the directory '#{theProjectPath}'."
|
|
93
91
|
end
|
|
94
|
-
|
|
92
|
+
|
|
95
93
|
# If current dir is /features and project dir is parent of it
|
|
96
94
|
# then we have an error
|
|
97
95
|
current_path = Pathname.getwd
|
|
@@ -99,10 +97,10 @@ EOS
|
|
|
99
97
|
if current_path.parent == Pathname.new(theProjectPath)
|
|
100
98
|
msg_prefix = "Don't place original feature file in 'features'"
|
|
101
99
|
msg_suffix = ' subdir of project dir.'
|
|
102
|
-
|
|
100
|
+
raise StandardError, msg_prefix + msg_suffix
|
|
103
101
|
end
|
|
104
102
|
end
|
|
105
|
-
|
|
103
|
+
|
|
106
104
|
|
|
107
105
|
return theProjectPath
|
|
108
106
|
end
|
data/lib/cukedep/config.rb
CHANGED
|
@@ -1,89 +1,85 @@
|
|
|
1
|
-
# File: config.rb
|
|
2
|
-
|
|
3
|
-
require 'yaml'
|
|
4
|
-
require_relative 'file-action'
|
|
5
|
-
|
|
6
|
-
module Cukedep # Module used as a namespace
|
|
7
|
-
FileMetaData = Struct.new(:name)
|
|
8
|
-
|
|
9
|
-
Config = Struct.new(
|
|
10
|
-
:feature_encoding, # The character encoding of feature files
|
|
11
|
-
:proj_dir, # The directory of the cucumber project
|
|
12
|
-
:feature2id, # Meta-data about the feature => feature id report
|
|
13
|
-
:id2feature, # Meta-data about the feature id => feature report
|
|
14
|
-
:graph_file, # Meta-data about the dependency graph file
|
|
15
|
-
:rake_file, # Name of the output rake file
|
|
16
|
-
:cucumber_args, # Command-line syntax to use for the cucumber application
|
|
17
|
-
# File actions triggered at Cucumber invocation events
|
|
18
|
-
:before_all_f_actions,
|
|
19
|
-
:before_each_f_actions,
|
|
20
|
-
:after_each_f_actions,
|
|
21
|
-
:after_all_f_actions
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
# Re-open the class for further customisation
|
|
25
|
-
# Configuration object for the Cukedep application.
|
|
26
|
-
class Config
|
|
27
|
-
# Factory method. Build a config object with default settings.
|
|
28
|
-
def self.default
|
|
29
|
-
instance = Config.new(
|
|
30
|
-
'UTF-8',
|
|
31
|
-
nil,
|
|
32
|
-
FileMetaData.new('feature2id.csv'),
|
|
33
|
-
FileMetaData.new('feature2id.csv'),
|
|
34
|
-
FileMetaData.new('dependencies.dot'),
|
|
35
|
-
'cukedep.rake',
|
|
36
|
-
[]
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
file_action_attrs.each do |attr|
|
|
40
|
-
instance[attr] = empty_action_triplet
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
return instance
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
#
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
end # class
|
|
87
|
-
end # module
|
|
88
|
-
|
|
89
|
-
# End of file
|
|
1
|
+
# File: config.rb
|
|
2
|
+
|
|
3
|
+
require 'yaml'
|
|
4
|
+
require_relative 'file-action'
|
|
5
|
+
|
|
6
|
+
module Cukedep # Module used as a namespace
|
|
7
|
+
FileMetaData = Struct.new(:name)
|
|
8
|
+
|
|
9
|
+
Config = Struct.new(
|
|
10
|
+
:feature_encoding, # The character encoding of feature files
|
|
11
|
+
:proj_dir, # The directory of the cucumber project
|
|
12
|
+
:feature2id, # Meta-data about the feature => feature id report
|
|
13
|
+
:id2feature, # Meta-data about the feature id => feature report
|
|
14
|
+
:graph_file, # Meta-data about the dependency graph file
|
|
15
|
+
:rake_file, # Name of the output rake file
|
|
16
|
+
:cucumber_args, # Command-line syntax to use for the cucumber application
|
|
17
|
+
# File actions triggered at Cucumber invocation events
|
|
18
|
+
:before_all_f_actions,
|
|
19
|
+
:before_each_f_actions,
|
|
20
|
+
:after_each_f_actions,
|
|
21
|
+
:after_all_f_actions
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
# Re-open the class for further customisation
|
|
25
|
+
# Configuration object for the Cukedep application.
|
|
26
|
+
class Config
|
|
27
|
+
# Factory method. Build a config object with default settings.
|
|
28
|
+
def self.default
|
|
29
|
+
instance = Config.new(
|
|
30
|
+
'UTF-8',
|
|
31
|
+
nil,
|
|
32
|
+
FileMetaData.new('feature2id.csv'),
|
|
33
|
+
FileMetaData.new('feature2id.csv'),
|
|
34
|
+
FileMetaData.new('dependencies.dot'),
|
|
35
|
+
'cukedep.rake',
|
|
36
|
+
[]
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
file_action_attrs.each do |attr|
|
|
40
|
+
instance[attr] = empty_action_triplet
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
return instance
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Read the YAML file with specified name from the current working directory.
|
|
47
|
+
# If that file does not exist, then return an instance with default values.
|
|
48
|
+
def self.load_cfg(filename)
|
|
49
|
+
# TODO: validation
|
|
50
|
+
instance = File.exist?(filename) ? YAML.load_file(filename) : default
|
|
51
|
+
|
|
52
|
+
return instance
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Save the Config object to a YAML file.
|
|
56
|
+
def write(filename)
|
|
57
|
+
File.open(filename, 'w') { |f| YAML.dump(self, f) }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Purpose: get the list of attributes referencing
|
|
61
|
+
# a file action triplet.
|
|
62
|
+
def self.file_action_attrs
|
|
63
|
+
return %I[
|
|
64
|
+
before_all_f_actions
|
|
65
|
+
before_each_f_actions
|
|
66
|
+
after_each_f_actions
|
|
67
|
+
after_all_f_actions
|
|
68
|
+
]
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Return Hash config for a no-op action triplet.
|
|
72
|
+
def self.empty_action_triplet
|
|
73
|
+
{
|
|
74
|
+
save_patterns: [],
|
|
75
|
+
save_subdir: '',
|
|
76
|
+
delete_patterns: [],
|
|
77
|
+
delete_subdir: '',
|
|
78
|
+
copy_patterns: [],
|
|
79
|
+
copy_subdir: ''
|
|
80
|
+
}
|
|
81
|
+
end
|
|
82
|
+
end # class
|
|
83
|
+
end # module
|
|
84
|
+
|
|
85
|
+
# End of file
|