Class: Kango::Tasks
- Inherits:
-
Thor
- Object
- Thor
- Kango::Tasks
- Defined in:
- lib/kango/tasks.rb
Instance Method Summary collapse
- #build ⇒ Object
- #compile ⇒ Object
- #create(name) ⇒ Object
- #docs ⇒ Object
- #install ⇒ Object
- #watch(*opts) ⇒ Object
Instance Method Details
#build ⇒ Object
18 19 20 21 22 23 |
# File 'lib/kango/tasks.rb', line 18 def build ensure_framework do self.compile if File.directory?(File.join(Dir.pwd, 'coffee')) Kango::Framework.build! end end |
#compile ⇒ Object
12 13 14 15 |
# File 'lib/kango/tasks.rb', line 12 def compile require 'kango/script_compiler' Kango::ScriptCompiler.new('coffee/**/*', 'coffee', CoffeeScript).compile end |
#create(name) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/kango/tasks.rb', line 26 def create name require 'kango/templates' ensure_framework do path = File.(File.join(Dir.pwd, name)) puts "Creating Kango project at #{path}" Kango::Framework.create_project! name, path File.open(File.join(path, 'Gemfile'), 'w') do |gemfile| gemfile.puts Kango::Templates.gemfile end FileUtils.mkdir File.join(path, 'coffee') File.open(File.join(path, 'coffee', 'main.coffee'), 'w') do |main| main.puts Kango::Templates.main_coffee end end end |
#docs ⇒ Object
43 44 45 46 |
# File 'lib/kango/tasks.rb', line 43 def docs require 'launchy' Launchy.open("http://kangoextensions.com/docs/index.html") end |
#install ⇒ Object
6 7 8 9 |
# File 'lib/kango/tasks.rb', line 6 def install require 'kango/installer' Kango::Installer.run! end |
#watch(*opts) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/kango/tasks.rb', line 49 def watch *opts ensure_framework do require 'directory_watcher' if opts.include? 'reload.extensions' require 'kango/reloader/chrome/extensions_reloader' @reloader = Kango::Reloader::Chrome::ExtensionsReloader.new end coffee = DirectoryWatcher.new(File.join(Dir.pwd,'coffee'), globs:'**/*.coffee', :pre_load => true) coffee.interval = 1 coffee.add_observer do |*args| self.compile end coffee.start common = DirectoryWatcher.new(File.join(Dir.pwd,'src','common'), :pre_load => true) common.interval = 1 common.add_observer do |*args| Kango::Framework.build! end common.start if @reloader @reloader.trigger do @reloader.reload_browser end end unless ['serving'] trap("INT") do puts " Halting auto-regeneration." exit 0 end loop { sleep 1000 } end end end |