Module: Schema2type

Defined in:
lib/schema2type/cli.rb,
lib/schema2type/version.rb,
lib/schema2type/covert_service.rb,
lib/schema2type/schema_converter.rb

Defined Under Namespace

Classes: CovertService, SchemaConverter

Constant Summary collapse

DEFAULT_SCHEMA_PATH =
"./db/schema.rb".freeze
DEFAULT_NAME_SPACE =
"schema".freeze
VERSION =
'0.2.2'

Class Method Summary collapse

Class Method Details

.execute(input_file:, out_file:, name_space:, snake_case:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/schema2type/cli.rb', line 6

def self.execute(input_file:, out_file:, name_space:, snake_case:)

  result = eval(File.read(input_file || DEFAULT_SCHEMA_PATH), CovertService.new(snake_case).get_binding)

  File.open(out_file, "w") do |f|
    f.puts "      /* eslint no-unused-vars: 0 */\n\n      /**\n       * auto-generated file\n       * schema version: \#{result[:version]}\n       * This file was automatically generated by schema2type\n       */\n      declare namespace \#{name_space || DEFAULT_NAME_SPACE} {\n        \#{result[:lines]}\n      }\n    EOS\n  end\nend\n"