Module: Codgen
- Defined in:
- lib/codgen/statement.rb,
lib/codgen.rb,
lib/codgen/logger.rb,
lib/codgen/mapping.rb,
lib/codgen/package.rb,
lib/codgen/version.rb,
lib/codgen/template.rb,
lib/codgen/constants.rb,
lib/codgen/flattener.rb,
lib/codgen/auto_style.rb,
lib/codgen/template_provider.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, HandleBarsTemplateProvider, MustacheTemplateProvider, Package, Statement, StaticTemplateProvider, Template, TemplateProvider, TemplateProviderList
Constant Summary
collapse
- VERSION =
"0.0.7"
- @@templates_providers =
TemplateProviderList.new
Class Method Summary
collapse
Class Method Details
.get_data_if_not_data(filepath_or_data) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/codgen.rb', line 40
def self.get_data_if_not_data(filepath_or_data)
if filepath_or_data != nil
if filepath_or_data.is_a?(String)
if /https?:\/\//.match(filepath_or_data)
resp = Net::HTTP.get_response(URI.parse(filepath_or_data))
file = resp.body
else
file = File.read(filepath_or_data)
end
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
65
66
67
68
69
70
71
72
73
|
# File 'lib/codgen.rb', line 65
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
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/codgen.rb', line 10
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']
packages = json_config['packages']
if packages != nil
packages.each do |packageInfo|
package = Package.new(packageInfo)
templates.concat(package.templates)
end
end
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
|
.template_provider ⇒ Object
93
94
95
|
# File 'lib/codgen/template_provider.rb', line 93
def self.template_provider
@@templates_providers
end
|