Class: OpenapiValidator::FileLoader
- Inherits:
-
Object
- Object
- OpenapiValidator::FileLoader
- Defined in:
- lib/openapi_validator/file_loader.rb
Class Method Summary collapse
-
.call(path) ⇒ Hash
Parsed file.
Instance Method Summary collapse
-
#call ⇒ Hash
Parsed file.
Class Method Details
.call(path) ⇒ Hash
Returns parsed file.
8 9 10 |
# File 'lib/openapi_validator/file_loader.rb', line 8 def self.call(path) new(path).call end |
Instance Method Details
#call ⇒ Hash
Returns parsed file.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/openapi_validator/file_loader.rb', line 13 def call case File.extname(path) when ".yml", ".yaml" YAML.load_file(path) when ".json" JSON.parse(File.read(path)) else raise "Can't parse #{path}. It should be json or yaml file.", Error end end |