22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/origen/code_generators/block_common.rb', line 22
def create_files
@block = true
@root_class = true
unless @nested
dir = File.join(Origen.root, 'app', 'blocks')
@fullname = Origen.app.namespace.to_s
@model_path.each do |path|
dir = File.join(dir, path)
@name = path
@fullname += "::#{camelcase(@name)}"
@resource_path = resource_path(dir)
if @generate_model
f = File.join(dir, 'model.rb')
template 'templates/code_generators/model.rb', f unless File.exist?(f)
f = File.join(dir, 'controller.rb')
template 'templates/code_generators/controller.rb', f unless File.exist?(f)
end
if @generate_pins
f = File.join(dir, 'pins.rb')
template 'templates/code_generators/pins.rb', f unless File.exist?(f)
end
if @generate_timesets
f = File.join(dir, 'timesets.rb')
template 'templates/code_generators/timesets.rb', f unless File.exist?(f)
end
if @generate_parameters
f = File.join(dir, 'parameters.rb')
template 'templates/code_generators/parameters.rb', f unless File.exist?(f)
end
f = File.join(dir, 'registers.rb')
template 'templates/code_generators/registers.rb', f unless File.exist?(f)
f = File.join(dir, 'sub_blocks.rb')
template 'templates/code_generators/sub_blocks.rb', f unless File.exist?(f)
f = File.join(dir, 'attributes.rb')
template 'templates/code_generators/attributes.rb', f unless File.exist?(f)
dir = File.join(dir, 'derivatives')
@namespaces << [:class, path]
@root_class = false
@parent_class = @namespaces.map { |type, name| camelcase(name) }.join('::')
end
@parent_class ||= @namespaces.map { |type, name| camelcase(name) }.join('::')
end
@name = @final_name
@fullname += "::#{camelcase(@name)}"
dir = @dir || File.join(dir, @name)
@resource_path = resource_path(dir)
if @generate_model
template 'templates/code_generators/model.rb', File.join(dir, 'model.rb')
template 'templates/code_generators/controller.rb', File.join(dir, 'controller.rb')
end
if @generate_pins
template 'templates/code_generators/pins.rb', File.join(dir, 'pins.rb')
end
if @generate_timesets
template 'templates/code_generators/timesets.rb', File.join(dir, 'timesets.rb')
end
if @generate_parameters
template 'templates/code_generators/parameters.rb', File.join(dir, 'parameters.rb')
end
template 'templates/code_generators/registers.rb', File.join(dir, 'registers.rb')
template 'templates/code_generators/sub_blocks.rb', File.join(dir, 'sub_blocks.rb')
template 'templates/code_generators/attributes.rb', File.join(dir, 'attributes.rb')
end
|