lib/closure.rb in closure-1.5.0 vs lib/closure.rb in closure-1.5.1

- old
+ new

@@ -26,27 +26,27 @@ # use Rack::ShowExceptions # use Closure::Middleware # run Rack::File.new './public' class Closure - + # Filesystem location of the Closure Script install. # Typically, where the gem was installed. This is mainly used # internally but may be useful for experimental configurations. # @return [String] def self.base_path @@base_path ||= File.expand_path(File.join(File.dirname(__FILE__), '..')) end - + # Scripts that are distributed with the gem. These will help get you started quickly. BUILT_INS = { :soy => File.join(base_path, 'closure-templates'), :docs => File.join(base_path, 'docs') } - - + + # Easy config. This adds to the global instance of sources and # supports using the {BUILT_INS}. # @example # Closure.add_source :soy, '/soy_js' # Closure.add_source './myapp', '/myapp' @@ -55,11 +55,11 @@ # @param (String) path http server mount point. # @param (String) directory Where the scripts are in the filesystem. # @param (Symbol) built_in def self.add_source(directory, path=nil) if directory.kind_of? Symbol - dir = BUILT_INS[directory] + dir = BUILT_INS[directory] raise "Unknown built-in: #{directory}" unless dir directory = dir end raise Errno::ENOENT, File.expand_path(directory, Dir.pwd) unless File.directory? directory sources.add directory, path @@ -71,12 +71,12 @@ # Path and directory pairs configured with Closure.add_source(). # @return [Array] def self.sources @@sources ||= Sources.new end - - + + # Execute jar in a REPL or with JRuby # @private - internal use only # @param (String) jar Path to .jar file # @param (String) mainClass Class with main(String[] args) # @param (Array) args Arguments @@ -100,12 +100,12 @@ out = cmdout.read; cmdout.close; cmdout.unlink err = cmderr.read; cmderr.close; cmderr.unlink end [out, err] end - - + + # Set these before the rack server is called for the first time. # === Attributes: # - (String) *java* -- default: "java" -- Your Java executable. Not used under JRuby. # - (String) *compiler_jar* -- A compiler.jar to use instead of the packaged one. # - (String) *soy_js_jar* -- A SoyToJsSrcCompiler.jar to use instead of the packaged one. @@ -121,11 +121,11 @@ if !defined? JRUBY_VERSION @@config.java = 'java' end @@config end - + # Run the welcome server. Handy for gem users. # @example # ruby -e "require 'rubygems'; gem 'closure'; require 'closure'; Closure.welcome" def self.welcome raise 'Use rackup, config.ru already exists.' if File.exist? 'config.ru' @@ -137,9 +137,9 @@ Rack::MockRequest.new(server.app).request port = server.options[:Port] || server.default_options[:Port] print "Closure Script Welcome Server: http://localhost:#{port}/\n" server.start end - + end -Dir.glob(File.expand_path('**/*.rb', File.dirname(__FILE__))).each {|f| require f} +Dir.glob(File.expand_path('**/*.rb', File.dirname(__FILE__))).each {|f| require f unless f == __FILE__}