cukedep 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG.md +4 -0
  3. data/Rakefile +4 -6
  4. data/lib/cukedep/application.rb +89 -91
  5. data/lib/cukedep/cli/cmd-line.rb +0 -7
  6. data/lib/cukedep/config.rb +70 -74
  7. data/lib/cukedep/constants.rb +1 -1
  8. data/lib/cukedep/cuke-runner.rb +0 -5
  9. data/lib/cukedep/customization.rb +0 -5
  10. data/lib/cukedep/feature-model.rb +1 -7
  11. data/lib/cukedep/feature-rep.rb +0 -4
  12. data/lib/cukedep/file-action.rb +209 -221
  13. data/lib/cukedep/gherkin-facade.rb +7 -10
  14. data/lib/cukedep/gherkin-listener.rb +82 -89
  15. data/lib/cukedep/hook-dsl.rb +0 -4
  16. data/lib/cukedep/sandbox.rb +0 -5
  17. data/sample/features/step_definitions/steps.rb +30 -26
  18. data/sample/features/support/env.rb +1 -1
  19. data/sample/model/model.rb +198 -205
  20. data/sample/result.html +1 -1
  21. data/spec/cukedep/application_spec.rb +15 -16
  22. data/spec/cukedep/cli/cmd-line_spec.rb +13 -16
  23. data/spec/cukedep/cuke-runner_spec.rb +55 -61
  24. data/spec/cukedep/customization_spec.rb +21 -26
  25. data/spec/cukedep/debug-file-action.rb +12 -10
  26. data/spec/cukedep/feature-model_spec.rb +13 -16
  27. data/spec/cukedep/feature-rep_spec.rb +4 -7
  28. data/spec/cukedep/file-action_spec.rb +18 -34
  29. data/spec/cukedep/file-parsing.rb +9 -11
  30. data/spec/cukedep/gherkin-facade_spec.rb +3 -8
  31. data/spec/cukedep/gherkin-listener_spec.rb +10 -12
  32. data/spec/cukedep/hook-dsl_spec.rb +6 -9
  33. data/spec/cukedep/sample_features/cukedep.rake +44 -37
  34. data/spec/cukedep/sample_features/cukedep_hooks.rb +2 -2
  35. data/spec/cukedep/sample_features/dependencies.dot +1 -1
  36. data/templates/rake.erb +36 -29
  37. metadata +2 -2
checksums.yaml CH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hOTU2MmQ4MWY3MzExZjYzNDc0MWIwYWU5MzgwY2MxZWNiMjFmNDNmNDgz
15
+ ODBjOGQzMzU2MzE5NzA1ZWNiYTk1YTE2MzYyNjI0YTc5OWFlN2M=
@@ -1,3 +1,7 @@
1
+ ### 0.1.11 / 2015-06-18
2
+ * [CHANGE] Code re-formatted to please Rubocop 0.32.0
3
+ * [FIX] File `.rubocop.yml`: disable some cop settings that were too loud.
4
+
1
5
  ### 0.1.10 / 2015-04-02
2
6
  * [FIX] File `.travis.yml`: Removed MRI Ruby 1.9.2 since it is rejected by latest Cucumber version. This caused a build failure on Travis
3
7
  * [NEW] File `.travis.yml` Added support for Ruby 2.2.0
data/Rakefile CHANGED
@@ -2,12 +2,10 @@ require 'rubygems'
2
2
  require_relative './lib/cukedep/constants'
3
3
 
4
4
  namespace :gem do
5
-
6
- desc 'Push the gem to rubygems.org'
7
- task :push do
8
- system("gem push cukedep-#{Cukedep::Version}.gem")
9
- end
10
-
5
+ desc 'Push the gem to rubygems.org'
6
+ task :push do
7
+ system("gem push cukedep-#{Cukedep::Version}.gem")
8
+ end
11
9
  end # namespace
12
10
 
13
11
  # Testing-specific tasks
@@ -8,107 +8,105 @@ require_relative 'gherkin-facade'
8
8
  require_relative 'feature-model'
9
9
 
10
10
  module Cukedep # Module used as a namespace
11
-
12
- # Runner for the Cukedep application.
13
- class Application
14
- attr_reader(:proj_dir)
15
-
16
- public
17
-
18
- # Entry point for the application object.
19
- def run!(theCmdLineArgs)
20
- options = options_from(theCmdLineArgs)
21
- create_default_cfg if options[:setup]
22
- config = Config.load_cfg(Cukedep::YMLFilename)
23
-
24
- # Complain if no project dir is specified
25
- if config.proj_dir.nil? || config.proj_dir.empty?
26
- if options[:project]
27
- @proj_dir = options[:project]
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
28
32
  else
29
- msg_p1 = "No project dir specified in '#{Cukedep::YMLFilename}'"
30
- msg_p2 = ' nor via --project option.'
31
- fail(StandardError, msg_p1 + msg_p2)
33
+ @proj_dir = config.proj_dir
32
34
  end
33
- else
34
- @proj_dir = config.proj_dir
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)
35
44
  end
36
45
 
37
- feature_files = parse_features(config.feature_encoding)
38
-
39
- model = FeatureModel.new(feature_files)
40
- generate_files(model, config)
41
-
42
- return if options[:dryrun]
43
- rake_cmd = 'rake -f cukedep.rake'
44
- system(rake_cmd)
45
- end
46
-
47
- protected
48
-
49
- # Retrieve the user-entered command-line options
50
- def options_from(theCmdLineArgs)
51
- cli = CLI::CmdLine.new
52
- cli.parse!(theCmdLineArgs.dup)
53
- end
54
-
55
-
56
- # Create a local copy of the .cukedep.yml file, then
57
- # stop the application.
58
- def create_default_cfg()
59
- if File.exist?(Cukedep::YMLFilename)
60
- puts "OK to overwrite file #{Cukedep::YMLFilename}."
61
- puts '(Y/N)?'
62
- answer = $stdin.gets
63
- exit if answer =~ /^\s*[Nn]\s*$/
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)
64
52
  end
65
- Config.default.write(Cukedep::YMLFilename)
66
-
67
- exit
68
- end
69
-
70
-
71
- # # Read the .cukedep.yml file in the current working directory
72
- # def load_cfg()
73
- # if File.exist?(Cukedep::YMLFilename)
74
- # YAML.load_file(Cukedep::YMLFilename)
75
- # else
76
- # Config.default
77
- # end
78
- # end
79
-
80
-
81
- # Parse the feature files (with the specified external encoding)
82
- def parse_features(external_encoding)
83
- # Create a Gherkin listener
84
- listener = Cukedep::GherkinListener.new
85
-
86
- # Parse the feature files in work directory
87
- is_verbose = true
88
- gherkin_facade = GherkinFacade.new(is_verbose, external_encoding)
89
- gherkin_facade.parse_features(listener, ['*.feature'])
90
53
 
91
- return listener.feature_files
92
- end
93
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)
94
65
 
95
- def generate_files(aModel, aConfig)
96
- # Sort the feature files by dependency order.
97
- aModel.sort_features_by_dep
98
-
99
- puts "\nGenerating:"
66
+ exit
67
+ end
100
68
 
101
- # Generate CSV files detailing the feature to identifier mapping
102
- # and vise versa
103
- # TODO: replace hard-coded names by value from config
104
- feature2id_report = aConfig.feature2id.name
105
- id2feature_report = aConfig.id2feature.name
106
- aModel.mapping_reports(feature2id_report, id2feature_report, true)
107
- aModel.draw_dependency_graph(aConfig.graph_file.name, true)
108
- aModel.generate_rake_tasks(aConfig.rake_file, proj_dir)
109
- end
110
- end # class
111
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
112
110
  end # module
113
111
 
114
112
  # End of file
@@ -7,11 +7,8 @@ require 'pathname'
7
7
  require_relative '../constants'
8
8
 
9
9
  module Cukedep # This module is used as a namespace
10
-
11
10
  # Module dedicated to the command-line interface
12
11
  module CLI
13
-
14
-
15
12
  # Manages the application command-line interface (CLI).
16
13
  # It is merely a thin wrapper around the OptionParser library.
17
14
  # Responsibilities:
@@ -64,7 +61,6 @@ EOS
64
61
  puts Cukedep::Version
65
62
  options[:version] = true
66
63
  end
67
-
68
64
  end
69
65
  end
70
66
 
@@ -110,11 +106,8 @@ EOS
110
106
 
111
107
  return theProjectPath
112
108
  end
113
-
114
109
  end # class
115
-
116
110
  end # module
117
-
118
111
  end # module
119
112
 
120
113
  # End of file
@@ -4,90 +4,86 @@ require 'yaml'
4
4
  require_relative 'file-action'
5
5
 
6
6
  module Cukedep # Module used as a namespace
7
-
8
- FileMetaData = Struct.new(:name)
9
-
10
- Config = Struct.new(
11
- :feature_encoding, # The character encoding of feature files
12
- :proj_dir, # The directory of the cucumber project
13
- :feature2id, # Meta-data about the feature => feature id report
14
- :id2feature, # Meta-data about the feature id => feature report
15
- :graph_file, # Meta-data about the dependency graph file
16
- :rake_file, # Name of the output rake file
17
- :cucumber_args, # Command-line syntax to use for the cucumber application
18
- # File actions triggered at Cucumber invocation events
19
- :before_all_f_actions,
20
- :before_each_f_actions,
21
- :after_each_f_actions,
22
- :after_all_f_actions
23
- )
24
-
25
- # Re-open the class for further customisation
26
-
27
- # Configuration object for the Cukedep application.
28
- class Config
29
- # Factory method. Build a config object with default settings.
30
- def self.default()
31
- instance = Config.new(
32
- 'UTF-8',
33
- nil,
34
- FileMetaData.new('feature2id.csv'),
35
- FileMetaData.new('feature2id.csv'),
36
- FileMetaData.new('dependencies.dot'),
37
- 'cukedep.rake',
38
- []
39
- )
40
-
41
- file_action_attrs.each do |attr|
42
- instance[attr] = empty_action_triplet
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
43
44
  end
44
45
 
45
- return instance
46
- end
47
-
48
-
49
- # Read the YAML file with specified name from the current working directory.
50
- # If that file does not exist, then return an instance with default values.
51
- def self.load_cfg(filename)
52
- # TODO: validation
53
- instance = File.exist?(filename) ? YAML.load_file(filename) : default
54
-
55
- return instance
56
- end
57
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
58
52
 
59
- # Save the Config object to a YAML file.
60
- def write(filename)
61
- File.open(filename, 'w') { |f| YAML.dump(self, f) }
62
- end
53
+ return instance
54
+ end
63
55
 
64
56
 
65
- # Purpose: get the list of attributes referencing
66
- # a file action triplet.
67
- def self.file_action_attrs()
68
- return [
69
- :before_all_f_actions,
70
- :before_each_f_actions,
71
- :after_each_f_actions,
72
- :after_all_f_actions
73
- ]
74
- end
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
75
61
 
76
62
 
77
- # Return Hash config for a no-op action triplet.
78
- def self.empty_action_triplet()
79
- {
80
- save_patterns: [],
81
- save_subdir: '',
82
- delete_patterns: [],
83
- delete_subdir: '',
84
- copy_patterns: [],
85
- copy_subdir: ''
86
- }
87
- end
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
88
73
 
89
- end # class
90
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
91
87
  end # module
92
88
 
93
89
  # End of file
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Cukedep # Module used as a namespace
5
5
  # The version number of the gem.
6
- Version = '0.1.10'
6
+ Version = '0.1.11'
7
7
 
8
8
  # Brief description of the gem.
9
9
  Description = 'Manage dependencies between Cucumber feature files'