bin/jsus in jsus-0.3.1 vs bin/jsus in jsus-0.3.2
- old
+ new
@@ -75,10 +75,15 @@
opts.on_tail('-v', '--verbose', 'verbose mode, shows various debug messages') do
Jsus.verbose = true
end
+ opts.on_tail('--very-verbose', 'very verbose mode, shows pool stats beside usual verbose stuff') do
+ Jsus.verbose = true
+ options[:display_pool_stats] = true
+ end
+
opts.on_tail('-b', '--benchmark', 'shows time spent on various stages') do
options[:benchmark] = true
end
opts.on_tail('--without-scripts-info', 'do not generate scripts.json') do
@@ -190,10 +195,11 @@
def launch
checkpoint(:start)
setup_output_directory
preload_pool
load_package
+ display_pool_stats if options[:display_pool_stats]
compile_package
post_process if options[:postproc]
compress_package if options[:compress]
package_filename = File.join(@output_dir, @package.filename)
File.open(package_filename, 'w') {|f| f << @package_content }
@@ -222,10 +228,34 @@
@package = Jsus::Package.new(options[:input_dir], :pool => @pool)
@package.include_dependencies!
checkpoint(:dependencies)
end
+ def display_pool_stats
+ checkpoint(:pool_stats)
+ puts ""
+ puts "Pool stats:"
+ puts ""
+ puts "Main package:"
+ display_package @package
+ puts "Supplementary packages:"
+ @pool.packages.each do |package|
+ display_package package
+ end
+ puts ""
+ end
+
+ def display_package(package)
+ puts "Package: #{package.name}"
+ package.source_files.to_a.sort_by {|sf| sf.filename}.each do |sf|
+ puts " [#{sf.relative_filename}]"
+ puts " Provides: [#{sf.provides_names.join(", ")}]"
+ puts " Requires: [#{sf.requires_names.join(", ")}]"
+ end
+ puts ""
+ end
+
def compile_package
@package_content = @package.compile(nil)
checkpoint(:compilation)
end
@@ -271,19 +301,12 @@
def generate_includes
includes_root = options[:includes_root] || @output_dir
File.open(File.join(@output_dir, "includes.js"), "w") do |f|
c = Jsus::Container.new(*(@package.source_files.to_a + @package.linked_external_dependencies.to_a))
- script = %{
- (function(prefix, loader) {
- var sources = %sources%;
- if (!loader) loader = function(path) {
- document.write('<scr' + 'ipt src="' + (prefix || '') + path + '"></script>');
- }
- for (var i = 0, j = sources.length; i < j; i++) loader(sources[i]);
- })(window.prefix, window.loader);}.sub("%sources%", JSON.pretty_generate(c.required_files(includes_root)))
- f.puts script
+ paths = c.required_files(includes_root)
+ f.puts Jsus::Util::CodeGenerator.generate_includes(paths)
end
checkpoint(:includes)
end
def generate_docs
@@ -352,6 +375,6 @@
"#{format("%.3f", time_for(checkpoint_name))}s"
end
end
end
-Jsus::CLI.run!
\ No newline at end of file
+Jsus::CLI.run!