cukedep 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWY3NmMwOGE1YjM3MzVmNjA3YzFhYzlhMGE3ZmMwNTNiYzZhYjA1NQ==
4
+ ZTAzMGZlZWQ2YWQxNzgyYjRiOWFkNWU0MmUxN2E2NjYzNjcwZjRkYQ==
5
5
  data.tar.gz: !binary |-
6
- MjI3ZDE2ZGY3NGU0ZDQxM2FjNjY2Mzk4OTZiMDg4NGE0M2RhNjdiYQ==
6
+ MDFmNGNmODNmMjMwZDEyMDFiMDUyYTNmYjIxYTg5NTE1ZmY3YjhlNQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NjQxZGZjZDNlMDU1MzRlZDhlZWI2NGYzNjJiYWZmNWRlZDFiMzRhMWQ3YmVh
10
- NzllMWI4OGUxMWU1ZGIxNzU5ZjJkNmJiNWMzN2ZjZTlmMTBkN2UxYTIxYzRk
11
- YjRjZDlhMzdkNDRmOWY4N2MwZGEyOTVhOTA5NTIyZjJhYWM3ZWM=
9
+ OWI2NmJjYjg5YmUxNjBhMTZmYmIwZDU3OWUyYjIzNjllYjA4NGRlYzk2NGNm
10
+ NDJmYjI1YWI3ZmQ1MTZkODI3ZWI0ZjI4NjFjNzVkMmNlZjU0MTI5Y2I3ZDMz
11
+ NTBjYmExYjMyZjY5Yjc3OWI0ZWJhOGM4MTEyNmJkOWJhNzZiZTg=
12
12
  data.tar.gz: !binary |-
13
- ODllMDNmNmNlMzIwZTZmNDFmM2FkYTMyMDhhYmRjNDg4Nzg3NjY4Zjc4NjUw
14
- NGFlOTAwMTc5MGY2ZjFlNzllMjMwMzQxN2U0ZWExMjgyYjhkMjBiMzI0YTg5
15
- YjMyZThjMmJiNGY1YTBiMDQ0MWQ5NWUxZDE4MGI1YmYxYzdkNTk=
13
+ YjcyZGI5YjFhNGMzNDlhMjI3ZGY1ZDUyOGQwZmQ4MzgwNWUxMGFkZTA2YmI4
14
+ Y2VlYjgwYWFmN2EzNWM0ZWQ5YzBiODBmZGEwYzRhMDM4YTk0MWI0OTA5NTQz
15
+ ZmJjMWQ0YjA3MmU2YzhmZDk5OTA2YzUyY2U5MDM0ZTczY2JhMmI=
@@ -1,3 +1,11 @@
1
- ### 0.0.01 / 2013-10-23
1
+ ### 0.0.3 / 2013-10-24
2
+ * [FIX] File `rake.erb`. Removal of pp method call.
3
+
4
+ ### 0.0.2 / 2013-10-24
5
+ * [CHANGE] Code cleanup done to fix most code style issues reported by Rubocop.
6
+
7
+ * [FEATURE] Initial public working version
8
+
9
+ ### 0.0.1 / 2013-10-23
2
10
 
3
11
  * [FEATURE] Initial public working version
data/README.md CHANGED
@@ -1,11 +1,12 @@
1
1
  Cukedep
2
2
  ===========
3
3
  [![Build Status](https://travis-ci.org/famished-tiger/cukedep.png?branch=master)](https://travis-ci.org/famished-tiger/cukedep)
4
+ [![Gem Version](https://badge.fury.io/rb/cukedep.png)](http://badge.fury.io/rb/cukedep)
4
5
 
5
6
  _Handle dependencies between feature file._
6
7
  [Homepage](https://github.com/famished-tiger/cukedep)
7
8
 
8
- __Cukedep__ is a command-line utility that helps to run feature files in the proper sequence.
9
+ __Cukedep__ is a command-line utility that helps to run a set feature files in the proper sequence.
9
10
 
10
11
  ### Highlights ###
11
12
  * Simple syntax to specify dependencies
@@ -23,7 +24,7 @@ $[sudo] gem install cukedep
23
24
  To check the installation, open a shell/command window
24
25
  and type the command-line:
25
26
  ```bash
26
- $[sudo] cukedep --version
27
+ cukedep --version
27
28
  ```
28
29
 
29
30
  You should see the version of cukedep gem.
@@ -34,21 +35,21 @@ To get a first taste of how cukedep works, install it first.
34
35
  Then go to the root dir of the cukedep gem, then open a shell/command window
35
36
  and type the command-line:
36
37
  ```bash
37
- $[sudo] rake
38
+ rake
38
39
  ```
39
40
 
40
41
  You will see tests running and Cucumber executing a number of feature files.
41
42
 
42
- To learn more what's happening, go to the ```pec/sample_features``` dir
43
+ To learn more what's happening, go to the ```rspec/sample_features``` dir
43
44
  You will notice a number of feature files for a sample application.
44
45
  Stay in that folder and type the following command-line:
45
46
  ```bash
46
- $[sudo] cukedep --project ../../../sample --dry-run
47
+ cukedep --project ../../../sample --dry-run
47
48
  ```
48
49
 
49
50
  You instructed cukedep to do the following:
50
51
  * Read (parse) all the feature files in the current dir.
51
- * Resolve the dependencies between the feature files (based on specific Gherkin @tags).
52
+ * Resolve the dependencies between the feature files (based on Gherkin @tags with a special format).
52
53
  * Generate a number of dependency reports and drawing.
53
54
  * Generate a rake file that will execute the feature files in the proper sequence for
54
55
  the project located at the relative path ```../../../sample```
@@ -56,9 +57,12 @@ the project located at the relative path ```../../../sample```
56
57
  To generate all the above files and run the feature files with Cucumber,
57
58
  then retry the command line without the --dry-run option:
58
59
  ```bash
59
- $[sudo] cukedep --project ../../../sample --dry-run
60
+ cukedep --project ../../../sample --dry-run
60
61
  ```
61
62
 
63
+ ### How can I define ###
64
+
65
+
62
66
  Copyright
63
67
  ---------
64
68
  Copyright (c) 2013, Dimitri Geshef. Cukedep is released under the MIT License see [LICENSE.txt](https://github.com/famished-tiger/Cukedep/blob/master/LICENSE.txt) for details.
@@ -4,11 +4,12 @@
4
4
 
5
5
  mydir = File.dirname(__FILE__)
6
6
  lib_dir = mydir + '/../lib'
7
- $LOAD_PATH.unshift lib_dir unless $:.include?(lib_dir)
7
+ $LOAD_PATH.unshift lib_dir unless $LOAD_PATH.include?(lib_dir)
8
8
 
9
9
  require 'cukedep' # Load the Cukedep::Application class
10
10
 
11
11
  # The application's entry point
12
12
  app = Cukedep::Application.new
13
13
  app.start!(ARGV)
14
+
14
15
  # End of file
@@ -5,5 +5,5 @@
5
5
  require_relative './cukedep/constants'
6
6
  require_relative './cukedep/application'
7
7
 
8
- # End of file
9
8
 
9
+ # End of file
@@ -10,62 +10,65 @@ require_relative 'feature-model'
10
10
 
11
11
  module Cukedep # Module used as a namespace
12
12
 
13
- # Runner for the Cukedep application
13
+ # Runner for the Cukedep application.
14
14
  class Application
15
15
  attr_reader(:proj_dir)
16
16
  public
17
17
 
18
- # Entry point for the application object.
19
- def start!(theCmdLineArgs)
18
+ # Entry point for the application object.
19
+ def start!(theCmdLineArgs)
20
20
  options = options_from(theCmdLineArgs)
21
- create_default_cfg() if options[:setup]
22
- config = load_cfg()
21
+ create_default_cfg if options[:setup]
22
+ config = load_cfg
23
23
 
24
24
  # Complain if no project dir is specified
25
25
  if config.proj_dir.nil? || config.proj_dir.empty?
26
26
  if options[:project]
27
27
  @proj_dir = options[:project]
28
28
  else
29
- fail(StandardError, "No project dir specified via 'Cukedep::YMLFilename' nor via --project option.")
29
+ msg_p1 = "No project dir specified via 'Cukedep::YMLFilename'"
30
+ msg_p2 = ' nor via --project option.'
31
+ fail(StandardError, msg_p1 + msg_p2)
30
32
  end
31
33
  else
32
34
  @proj_dir = config.proj_dir
33
35
  end
34
36
 
35
- feature_files = parse_features()
37
+ feature_files = parse_features
36
38
 
37
39
  model = FeatureModel.new(feature_files)
38
40
  generate_files(model)
39
- unless options[:"dry-run"]
40
- rake_cmd = "rake -f cukedep.rake"
41
+ unless options[:dryrun]
42
+ rake_cmd = 'rake -f cukedep.rake'
41
43
  system(rake_cmd)
42
44
  end
43
45
  end
44
46
 
45
47
  protected
46
- # Retrieve the user-entered command-line options
48
+ # Retrieve the user-entered command-line options
47
49
  def options_from(theCmdLineArgs)
48
50
  cli = CLI::CmdLine.new
49
- options = cli.parse!(theCmdLineArgs.dup)
51
+ cli.parse!(theCmdLineArgs.dup)
50
52
  end
51
53
 
54
+
52
55
  # Create a local copy of the .cukedep.yml file, then
53
56
  # stop the application.
54
57
  def create_default_cfg()
55
58
  if File.exist?(Cukedep::YMLFilename)
56
59
  puts "OK to overwrite file #{Cukedep::YMLFilename}."
57
60
  puts '(Y/N)?'
58
- answer = $stdin.gets()
61
+ answer = $stdin.gets
59
62
  exit if answer =~ /^\s*[Nn]\s*$/
60
63
  end
61
- File::open(Cukedep::YMLFilename, 'w') { |f| YAML.dump(Config.default, f) }
64
+ File.open(Cukedep::YMLFilename, 'w') { |f| YAML.dump(Config.default, f) }
62
65
  exit
63
66
  end
64
67
 
65
68
  # Read the .cukedep.yml file in the current working directory
66
69
  def load_cfg()
67
70
  if File.exist?(Cukedep::YMLFilename)
68
- YAML::load_file(Cukedep::YMLFilename)
71
+ YAML.load_file(Cukedep::YMLFilename)
69
72
  else
70
73
  Config.default
71
74
  end
@@ -86,7 +89,7 @@ protected
86
89
  # Parse them
87
90
  filenames.each do |fname|
88
91
  puts " #{fname}"
89
- File::open(fname, 'r') { |f| parser.parse(f.read, fname, 0) }
92
+ File.open(fname, 'r') { |f| parser.parse(f.read, fname, 0) }
90
93
  end
91
94
 
92
95
  return listener.feature_files
@@ -95,12 +98,13 @@ protected
95
98
 
96
99
  def generate_files(aModel)
97
100
  # Sort the feature files by dependency order.
98
- aModel.sort_features_by_dep()
101
+ aModel.sort_features_by_dep
99
102
 
100
103
  puts "\nGenerating:"
101
104
 
102
105
  # Generate CSV files detailing the feature to identifier mapping
103
106
  # and vise versa
107
+ # TODO: replace hardcoded names by value from config
104
108
  aModel.mapping_reports('feature2id.csv', 'id2feature.csv', true)
105
109
  aModel.draw_dependency_graph('dependencies.dot', true)
106
110
  aModel.generate_rake_tasks('cukedep.rake', proj_dir)
@@ -109,4 +113,4 @@ end # class
109
113
 
110
114
  end # module
111
115
 
112
- # End of file
116
+ # End of file
@@ -35,9 +35,10 @@ The command-line options are:
35
35
  EOS
36
36
 
37
37
  # No argument. Check
38
- dry_txt = 'Check the feature file dependencies without running the feature files.'
39
- opts.on(nil, '--dry-run', dry_txt) do
40
- options[:"dry-run"] = true
38
+ dry_txt1 = 'Check the feature file dependencies'
39
+ dry_txt2 = ' without running the feature files.'
40
+ opts.on(nil, '--dry-run', dry_txt1 + dry_txt2) do
41
+ options[:dryrun] = true
41
42
  end
42
43
 
43
44
  # No argument. Create .cukedep.yml file
@@ -47,8 +48,9 @@ EOS
47
48
  end
48
49
 
49
50
  # Mandatory argument
50
- msg = 'Run the Cucumber project at given path with features from current dir.'
51
- opts.on('--project PROJ_PATH', msg) do |project_path|
51
+ msg_p1 = 'Run the Cucumber project at given path '
52
+ msg_p2 = 'with features from current dir.'
53
+ opts.on('--project PROJ_PATH', msg_p1 + msg_p2) do |project_path|
52
54
  options[:project] = validated_project(project_path)
53
55
  end
54
56
 
@@ -77,7 +79,7 @@ public
77
79
  err_msg << "No argument provided with command line option: #{arg}\n"
78
80
  end
79
81
  err_msg << 'To see the command-line syntax, do:\ncukedep --help'
80
- fail(StandardError, err_msg)
82
+ raise(StandardError, err_msg)
81
83
  end
82
84
 
83
85
  # Some options stop the application
@@ -94,11 +96,12 @@ private
94
96
 
95
97
  # If current dir is /features and project dir is parent of it
96
98
  # then we have an error
97
- current_path = Pathname.getwd()
99
+ current_path = Pathname.getwd
98
100
  if current_path.to_s =~ /features$/
99
101
  if current_path.parent == Pathname.new(theProjectPath)
100
- msg = "Original feature file may not be in 'features' subdir of project dir."
101
- fail StandardError, msg
102
+ msg_prefix = "Don't place original feature file in 'features'"
103
+ msg_suffix = ' subdir of project dir.'
104
+ fail StandardError, msg_prefix + msg_suffix
102
105
  end
103
106
  end
104
107
 
@@ -112,4 +115,4 @@ end # module
112
115
 
113
116
  end # module
114
117
 
115
- # End of file
118
+ # End of file
@@ -19,13 +19,18 @@ Config = Struct.new(
19
19
  class Config
20
20
  # Factory method. Build a config object with default settings.
21
21
  def self.default()
22
- Config.new(nil, FileMetaData.new('feature2id.csv'),
23
- FileMetaData.new('feature2id.csv'), FileMetaData.new('dependencies.dot'),
24
- 'cukedep.rake', [])
22
+ Config.new(
23
+ nil,
24
+ FileMetaData.new('feature2id.csv'),
25
+ FileMetaData.new('feature2id.csv'),
26
+ FileMetaData.new('dependencies.dot'),
27
+ 'cukedep.rake',
28
+ []
29
+ )
25
30
  end
26
31
 
27
32
  end # class
28
33
 
29
34
  end # module
30
35
 
31
- # End of file
36
+ # 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.0.1'
6
+ Version = '0.0.3'
7
7
 
8
8
  # Brief description of the gem.
9
9
  Description = 'Manage dependencies between Cucumber feature files'
@@ -16,7 +16,9 @@ class FeatureModel
16
16
 
17
17
  FeatureDependencies = Struct.new(:dependee, :dependents)
18
18
 
19
-
19
+ # Helper class used internally by FeatureModel class.
20
+ # Purpose: to try to create a valid dependency graph and perform a
21
+ # topological sort of the nodes.
20
22
  class DepGraph
21
23
  include TSort # Mix-in module for topological sorting
22
24
 
@@ -61,7 +63,7 @@ end # class
61
63
  # Retrieve the feature file matching the given feature identifiers
62
64
  # theIds one or more Strings, each being one feature identifier
63
65
  def select_by_ids(*theIds)
64
- features_by_ids = id2features()
66
+ features_by_ids = id2features
65
67
  selection = theIds.each_with_object([]) do |an_id, sub_result|
66
68
  found_feature = features_by_ids[an_id]
67
69
  if found_feature.nil?
@@ -82,7 +84,7 @@ end # class
82
84
  def dependency_links()
83
85
  if @dependencies.nil?
84
86
  # Build the mapping: feature identifier => feature
85
- features_by_id = id2features()
87
+ features_by_id = id2features
86
88
 
87
89
  # Resolve the dependency tags
88
90
  resolve_dependencies(features_by_id)
@@ -94,9 +96,9 @@ end # class
94
96
 
95
97
  # Sort the feature files by dependency order.
96
98
  def sort_features_by_dep()
97
- dep_links = dependency_links()
99
+ dep_links = dependency_links
98
100
  graph = DepGraph.new(dep_links)
99
- sorted_deps = graph.tsort()
101
+ sorted_deps = graph.tsort
100
102
 
101
103
  all_sorted = sorted_deps.map(&:dependee)
102
104
  @sorted_features = all_sorted.reject { |f| f.feature.anonymous? }
@@ -142,7 +144,7 @@ end # class
142
144
 
143
145
  def emit_heading(anIO)
144
146
  dir = File.dirname(File.absolute_path(feature_files[0].filepath))
145
- heading =<<-EOS
147
+ heading = <<-EOS
146
148
  // Graph of dependencies of feature files in directory:
147
149
  // '#{dir}'
148
150
  // This file uses the DOT syntax, a free utility from the Graphviz toolset.
@@ -166,7 +168,9 @@ EOS
166
168
  subgraph island {
167
169
  node [shape = box, style=filled, color=lightgray];
168
170
  EOS
169
- feature_files.each_with_index { |ff, i| draw_node(anIO, ff, i) if ff.feature.anonymous? }
171
+ feature_files.each_with_index do |ff, i|
172
+ draw_node(anIO, ff, i) if ff.feature.anonymous?
173
+ end
170
174
 
171
175
  anIO.puts <<-EOS
172
176
  label = "Isolated features";
@@ -175,26 +179,33 @@ EOS
175
179
  subgraph dependencies {
176
180
  node [shape = box, fillcolor = none];
177
181
  EOS
178
- feature_files.each_with_index { |ff, i| draw_node(anIO, ff, i) unless ff.feature.anonymous? }
182
+ feature_files.each_with_index do |ff, i|
183
+ draw_node(anIO, ff, i) unless ff.feature.anonymous?
184
+ end
179
185
  anIO.puts <<-EOS
180
186
  label = "Dependencies";
181
187
  }
182
188
 
183
189
  // The edges represent dependencies
184
190
  EOS
185
- dependencies.each {|a_dep| draw_edge(anIO, a_dep) }
191
+ dependencies.each { |a_dep| draw_edge(anIO, a_dep) }
186
192
  end
187
193
 
188
194
  # Output the closing part of the graph drawing
189
195
  def emit_trailing(anIO)
190
- anIO.puts "} // End of graph"
196
+ anIO.puts '} // End of graph'
191
197
  end
192
198
 
193
199
  # Draw a refinement node in DOT format
194
200
  def draw_node(anIO, aFeatureFile, anIndex)
195
201
  basename = File.basename(aFeatureFile.filepath, '.feature')
196
- identifier_suffix = aFeatureFile.feature.anonymous? ? '' : " -- #{aFeatureFile.feature.identifier}"
197
- anIO.puts %Q| node_#{anIndex} [label = "#{basename}#{identifier_suffix}"];|
202
+ its_feature = aFeatureFile.feature
203
+ if its_feature.anonymous?
204
+ id_suffix = ''
205
+ else
206
+ id_suffix = " -- #{its_feature.identifier}"
207
+ end
208
+ anIO.puts %Q| node_#{anIndex} [label = "#{basename}#{id_suffix}"];|
198
209
  end
199
210
 
200
211
  # Draw an edge between feature files having dependencies.
@@ -212,18 +223,18 @@ EOS
212
223
 
213
224
  def generate_rake_tasks(rakefile, theProjDir)
214
225
  puts " #{rakefile}"
215
- template_filepath = Pathname.new(File.dirname(__FILE__)).parent.parent + './templates/rake.erb'
216
- template_source = File.read(template_filepath)
226
+ grandparent_path = Pathname.new(File.dirname(__FILE__)).parent.parent
227
+ template_source = File.read(grandparent_path + './templates/rake.erb')
217
228
 
218
229
  # Create one template engine instance
219
230
  engine = ERB.new(template_source)
220
231
 
221
- source_dir = File.absolute_path(Dir.getwd())
232
+ source_dir = File.absolute_path(Dir.getwd)
222
233
  proj_dir = File.absolute_path(theProjDir)
223
- anonymous = anonymous_features.map {|ff| ff.basename}
234
+ anonymous = anonymous_features.map { |ff| ff.basename }
224
235
  feature_ids = feature_files.map { |ff| ff.feature.identifier }
225
236
  feature_ids.compact!
226
- deps = dependencies.reject {|dep| dep.dependee.feature.anonymous?}
237
+ deps = dependencies.reject { |dep| dep.dependee.feature.anonymous? }
227
238
 
228
239
  # Generate the text representation with given context
229
240
  file_source = engine.result(binding)
@@ -266,8 +277,9 @@ EOS
266
277
  # Complain when dependency tag refers to an unknown feature
267
278
  dependents = dep_tags.map do |a_tag|
268
279
  unless aMapping.include?(a_tag)
269
- msg = "Feature with identifier '#{its_id}' depends on unknown feature '#{a_tag}'"
270
- fail(StandardError, msg)
280
+ msg_p1 = "Feature with identifier '#{its_id}'"
281
+ msg_p2 = " depends on unknown feature '#{a_tag}'"
282
+ fail(StandardError, msg_p1 = msg_p2)
271
283
  end
272
284
  aMapping[a_tag]
273
285
  end
@@ -37,7 +37,7 @@ describe CLI::CmdLine do
37
37
 
38
38
  it 'should accept the dry-run option' do
39
39
  expect { subject.parse!(['--dry-run']) }.not_to raise_error
40
- expect(subject.options).to eq({ :"dry-run" => true })
40
+ expect(subject.options).to eq({ :dryrun => true })
41
41
  end
42
42
 
43
43
  it 'should accept the setup option' do
@@ -1,8 +1,7 @@
1
1
  # File: <%=rakefile%>
2
- # Generated by Cukedep <%=Cukedep::Version%>
2
+ # Generated by Cukedep <%=Cukedep::Version%> on <%=Time.now.strftime('%d/%m/%Y %H:%M:%S')%>
3
3
 
4
4
  require 'rake'
5
- require 'pp'
6
5
 
7
6
  # Run Cucumber via specialized Rake task
8
7
  require 'cucumber/rake/task'
@@ -80,7 +79,6 @@ def clean_project_dir(fname_patterns)
80
79
  Dir.chdir(CUKE_PROJECT + '/features')
81
80
  fname_patterns.each do |patt|
82
81
  filenames = Dir.glob(patt)
83
- pp filenames
84
82
  filenames.each { |fn| FileUtils.remove_file(fn) }
85
83
  end
86
84
  ensure #Always restore previous working dir.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cukedep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-23 00:00:00.000000000 Z
11
+ date: 2013-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -102,9 +102,7 @@ files:
102
102
  - README.md
103
103
  - bin/cukedep
104
104
  - lib/cukedep.rb
105
- - lib/macros4cuke.rb
106
105
  - lib/cukedep/application.rb
107
- - lib/cukedep/cli/application.rb
108
106
  - lib/cukedep/cli/cmd-line.rb
109
107
  - lib/cukedep/config.rb
110
108
  - lib/cukedep/constants.rb
File without changes
@@ -1,8 +0,0 @@
1
- # File: macros4cuke.rb
2
- # This file acts as a jumping-off point for loading dependencies expected
3
- # for a Macros4Cuke user.
4
-
5
- require_relative './macros4cuke/constants'
6
- require_relative './macros4cuke/macro-step-support'
7
-
8
- # End of file