Class: Xmvc::Generator::App
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Xmvc::Generator::App
- Includes:
- Thor::Actions
- Defined in:
- lib/xmvc/generators/app.rb
Class Method Summary collapse
Instance Method Summary collapse
- #boot ⇒ Object
- #create_app ⇒ Object
- #create_config ⇒ Object
- #create_lib ⇒ Object
- #create_public ⇒ Object
- #create_root ⇒ Object
- #create_spec ⇒ Object
- #create_vendor ⇒ Object
- #environment ⇒ Object
- #install_plugins ⇒ Object
- #vendor_spec ⇒ Object
Class Method Details
.source_root ⇒ Object
7 8 9 |
# File 'lib/xmvc/generators/app.rb', line 7 def self.source_root File.join(Xmvc::TEMPLATE_PATH, "app", "public") end |
Instance Method Details
#boot ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/xmvc/generators/app.rb', line 84 def boot ## # We want to get rid of Xmvc::Builder in favour of each vendor providing its own secretary # @vendors = [] # bundle all vendor assets inside "vendor" do |dir| Xmvc.vendors.each do |vendor| api = vendor::API.load({ :root => dir, :format => :js, :asset_root => Xmvc::PUBLIC_PATH }) api.invoke(:bundle) @vendors << api end end # Bundle application code last app = Xmvc::API.load({ :root => ".", :format => :js, :asset_root => Xmvc::PUBLIC_PATH }) app.invoke(:bundle) @vendors << app # Create a boot-generator boot = Xmvc::Generator::Boot.new([], { :root => self.destination_root, :vendors => @vendors }) boot.invoke(:default) boot.invoke(:sprockets) end |
#create_app ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/xmvc/generators/app.rb', line 24 def create_app empty_directory("app") inside("app", {}) do #copy_file("App.js", "#{destination_root}/App.js") empty_directory("models") directory("views", "views") directory("controllers", "controllers") end end |
#create_config ⇒ Object
34 35 36 |
# File 'lib/xmvc/generators/app.rb', line 34 def create_config directory("config", "config") end |
#create_lib ⇒ Object
38 39 40 |
# File 'lib/xmvc/generators/app.rb', line 38 def create_lib empty_directory("lib") end |
#create_public ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/xmvc/generators/app.rb', line 42 def create_public empty_directory("public") inside("public", {}) do copy_file("index.html", "index.html") empty_directory("images") empty_directory("javascripts") directory("stylesheets", "stylesheets") end end |
#create_root ⇒ Object
14 15 16 17 18 |
# File 'lib/xmvc/generators/app.rb', line 14 def create_root empty_directory(name) self.destination_root = name FileUtils.chdir(name) end |
#create_spec ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/xmvc/generators/app.rb', line 53 def create_spec directory("spec", "spec", :recursive => false) inside("spec", {}) do empty_directory("models") empty_directory("controllers") end end |
#create_vendor ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/xmvc/generators/app.rb', line 61 def create_vendor directory("vendor", "vendor") inside("vendor", {}) do |vendor_dir| empty_directory("plugins") # install vendors Xmvc.vendors.each do |vendor| vendor::API.install({ :root => vendor_dir }) end end end |
#environment ⇒ Object
80 81 82 |
# File 'lib/xmvc/generators/app.rb', line 80 def environment Xmvc::Config.setup end |
#install_plugins ⇒ Object
74 75 76 77 78 |
# File 'lib/xmvc/generators/app.rb', line 74 def install_plugins inside("vendor/plugins", {}) do # install vendor/plugins here end end |
#vendor_spec ⇒ Object
20 21 22 |
# File 'lib/xmvc/generators/app.rb', line 20 def vendor_spec copy_file("vendor.yml", "vendor.yml") end |