Class: NamedCommandDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/pomodoro/commands/run.rb

Defined Under Namespace

Classes: Matcher, Thing

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNamedCommandDSL

Returns a new instance of NamedCommandDSL.


57
58
59
# File 'lib/pomodoro/commands/run.rb', line 57

def initialize
  @matchers = Array.new
end

Instance Attribute Details

#matchersObject (readonly)

Returns the value of attribute matchers


56
57
58
# File 'lib/pomodoro/commands/run.rb', line 56

def matchers
  @matchers
end

Instance Method Details

#configObject

TODO: Copied from dsl.rb, use a mixin. AND un-hard-code the path below.


71
72
73
# File 'lib/pomodoro/commands/run.rb', line 71

def config
  @config ||= OpenStruct.new(YAML.load_file(self.config_path))
end

#config_pathObject


75
76
77
# File 'lib/pomodoro/commands/run.rb', line 75

def config_path
  File.expand_path("/Users/botanicus/Dropbox/Data/Data/Pomodoro/Schedules/config.yml")
end

#match(name, condition, &block) ⇒ Object


61
62
63
# File 'lib/pomodoro/commands/run.rb', line 61

def match(name, condition, &block)
  self.matchers << Matcher.new(name, condition, &block)
end

#sh(command) ⇒ Object


65
66
67
68
# File 'lib/pomodoro/commands/run.rb', line 65

def sh(command)
  system("zsh -c '#{command}'") # TODO: use shell words
rescue Interrupt
end