Sha256: 115e6040b8fd21ab9f5bc87325d20bfb29afac133f14f25b48c06a915be6283c
Contents?: true
Size: 1.74 KB
Versions: 2
Compression:
Stored size: 1.74 KB
Contents
module Ninjs class Generator def initialize(project, name) @project = project @name = name end def generate_module_file(with = { :elements => false, :model => false }) File.open "#{@project.project_path}modules/#{@name.downcase}.module.js", "w" do |file| file << "(function(){\n" file << "\tvar self = " + @project.config.name + ".add_module('" + @name + "');\n\n" file << "\t" + '//= require "../elements/' + @name.downcase + '.elements.js"' + "\n\n" if with[:elements] file << "\t" + '//= require "../models/' + @name.downcase + '.model.js"' + "\n\n" if with[:model] file << "\t#{@project.config.name}." + @name + ".actions = function() {\n\n\t}\n\n" file << "\t#{@project.config.name}." + @name + ".run();\n" file << "})();" Ninjs::Notification.added "created #{@name.downcase}.module.js" end unless File.exists? "#{@project.project_path}modules/#{@name.downcase}.module.js" end def generate_elements_file() File.open("#{@project.project_path}elements/#{@name.downcase}" + ".elements.js", "w") do |file| file << @project.config.name + "." + @name + ".elements(function({\n\n}));" Ninjs::Notification.added "created #{@name.downcase}.elements.js" end unless File.exists? "#{@project.project_path}elements/#{@name.downcase}.elements.js" end def generate_model_file() File.open "#{@project.project_path}models/#{@name.downcase}.model.js", "w" do |file| file << @project.config.name + "." + @name + ".set_data({\n\t\n});" Ninjs::Notification.added "created #{@name.downcase}.model.js" end unless File.exists? "#{@project.project_path}models/#{@name.downcase}.model.js" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ninjs-0.13.0 | lib/ninjs/generator.rb |
ninjs-0.12.3 | lib/ninjs/generator.rb |