Module: RSpec::StackProf::FilenameHelpers
- Included in:
- RSpec::StackProf
- Defined in:
- lib/rspec/stackprof/filename_helpers.rb
Instance Method Summary collapse
- #create_missing_dirs ⇒ Object
- #create_unique_file_name ⇒ Object
- #file_basename ⇒ Object
- #file_dirname ⇒ Object
- #file_extension ⇒ Object
- #filename_for(example) ⇒ Object
- #output_dir ⇒ Object
- #output_file ⇒ Object
- #path_for(metadata) ⇒ Object
- #uniqueness ⇒ Object
Instance Method Details
#create_missing_dirs ⇒ Object
39 40 41 42 |
# File 'lib/rspec/stackprof/filename_helpers.rb', line 39 def create_missing_dirs dirname = File.dirname(File.join(output_dir,output_file)) FileUtils.mkdir_p(dirname) end |
#create_unique_file_name ⇒ Object
44 45 46 |
# File 'lib/rspec/stackprof/filename_helpers.rb', line 44 def create_unique_file_name "#{file_basename}_#{uniqueness}#{file_extension}" end |
#file_basename ⇒ Object
19 20 21 |
# File 'lib/rspec/stackprof/filename_helpers.rb', line 19 def file_basename File.basename(RSpec::StackProf.configuration.out_file,".*") end |
#file_dirname ⇒ Object
23 24 25 |
# File 'lib/rspec/stackprof/filename_helpers.rb', line 23 def file_dirname File.dirname(RSpec::StackProf.configuration.out_file) end |
#file_extension ⇒ Object
13 14 15 16 17 |
# File 'lib/rspec/stackprof/filename_helpers.rb', line 13 def file_extension ext = File.extname(RSpec::StackProf.configuration.out_file) return ".out" if ext.length == 0 return ext end |
#filename_for(example) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rspec/stackprof/filename_helpers.rb', line 48 def filename_for example require 'pry' raise "No example specified" if example.nil? path = path_for(example.[:example_group]) line_number = example.[:line_number].to_s description = example.[:description] File.join( path, description ).gsub(/\s+/, '_') + ":" + line_number end |
#output_dir ⇒ Object
5 6 7 |
# File 'lib/rspec/stackprof/filename_helpers.rb', line 5 def output_dir RSpec::StackProf.configuration.out_dir end |
#output_file ⇒ Object
9 10 11 |
# File 'lib/rspec/stackprof/filename_helpers.rb', line 9 def output_file RSpec::StackProf.configuration.out_file end |
#path_for(metadata) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/rspec/stackprof/filename_helpers.rb', line 27 def path_for if [:parent_example_group] File.join(path_for([:parent_example_group]), [:description]) else [:description] end end |
#uniqueness ⇒ Object
35 36 37 |
# File 'lib/rspec/stackprof/filename_helpers.rb', line 35 def uniqueness "#{Process.pid}_#{Time.now.to_i}" end |