Add support for resin-compiling everything into a single .js file
Bumping another minor version for it
This commit is contained in:
parent
161d2a2293
commit
dec9e050d0
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'rubygems'
|
||||
require 'resin/compiler'
|
||||
|
||||
Resin::Compiler.run
|
|
@ -0,0 +1,81 @@
|
|||
|
||||
module Resin
|
||||
module Compiler
|
||||
CORE = ['boot', 'Kernel-Objects', 'Kernel-Classes', 'Kernel-Methods',
|
||||
'Kernel-Collections', 'Kernel-Exceptions', 'Canvas']
|
||||
|
||||
def self.write_file(handle, filepath)
|
||||
package = File.basename(filepath).split('.').first
|
||||
puts "#{package} #{filepath}"
|
||||
handle.write("/* start #{package} */\n")
|
||||
handle.write(File.open(filepath, 'r').read)
|
||||
handle.write("\n/* end #{package} */\n")
|
||||
|
||||
end
|
||||
|
||||
def self.run(additional_files=nil)
|
||||
begin
|
||||
spec = Gem::Specification.find_by_name('resin')
|
||||
amber_path = File.join(spec.full_gem_path, 'amber')
|
||||
rescue Gem::LoadError
|
||||
amber_path = File.expand_path(File.dirname(__FILE__) + '/../amber/')
|
||||
end
|
||||
project_path = Dir.pwd
|
||||
|
||||
|
||||
files = Dir["#{project_path}/js/*.deploy.js"]
|
||||
drop_files = Dir["#{project_path}/drops/**/js/*.deploy.js"]
|
||||
out = File.open('resin-app.deploy.js', 'w')
|
||||
|
||||
write_file(out, File.join(amber_path, 'js', 'lib', 'jQuery', 'jquery-1.6.4.min.js'))
|
||||
|
||||
puts ">> Writing the Amber core: "
|
||||
CORE.each do |package|
|
||||
# Default to try to load the deploy script if it exists
|
||||
path = File.join(amber_path, 'js', "#{package}.deploy.js")
|
||||
unless File.exists? path
|
||||
path = File.join(amber_path, 'js', "#{package}.js")
|
||||
unless File.exists? path
|
||||
puts "Missing #{package}!"
|
||||
puts "(looked for #{path})"
|
||||
puts "Aborting."
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
write_file(out, path)
|
||||
end
|
||||
puts
|
||||
|
||||
puts ">> Writing project files: "
|
||||
files.each do |path|
|
||||
if path =~ /.*-Tests.*/
|
||||
next
|
||||
end
|
||||
write_file(out, path)
|
||||
end
|
||||
puts
|
||||
|
||||
puts ">> Writing drop files: "
|
||||
drop_files.each do |path|
|
||||
if path =~ /.*-Tests.*/
|
||||
next
|
||||
end
|
||||
write_file(out, path)
|
||||
end
|
||||
puts
|
||||
|
||||
unless additional_files.nil?
|
||||
additional_files.each do |path|
|
||||
path = File.join(project_path, 'js', additional_files)
|
||||
write_file(out, path)
|
||||
end
|
||||
end
|
||||
|
||||
write_file(out, File.join(amber_path, 'js', 'init.js'))
|
||||
|
||||
out.close
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
spec = Gem::Specification.new do |s|
|
||||
s.name = 'resin'
|
||||
s.version = '0.1.0'
|
||||
s.version = '0.2.0'
|
||||
s.author = "R. Tyler Croy"
|
||||
s.email = "tyler@linux.com"
|
||||
s.homepage = "https://github.com/rtyler/resin"
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.summary = %q{A tool for building Amber applications with Ruby}
|
||||
s.files = Dir['bin/*'] + Dir['lib/**/*.rb'] + Dir['lib/**/*.haml'] + Dir['amber/css/*'] +
|
||||
Dir['amber/js/**/*'] + Dir['amber/st/**/*.st'] + Dir['amber/images/*']
|
||||
Dir['amber/js/**/*'] + Dir['amber/st/**/*.st'] + Dir['amber/images/*'] + ['amber/bin/amberc', 'amber/bin/nodecompile.js']
|
||||
s.bindir = 'bin'
|
||||
s.executables = ['runresin']
|
||||
s.executables = ['runresin', 'resin-compile']
|
||||
s.has_rdoc = true
|
||||
s.extra_rdoc_files = ["README.markdown"]
|
||||
|
||||
|
|
Loading…
Reference in New Issue