Class: ClientGenerator
- Inherits:
-
BaseScaffold
show all
- Defined in:
- lib/vraptor-scaffold/generators/scaffold/client_generator/client_generator.rb
Instance Method Summary
collapse
#base_path, #class_name, #controller_class_name, #controller_test_class_name, #initialize, #model_list_name, #model_parameter_name, #repository_impl_name, #repository_interface_name, #repository_test_class_name, #test_class_name
Constructor Details
This class inherits a constructor from BaseScaffold
Instance Method Details
#build ⇒ Object
3
4
5
6
7
8
9
10
11
12
|
# File 'lib/vraptor-scaffold/generators/scaffold/client_generator/client_generator.rb', line 3
def build
define_source_paths
@template_dir = "#{Configuration::FRONTEND}/#{model_parameter_name}/"
empty_directory @template_dir
create_js("controller", "#{controller_class_name}")
generate_html("list")
generate_html("details")
generate_html("form")
update_index
end
|
#create_js(template_name, file_name = template_name) ⇒ Object
14
15
16
|
# File 'lib/vraptor-scaffold/generators/scaffold/client_generator/client_generator.rb', line 14
def create_js(template_name, file_name=template_name)
template("#{template_name}.erb", "#{Configuration::JAVASCRIPTS}/#{file_name}.js")
end
|
#generate_html(template_name) ⇒ Object
18
19
20
|
# File 'lib/vraptor-scaffold/generators/scaffold/client_generator/client_generator.rb', line 18
def generate_html(template_name)
template("#{template_name}.erb", "#{@template_dir}/#{template_name}.html")
end
|
#path ⇒ Object
38
39
40
|
# File 'lib/vraptor-scaffold/generators/scaffold/client_generator/client_generator.rb', line 38
def path
"/#{base_path}"
end
|
#source_root ⇒ Object
34
35
36
|
# File 'lib/vraptor-scaffold/generators/scaffold/client_generator/client_generator.rb', line 34
def source_root
File.join File.dirname(__FILE__), "templates"
end
|
#template_path ⇒ Object
30
31
32
|
# File 'lib/vraptor-scaffold/generators/scaffold/client_generator/client_generator.rb', line 30
def template_path
"src/templates/client"
end
|
#update_index ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/vraptor-scaffold/generators/scaffold/client_generator/client_generator.rb', line 22
def update_index
file = "#{Configuration::WEB_APP}/index.html"
index_content = File.read(file)
updated_content = index_content.gsub("NGAPP", "ng-app=\"#{class_name}Module\"")
updated_content = updated_content.gsub("CONTROLLER", "#{controller_class_name}.js")
File.open(file, "w") { |file| file.puts updated_content }
end
|