Class: Xmvc::Generator::Boot

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

Defined Under Namespace

Classes: PathError

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



8
9
10
# File 'lib/xmvc/generators/boot.rb', line 8

def self.source_root 
  File.join(Xmvc::TEMPLATE_PATH)
end

Instance Method Details

#defaultObject



13
14
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
# File 'lib/xmvc/generators/boot.rb', line 13

def default
  puts "Boot default is disabled"
  return false
  
  #builder = Xmvc::Builder.new([], {})    
  #packages = builder.invoke(:setup, [])
  
  host = Xmvc.host.config["name"]
  @development = []
  @production = []
  @test = []
  
  packages.each do |pkg|
    if pkg[:vendor] == :host
      pkg[:source_files].each do |file|
        #@development << url_for_path(file.pathname.to_s)
      end
      @production << Xmvc.public_build_url(:js, "app")
    else
      spec = pkg[:vendor]
      # No source-files generated but host defined?  cachefly resources (ie: ext)?
      if pkg[:source_files].empty? and spec["host"] 
        package = spec["name"].to_s
        version = spec["version"].to_s
        package += "-#{version}" unless version.empty?
        spec["javascripts"].each do |file|
          debug = file.gsub(/(\.js)/, "-debug.js")
          #TODO Fix this hard-coded "-debug" hack for Ext cachefly resources.
          @development << File.join(spec["host"], package, debug)
          @production << File.join(spec["host"], package, file)
        end
      elsif pkg[:source_files].length
        @development << Xmvc.public_build_url(:js, spec["name"], spec["version"], "debug")
        @production << Xmvc.public_build_url(:js, spec["name"], spec["version"])
      end
    end  
  end  
  @test = @development
  
  template("boot.js", "config/boot.js")
end

#sprocketsObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/xmvc/generators/boot.rb', line 56

def sprockets        
  @javascripts = []
  @stylesheets = []
  options[:vendors].each do |vendor|
    config = vendor.invoke(:config)
    if config["host"] # <-- Host as in http://extjs.cachefly.net/...
      config["javascripts"].each do |script|
        @javascripts << File.join(config["host"], script)
      end
      config["stylesheets"].each do |url|
        @stylesheets << File.join(config["host"], url)
      end
    else
      @javascripts << File.join("/sprockets", "#{config['name']}.js")
      if config["stylesheets"]  # <-- We wanna' use Sass!
        config["stylesheets"].each do |url|
          @stylesheets << File.join("/public", "stylesheets", config["name"], url)
        end
      end
    end  
  end
  
  # Finallly, add the xmvc assets (ie: controllers, models, views, plugins, etc)
  @javascripts << File.join("/sprockets", "app.js")
  
  # Application sass / css??
  
  template("index.html.sprockets", "public/index.html.sprockets")
end