Sha256: df23f898d2d82e2c9e00aac3e2324214fa127c9f99a279a40f6af4eb6b9f8cc2

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

require "thor"
require "listen"

module Linner
  class Command < Thor
    include Thor::Actions
    map "-v" => :version

    def self.source_root
      File.dirname(__FILE__)
    end

    desc "version", "show version"
    def version
      puts Linner::VERSION
    end

    desc "build", "build assets"
    def build
      Linner.compile = true
      Notifier.info do
        Linner.perform
      end
    end

    desc "watch", "watch assets"
    def watch
      trap :INT do
        Notifier.exit
        exit!
      end

      @proc = Proc.new do |modified, added, removed|
        begin
          Notifier.info{ Linner.perform }
        rescue
          Notifier.error $!
        end
      end
      @proc.call

      Listen.to env.app_folder, env.vendor_folder, env.test_folder do |modified, added, removed|
        @proc.call
      end

      @reactor = Reactor.supervise_as(:reactor).actors.first
      Listen.to env.public_folder, relative_path: true do |modified, added, removed|
        @reactor.reload_browser(modified + added + removed)
      end

      sleep
    end

    desc "clean", "clean assets"
    def clean
      FileUtils.rm_rf Dir.glob("#{env.public_folder}/*")
    end

    desc "new", "create the skeleton of project"
    def new(name)
      directory('templates', name)
      chmod("#{name}/bin/server", 0755)
    end

  private
    def env
      Linner.env
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
linner-0.3.2 lib/linner/command.rb
linner-0.3.1 lib/linner/command.rb