Sha256: 22215cded7596eb878e898aafae1b25bb3cfe95bb10453839332a58bc413b1de
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
module Space module Shell autoload :Command, 'space/shell/command' autoload :Watch, 'space/shell/watch' autoload :Watcher, 'space/shell/watcher' module ClassMethods def commands(commands = nil) commands ? @commands = commands : @commands end def watch(*paths) paths.empty? ? (@paths || []) : (@paths = paths) end end include Watcher class << self def included(base) base.extend(ClassMethods) end def all @all ||= [] end def refresh all.map(&:refresh) end end attr_reader :path def initialize(path = '.') @path = File.expand_path(path) Shell.all << self super end def result(command) commands[command].result end def commands @commands ||= self.class.commands.inject({}) do |commands, (key, command)| commands.merge(key => Command.new(self, command)) end end def refresh commands.each { |key, command| command.run } # notify(:refresh, self.class.name) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
space-0.0.5 | lib/space/shell.rb |
space-0.0.4 | lib/space/shell.rb |