Class: Depo::Build

Inherits:
Object
  • Object
show all
Defined in:
lib/depo/build.rb

Class Method Summary collapse

Class Method Details

.generate_profile(opts = {}) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/depo/build.rb', line 7

def generate_profile(opts={})
  @rails_root = opts[:rails_root] if opts.key?(:rails_root)
  profile_content = profile_template.result(binding)
  open(profile_path,'w') do |f|
    f<< profile_content
  end
end

.layersObject



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/depo/build.rb', line 31

def layers
  Depo.config.build_profile.pages.map do |page|
    file="../#{page.gsub('.','/')}.js"
    <<-JS
    {
      name:"#{file}",
      dependencies: ["#{page}"]
    }
    JS
  end.join(',')
end

.prefixesObject



43
44
45
46
47
48
49
# File 'lib/depo/build.rb', line 43

def prefixes
  result = %w{dijit dojox}.map{|lib| %Q<["#{lib}","../#{lib}"]>}
  Depo.config.build_profile.libs.each do |lib|
    result<< %Q<["#{lib}","#{@rails_root}/#{Depo.config.src_path}/#{lib}"]>
  end
  "#{result.join(',')}"
end

.profile_pathObject



15
16
17
18
19
20
21
22
23
# File 'lib/depo/build.rb', line 15

def profile_path
  raise "I need RAILS ROOT to generate profile" unless Object.const_defined? :RAILS_ROOT
  file_path = File.join(RAILS_ROOT,Depo.config.profile_path)
  file_dir = File.dirname(file_path)
  unless File.exists?(file_dir)
    FileUtils.mkdir_p(file_dir)
  end
  file_path
end

.profile_templateObject



25
26
27
28
29
# File 'lib/depo/build.rb', line 25

def profile_template
  return @template if @template
  tpl_string = File.read("#{File.dirname(__FILE__)}/templates/profile.js")
  @template = ERB.new(tpl_string)
end