Class: Xmvc::Generator::App

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/xmvc/generators/app.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



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

#bootObject



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_appObject



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_configObject



34
35
36
# File 'lib/xmvc/generators/app.rb', line 34

def create_config
  directory("config", "config")
end

#create_libObject



38
39
40
# File 'lib/xmvc/generators/app.rb', line 38

def create_lib
  empty_directory("lib")
end

#create_publicObject



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_rootObject



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_specObject



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_vendorObject



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

#environmentObject



80
81
82
# File 'lib/xmvc/generators/app.rb', line 80

def environment
  Xmvc::Config.setup
end

#install_pluginsObject



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_specObject



20
21
22
# File 'lib/xmvc/generators/app.rb', line 20

def vendor_spec
  copy_file("vendor.yml", "vendor.yml")
end