Class: OasContrib::Resolver::Merge

Inherits:
Base
  • Object
show all
Defined in:
lib/oas_contrib/resolver/merge.rb

Overview

Merge command resolver class

Constant Summary

Constants inherited from Base

Base::DEFINED_FILE_EXT, Base::DIR_NAME_META, Base::DIR_NAME_MODEL, Base::DIR_NAME_PATH

Instance Attribute Summary

Attributes inherited from Base

#data, #spec

Instance Method Summary collapse

Methods inherited from Base

#file_ext_check, #input, #input_dir, #input_lambda, #output, #resolve, #v2?, #v3?

Methods included from Interface::Resolver

#resolve

Constructor Details

#initialize(indir, outfile, options) ⇒ Merge

Initialize

Parameters:

  • indir (String)

    input directory path

  • outfile (String)

    output spec file path

  • options (Array)

    command options



11
12
13
14
15
16
17
# File 'lib/oas_contrib/resolver/merge.rb', line 11

def initialize(indir, outfile, options)
  @meta_dir   = indir + '/' + DIR_NAME_META
  @path_dir   = indir + '/' + DIR_NAME_PATH
  @model_dir  = indir + '/' + DIR_NAME_MODEL
  @outfile    = outfile
  @infile_ext = options['in_ext']
end

Instance Method Details

#distributeBoolean

Distribute the command artifacts.

Returns:

  • (Boolean)


40
41
42
43
# File 'lib/oas_contrib/resolver/merge.rb', line 40

def distribute
  output(@data, @outfile)
  true
end

#loadBoolean

Load and parse the input files.

Returns:

  • (Boolean)


29
30
31
32
33
34
35
36
# File 'lib/oas_contrib/resolver/merge.rb', line 29

def load
  @data = input_dir(@meta_dir)
  resolve
  @data['paths'] = input_dir(@path_dir)
  @data['definitions'] = input_dir(@model_dir) if v2?
  @data['components'] = { 'schemas' => input_dir(@model_dir) } if v3?
  true
end

#setupBoolean

Setup the resolver object.

Returns:

  • (Boolean)


21
22
23
24
25
# File 'lib/oas_contrib/resolver/merge.rb', line 21

def setup
  @outfile_ext = File.extname(@outfile)
  file_ext_check
  true
end