lucid 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +13 -0
- data/bin/lucid +1 -7
- data/lib/lucid/ast/doc_string.rb +1 -1
- data/lib/lucid/ast/step_invocation.rb +2 -2
- data/lib/lucid/cli/app.rb +6 -2
- data/lib/lucid/cli/configuration.rb +18 -5
- data/lib/lucid/cli/options.rb +56 -53
- data/lib/lucid/core_ext/instance_exec.rb +1 -2
- data/lib/lucid/core_ext/proc.rb +2 -2
- data/lib/lucid/errors.rb +3 -3
- data/lib/lucid/formatter/ansicolor.rb +20 -21
- data/lib/lucid/formatter/console.rb +1 -1
- data/lib/lucid/formatter/progress.rb +1 -1
- data/lib/lucid/generators/project.rb +1 -7
- data/lib/lucid/generators/project/browser-fluent.rb +0 -1
- data/lib/lucid/generators/project/events-fluent.rb +1 -4
- data/lib/lucid/interface_rb/matcher.rb +7 -7
- data/lib/lucid/interface_rb/rb_lucid.rb +2 -0
- data/lib/lucid/interface_rb/rb_step_definition.rb +5 -6
- data/lib/lucid/interface_rb/rb_world.rb +2 -3
- data/lib/lucid/platform.rb +3 -3
- data/lib/lucid/runtime/facade.rb +9 -11
- data/lib/lucid/runtime/orchestrator.rb +2 -3
- data/lib/lucid/runtime/results.rb +0 -2
- data/lib/lucid/spec_file.rb +1 -3
- data/spec/lucid/ansicolor_spec.rb +31 -0
- data/spec/lucid/app_spec.rb +73 -4
- data/spec/lucid/ast/background_spec.rb +128 -0
- data/spec/lucid/ast/doc_string_spec.rb +36 -0
- data/spec/lucid/ast/feature_spec.rb +66 -0
- data/spec/lucid/ast/outline_table_spec.rb +21 -0
- data/spec/lucid/ast/scenario_outline_spec.rb +81 -0
- data/spec/lucid/ast/specs_spec.rb +48 -0
- data/spec/lucid/ast/step_invocation_spec.rb +45 -0
- data/spec/lucid/ast/step_spec.rb +72 -0
- data/spec/lucid/ast/table_spec.rb +265 -0
- data/spec/lucid/ast/tdl_factory.rb +78 -0
- data/spec/lucid/ast/tdl_walker_spec.rb +21 -0
- data/spec/lucid/configuration_spec.rb +163 -8
- data/spec/lucid/duration_spec.rb +22 -0
- data/spec/lucid/facade_spec.rb +31 -0
- data/spec/lucid/matcher_spec.rb +127 -0
- data/spec/lucid/options_spec.rb +223 -3
- data/spec/lucid/orchestrator_spec.rb +117 -0
- data/spec/lucid/pending_spec.rb +45 -0
- data/spec/lucid/progress_spec.rb +34 -0
- data/spec/lucid/rb_step_definition_spec.rb +127 -0
- data/spec/lucid/rb_transform_spec.rb +24 -0
- data/spec/lucid/regexp_argument_matcher_spec.rb +19 -0
- data/spec/lucid/results_spec.rb +81 -0
- data/spec/lucid/runtime_spec.rb +1 -1
- data/spec/lucid/step_match_spec.rb +55 -0
- data/spec/spec_helper.rb +11 -5
- metadata +51 -7
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/lib/lucid/generators/project/lucid-fluent.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f6ab1b9e2bd7bdabc5f6190c735f385d635a538
|
4
|
+
data.tar.gz: ff6d239bc7d8e5d962c8b19de35a8e44ea9199a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f45cfb6e7b5cea2e9ae16e580df9007f08156c92904eb88247ab5186ecad39b1bf7f29c187a14c14ebb8e7a16cccf927810b0e4e245f3bece110e7c5afe3bc0d
|
7
|
+
data.tar.gz: 33f231e265a202d24de4f770d23bace5695f8de362b15cd35ccab38662ef895f194b16c09e969845b4a15e5b77702e7a088a82812bbbf614a252f1434ac55b08
|
data/HISTORY.md
CHANGED
@@ -1,11 +1,24 @@
|
|
1
1
|
Change Log and History
|
2
2
|
======================
|
3
3
|
|
4
|
+
Version 0.3.0 / 2013-11-05
|
5
|
+
--------------------------
|
6
|
+
|
7
|
+
* Lucid now allows multiple spec file types. ([Allow Multiple Spec Files](https://github.com/jnyman/lucid/issues/6))
|
8
|
+
|
9
|
+
Prior to this, Lucid would only recognize one spec file type. It was `.spec` by default or you could specify another one via the --spec-type option. Now Lucid will recognize `.feature`, `.spec`, and `.story` by default. Further, it will execute all such test spec files if it finds them. You can also still specify a custom file type via the --spec-type option. In that case Lucid will recognize your custom file type as well as all the standard ones.
|
10
|
+
|
11
|
+
Lucid already uses the concept of a Domain, which is similar to Cucumber's World concept. Lucid now lets you refer to the Domain as World. This allows those familiar with Cucumber to use that wording and it also allows Lucid to better integrate into the Cucumber ecosystem.
|
12
|
+
|
13
|
+
The project generator for creating Fluent projects has been updated. The main change of note here is that the `lucid.yml` configuration file is no longer automatically generated. The reason for this is that Lucid operation requires no configuration at all if the conventions in place are what you want to use.
|
14
|
+
|
15
|
+
|
4
16
|
Version 0.2.1 / 2013-10-21
|
5
17
|
--------------------------
|
6
18
|
|
7
19
|
This is a small patch release. The patch is in the project generator. The [Symbiont](https://github.com/jnyman/symbiont) test framework is being deprecated in favor of [Fluent](https://github.com/jnyman/fluent). The project generator has been updated accordingly.
|
8
20
|
|
21
|
+
|
9
22
|
Version 0.2.0 / 2013-09-28
|
10
23
|
--------------------------
|
11
24
|
|
data/bin/lucid
CHANGED
@@ -3,13 +3,7 @@
|
|
3
3
|
app_lib = File.expand_path('../lib', File.dirname(__FILE__))
|
4
4
|
$LOAD_PATH.unshift(app_lib) unless $LOAD_PATH.include?(app_lib)
|
5
5
|
|
6
|
-
if(ENV['SIMPLECOV'] && RUBY_VERSION =~ /1\.9/)
|
7
|
-
require 'simplecov'
|
8
|
-
SimpleCov.root(File.expand_path(File.dirname(__FILE__) + '/..'))
|
9
|
-
SimpleCov.start
|
10
|
-
end
|
11
|
-
|
12
6
|
require 'lucid/rspec/disallow_options'
|
13
7
|
require 'lucid/cli/app'
|
14
8
|
|
15
|
-
Lucid::CLI::App.new(ARGV.dup).start
|
9
|
+
Lucid::CLI::App.new(ARGV.dup).start!
|
data/lib/lucid/ast/doc_string.rb
CHANGED
@@ -91,8 +91,8 @@ module Lucid
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
BACKTRACE_FILTER_PATTERNS = [/vendor\/rails|lib\/lucid|bin\/lucid:|lib\/rspec|gems\/|minitest|test\/unit
|
95
|
-
|
94
|
+
BACKTRACE_FILTER_PATTERNS = [/vendor\/rails|lib\/lucid|bin\/lucid:|lib\/rspec|gems\/|minitest|test\/unit|\/\.gem\//]
|
95
|
+
|
96
96
|
if(Lucid::JRUBY)
|
97
97
|
BACKTRACE_FILTER_PATTERNS << /org\/jruby/
|
98
98
|
end
|
data/lib/lucid/cli/app.rb
CHANGED
@@ -8,6 +8,10 @@ require 'lucid/cli/configuration'
|
|
8
8
|
module Lucid
|
9
9
|
module CLI
|
10
10
|
class App
|
11
|
+
def self.start(args)
|
12
|
+
new(args).start!
|
13
|
+
end
|
14
|
+
|
11
15
|
def initialize(args, stdin=STDIN, out=STDOUT, err=STDERR, kernel=Kernel)
|
12
16
|
raise "args can't be nil" unless args
|
13
17
|
raise "out can't be nil" unless out
|
@@ -19,8 +23,8 @@ module Lucid
|
|
19
23
|
@kernel = kernel
|
20
24
|
@configuration = nil
|
21
25
|
end
|
22
|
-
|
23
|
-
def start(existing_runtime = nil)
|
26
|
+
|
27
|
+
def start!(existing_runtime = nil)
|
24
28
|
trap_interrupt
|
25
29
|
|
26
30
|
runtime = if existing_runtime
|
@@ -25,7 +25,7 @@ module Lucid
|
|
25
25
|
log.debug("Options: #{@options.inspect}")
|
26
26
|
|
27
27
|
prepare_output_formatting
|
28
|
-
raise(
|
28
|
+
raise('You cannot use both --strict and --wip tags.') if strict? && wip?
|
29
29
|
|
30
30
|
@options[:tag_expression] = Gherkin::TagExpression.new(@options[:tag_expressions])
|
31
31
|
|
@@ -92,7 +92,11 @@ module Lucid
|
|
92
92
|
extract_excluded_files(files)
|
93
93
|
|
94
94
|
files.reject! {|f| !File.file?(f)}
|
95
|
-
|
95
|
+
|
96
|
+
spec_types = spec_type.each do |type|
|
97
|
+
files.reject! {|f| File.extname(f) == ".#{type}" }
|
98
|
+
end
|
99
|
+
|
96
100
|
files.reject! {|f| f =~ /^http/}
|
97
101
|
|
98
102
|
files.sort
|
@@ -120,8 +124,15 @@ module Lucid
|
|
120
124
|
files = specs_path(spec_source).map do |path|
|
121
125
|
path = path.gsub(/\\/, '/') # convert \ to /
|
122
126
|
path = path.chomp('/') # removing trailing /
|
127
|
+
|
128
|
+
files_to_sort = []
|
129
|
+
|
123
130
|
if File.directory?(path)
|
124
|
-
|
131
|
+
spec_type.each do |type|
|
132
|
+
files_to_sort << Dir["#{path}/**/*.#{type}"].sort
|
133
|
+
end
|
134
|
+
|
135
|
+
files_to_sort
|
125
136
|
elsif path[0..0] == '@' and # @listfile.txt
|
126
137
|
File.file?(path[1..-1]) # listfile.txt is a file
|
127
138
|
IO.read(path[1..-1]).split
|
@@ -131,6 +142,7 @@ module Lucid
|
|
131
142
|
end.flatten.uniq
|
132
143
|
|
133
144
|
extract_excluded_files(files)
|
145
|
+
|
134
146
|
files
|
135
147
|
end
|
136
148
|
|
@@ -142,7 +154,8 @@ module Lucid
|
|
142
154
|
end
|
143
155
|
|
144
156
|
def spec_type
|
145
|
-
@options[:spec_type]
|
157
|
+
@options[:spec_type]
|
158
|
+
|
146
159
|
end
|
147
160
|
|
148
161
|
def library_path
|
@@ -215,7 +228,7 @@ module Lucid
|
|
215
228
|
streams = @options[:formats].map { |(_, stream)| stream }
|
216
229
|
|
217
230
|
if streams != streams.uniq
|
218
|
-
raise
|
231
|
+
raise 'All but one formatter must use --out, only one can print to each stream (or STDOUT)'
|
219
232
|
end
|
220
233
|
end
|
221
234
|
|
data/lib/lucid/cli/options.rb
CHANGED
@@ -28,16 +28,16 @@ module Lucid
|
|
28
28
|
largest = LUCID_FORMATS.keys.map{|s| s.length}.max
|
29
29
|
FORMAT_LIST = (LUCID_FORMATS.keys.sort.map do |key|
|
30
30
|
" #{key}#{' ' * (largest - key.length)} : #{LUCID_FORMATS[key][1]}"
|
31
|
-
end) + [
|
32
|
-
|
33
|
-
|
31
|
+
end) + ['Use --format rerun --out rerun.txt to write out failing',
|
32
|
+
'specs. You can rerun them with lucid @rerun.txt.',
|
33
|
+
'FORMAT can also be the fully qualified class name of',
|
34
34
|
"your own custom formatter. If the class isn't loaded,",
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
'Lucid will attempt to require a file with a relative',
|
36
|
+
'file name that is the underscore name of the class name.',
|
37
|
+
' Example: --format Formatter::WordDoc',
|
38
|
+
'With that, Lucid will look for formatter/word_doc.rb',
|
39
|
+
'You can place the file with this relative path',
|
40
|
+
'underneath your common/support directory or anywhere',
|
41
41
|
"on Ruby's LOAD_PATH."
|
42
42
|
]
|
43
43
|
PROFILE_SHORT_FLAG = '-p'
|
@@ -83,23 +83,24 @@ module Lucid
|
|
83
83
|
@args.extend(::OptionParser::Arguable)
|
84
84
|
|
85
85
|
@args.options do |opts|
|
86
|
-
opts.banner = [
|
87
|
-
|
86
|
+
opts.banner = ['Lucid: Test Description Language Execution Engine',
|
87
|
+
'Usage: lucid [options] [ [FILE|DIR|URL][:LINE[:LINE]*] ]+', '', ''
|
88
88
|
].join("\n")
|
89
89
|
|
90
|
-
opts.on(
|
90
|
+
opts.on('--library-path PATH', 'Location of spec project library files.') do |path|
|
91
91
|
@options[:library_path] = path
|
92
92
|
end
|
93
93
|
|
94
|
-
opts.on(
|
95
|
-
|
94
|
+
opts.on('--spec-type TYPE', 'The file type (extension) for Lucid specifications.') do |type|
|
95
|
+
#@options[:spec_type] = type
|
96
|
+
@options[:spec_type] << type
|
96
97
|
end
|
97
98
|
|
98
|
-
opts.on(
|
99
|
+
opts.on('--driver-file FILE', 'The file for Lucid to connect to an execution library.') do |file|
|
99
100
|
@options[:driver_file] = file
|
100
101
|
end
|
101
102
|
|
102
|
-
opts.separator
|
103
|
+
opts.separator ''
|
103
104
|
|
104
105
|
opts.on('-r LIBRARY|DIR', '--require LIBRARY|DIR',
|
105
106
|
'Require files before executing the features. If this option',
|
@@ -107,8 +108,9 @@ module Lucid
|
|
107
108
|
'the features will be loaded automatically. Automatic loading',
|
108
109
|
'is disabled when this option is specified. That means all',
|
109
110
|
'loading becomes explicit.',
|
110
|
-
|
111
|
-
|
111
|
+
'Assuming a default specs repo configuration, files under',
|
112
|
+
"directories named \"common\\support\" will always be loaded",
|
113
|
+
'before any others.',
|
112
114
|
'This option can be specified multiple times.') do |v|
|
113
115
|
@options[:require] << v
|
114
116
|
if(Lucid::JRUBY && File.directory?(v))
|
@@ -147,10 +149,10 @@ module Lucid
|
|
147
149
|
end
|
148
150
|
|
149
151
|
opts.on('-n NAME', '--name NAME',
|
150
|
-
'Lucid will only execute features or abilities that match with the name
|
151
|
-
|
152
|
-
|
153
|
-
|
152
|
+
'Lucid will only execute features or abilities that match with the name',
|
153
|
+
'provided. The match can be done on partial information. If this option',
|
154
|
+
'is provided multiple times, then the match will be performed against',
|
155
|
+
'each set of provided names.'
|
154
156
|
) do |v|
|
155
157
|
@options[:name_regexps] << /#{v}/
|
156
158
|
end
|
@@ -203,73 +205,73 @@ module Lucid
|
|
203
205
|
|
204
206
|
opts.separator ''
|
205
207
|
|
206
|
-
opts.on(
|
207
|
-
|
208
|
-
|
209
|
-
|
208
|
+
opts.on('-c', '--[no-]color',
|
209
|
+
'Specifies whether or not to use ANSI color in the output. If this',
|
210
|
+
'option is not specified, Lucid makes the decision on colored output',
|
211
|
+
'based on your platform and the output destination.'
|
210
212
|
) do |v|
|
211
213
|
Lucid::Term::ANSIColor.coloring = v
|
212
214
|
end
|
213
215
|
|
214
|
-
opts.on(
|
215
|
-
|
216
|
+
opts.on('-m', '--no-multiline',
|
217
|
+
'Lucid will not print multiline strings and tables under steps.') do
|
216
218
|
@options[:no_multiline] = true
|
217
219
|
end
|
218
220
|
|
219
|
-
opts.on(
|
220
|
-
|
221
|
+
opts.on('-s', '--no-source',
|
222
|
+
'Lucid will not print the file and line of the test definition with the steps.') do
|
221
223
|
@options[:source] = false
|
222
224
|
end
|
223
225
|
|
224
|
-
opts.on(
|
225
|
-
|
226
|
+
opts.on('-i', '--no-matchers',
|
227
|
+
'Lucid will not print matchers for pending steps.') do
|
226
228
|
@options[:matchers] = false
|
227
229
|
end
|
228
230
|
|
229
|
-
opts.on(
|
230
|
-
|
231
|
-
|
231
|
+
opts.on('-I', '--matchers-type TYPE',
|
232
|
+
'Use different matcher type (Default: regexp).',
|
233
|
+
'Available types:',
|
232
234
|
*Lucid::InterfaceRb::RbLanguage.cli_matcher_type_options
|
233
235
|
) do |v|
|
234
236
|
@options[:matcher_type] = v.to_sym
|
235
237
|
end
|
236
238
|
|
237
|
-
opts.on(
|
239
|
+
opts.on('-q', '--quiet', 'Alias for --no-matchers --no-source.') do
|
238
240
|
@quiet = true
|
239
241
|
end
|
240
242
|
|
241
|
-
opts.on(
|
243
|
+
opts.on('-S', '--strict', 'Fail if there are any undefined or pending steps.') do
|
242
244
|
@options[:strict] = true
|
243
245
|
end
|
244
246
|
|
245
|
-
opts.on(
|
247
|
+
opts.on('-w', '--wip', 'Fail if there are any passing scenarios.') do
|
246
248
|
@options[:wip] = true
|
247
249
|
end
|
248
250
|
|
249
|
-
opts.on(
|
251
|
+
opts.on('-g', '--guess', 'Guess best match for ambiguous steps.') do
|
250
252
|
@options[:guess] = true
|
251
253
|
end
|
252
254
|
|
253
|
-
opts.on(
|
255
|
+
opts.on('-x', '--expand', 'Expand Scenario Outline tables in output.') do
|
254
256
|
@options[:expand] = true
|
255
257
|
end
|
256
258
|
|
257
|
-
opts.separator
|
259
|
+
opts.separator ''
|
258
260
|
|
259
|
-
opts.on(
|
261
|
+
opts.on('--testdefs DIR', 'Lucid will write test definition metadata to the DIR.') do |dir|
|
260
262
|
@options[:testdefs] = dir
|
261
263
|
end
|
262
264
|
|
263
265
|
if(Lucid::JRUBY)
|
264
|
-
opts.on(
|
265
|
-
|
266
|
+
opts.on('-j DIR', '--jars DIR',
|
267
|
+
'Load all the jars under the specified directory.') do |jars|
|
266
268
|
Dir["#{jars}/**/*.jar"].each {|jar| require jar}
|
267
269
|
end
|
268
270
|
end
|
269
271
|
|
270
|
-
opts.on(
|
271
|
-
|
272
|
-
|
272
|
+
opts.on('--i18n LANG',
|
273
|
+
'List keywords for a particular language.',
|
274
|
+
'Run with "--i18n help" to see all languages') do |lang|
|
273
275
|
if lang == 'help'
|
274
276
|
list_languages_and_exit
|
275
277
|
else
|
@@ -310,14 +312,14 @@ module Lucid
|
|
310
312
|
rescue OptionParser::InvalidOption
|
311
313
|
if $!.to_s =~ /invalid option\:\s+((?:-)?-\S+)/
|
312
314
|
puts "You specified an invalid option: #{$1}"
|
313
|
-
puts
|
315
|
+
puts 'Please run lucid --help to see the list of available options.'
|
314
316
|
end
|
315
317
|
|
316
318
|
rescue OptionParser::MissingArgument
|
317
319
|
if $!.to_s =~ /missing argument\:\s+((?:-)?-\S+)/
|
318
320
|
puts "You specified an valid option (#{$1}), but with an invalid argument."
|
319
|
-
puts
|
320
|
-
puts
|
321
|
+
puts 'Make sure you are providing the expected argument for the option.'
|
322
|
+
puts 'Run lucid --help to see the list of available options.'
|
321
323
|
end
|
322
324
|
|
323
325
|
Kernel.exit(1)
|
@@ -417,6 +419,7 @@ module Lucid
|
|
417
419
|
def reverse_merge(other_options)
|
418
420
|
@options = other_options.options.merge(@options)
|
419
421
|
@options[:require] += other_options[:require]
|
422
|
+
|
420
423
|
@options[:excludes] += other_options[:excludes]
|
421
424
|
@options[:name_regexps] += other_options[:name_regexps]
|
422
425
|
@options[:tag_expressions] += other_options[:tag_expressions]
|
@@ -471,9 +474,9 @@ module Lucid
|
|
471
474
|
:name_regexps => [],
|
472
475
|
:env_vars => {},
|
473
476
|
:diff_enabled => true,
|
474
|
-
:spec_type =>
|
475
|
-
:library_path =>
|
476
|
-
:driver_file =>
|
477
|
+
:spec_type => %w(feature spec story),
|
478
|
+
:library_path => '',
|
479
|
+
:driver_file => ''
|
477
480
|
}
|
478
481
|
end
|
479
482
|
end
|
@@ -63,8 +63,7 @@ class Object #:nodoc:
|
|
63
63
|
backtrace[replacement_line+1..end_pos] = nil
|
64
64
|
backtrace.compact!
|
65
65
|
else
|
66
|
-
#
|
67
|
-
# before we get here (injecting erb stacktrace and such)
|
66
|
+
# Not sure what should happen here.
|
68
67
|
end
|
69
68
|
end
|
70
69
|
end
|
data/lib/lucid/core_ext/proc.rb
CHANGED
@@ -27,10 +27,10 @@ class Proc #:nodoc:
|
|
27
27
|
end
|
28
28
|
else
|
29
29
|
# This Ruby implementation doesn't implement Proc#to_s correctly
|
30
|
-
STDERR.puts
|
30
|
+
STDERR.puts '*** THIS RUBY IMPLEMENTATION DOES NOT REPORT FILE AND LINE FOR PROCS ***'
|
31
31
|
|
32
32
|
def file_colon_line
|
33
|
-
|
33
|
+
'UNKNOWN:-1'
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
data/lib/lucid/errors.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Lucid
|
2
|
-
# Raised when there is no matching
|
2
|
+
# Raised when there is no matching test definition for a step.
|
3
3
|
class Undefined < StandardError
|
4
4
|
attr_reader :step_name
|
5
5
|
|
@@ -17,11 +17,11 @@ module Lucid
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
# Raised when a
|
20
|
+
# Raised when a test definition block invokes Domain#pending.
|
21
21
|
class Pending < StandardError
|
22
22
|
end
|
23
23
|
|
24
|
-
# Raised when a step matches
|
24
|
+
# Raised when a step matches two or more test definitions.
|
25
25
|
class Ambiguous < StandardError
|
26
26
|
def initialize(step_name, step_definitions, used_guess)
|
27
27
|
message = "Ambiguous match of \"#{step_name}\":\n\n"
|
@@ -5,28 +5,27 @@ if Lucid::IRONRUBY
|
|
5
5
|
begin
|
6
6
|
require 'iron-term-ansicolor'
|
7
7
|
rescue LoadError
|
8
|
-
STDERR.puts %{*** WARNING: You must "
|
8
|
+
STDERR.puts %{*** WARNING: You must "gem install iron-term-ansicolor" to get colored ouput in on IronRuby}
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
if Lucid::WINDOWS_MRI
|
13
13
|
unless ENV['ANSICON']
|
14
|
-
STDERR.puts %{*** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansicon/) to get
|
14
|
+
STDERR.puts %{*** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansicon/) to get colored output on Windows}
|
15
15
|
Lucid::Term::ANSIColor.coloring = false
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
Lucid::Term::ANSIColor.coloring = false if !STDOUT.tty? && !ENV.has_key?(
|
19
|
+
Lucid::Term::ANSIColor.coloring = false if !STDOUT.tty? && !ENV.has_key?('AUTOTEST')
|
20
20
|
|
21
21
|
module Lucid
|
22
22
|
module Formatter
|
23
|
-
# Defines aliases for
|
24
|
-
# module directly, but you can change the output
|
25
|
-
# a <tt>
|
26
|
-
# tweak the familiar POSIX command <tt>ls</tt> with
|
27
|
-
# <a href="http://mipsisrisc.com/rambling/2008/06/27/lscolorsls_colors-now-with-linux-support/">$LSCOLORS/$LS_COLORS</a>
|
23
|
+
# Defines aliases for colored output. You don't invoke any methods from this
|
24
|
+
# module directly, but you can change the output colors by defining
|
25
|
+
# a <tt>LUCID_COLORS</tt> variable in your shell, very much like how you can
|
26
|
+
# tweak the familiar POSIX command <tt>ls</tt> with $LS_COLORS.
|
28
27
|
#
|
29
|
-
# The
|
28
|
+
# The colors that you can change are:
|
30
29
|
#
|
31
30
|
# * <tt>undefined</tt> - defaults to <tt>yellow</tt>
|
32
31
|
# * <tt>pending</tt> - defaults to <tt>yellow</tt>
|
@@ -50,10 +49,10 @@ module Lucid
|
|
50
49
|
#
|
51
50
|
# Examples: (On Windows, use SET instead of export.)
|
52
51
|
#
|
53
|
-
# export
|
54
|
-
# export
|
52
|
+
# export LUCID_COLORS="passed=white"
|
53
|
+
# export LUCID_COLORS="passed=white,bold:passed_param=white,bold,underline"
|
55
54
|
#
|
56
|
-
# To see what
|
55
|
+
# To see what colors and effects are available, just run this in your shell:
|
57
56
|
#
|
58
57
|
# ruby -e "require 'rubygems'; require 'term/ansicolor'; puts Lucid::Term::ANSIColor.attributes"
|
59
58
|
#
|
@@ -75,8 +74,8 @@ module Lucid
|
|
75
74
|
'tag' => 'cyan'
|
76
75
|
})
|
77
76
|
|
78
|
-
if ENV['
|
79
|
-
ENV['
|
77
|
+
if ENV['LUCID_COLORS'] # Example: export LUCID_COLORS="passed=red:failed=yellow"
|
78
|
+
ENV['LUCID_COLORS'].split(':').each do |pair|
|
80
79
|
a = pair.split('=')
|
81
80
|
ALIASES[a[0]] = a[1]
|
82
81
|
end
|
@@ -97,11 +96,11 @@ module Lucid
|
|
97
96
|
unless method_name =~ /.*_param/
|
98
97
|
code = <<-EOF
|
99
98
|
def #{method_name}(string=nil, &proc)
|
100
|
-
#{ALIASES[method_name].split(
|
99
|
+
#{ALIASES[method_name].split(',').join('(') + '(string, &proc' + ')' * ALIASES[method_name].split(',').length}
|
101
100
|
end
|
102
101
|
# This resets the colour to the non-param colour
|
103
102
|
def #{method_name}_param(string=nil, &proc)
|
104
|
-
#{ALIASES[method_name+'_param'].split(
|
103
|
+
#{ALIASES[method_name+'_param'].split(',').join('(') + '(string, &proc' + ')' * ALIASES[method_name+'_param'].split(',').length} + #{ALIASES[method_name].split(',').join(' + ')}
|
105
104
|
end
|
106
105
|
EOF
|
107
106
|
eval(code)
|
@@ -112,9 +111,9 @@ module Lucid
|
|
112
111
|
begin
|
113
112
|
gem 'genki-ruby-terminfo'
|
114
113
|
require 'terminfo'
|
115
|
-
case TermInfo.default_object.tigetnum(
|
114
|
+
case TermInfo.default_object.tigetnum('colors')
|
116
115
|
when 0
|
117
|
-
raise "Your terminal doesn't support
|
116
|
+
raise "Your terminal doesn't support colors."
|
118
117
|
when 1
|
119
118
|
::Lucid::Term::ANSIColor.coloring = false
|
120
119
|
alias grey white
|
@@ -125,9 +124,9 @@ module Lucid
|
|
125
124
|
end
|
126
125
|
rescue Exception => e
|
127
126
|
if e.class.name == 'TermInfo::TermInfoError'
|
128
|
-
STDERR.puts
|
127
|
+
STDERR.puts '*** WARNING ***'
|
129
128
|
STDERR.puts "You have the genki-ruby-terminfo gem installed, but you haven't set your TERM variable."
|
130
|
-
STDERR.puts
|
129
|
+
STDERR.puts 'Try setting it to TERM=xterm-256color to get grey color in output.'
|
131
130
|
STDERR.puts "\n"
|
132
131
|
alias grey white
|
133
132
|
else
|
@@ -149,7 +148,7 @@ module Lucid
|
|
149
148
|
define_grey
|
150
149
|
|
151
150
|
def cukes(n)
|
152
|
-
(
|
151
|
+
('(::) ' * n).strip
|
153
152
|
end
|
154
153
|
|
155
154
|
def green_cukes(n)
|