Class: RailsInfo::Logs::Test::Rspec

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_info/logs/test/rspec.rb

Defined Under Namespace

Classes: FilePresenter

Constant Summary collapse

FILE_NAME_REGEXP =
/[a-zA-Z]|[0-9]|\/|\.|_|-|@/

Instance Method Summary collapse

Constructor Details

#initialize(options = {log: {}, debug: false}) ⇒ Rspec

Returns a new instance of Rspec.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rails_info/logs/test/rspec.rb', line 4

def initialize(options = {log: {}, debug: false})
  options ||= {log: {}, debug: false}
  options[:log] ||= {}
  
  @rails_root = options[:log][:rails_root] || Rails.root.to_s
  @body = options[:log][:body]
  @show_all = options[:log][:show_all] || false
  @debug = options[:debug]
  
  unless @body
    file_path = "#{@rails_root}/log/rspec.log"
    
    @body = File.new(file_path, 'r').read if File.exist?(file_path)
  end
 
  @log ||= {}
  
  process if @body.present?
end

Instance Method Details

#hashObject



28
29
30
# File 'lib/rails_info/logs/test/rspec.rb', line 28

def hash
  @log.keys.any? ? @log : (@body || [''])
end

#number_of_filesObject



32
33
34
# File 'lib/rails_info/logs/test/rspec.rb', line 32

def number_of_files 
  hash.is_a?(Hash) ? hash.keys.length : 0
end

#rails_rootObject



36
37
38
# File 'lib/rails_info/logs/test/rspec.rb', line 36

def rails_root
  @rails_root
end

#summaryObject



24
25
26
# File 'lib/rails_info/logs/test/rspec.rb', line 24

def summary
  @summary
end