Class: CassetteExplorer::Reader
- Inherits:
-
Object
- Object
- CassetteExplorer::Reader
- Defined in:
- lib/cassette_explorer/reader.rb
Instance Method Summary collapse
-
#initialize(path) ⇒ Reader
constructor
A new instance of Reader.
- #read ⇒ Object
- #section_name_from_file_path(file_path) ⇒ Object
Constructor Details
#initialize(path) ⇒ Reader
Returns a new instance of Reader.
3 4 5 |
# File 'lib/cassette_explorer/reader.rb', line 3 def initialize(path) @path = File.(path) end |
Instance Method Details
#read ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cassette_explorer/reader.rb', line 7 def read files = Dir["#{@path}/**/**"] sections = {} files.reject{ |f| File.directory? f }.each do |file| section_name = section_name_from_file_path(file) sections[section_name] ||= [] data = YAML.load_file(file) if data['http_interactions'] data['http_interactions'].each do |request| sections[section_name].push Page.new(request) end end end sections end |
#section_name_from_file_path(file_path) ⇒ Object
28 29 30 |
# File 'lib/cassette_explorer/reader.rb', line 28 def section_name_from_file_path(file_path) file_path.gsub(@path, '') end |