lucid 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. data/.gitignore +30 -10
  2. data/.rspec +1 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +15 -0
  6. data/Gemfile +4 -2
  7. data/HISTORY.md +22 -0
  8. data/{LICENSE.txt → LICENSE} +6 -3
  9. data/README.md +22 -8
  10. data/Rakefile +2 -1
  11. data/bin/lucid +10 -10
  12. data/bin/lucid-gen +4 -0
  13. data/lib/autotest/discover.rb +11 -0
  14. data/lib/autotest/lucid.rb +6 -0
  15. data/lib/autotest/lucid_mixin.rb +135 -0
  16. data/lib/autotest/lucid_rails.rb +6 -0
  17. data/lib/autotest/lucid_rails_rspec.rb +6 -0
  18. data/lib/autotest/lucid_rails_rspec2.rb +6 -0
  19. data/lib/autotest/lucid_rspec.rb +6 -0
  20. data/lib/autotest/lucid_rspec2.rb +6 -0
  21. data/lib/lucid.rb +32 -1
  22. data/lib/lucid/ast.rb +20 -0
  23. data/lib/lucid/ast/background.rb +116 -0
  24. data/lib/lucid/ast/comment.rb +24 -0
  25. data/lib/lucid/ast/doc_string.rb +44 -0
  26. data/lib/lucid/ast/empty_background.rb +33 -0
  27. data/lib/lucid/ast/examples.rb +49 -0
  28. data/lib/lucid/ast/feature.rb +99 -0
  29. data/lib/lucid/ast/has_steps.rb +74 -0
  30. data/lib/lucid/ast/location.rb +41 -0
  31. data/lib/lucid/ast/multiline_argument.rb +31 -0
  32. data/lib/lucid/ast/names.rb +13 -0
  33. data/lib/lucid/ast/outline_table.rb +194 -0
  34. data/lib/lucid/ast/scenario.rb +103 -0
  35. data/lib/lucid/ast/scenario_outline.rb +144 -0
  36. data/lib/lucid/ast/specs.rb +38 -0
  37. data/lib/lucid/ast/step.rb +122 -0
  38. data/lib/lucid/ast/step_collection.rb +92 -0
  39. data/lib/lucid/ast/step_invocation.rb +196 -0
  40. data/lib/lucid/ast/table.rb +730 -0
  41. data/lib/lucid/ast/tags.rb +28 -0
  42. data/lib/lucid/ast/tdl_walker.rb +195 -0
  43. data/lib/lucid/cli/app.rb +78 -0
  44. data/lib/lucid/cli/configuration.rb +261 -0
  45. data/lib/lucid/cli/options.rb +463 -0
  46. data/lib/lucid/cli/profile.rb +101 -0
  47. data/lib/lucid/configuration.rb +53 -0
  48. data/lib/lucid/core_ext/disable_autorunners.rb +15 -0
  49. data/lib/lucid/core_ext/instance_exec.rb +70 -0
  50. data/lib/lucid/core_ext/proc.rb +36 -0
  51. data/lib/lucid/core_ext/string.rb +9 -0
  52. data/lib/lucid/errors.rb +40 -0
  53. data/lib/lucid/factory.rb +43 -0
  54. data/lib/lucid/formatter/ansicolor.rb +168 -0
  55. data/lib/lucid/formatter/console.rb +218 -0
  56. data/lib/lucid/formatter/debug.rb +33 -0
  57. data/lib/lucid/formatter/duration.rb +11 -0
  58. data/lib/lucid/formatter/gherkin_formatter_adapter.rb +94 -0
  59. data/lib/lucid/formatter/gpretty.rb +24 -0
  60. data/lib/lucid/formatter/html.rb +610 -0
  61. data/lib/lucid/formatter/interceptor.rb +66 -0
  62. data/lib/lucid/formatter/io.rb +31 -0
  63. data/lib/lucid/formatter/jquery-min.js +154 -0
  64. data/lib/lucid/formatter/json.rb +19 -0
  65. data/lib/lucid/formatter/json_pretty.rb +10 -0
  66. data/lib/lucid/formatter/junit.rb +177 -0
  67. data/lib/lucid/formatter/lucid.css +283 -0
  68. data/lib/lucid/formatter/lucid.sass +244 -0
  69. data/lib/lucid/formatter/ordered_xml_markup.rb +24 -0
  70. data/lib/lucid/formatter/progress.rb +95 -0
  71. data/lib/lucid/formatter/rerun.rb +91 -0
  72. data/lib/lucid/formatter/standard.rb +235 -0
  73. data/lib/lucid/formatter/stepdefs.rb +14 -0
  74. data/lib/lucid/formatter/steps.rb +49 -0
  75. data/lib/lucid/formatter/summary.rb +35 -0
  76. data/lib/lucid/formatter/unicode.rb +53 -0
  77. data/lib/lucid/formatter/usage.rb +132 -0
  78. data/lib/lucid/generator.rb +21 -0
  79. data/lib/lucid/generators/project.rb +70 -0
  80. data/lib/lucid/generators/project/Gemfile.tt +6 -0
  81. data/lib/lucid/generators/project/browser-symbiont.rb +24 -0
  82. data/lib/lucid/generators/project/driver-symbiont.rb +4 -0
  83. data/lib/lucid/generators/project/errors.rb +26 -0
  84. data/lib/lucid/generators/project/events-symbiont.rb +36 -0
  85. data/lib/lucid/generators/project/lucid-symbiont.yml +6 -0
  86. data/lib/lucid/interface.rb +8 -0
  87. data/lib/lucid/interface_methods.rb +125 -0
  88. data/lib/lucid/interface_rb/matcher.rb +108 -0
  89. data/lib/lucid/interface_rb/rb_hook.rb +18 -0
  90. data/lib/lucid/interface_rb/rb_language.rb +190 -0
  91. data/lib/lucid/interface_rb/rb_lucid.rb +119 -0
  92. data/lib/lucid/interface_rb/rb_step_definition.rb +122 -0
  93. data/lib/lucid/interface_rb/rb_transform.rb +57 -0
  94. data/lib/lucid/interface_rb/rb_world.rb +136 -0
  95. data/lib/lucid/interface_rb/regexp_argument_matcher.rb +21 -0
  96. data/lib/lucid/load_path.rb +13 -0
  97. data/lib/lucid/parser.rb +2 -126
  98. data/lib/lucid/platform.rb +27 -0
  99. data/lib/lucid/rspec/allow_doubles.rb +20 -0
  100. data/lib/lucid/rspec/disallow_options.rb +27 -0
  101. data/lib/lucid/runtime.rb +200 -0
  102. data/lib/lucid/runtime/facade.rb +60 -0
  103. data/lib/lucid/runtime/interface_io.rb +60 -0
  104. data/lib/lucid/runtime/orchestrator.rb +218 -0
  105. data/lib/lucid/runtime/results.rb +64 -0
  106. data/lib/lucid/runtime/specs_loader.rb +79 -0
  107. data/lib/lucid/spec_file.rb +112 -0
  108. data/lib/lucid/step_definition_light.rb +20 -0
  109. data/lib/lucid/step_definitions.rb +13 -0
  110. data/lib/lucid/step_match.rb +99 -0
  111. data/lib/lucid/tdl_builder.rb +282 -0
  112. data/lib/lucid/term/ansicolor.rb +118 -0
  113. data/lib/lucid/unit.rb +11 -0
  114. data/lib/lucid/wire_support/configuration.rb +38 -0
  115. data/lib/lucid/wire_support/connection.rb +61 -0
  116. data/lib/lucid/wire_support/request_handler.rb +32 -0
  117. data/lib/lucid/wire_support/wire_exception.rb +32 -0
  118. data/lib/lucid/wire_support/wire_language.rb +54 -0
  119. data/lib/lucid/wire_support/wire_packet.rb +34 -0
  120. data/lib/lucid/wire_support/wire_protocol.rb +43 -0
  121. data/lib/lucid/wire_support/wire_protocol/requests.rb +125 -0
  122. data/lib/lucid/wire_support/wire_step_definition.rb +26 -0
  123. data/lucid.gemspec +25 -14
  124. metadata +220 -12
  125. data/lib/lucid/app.rb +0 -103
  126. data/lib/lucid/options.rb +0 -168
  127. data/lib/lucid/version.rb +0 -3
  128. data/lucid.yml +0 -8
data/lucid.gemspec CHANGED
@@ -1,22 +1,33 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'lucid/version'
4
+
5
+ require "lucid/platform"
5
6
 
6
7
  Gem::Specification.new do |gem|
7
- gem.name = "lucid"
8
- gem.version = Lucid::VERSION
9
- gem.authors = ["Jeff Nyman"]
10
- gem.email = ["jeffnyman@gmail.com"]
11
- gem.license = "MIT"
12
- gem.description = %q{Execution Wrapper for Cucumber}
13
- gem.summary = %q{Execution Wrapper for Cucumber}
14
- gem.homepage = "https://github.com/jnyman/lucid"
8
+ gem.name = 'lucid'
9
+ gem.version = Lucid::VERSION
10
+ gem.authors = ["Jeff Nyman"]
11
+ gem.description = "Test Description Language Execution Engine"
12
+ gem.summary = "lucid-#{gem.version}"
13
+ gem.email = ["jeffnyman@gmail.com"]
14
+ gem.license = "MIT"
15
+ gem.homepage = "https://github.com/jnyman/lucid"
16
+ gem.platform = Gem::Platform::RUBY
15
17
 
16
- gem.required_ruby_version = '>= 1.9.2'
18
+ gem.required_ruby_version = ">= 1.9.3"
19
+ gem.rubygems_version = ">= 1.6.1"
20
+
21
+ gem.add_runtime_dependency 'rake', '>= 10.0.4'
22
+ gem.add_runtime_dependency 'thor', '>= 0.18.1'
23
+ gem.add_runtime_dependency 'builder', '>= 2.1.2'
24
+ gem.add_runtime_dependency 'diff-lcs', '>= 1.1.3'
25
+ gem.add_runtime_dependency 'gherkin', '~> 2.12.0'
26
+ gem.add_runtime_dependency 'multi_json', '~> 1.3'
17
27
 
18
- gem.files = `git ls-files`.split($/)
19
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
20
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
21
- gem.require_paths = ["lib"]
28
+ gem.files = `git ls-files`.split($/)
29
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
30
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
31
+ gem.rdoc_options = ["--charset=UTF-8"]
32
+ gem.require_paths = ["lib"]
22
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lucid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,34 +9,242 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-09 00:00:00.000000000 Z
13
- dependencies: []
14
- description: Execution Wrapper for Cucumber
12
+ date: 2013-05-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 10.0.4
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 10.0.4
30
+ - !ruby/object:Gem::Dependency
31
+ name: thor
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.18.1
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.18.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: builder
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 2.1.2
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.1.2
62
+ - !ruby/object:Gem::Dependency
63
+ name: diff-lcs
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 1.1.3
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 1.1.3
78
+ - !ruby/object:Gem::Dependency
79
+ name: gherkin
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 2.12.0
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 2.12.0
94
+ - !ruby/object:Gem::Dependency
95
+ name: multi_json
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '1.3'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '1.3'
110
+ description: Test Description Language Execution Engine
15
111
  email:
16
112
  - jeffnyman@gmail.com
17
113
  executables:
18
114
  - lucid
115
+ - lucid-gen
19
116
  extensions: []
20
117
  extra_rdoc_files: []
21
118
  files:
22
119
  - .gitignore
120
+ - .rspec
121
+ - .ruby-gemset
122
+ - .ruby-version
123
+ - .travis.yml
23
124
  - Gemfile
24
- - LICENSE.txt
125
+ - HISTORY.md
126
+ - LICENSE
25
127
  - README.md
26
128
  - Rakefile
27
129
  - bin/lucid
130
+ - bin/lucid-gen
131
+ - lib/autotest/discover.rb
132
+ - lib/autotest/lucid.rb
133
+ - lib/autotest/lucid_mixin.rb
134
+ - lib/autotest/lucid_rails.rb
135
+ - lib/autotest/lucid_rails_rspec.rb
136
+ - lib/autotest/lucid_rails_rspec2.rb
137
+ - lib/autotest/lucid_rspec.rb
138
+ - lib/autotest/lucid_rspec2.rb
28
139
  - lib/lucid.rb
29
- - lib/lucid/app.rb
30
- - lib/lucid/options.rb
140
+ - lib/lucid/ast.rb
141
+ - lib/lucid/ast/background.rb
142
+ - lib/lucid/ast/comment.rb
143
+ - lib/lucid/ast/doc_string.rb
144
+ - lib/lucid/ast/empty_background.rb
145
+ - lib/lucid/ast/examples.rb
146
+ - lib/lucid/ast/feature.rb
147
+ - lib/lucid/ast/has_steps.rb
148
+ - lib/lucid/ast/location.rb
149
+ - lib/lucid/ast/multiline_argument.rb
150
+ - lib/lucid/ast/names.rb
151
+ - lib/lucid/ast/outline_table.rb
152
+ - lib/lucid/ast/scenario.rb
153
+ - lib/lucid/ast/scenario_outline.rb
154
+ - lib/lucid/ast/specs.rb
155
+ - lib/lucid/ast/step.rb
156
+ - lib/lucid/ast/step_collection.rb
157
+ - lib/lucid/ast/step_invocation.rb
158
+ - lib/lucid/ast/table.rb
159
+ - lib/lucid/ast/tags.rb
160
+ - lib/lucid/ast/tdl_walker.rb
161
+ - lib/lucid/cli/app.rb
162
+ - lib/lucid/cli/configuration.rb
163
+ - lib/lucid/cli/options.rb
164
+ - lib/lucid/cli/profile.rb
165
+ - lib/lucid/configuration.rb
166
+ - lib/lucid/core_ext/disable_autorunners.rb
167
+ - lib/lucid/core_ext/instance_exec.rb
168
+ - lib/lucid/core_ext/proc.rb
169
+ - lib/lucid/core_ext/string.rb
170
+ - lib/lucid/errors.rb
171
+ - lib/lucid/factory.rb
172
+ - lib/lucid/formatter/ansicolor.rb
173
+ - lib/lucid/formatter/console.rb
174
+ - lib/lucid/formatter/debug.rb
175
+ - lib/lucid/formatter/duration.rb
176
+ - lib/lucid/formatter/gherkin_formatter_adapter.rb
177
+ - lib/lucid/formatter/gpretty.rb
178
+ - lib/lucid/formatter/html.rb
179
+ - lib/lucid/formatter/interceptor.rb
180
+ - lib/lucid/formatter/io.rb
181
+ - lib/lucid/formatter/jquery-min.js
182
+ - lib/lucid/formatter/json.rb
183
+ - lib/lucid/formatter/json_pretty.rb
184
+ - lib/lucid/formatter/junit.rb
185
+ - lib/lucid/formatter/lucid.css
186
+ - lib/lucid/formatter/lucid.sass
187
+ - lib/lucid/formatter/ordered_xml_markup.rb
188
+ - lib/lucid/formatter/progress.rb
189
+ - lib/lucid/formatter/rerun.rb
190
+ - lib/lucid/formatter/standard.rb
191
+ - lib/lucid/formatter/stepdefs.rb
192
+ - lib/lucid/formatter/steps.rb
193
+ - lib/lucid/formatter/summary.rb
194
+ - lib/lucid/formatter/unicode.rb
195
+ - lib/lucid/formatter/usage.rb
196
+ - lib/lucid/generator.rb
197
+ - lib/lucid/generators/project.rb
198
+ - lib/lucid/generators/project/Gemfile.tt
199
+ - lib/lucid/generators/project/browser-symbiont.rb
200
+ - lib/lucid/generators/project/driver-symbiont.rb
201
+ - lib/lucid/generators/project/errors.rb
202
+ - lib/lucid/generators/project/events-symbiont.rb
203
+ - lib/lucid/generators/project/lucid-symbiont.yml
204
+ - lib/lucid/interface.rb
205
+ - lib/lucid/interface_methods.rb
206
+ - lib/lucid/interface_rb/matcher.rb
207
+ - lib/lucid/interface_rb/rb_hook.rb
208
+ - lib/lucid/interface_rb/rb_language.rb
209
+ - lib/lucid/interface_rb/rb_lucid.rb
210
+ - lib/lucid/interface_rb/rb_step_definition.rb
211
+ - lib/lucid/interface_rb/rb_transform.rb
212
+ - lib/lucid/interface_rb/rb_world.rb
213
+ - lib/lucid/interface_rb/regexp_argument_matcher.rb
214
+ - lib/lucid/load_path.rb
31
215
  - lib/lucid/parser.rb
32
- - lib/lucid/version.rb
216
+ - lib/lucid/platform.rb
217
+ - lib/lucid/rspec/allow_doubles.rb
218
+ - lib/lucid/rspec/disallow_options.rb
219
+ - lib/lucid/runtime.rb
220
+ - lib/lucid/runtime/facade.rb
221
+ - lib/lucid/runtime/interface_io.rb
222
+ - lib/lucid/runtime/orchestrator.rb
223
+ - lib/lucid/runtime/results.rb
224
+ - lib/lucid/runtime/specs_loader.rb
225
+ - lib/lucid/spec_file.rb
226
+ - lib/lucid/step_definition_light.rb
227
+ - lib/lucid/step_definitions.rb
228
+ - lib/lucid/step_match.rb
229
+ - lib/lucid/tdl_builder.rb
230
+ - lib/lucid/term/ansicolor.rb
231
+ - lib/lucid/unit.rb
232
+ - lib/lucid/wire_support/configuration.rb
233
+ - lib/lucid/wire_support/connection.rb
234
+ - lib/lucid/wire_support/request_handler.rb
235
+ - lib/lucid/wire_support/wire_exception.rb
236
+ - lib/lucid/wire_support/wire_language.rb
237
+ - lib/lucid/wire_support/wire_packet.rb
238
+ - lib/lucid/wire_support/wire_protocol.rb
239
+ - lib/lucid/wire_support/wire_protocol/requests.rb
240
+ - lib/lucid/wire_support/wire_step_definition.rb
33
241
  - lucid.gemspec
34
- - lucid.yml
35
242
  homepage: https://github.com/jnyman/lucid
36
243
  licenses:
37
244
  - MIT
38
245
  post_install_message:
39
- rdoc_options: []
246
+ rdoc_options:
247
+ - --charset=UTF-8
40
248
  require_paths:
41
249
  - lib
42
250
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -44,7 +252,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
44
252
  requirements:
45
253
  - - ! '>='
46
254
  - !ruby/object:Gem::Version
47
- version: 1.9.2
255
+ version: 1.9.3
48
256
  required_rubygems_version: !ruby/object:Gem::Requirement
49
257
  none: false
50
258
  requirements:
@@ -56,6 +264,6 @@ rubyforge_project:
56
264
  rubygems_version: 1.8.24
57
265
  signing_key:
58
266
  specification_version: 3
59
- summary: Execution Wrapper for Cucumber
267
+ summary: lucid-0.0.5
60
268
  test_files: []
61
269
  has_rdoc:
data/lib/lucid/app.rb DELETED
@@ -1,103 +0,0 @@
1
- require "lucid/options"
2
- require "lucid/parser"
3
-
4
- module Lucid
5
-
6
- PROJECT_OPTIONS = 'lucid.yml'
7
-
8
- class App
9
- def initialize(args=nil)
10
- args ||= ARGV
11
- @project_options = Lucid::PROJECT_OPTIONS
12
- @options = Lucid::Options.parse(args)
13
-
14
- parser = Lucid::Parser.new(@options)
15
-
16
- @specs = parser.specs
17
- @tags = parser.tags
18
-
19
- @message = "No specs were found matching the pattern '#{@options[:pattern]}'." and return unless @specs
20
-
21
- @command = generate_command
22
- end
23
-
24
- def run
25
- puts @message and return if @message
26
- @options[:print] ? puts(@command) : system("#{@command}\n\n")
27
- end
28
-
29
- private
30
-
31
- def generate_command
32
- specs = []
33
- steps = []
34
-
35
- command = "#{@options[:command]} #{@options[:options]}"
36
-
37
- if @specs.any?
38
- @specs.each do |file|
39
- file_parts = split_spec(file)
40
- specs << construct_spec_file(file_parts[:path], file_parts[:name], file_parts[:full_name])
41
- end
42
- else
43
- # If there are no spec files explicitly identified, then all of them
44
- # will be run. However, if non-standard locations for features or step
45
- # definitions are being used, that information has to be passed along.
46
- specs << @options[:spec_path] if @options[:non_standard_spec_path]
47
- ##steps << @options[:step_path] if @options[:non_standard_step_path]
48
- end
49
-
50
- need_root = nil
51
-
52
- specs.each do |spec|
53
- start_path = spec[0..spec.index("/") - 1] unless spec.index("/").nil?
54
- start_path = spec if spec.index("/").nil?
55
-
56
- if start_path != @options[:spec_path]
57
- need_root = true
58
- end
59
- end
60
-
61
- specs << @options[:spec_path] if @options[:non_standard_spec_path] unless need_root.nil?
62
- steps << @options[:step_path] if @options[:non_standard_step_path]
63
-
64
- requires = (@options[:requires] + steps).compact.uniq
65
-
66
- command += " -r #{requires.join(' -r ')}" if requires.any?
67
- command += " #{specs.join(' ')}" if specs.any?
68
-
69
- return "#{command} #{@tags}".gsub(' ', ' ')
70
- end
71
-
72
- def split_spec(file)
73
- name = File.basename(file, '.feature')
74
-
75
- # The next bit gets rid of the file name and the actual path
76
- # to the spec.
77
- path = File.dirname(file).gsub(@options[:spec_path_regex], '')
78
-
79
- return {:path => path, :name => name, :full_name => file}
80
- end
81
-
82
- def construct_spec_file(path, file, file_name)
83
- construct = ""
84
-
85
- # If the file that is passed in matches the name of the specs path
86
- # then the assumption is that the user specified the main specs path
87
- # to be executed, such as with "lucid specs". If the information
88
- # provided does not end with ".feature" then it is assumed that a
89
- # full directory is being referenced.
90
- if file == @options[:spec_path]
91
- construct = "#{file}"
92
- elsif file_name[-8, 8] == ".feature" #not file =~ /\.feature$/
93
- construct = "#{file_name}".gsub('//', '/')
94
- else
95
- #construct = "#{@options[:spec_path]}/#{path}/#{file}.feature".gsub('//', '/')
96
- construct = "#{file_name}".gsub('//', '/')
97
- end
98
-
99
- construct
100
- end
101
-
102
- end
103
- end
data/lib/lucid/options.rb DELETED
@@ -1,168 +0,0 @@
1
- require "lucid/version"
2
- require 'optparse'
3
- require 'yaml'
4
-
5
- module Lucid
6
- class Options
7
- def self.parse(args)
8
- orig_args = args.dup
9
- name = nil
10
-
11
- if orig_args.index("--name")
12
- name_loc = orig_args.index("--name") + 1
13
- name = orig_args[name_loc]
14
- end
15
-
16
- default_options = self.get_options(:default)
17
- project_options = self.get_options(:project)
18
- combine_options = default_options.merge(project_options)
19
-
20
- option_parser = OptionParser.new do |opts|
21
- opts.banner = ["Lucid: Test Description Language Execution Engine",
22
- "Usage: lucid [options] PATTERN", ""].join("\n")
23
-
24
- opts.separator ''
25
-
26
- opts.on('-p', '--print', "Echo the Lucid command instead of executing it.") do
27
- combine_options[:print] = true
28
- end
29
-
30
- opts.on('-o', '--options OPTIONS', "Options to pass to the tool.") do |options|
31
- if options =~ (/^--name/)
32
- combine_options[:c_options] = "#{options} \"#{name}\""
33
- else
34
- combine_options[:c_options] = options
35
- end
36
- end
37
-
38
- opts.on('-t', '--tags TAGS', "Tags to include or exclude.") do |tags|
39
- combine_options[:tags] = tags
40
- end
41
-
42
- opts.on('-v', '--version', "Display Lucid version information.") do
43
- puts Lucid::VERSION
44
- Kernel.exit(0)
45
- end
46
-
47
- opts.on('-h', '--help', "Display help on how to use Lucid.") do
48
- puts opts
49
- Kernel.exit(0)
50
- end
51
- end
52
-
53
- option_parser.parse!(args)
54
-
55
- # This statement is necessary to get the spec execution pattern from
56
- # the command line. This will not be a switch and so it will be the
57
- # only actual command line argument. However, account must be taken
58
- # of the potential of using the --name option, which means that the
59
- # argument to that option will be the first argument and thus the
60
- # second argument will be the spec execution pattern.
61
- combine_options[:pattern] = args.first if args.count == 1
62
- combine_options[:pattern] = args[1] if args.count == 2
63
-
64
- return self.establish(combine_options)
65
- end
66
-
67
- private
68
-
69
- def self.get_options(type = :default)
70
- if type == :project
71
- project_options = {}
72
-
73
- if File.exist?(Lucid::PROJECT_OPTIONS)
74
- yaml_options = YAML.load_file(Lucid::PROJECT_OPTIONS)
75
-
76
- ['command', 'options', 'spec_path', 'step_path', 'requires', 'shared', 'spec_path_regex'].each do |key|
77
- begin
78
- project_options[key.to_sym] = yaml_options[key] if yaml_options.has_key?(key)
79
- rescue NoMethodError
80
- # noop
81
- end
82
- end
83
- end
84
-
85
- project_options
86
- else
87
- {
88
- :command => 'cucumber',
89
- :options => nil,
90
- :spec_path => 'features',
91
- :step_path => 'features/step_definitions',
92
- :requires => [],
93
- :shared => 'true',
94
- :print => false,
95
- :tags => nil,
96
- :spec_path_regex => nil,
97
- :step_path_regex => nil,
98
- :pattern => nil
99
- }
100
- end
101
-
102
- end
103
-
104
- def self.establish(options)
105
- # The next statement makes sure that any project options and command
106
- # line options are merged.
107
- options[:options] += " #{options[:c_options]}"
108
-
109
- defaults = self.get_options(:default)
110
-
111
- current_set = options.dup
112
-
113
- current_set[:spec_path] = current_set[:spec_path].gsub(/\\/, '/')
114
- current_set[:spec_path] = current_set[:spec_path].sub(/\/$/, '')
115
-
116
- current_set[:step_path] = current_set[:step_path].gsub(/\\/, '/')
117
- current_set[:step_path] = current_set[:step_path].sub(/\/$/, '')
118
-
119
- unless current_set[:pattern].nil?
120
- current_set[:pattern] = current_set[:pattern].gsub(/\\/, '/')
121
- current_set[:pattern] = current_set[:pattern].sub(/\/$/, '')
122
- end
123
-
124
- # Establish that the spec path and the step path are not the standard
125
- # values that Cucumber would expect by default.
126
- current_set[:non_standard_spec_path] = current_set[:spec_path] != defaults[:spec_path]
127
- current_set[:non_standard_step_path] = current_set[:step_path] != defaults[:step_path]
128
-
129
- # Create a regular expression from the spec path and the step path.
130
- # This is done so that Lucid can look at the paths dynamically, mainly
131
- # when dealing with shared steps.
132
- current_set[:spec_path_regex] = Regexp.new(current_set[:spec_path].gsub('/', '\/')) unless current_set[:spec_path_regex]
133
- current_set[:step_path_regex] = Regexp.new(current_set[:step_path].gsub('/', '\/')) unless current_set[:step_path_regex]
134
-
135
- # If the values are set to nil, the following commands make sure to
136
- # revert to the defaults.
137
- current_set[:spec_path] ||= defaults[:spec_path]
138
- current_set[:step_path] ||= defaults[:step_path]
139
- current_set[:requires] ||= defaults[:requires]
140
- current_set[:command] ||= defaults[:command]
141
-
142
- # The shared setting has to be something that Lucid can use.
143
- shared = current_set[:shared].nil? ? 'true' : current_set[:shared].to_s.strip
144
- shared = 'true' if shared.strip == ''
145
-
146
- # Here the shared value is established based on a few likely usage
147
- # patterns for it. Note that if one of these usage patterns is not
148
- # used, then shared will be kept at whatever setting it has.
149
- if ['shared', 'yes', ''].include?(shared.downcase)
150
- shared == true
151
- elsif ['false', 'no'].include?(shared.downcase)
152
- shared == false
153
- end
154
-
155
- current_set[:shared] = shared
156
-
157
- # The pattern that was specified must be handled to make sure it is
158
- # something that can be worked with.
159
- unless current_set[:pattern].nil?
160
- current_set[:pattern] = current_set[:pattern].strip
161
- current_set[:pattern] = nil unless current_set[:pattern] && !current_set[:pattern].empty?
162
- end
163
-
164
- return current_set
165
- end
166
-
167
- end # class: Options
168
- end # module: Lucid