Sha256: 22851770feac2de7f1e2c88ae108f4df650f90b33711ebc3ad4d5964630a8c43

Contents?: true

Size: 936 Bytes

Versions: 1

Compression:

Stored size: 936 Bytes

Contents

class NationBuilder::SpecParser

  def self.parse(spec_path)
    spec = JSON.parse(File.read(spec_path))

    spec['endpoints'].each_with_object([]) do |endpoint, endpoints|
      nb_endpoint = NationBuilder::Endpoint.new(endpoint['name'])
      endpoints << nb_endpoint
      endpoint['methods'].each do |method|
        nb_method = NationBuilder::Method.new(method['MethodName'],
                                              method['HTTPMethod'],
                                              method['URI'],
                                              method['Synopsis'])
        nb_endpoint.register_method(nb_method)
        method['parameters'].each do |parameter|
          if (parameter['Required'] == 'Y') && (parameter['Name'] != 'body')
            nb_parameter = NationBuilder::Parameter.new(parameter['Name'])
            nb_method.register_parameter(nb_parameter)
          end
        end
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nationbuilder-rb-1.6.2 lib/nationbuilder/spec_parser.rb