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.
Files changed (45) hide show
  1. checksums.yaml +6 -14
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +10 -10
  4. data/CHANGELOG.md +6 -0
  5. data/Gemfile +5 -5
  6. data/LICENSE.txt +1 -1
  7. data/README.md +1 -1
  8. data/Rakefile +30 -30
  9. data/bin/cukedep +15 -15
  10. data/lib/cukedep/application.rb +105 -112
  11. data/lib/cukedep/cli/cmd-line.rb +11 -13
  12. data/lib/cukedep/config.rb +85 -89
  13. data/lib/cukedep/constants.rb +5 -5
  14. data/lib/cukedep/cuke-runner.rb +191 -198
  15. data/lib/cukedep/customization.rb +30 -30
  16. data/lib/cukedep/feature-model.rb +43 -46
  17. data/lib/cukedep/feature-rep.rb +9 -11
  18. data/lib/cukedep/file-action.rb +11 -18
  19. data/lib/cukedep/gherkin-facade.rb +11 -6
  20. data/lib/cukedep/gherkin-listener.rb +12 -42
  21. data/lib/cukedep/hook-dsl.rb +78 -78
  22. data/lib/cukedep/sandbox.rb +15 -16
  23. data/lib/cukedep.rb +1 -2
  24. data/sample/features/step_definitions/steps.rb +2 -2
  25. data/sample/model/model.rb +19 -20
  26. data/spec/cukedep/application_spec.rb +80 -80
  27. data/spec/cukedep/cli/cmd-line_spec.rb +88 -88
  28. data/spec/cukedep/cuke-runner_spec.rb +74 -74
  29. data/spec/cukedep/customization_spec.rb +31 -31
  30. data/spec/cukedep/debug-file-action.rb +29 -29
  31. data/spec/cukedep/feature-model_spec.rb +100 -100
  32. data/spec/cukedep/feature-rep_spec.rb +2 -1
  33. data/spec/cukedep/file-action_spec.rb +365 -366
  34. data/spec/cukedep/file-parsing.rb +39 -41
  35. data/spec/cukedep/gherkin-facade_spec.rb +48 -49
  36. data/spec/cukedep/gherkin-listener_spec.rb +55 -57
  37. data/spec/cukedep/hook-dsl_spec.rb +182 -182
  38. data/spec/cukedep/sample_features/cukedep_hooks.rb +30 -30
  39. data/spec/cukedep/sample_features/standalone.feature +1 -1
  40. data/templates/rake.erb +12 -21
  41. metadata +80 -58
  42. data/sample/result.html +0 -472
  43. data/spec/cukedep/sample_features/cukedep.rake +0 -215
  44. data/spec/cukedep/sample_features/dependencies.dot +0 -38
  45. data/spec/cukedep/sample_features/feature2id.csv +0 -7
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZjAwNWNhNzFkYjlkMDJlMTk4ZGViNGI0ZmI0YWYwNjIxOWJlYzNlYg==
5
- data.tar.gz: !binary |-
6
- ZDI4ZWY5MzM3NDM3NDFmOTNmZWM4MDIyNjI2ZDFjYjdiNmMzMGZkOA==
7
- !binary "U0hBNTEy":
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.9.3
1
+ 2.2.0
data/.travis.yml CHANGED
@@ -1,22 +1,22 @@
1
1
  language: ruby
2
2
  rvm:
3
- - ruby-head
4
- - 2.2.0
5
- - 2.1.0
6
- - 2.0.0
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-19mode
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 'gherkin', ['>=' '1.0.24']
5
- gem 'cucumber', ['>= 0.7.0']
6
- gem 'rake', ['>= 0.8.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.0.0'
10
- gem 'simplecov', '>= 0.5.0'
9
+ gem 'rspec', '>= 3.6.0'
10
+ gem 'simplecov', '>= 0.10.0'
11
11
  end
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013, 2014 Dimitri Geshef
1
+ Copyright (c) 2013-2018 Dimitri Geshef
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
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, 2014, Dimitri Geshef.
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
@@ -1,112 +1,105 @@
1
- # File: application.rb
2
-
3
-
4
- require_relative 'cli/cmd-line'
5
- require_relative 'config'
6
- require_relative 'gherkin-listener'
7
- require_relative 'gherkin-facade'
8
- require_relative 'feature-model'
9
-
10
- module Cukedep # Module used as a namespace
11
- # Runner for the Cukedep application.
12
- class Application
13
- attr_reader(:proj_dir)
14
-
15
- public
16
-
17
- # Entry point for the application object.
18
- def run!(theCmdLineArgs)
19
- options = options_from(theCmdLineArgs)
20
- create_default_cfg if options[:setup]
21
- config = Config.load_cfg(Cukedep::YMLFilename)
22
-
23
- # Complain if no project dir is specified
24
- if config.proj_dir.nil? || config.proj_dir.empty?
25
- if options[:project]
26
- @proj_dir = options[:project]
27
- else
28
- msg_p1 = "No project dir specified in '#{Cukedep::YMLFilename}'"
29
- msg_p2 = ' nor via --project option.'
30
- fail(StandardError, msg_p1 + msg_p2)
31
- end
32
- else
33
- @proj_dir = config.proj_dir
34
- end
35
-
36
- feature_files = parse_features(config.feature_encoding)
37
-
38
- model = FeatureModel.new(feature_files)
39
- generate_files(model, config)
40
-
41
- return if options[:dryrun]
42
- rake_cmd = 'rake -f cukedep.rake'
43
- system(rake_cmd)
44
- end
45
-
46
- protected
47
-
48
- # Retrieve the user-entered command-line options
49
- def options_from(theCmdLineArgs)
50
- cli = CLI::CmdLine.new
51
- cli.parse!(theCmdLineArgs.dup)
52
- end
53
-
54
-
55
- # Create a local copy of the .cukedep.yml file, then
56
- # stop the application.
57
- def create_default_cfg()
58
- if File.exist?(Cukedep::YMLFilename)
59
- puts "OK to overwrite file #{Cukedep::YMLFilename}."
60
- puts '(Y/N)?'
61
- answer = $stdin.gets
62
- exit if answer =~ /^\s*[Nn]\s*$/
63
- end
64
- Config.default.write(Cukedep::YMLFilename)
65
-
66
- exit
67
- end
68
-
69
-
70
- # # Read the .cukedep.yml file in the current working directory
71
- # def load_cfg()
72
- # if File.exist?(Cukedep::YMLFilename)
73
- # YAML.load_file(Cukedep::YMLFilename)
74
- # else
75
- # Config.default
76
- # end
77
- # end
78
-
79
-
80
- # Parse the feature files (with the specified external encoding)
81
- def parse_features(external_encoding)
82
- # Create a Gherkin listener
83
- listener = Cukedep::GherkinListener.new
84
-
85
- # Parse the feature files in work directory
86
- is_verbose = true
87
- gherkin_facade = GherkinFacade.new(is_verbose, external_encoding)
88
- gherkin_facade.parse_features(listener, ['*.feature'])
89
-
90
- return listener.feature_files
91
- end
92
-
93
-
94
- def generate_files(aModel, aConfig)
95
- # Sort the feature files by dependency order.
96
- aModel.sort_features_by_dep
97
-
98
- puts "\nGenerating:"
99
-
100
- # Generate CSV files detailing the feature to identifier mapping
101
- # and vise versa
102
- # TODO: replace hard-coded names by value from config
103
- feature2id_report = aConfig.feature2id.name
104
- id2feature_report = aConfig.id2feature.name
105
- aModel.mapping_reports(feature2id_report, id2feature_report, true)
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
@@ -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 = <<-EOS
29
+ opts.banner = <<-HELP
30
30
  Usage: cukedep [options]
31
31
  The command-line options are:
32
- EOS
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(StandardError, err_msg)
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
- fail StandardError, "Cannot find the directory '#{theProjectPath}'."
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
- fail StandardError, msg_prefix + msg_suffix
100
+ raise StandardError, msg_prefix + msg_suffix
103
101
  end
104
102
  end
105
-
103
+
106
104
 
107
105
  return theProjectPath
108
106
  end
@@ -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
- # Read the YAML file with specified name from the current working directory.
48
- # If that file does not exist, then return an instance with default values.
49
- def self.load_cfg(filename)
50
- # TODO: validation
51
- instance = File.exist?(filename) ? YAML.load_file(filename) : default
52
-
53
- return instance
54
- end
55
-
56
-
57
- # Save the Config object to a YAML file.
58
- def write(filename)
59
- File.open(filename, 'w') { |f| YAML.dump(self, f) }
60
- end
61
-
62
-
63
- # Purpose: get the list of attributes referencing
64
- # a file action triplet.
65
- def self.file_action_attrs()
66
- return [
67
- :before_all_f_actions,
68
- :before_each_f_actions,
69
- :after_each_f_actions,
70
- :after_all_f_actions
71
- ]
72
- end
73
-
74
-
75
- # Return Hash config for a no-op action triplet.
76
- def self.empty_action_triplet()
77
- {
78
- save_patterns: [],
79
- save_subdir: '',
80
- delete_patterns: [],
81
- delete_subdir: '',
82
- copy_patterns: [],
83
- copy_subdir: ''
84
- }
85
- end
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