Module: Codgen
- Defined in:
- lib/codgen/statement.rb,
lib/codgen.rb,
lib/codgen/logger.rb,
lib/codgen/mapping.rb,
lib/codgen/version.rb,
lib/codgen/template.rb,
lib/codgen/constants.rb,
lib/codgen/flattener.rb,
lib/codgen/auto_style.rb
Overview
Not currently used but will be for an up coming feature that used be implemented in an older version
Defined Under Namespace
Modules: AutoStyle, Flattener, Logger, Mapping, RegularExpressions
Classes: FilledTemplate, Statement, Template
Constant Summary
collapse
- VERSION =
"0.0.1"
Class Method Summary
collapse
Class Method Details
.get_data_if_not_data(filepath_or_data) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/codgen.rb', line 30
def self.get_data_if_not_data(filepath_or_data)
if filepath_or_data != nil
if filepath_or_data.is_a?(String)
file = File.read(filepath_or_data)
JSON.parse(file)
elsif filepath_or_data.is_a?(Hash)
filepath_or_data
else
Logger.error('In json config file: "map" must be either a filepath or a json object.')
end
end
end
|
.map_and_style(map_data, json_data) ⇒ Object
50
51
52
53
54
55
56
57
58
|
# File 'lib/codgen.rb', line 50
def self.map_and_style(map_data, json_data)
if map_data
Mapping.map_object(json_data, map_data)
end
AutoStyle.style(json_data)
json_data
end
|
.run(json_config) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/codgen.rb', line 8
def self.run(json_config)
map = json_config['map']
map = get_data_if_not_data(map)
json_data = json_config['data']
json_data = get_data_if_not_data(json_data)
json_data = map_and_style(map, json_data)
filled_templates = Array.new
templates = json_config['templates']
templates.each do |template_info|
template = Template.new(template_info, json_data)
template.fill_template.each {|filled_template| filled_templates.push(filled_template)}
end
filled_templates
end
|