cukedep 0.0.7 → 0.0.8

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTViZGY3MjYyZjAyOThlODc2YmQ4ODE1M2Y4NGI0N2IzMzliNmU5Yw==
4
+ YTdmNmY0Y2RkMTQxYjk5NmY2OGU2ZGIzMWVkNWQ0MmQ3MTFjNTk5OA==
5
5
  data.tar.gz: !binary |-
6
- ZWFkN2Y4YThkZDNiODQ4ZDczMmFkMTBhNTk4OTQ0NTMzNWZmN2FlYg==
6
+ NjMxMWRiMmZiOWEwYjAwMmFiZWRlYTVlZDczMTU4OThkMjM1MTE2ZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MTEzZjdmYmVhNmNhMzU2MWVhMGFhYzhhYmM2NDdlOGNkOTMzNzkwYjBmNGNi
10
- YmNkYWE5YzBlZTU4N2Y1OTJiOGI2MGRjNjg3MzMzZGFiYmUxMmRlYTQ4ZWZl
11
- YjE0MDViOTc5M2E0ZmQxOGE2NDYzNWM5ODU5YWMwMzdlYjU1NTQ=
9
+ OTExMGMwMzliMTA0NGU2MGU2NTdhMjNlYWQxYjg1YjJlN2NlMDBmYWZiOWZh
10
+ Yzc2MGU2M2I0ZjkwOWJjZGFlZGJiMmRhNTgzMWU5N2RiNWQwMmUwN2EzYzUy
11
+ ODUwOGFlZjlmOWVjYjQ4YzZlMTkzMGUwZTE1OWFlNzY3NDAzMzQ=
12
12
  data.tar.gz: !binary |-
13
- ZjllNDM1ZDE4NGRmMWQzMGE5ZWUxYzIyMjg4ZGU2NGE1ZTg2ZWRiZWEwN2Nj
14
- OTQ2ZGE1MTc1ZDRlNTRmZTgzYjJkZjk1Zjg3MzU2ZjE4Y2MzZmIyNjg0NDYx
15
- OWVmMDhhMWEzYzc4YmRjNzgzM2I3YzA5NTlhOTZjNmVhZGY3NzE=
13
+ YzU1MDgyZjk5ZGM3OGE4NTMxNDMwYTk5MWQyNGRmZDY1MGQwMWIyMTI0YmU0
14
+ YTkxZWYzMTE0N2I0NDVkYjkzMDJjZjhiOTRlMGNmZDJkZmE2NjQxMDRmNWMw
15
+ MjM4NGJlZDQ4YmYwZWJkMzhkZDkzOWE5OWY1Mjk0NjI2NDgxNmM=
@@ -1,3 +1,9 @@
1
+ ### 0.0.8 / 2013-10-31
2
+ * [Fix] After adding a non-ASCII in a sample feature, Gherkin raised an encoding incompatibility error. Fixed
3
+ * [CHANGE] Added a new field 'feature_encoding' in Config object to store the encoding of feature files (default = 'UTF-8')
4
+ * [NEW] Class `GherkinFacade`
5
+ * [CHANGE] `Application#parse_features` method
6
+
1
7
  ### 0.0.7 / 2013-10-25
2
8
  * [CHANGE] Method `Application#generate_files` now uses the filenames as specified in the `cukedep.yml` file.
3
9
 
@@ -1,11 +1,11 @@
1
1
  # File: application.rb
2
2
 
3
3
  require 'yaml'
4
- require 'gherkin/parser/parser'
5
4
 
6
5
  require_relative 'cli/cmd-line'
7
6
  require_relative 'config'
8
7
  require_relative 'gherkin-listener'
8
+ require_relative 'gherkin-facade'
9
9
  require_relative 'feature-model'
10
10
 
11
11
  module Cukedep # Module used as a namespace
@@ -34,7 +34,7 @@ public
34
34
  @proj_dir = config.proj_dir
35
35
  end
36
36
 
37
- feature_files = parse_features
37
+ feature_files = parse_features(config.feature_encoding)
38
38
 
39
39
  model = FeatureModel.new(feature_files)
40
40
  generate_files(model, config)
@@ -75,23 +75,15 @@ protected
75
75
  end
76
76
  end
77
77
 
78
- # Parse the feature files
79
- def parse_features()
78
+ # Parse the feature files (with the specified external encoding)
79
+ def parse_features(external_encoding)
80
80
  # Create a Gherkin listener
81
81
  listener = Cukedep::GherkinListener.new
82
-
83
- # Create a Gherkin parser
84
- parser = Gherkin::Parser::Parser.new(listener)
85
-
86
- # List all the .feature files
87
- filenames = Dir.glob('*.feature')
88
- puts "\nParsing:"
89
82
 
90
- # Parse them
91
- filenames.each do |fname|
92
- puts " #{fname}"
93
- File.open(fname, 'r') { |f| parser.parse(f.read, fname, 0) }
94
- end
83
+ # Parse the feature files in work directory
84
+ is_verbose = true
85
+ gherkin_facade = GherkinFacade.new(is_verbose, external_encoding)
86
+ gherkin_facade.parse_features(listener, ['*.feature'])
95
87
 
96
88
  return listener.feature_files
97
89
  end
@@ -5,6 +5,7 @@ module Cukedep # Module used as a namespace
5
5
  FileMetaData = Struct.new(:name)
6
6
 
7
7
  Config = Struct.new(
8
+ :feature_encoding, # The encoding of feature files
8
9
  :proj_dir, # The directory of the cucumber project
9
10
  :feature2id, # Meta-data about the feature => feature id report
10
11
  :id2feature, # Meta-data about the feature id => feature report
@@ -20,6 +21,7 @@ class Config
20
21
  # Factory method. Build a config object with default settings.
21
22
  def self.default()
22
23
  Config.new(
24
+ 'UTF-8',
23
25
  nil,
24
26
  FileMetaData.new('feature2id.csv'),
25
27
  FileMetaData.new('feature2id.csv'),
@@ -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.7'
6
+ Version = '0.0.8'
7
7
 
8
8
  # Brief description of the gem.
9
9
  Description = 'Manage dependencies between Cucumber feature files'
@@ -11,7 +11,7 @@ module Cukedep # Module used as a namespace
11
11
  # Constant Cukedep::RootDir contains the absolute path of Rodent's
12
12
  # root directory. Note: it also ends with a slash character.
13
13
  unless defined?(RootDir)
14
- # The initialisation of constant RootDir is guarded in order
14
+ # The initialisation of constant RootDir is guarded in order
15
15
  # to avoid multiple initialisation (not allowed for constants)
16
16
 
17
17
  # The root folder of Cukedep.
@@ -20,7 +20,7 @@ module Cukedep # Module used as a namespace
20
20
  rootdir = Pathname(__FILE__).dirname.parent.parent.expand_path
21
21
  rootdir.to_s + '/' # Append trailing slash character to it
22
22
  end
23
-
23
+
24
24
  # The file name for the user's settings
25
25
  YMLFilename = '.cukedep.yml'
26
26
  end
@@ -0,0 +1,52 @@
1
+ # File: gherkin-facade.rb
2
+
3
+ require 'gherkin'
4
+ require 'gherkin/lexer/encoding'
5
+
6
+ module Cukedep # This module is used as a namespace
7
+
8
+ # Facade design pattern: A facade is an object that provides
9
+ # a simplified interface to a larger body of code.
10
+ # Here the GherkinFacade class provides basic parsing service.
11
+ class GherkinFacade
12
+ # Indicate whether the parsing must be verbose or silent
13
+ attr_reader(:verbose)
14
+
15
+ # (External) encoding of the feature files.
16
+ # It is a string that represents the name of an encoding
17
+ # as expected by the mode argument of the IO#new method
18
+ attr_reader(:external_encoding)
19
+
20
+
21
+ def initialize(isVerbose, anExternalEncoding)
22
+ @verbose = isVerbose
23
+ @external_encoding = anExternalEncoding
24
+ end
25
+
26
+ # Parse feature files from the work directory that match
27
+ # one of the given file name patterns.
28
+ # Parse events are sent to the passed listener object.
29
+ def parse_features(aListener, file_patterns)
30
+ # Create a Gherkin parser
31
+ parser = Gherkin::Parser::Parser.new(aListener)
32
+
33
+ puts "\nParsing:" if verbose
34
+ # List all .feature files in work directory that match the pattern
35
+ filenames = []
36
+ file_patterns.each { |patt| filenames.concat(Dir.glob(patt)) }
37
+
38
+ # Parse them
39
+ filenames.each do |fname|
40
+ puts " #{fname}" if verbose
41
+ # To prevent encoding issue, open the file with an explicit external encoding
42
+ File::open(fname, "r:#{external_encoding}") { |f| parser.parse(f.read, fname, 0) }
43
+ end
44
+
45
+ return aListener
46
+ end
47
+
48
+ end # class
49
+
50
+ end # module
51
+
52
+ # End of file
@@ -1,6 +1,6 @@
1
1
  # File: file-parsing.rb
2
2
 
3
- require 'gherkin/parser/parser'
3
+ require_relative '../../lib/cukedep/gherkin-facade'
4
4
 
5
5
  module Cukedep # This module is used as a namespace
6
6
 
@@ -19,18 +19,21 @@ module Cukedep # This module is used as a namespace
19
19
  # Helper method. It parses sample feature files and
20
20
  # notifies the provided listener of its progress.
21
21
  def parse_for(aListener)
22
- # Determine the folder where the sample files reside
23
- my_dir = File.dirname(__FILE__)
24
- sample_dir = File.expand_path(my_dir + '/sample_features')
25
-
26
- # Create a Gherkin parser
27
- parser = Gherkin::Parser::Parser.new(aListener)
28
-
29
- # Let it parse the requested files
30
- SampleFileNames.each do |sample|
31
- path = sample_dir + '/' + sample
32
- File::open(path, 'r') { |f| parser.parse(f.read, path, 0) }
22
+ orig_dir = Dir.getwd()
23
+ begin
24
+ # Determine the folder where the sample files reside
25
+ my_dir = File.dirname(__FILE__)
26
+ sample_dir = File.expand_path(my_dir + '/sample_features')
27
+ Dir.chdir(sample_dir)
28
+
29
+ # Parse the specified feature files in work directory
30
+ is_verbose = false
31
+ gherkin_facade = GherkinFacade.new(is_verbose, 'UTF-8')
32
+ gherkin_facade.parse_features(aListener, SampleFileNames)
33
+ ensure
34
+ Dir.chdir(orig_dir)
33
35
  end
36
+
34
37
  end
35
38
 
36
39
  end # module
@@ -1,3 +1,4 @@
1
+ # § <- This character is UTF-8
1
2
  # This feature has no identifier and no explicit dependencies
2
3
  Feature: Registering new videos
3
4
  As a video rental owner
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.7
4
+ version: 0.0.8
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-25 00:00:00.000000000 Z
11
+ date: 2013-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -122,14 +122,11 @@ files:
122
122
  - lib/cukedep/constants.rb
123
123
  - lib/cukedep/feature-model.rb
124
124
  - lib/cukedep/feature-rep.rb
125
+ - lib/cukedep/gherkin-facade.rb
125
126
  - lib/cukedep/gherkin-listener.rb
126
127
  - sample/features/step_definitions/steps.rb
127
128
  - sample/features/support/env.rb
128
- - sample/model/catalogue.yml
129
- - sample/model/members.yml
130
129
  - sample/model/model.rb
131
- - sample/model/rentals.yml
132
- - sample/model/users.yml
133
130
  - spec/cukedep/application_spec.rb
134
131
  - spec/cukedep/cli/cmd-line_spec.rb
135
132
  - spec/cukedep/feature-model_spec.rb
@@ -138,10 +135,6 @@ files:
138
135
  - spec/cukedep/gherkin-listener_spec.rb
139
136
  - spec/spec_helper.rb
140
137
  - spec/cukedep/sample_features/a_few_tests.feature
141
- - spec/cukedep/sample_features/cukedep.rake
142
- - spec/cukedep/sample_features/dependencies.dot
143
- - spec/cukedep/sample_features/feature2id.csv
144
- - spec/cukedep/sample_features/id2feature.csv
145
138
  - spec/cukedep/sample_features/more_tests.feature
146
139
  - spec/cukedep/sample_features/other_tests.feature
147
140
  - spec/cukedep/sample_features/some_tests.feature
@@ -1,13 +0,0 @@
1
- ---
2
- - !ruby/struct:Sample::Video
3
- title: The empire of Cucumber
4
- state: :available
5
- - !ruby/struct:Sample::Video
6
- title: The revenge of the Cucumber
7
- state: :available
8
- - !ruby/struct:Sample::Video
9
- title: The peeled Cucumber
10
- state: :available
11
- - !ruby/struct:Sample::Video
12
- title: The masked Cucumber
13
- state: :available
@@ -1,13 +0,0 @@
1
- ---
2
- - !ruby/struct:Sample::Member
3
- name: John Doe
4
- - !ruby/struct:Sample::Member
5
- name: Jed Eye
6
- - !ruby/struct:Sample::Member
7
- name: Bill Bo
8
- - !ruby/struct:Sample::Member
9
- name: Jack Orjones
10
- - !ruby/struct:Sample::Member
11
- name: Mary Gherkin
12
- - !ruby/struct:Sample::Member
13
- name: Waldo Cuke
@@ -1,4 +0,0 @@
1
- ---
2
- - !ruby/struct:Sample::Rental
3
- video: The masked Cucumber
4
- member: John Doe
@@ -1,7 +0,0 @@
1
- ---
2
- - !ruby/struct:Sample::User
3
- credential: it's me
4
- - !ruby/struct:Sample::User
5
- credential: himself
6
- - !ruby/struct:Sample::User
7
- credential: nemo
@@ -1,191 +0,0 @@
1
- # File: cukedep.rake
2
- # Generated by Cukedep 0.0.6 on 25/10/2013 21:52:06
3
-
4
- require 'rake'
5
-
6
- # Run Cucumber via specialized Rake task
7
- require 'cucumber/rake/task'
8
- # UGLY workaround for bug in Cucumber's rake task
9
- if Gem::VERSION[0].to_i >= 2 && Cucumber::VERSION <= '1.3.2'
10
- # Monkey-patch a buggy method
11
- class Cucumber::Rake::Task::ForkedCucumberRunner
12
- def gem_available?(gemname)
13
- if Gem::VERSION[0].to_i >= 2
14
- gem_available_new_rubygems?(gemname)
15
- else
16
- gem_available_old_rubygems?(gemname)
17
- end
18
- end
19
- end # class
20
- end
21
-
22
- # Create a task called cucumber
23
- Cucumber::Rake::Task.new do |t|
24
- end
25
-
26
-
27
- # Constant holding the location of the original feature files
28
- SOURCE_DIR = 'C:/Ruby193/lib/ruby/site_ruby/Cukedep/spec/cukedep/sample_features'
29
-
30
- # Constant holding the location of the project
31
- CUKE_PROJECT = 'C:/Ruby193/lib/ruby/site_ruby/Cukedep/sample'
32
-
33
- # Helper method. Calculate the filepath of a file with given name
34
- # if it is located in the source dir.
35
- def source_path_of(aFilename)
36
- SOURCE_DIR + '/' + aFilename
37
- end
38
-
39
- # Helper method. Calculate the filepath of a file with given name
40
- # if it is located in the project featurers dir.
41
- def project_path_of(aFilename)
42
- CUKE_PROJECT + '/features/' + aFilename
43
- end
44
-
45
- # Helper method. Given the name of files in the source dir, copy them
46
- # into the project dir.
47
- def copy_to_project(filenames)
48
- filenames.each do |fname|
49
- source_path = source_path_of(fname)
50
- dest_path = project_path_of(fname)
51
- FileUtils.copy_file(source_path, dest_path)
52
- end
53
- end
54
-
55
-
56
- # Helper method. Given the name of files in the features dir of the project,
57
- # copy them into the source dir.
58
- def copy_from_project(*filenames)
59
- filenames.each do |fname|
60
- source_path = project_path_of(fname)
61
- dest_path = source_path_of(fname)
62
- FileUtils.copy_file(source_path, dest_path)
63
- end
64
- end
65
-
66
- def del_from_project(filenames)
67
- filenames.each do |fname|
68
- dest_path = project_path_of(fname)
69
- FileUtils.remove_file(dest_path)
70
- end
71
- end
72
-
73
- # Helper method. Delete all the files in the
74
- # the project's features dir that match one of
75
- # the file name pattern
76
- def clean_project_dir(fname_patterns)
77
- curr_dir = Dir.getwd()
78
- begin
79
- Dir.chdir(CUKE_PROJECT + '/features')
80
- fname_patterns.each do |patt|
81
- filenames = Dir.glob(patt)
82
- filenames.each { |fn| FileUtils.remove_file(fn) }
83
- end
84
- ensure #Always restore previous working dir.
85
- Dir.chdir(curr_dir)
86
- end
87
- end
88
-
89
-
90
- def process_files(filenames)
91
- copy_to_project(filenames)
92
- curr_dir = Dir.getwd()
93
- Dir.chdir(CUKE_PROJECT)
94
- begin
95
- do_cuke = Rake::Task[:cucumber]
96
- do_cuke.reenable
97
- do_cuke.invoke
98
- ensure
99
- Dir.chdir(curr_dir)
100
- end
101
- del_from_project(filenames)
102
- end
103
-
104
- def process_a_feature(filename)
105
- process_files([filename])
106
- end
107
-
108
-
109
- AllUnidentifiedFeatures = [
110
- 'standalone.feature'
111
- ]
112
-
113
-
114
- AllFeatureIdentifiers = [
115
- :qux,
116
- :quux,
117
- :corge,
118
- :foo,
119
- :baz,
120
- :bar
121
- ]
122
-
123
- # Default rake task is also top-level task
124
- task :default => :run_all_features
125
-
126
-
127
- desc 'Run all features'
128
- task :run_all_features => [:before_all, :all_features, :after_all] do
129
- ; # Do nothing
130
- end
131
-
132
-
133
- # Remove feature files from a cuke project
134
- task :dir_cleanup do
135
- clean_project_dir(['*.feature'])
136
- end
137
-
138
-
139
-
140
- desc 'Before all'
141
- task :before_all => [:dir_cleanup] do
142
- ; # Do nothing
143
- end
144
-
145
- desc 'After_all'
146
- task :after_all do
147
- ; # Do nothing
148
- end
149
-
150
-
151
- task :unidentified do
152
- process_files(AllUnidentifiedFeatures)
153
- end
154
-
155
- # Tasks for feature files involved in dependencies
156
-
157
-
158
- task :qux do
159
- process_a_feature('a_few_tests.feature')
160
- end
161
-
162
-
163
- task :quux do
164
- process_a_feature('more_tests.feature')
165
- end
166
-
167
-
168
- task :corge => [:foo] do
169
- process_a_feature('other_tests.feature')
170
- end
171
-
172
-
173
- task :foo => [:bar, :qux] do
174
- process_a_feature('some_tests.feature')
175
- end
176
-
177
-
178
- task :baz do
179
- process_a_feature('still_other_tests.feature')
180
- end
181
-
182
-
183
- task :bar => [:baz, :qux, :quux] do
184
- process_a_feature('yet_other_tests.feature')
185
- end
186
-
187
-
188
- task :all_features => ([:unidentified] + AllFeatureIdentifiers) do
189
- end
190
-
191
- # End of file
@@ -1,38 +0,0 @@
1
- // Graph of dependencies of feature files in directory:
2
- // 'C:/Ruby193/lib/ruby/site_ruby/Cukedep/spec/cukedep/sample_features'
3
- // This file uses the DOT syntax, a free utility from the Graphviz toolset.
4
- // Graphviz is available at: www.graphviz.org
5
- // File generated on Fri Oct 25 21:52:06 2013.
6
-
7
- digraph g {
8
- size = "7, 11"; // Dimensions in inches...
9
- center = true;
10
- rankdir = BT; // Draw from bottom to top
11
- label = "\nDependency graph of 'C:/Ruby193/lib/ruby/site_ruby/Cukedep/spec/cukedep/sample_features'";
12
-
13
- // Nodes represent feature files
14
- subgraph island {
15
- node [shape = box, style=filled, color=lightgray];
16
- node_4 [label = "standalone"];
17
- label = "Isolated features";
18
- }
19
-
20
- subgraph dependencies {
21
- node [shape = box, fillcolor = none];
22
- node_0 [label = "a_few_tests -- qux"];
23
- node_1 [label = "more_tests -- quux"];
24
- node_2 [label = "other_tests -- corge"];
25
- node_3 [label = "some_tests -- foo"];
26
- node_5 [label = "still_other_tests -- baz"];
27
- node_6 [label = "yet_other_tests -- bar"];
28
- label = "Dependencies";
29
- }
30
-
31
- // The edges represent dependencies
32
- node_2 -> node_3;
33
- node_3 -> node_6;
34
- node_3 -> node_0;
35
- node_6 -> node_5;
36
- node_6 -> node_0;
37
- node_6 -> node_1;
38
- } // End of graph
@@ -1,7 +0,0 @@
1
- identifier,feature file
2
- qux,a_few_tests.feature
3
- quux,more_tests.feature
4
- corge,other_tests.feature
5
- foo,some_tests.feature
6
- baz,still_other_tests.feature
7
- bar,yet_other_tests.feature
@@ -1,7 +0,0 @@
1
- identifier,feature file
2
- qux,a_few_tests.feature
3
- quux,more_tests.feature
4
- corge,other_tests.feature
5
- foo,some_tests.feature
6
- baz,still_other_tests.feature
7
- bar,yet_other_tests.feature