class SwaggerParser::FileParser
Constants
- YAML_EXTNAMES
Public Class Methods
new(path)
click to toggle source
@param [String] path
# File lib/swagger_parser/file_parser.rb, line 19 def initialize(path) @path = path end
parse(path)
click to toggle source
@param [String] path @return [SwaggerParser::Swagger]
# File lib/swagger_parser/file_parser.rb, line 13 def parse(path) new(path).parse end
Public Instance Methods
parse()
click to toggle source
@return [SwaggerParser::Swagger] @raise [SwaggerParser::Errors::FileParsingError]
# File lib/swagger_parser/file_parser.rb, line 25 def parse SwaggerParser::Swagger.new(parse_file) end
Private Instance Methods
content()
click to toggle source
@return [String]
# File lib/swagger_parser/file_parser.rb, line 32 def content File.read(path) end
parse_file()
click to toggle source
@return [Object] @raise [SwaggerParser::Errors::FileParsingError]
# File lib/swagger_parser/file_parser.rb, line 38 def parse_file if yaml? YAML.load(content) else JSON.parse(content) end rescue => exception raise SwaggerParser::Errors::FileParsingError, exception end
path()
click to toggle source
@return [String]
# File lib/swagger_parser/file_parser.rb, line 49 def path @path end
yaml?()
click to toggle source
@return [false, true]
# File lib/swagger_parser/file_parser.rb, line 54 def yaml? YAML_EXTNAMES.include?(File.extname(path)) end