Class: JBundle::CommandLine
- Inherits:
-
Thor
- Object
- Thor
- JBundle::CommandLine
- Includes:
- Thor::Actions
- Defined in:
- lib/jbundle/command_line.rb
Constant Summary collapse
- AFTER_INIT_MESSAGE =
%( Done. Try it! jbundle s open test/index.html Then package your work jsbundle )
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.source_root ⇒ Object
55 56 57 |
# File 'lib/jbundle/command_line.rb', line 55 def self.source_root ::File.dirname(__FILE__) end |
Instance Method Details
#bundle ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/jbundle/command_line.rb', line 15 def bundle begin JBundle.config_from_file([:jfile]) JBundle.write! rescue JBundle::NoJFileError => boom puts boom. end end |
#init(name = nil) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/jbundle/command_line.rb', line 72 def init(name = nil) name = ask("Name of your library (ie. foo.js, awesome.js, etc.):") unless name @name = name @klass_name = name.sub('.js', '').split(/[^a-z0-9]/i).map{|w| w.capitalize}.join template('templates/jfile.tt', "JFile") empty_directory 'src' template('templates/license.tt', "src/license.txt") template('templates/lib.tt', "src/#{name}") case [:tests] when 'qunit' then init_qunit when 'jasmine' then init_jasmine else puts "Don't know how to initalize tests for #{[:tests].inspect}" end empty_directory 'dist' say AFTER_INIT_MESSAGE, :yellow end |
#server ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/jbundle/command_line.rb', line 27 def server JBundle.config_from_file([:jfile]) say "Starting test server on http://localhost:#{[:port]}. Available bundles:", :yellow JBundle.config.bundles_and_files.each do |f| say "- /#{f.original_name} ==> /#{f.name}", :green end say "Run tests on ./tests/index.html" handler = Rack::Handler.default downward = false ['INT', 'TERM', 'QUIT'].each do |signal| trap(signal) do exit! if downward downward = true handler.shutdown if handler.respond_to?(:shutdown) Process.wait rescue nil say 'Shutting down test server', :yellow exit! end end handler.run JBundle::Server.new, {:Port => [:port]} end |