Class: RSpec::LogSplit::Config
- Inherits:
-
Object
- Object
- RSpec::LogSplit::Config
- Defined in:
- lib/rspec/log_split.rb
Instance Method Summary collapse
-
#initialize(mod, dir) ⇒ Config
constructor
A new instance of Config.
- #logger(path) ⇒ Object
- #run(example, &block) ⇒ Object
Constructor Details
#initialize(mod, dir) ⇒ Config
Returns a new instance of Config.
39 40 41 42 43 44 45 |
# File 'lib/rspec/log_split.rb', line 39 def initialize(mod, dir) @mod = mod @path = Pathname.new(dir) @path.mkpath @logger = logger(@path.join("main")) end |
Instance Method Details
#logger(path) ⇒ Object
54 55 56 57 58 |
# File 'lib/rspec/log_split.rb', line 54 def logger(path) file = File.open(path, "a") file.sync = true Logger.new(file) end |
#run(example, &block) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/rspec/log_split.rb', line 47 def run(example, &block) example_path = @path.join(example.location) example_path.parent.mkpath example_logger = logger(example_path.to_path) MyExample.new(@logger, @mod, example, example_logger).run(&block) end |