Class: JSONCop::Command::Generate

Inherits:
JSONCop::Command show all
Defined in:
lib/jsoncop/command/generate.rb

Instance Method Summary collapse

Methods inherited from JSONCop::Command

options, run

Constructor Details

#initialize(argv) ⇒ Generate

Returns a new instance of Generate.



12
13
14
# File 'lib/jsoncop/command/generate.rb', line 12

def initialize(argv)
  super
end

Instance Method Details

#create_analyzer_for_file(file_path) ⇒ Object



27
28
29
# File 'lib/jsoncop/command/generate.rb', line 27

def create_analyzer_for_file(file_path)
  Analyzer.new file_path
end

#create_generator_for_file(file_path, model) ⇒ Object



31
32
33
# File 'lib/jsoncop/command/generate.rb', line 31

def create_generator_for_file(file_path, model)
  Generator.new file_path, model
end

#runObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/jsoncop/command/generate.rb', line 16

def run
  Dir.glob("**/*.swift").each do |file|
    analyzer = create_analyzer_for_file file
    model = analyzer.analyze!
    next unless model

    generator = create_generator_for_file file, model
    generator.generate!
  end
end