Module: Xmvc::Generator
- Defined in:
- lib/xmvc/generator.rb,
lib/xmvc/generators/app.rb,
lib/xmvc/generators/boot.rb,
lib/xmvc/generators/view.rb,
lib/xmvc/generators/model.rb,
lib/xmvc/generators/layout.rb,
lib/xmvc/generators/scaffold.rb,
lib/xmvc/generators/controller.rb
Defined Under Namespace
Classes: App, Boot, Controller, Layout, Model, Scaffold, View
Constant Summary collapse
- GENERATORS =
%w(app model controller scaffold view namespace)
Class Method Summary collapse
- .dispatch(generator, options, *params) ⇒ Object
-
.namespace(namespace) ⇒ Object
overwrites all instances of ‘MyApp’ with the namespace provided.
- .script_tag(file) ⇒ Object
Class Method Details
.dispatch(generator, options, *params) ⇒ Object
15 16 17 18 19 20 21 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 |
# File 'lib/xmvc/generator.rb', line 15 def self.dispatch(generator, , *params) Xmvc.public_path = File.("./public") unless GENERATORS.include?(generator) raise MVC::ArgumentError.new("Must use one of the following: " + GENERATORS.join(", ").downcase) end case generator when "app" = .dup App.start(params, ) when "model" model = Model.new([], .dup) model.invoke("generate", [params.shift, *params]) when "controller" name = params.shift controller = Controller.new([], .dup) controller.invoke("generate", [name]) if params.length params.each do |v| view = View.new([], .dup) # why have to create new instance for each?? view.invoke("generate", [name, v]) end end when "scaffold" name = params.shift Xmvc.ui.warn("scaffold generation is not yet implemented") scaffold = Scaffold.new([], .dup) scaffold.invoke("generate", [name, params]) when "view" package = params.shift name = params.shift view = View.new([], .dup) view.invoke("generate", [package, name]) when "namespace" #self.namespace(name) end end |
.namespace(namespace) ⇒ Object
overwrites all instances of ‘MyApp’ with the namespace provided
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/xmvc/generator.rb', line 57 def self.namespace(namespace) current = Xmvc.namespace configs = %w( config/settings.yml config/application.js ) Dir["app/controllers/*.js"].each do |f| write_namespace(f, current, namespace) end Dir["app/views/*/*.js"].each do |f| write_namespace(f, current, namespace) end configs.each {|f| write_namespace(f, current, namespace) } end |
.script_tag(file) ⇒ Object
4 5 6 |
# File 'lib/xmvc/generators/layout.rb', line 4 def self.script_tag(file) '<script type="text/javascript" src="' + file + '"></script>' end |