Module: Spackle
- Defined in:
- lib/spackle.rb,
lib/spackle/error.rb,
lib/spackle/commandline.rb,
lib/spackle/configuration.rb
Defined Under Namespace
Modules: Output, Spec
Classes: BacktraceEntry, Commandline, Configuration, Error
Class Method Summary
collapse
Class Method Details
.already_initialized? ⇒ Boolean
12
13
14
|
# File 'lib/spackle.rb', line 12
def already_initialized?
@already_initialized == true
end
|
.callback_command ⇒ Object
16
17
18
|
# File 'lib/spackle.rb', line 16
def callback_command
Spackle.configuration.callback_command
end
|
.configuration ⇒ Object
20
21
22
|
# File 'lib/spackle.rb', line 20
def configuration
@configuration ||= Spackle::Configuration.new
end
|
24
25
26
|
# File 'lib/spackle.rb', line 24
def configure
yield configuration
end
|
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/spackle.rb', line 28
def error_formatter_class
class_name = configuration.error_formatter.to_s.
split("_").collect { |w| w.capitalize }.join
begin
eval("Spackle::Output::#{class_name}")
rescue SyntaxError
raise RuntimeError.new("Spackle Error: no configuration for error_formatter_class -- have you configured Spackle with a .spackle file?")
rescue NameError
raise RuntimeError.new("Spackle Error: Cannot find Spackle::Output::#{class_name} -- have you configured Spackle with a .spackle file?")
end
end
|
.init(options = {}) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/spackle.rb', line 40
def init(options = {})
return if already_initialized?
@already_initialized = true
load_config
File.unlink(spackle_file) if File.exists?(spackle_file)
case options[:with]
when :spec_formatter
::Spec::Runner.options.parse_format "Spackle::Spec::SpackleFormatter:/dev/null"
end
end
|
.load_config ⇒ Object
53
54
55
|
# File 'lib/spackle.rb', line 53
def load_config
load_config_from_dotfile
end
|
.load_config_from_dotfile ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/spackle.rb', line 57
def load_config_from_dotfile
config_files = []
if ENV['SPACKLE_CONFIG']
config_files << File.expand_path(ENV['SPACKLE_CONFIG'])
else
config_files << File.expand_path("~/.spackle")
project_root = ProjectScout.scan Dir.pwd
if project_root
config_files << File.join(project_root, ".spackle")
end
end
config_files.inject(false) do |config_loaded, file|
if File.exists? file
load file
config_loaded = true
end
config_loaded
end
end
|
.spackle_file ⇒ Object
81
82
83
84
85
86
87
|
# File 'lib/spackle.rb', line 81
def spackle_file
projectname = ProjectScout.scan Dir.pwd
projectname = File.basename(projectname) + ".spackle" if projectname
filename = configuration.spackle_file || projectname || "default.spackle"
File.join(tempdir, filename)
end
|
.tempdir ⇒ Object
89
90
91
|
# File 'lib/spackle.rb', line 89
def tempdir
configuration.tempdir || '/tmp'
end
|
.test_finished(errors) ⇒ Object
93
94
95
96
97
98
99
100
101
|
# File 'lib/spackle.rb', line 93
def test_finished(errors)
return unless configuration.error_formatter
File.open( spackle_file, "w", 0600 ) do |f|
errors.each do |error|
f.write error_formatter_class.format(error)
end
end
system(configuration.callback_command, spackle_file) if configuration.callback_command
end
|