File: config.rb

package info (click to toggle)
ruby-rspec-logsplit 0.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 136 kB
  • sloc: ruby: 133; makefile: 7
file content (25 lines) | stat: -rw-r--r-- 585 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module RSpec
  module LogSplit
    class Config
      def initialize(mod, dir)
        @mod = mod
        @path = Pathname.new(dir)
        @path.mkpath
        @logger = logger(@path.join("main"))
      end

      def run(example)
        example_path = @path.join(example.location)
        example_path.parent.mkpath
        example_logger = logger(example_path.to_path)
        Handler.new(@logger, @mod, example, example_logger).run
      end

      def logger(path)
        file = File.open(path, "a")
        file.sync = true
        Logger.new(file)
      end
    end
  end
end