Module: Ergane

Defined in:
lib/ergane.rb,
lib/ergane/tool.rb,
lib/ergane/util.rb,
lib/ergane/debug.rb,
lib/ergane/version.rb,
lib/ergane/helpers/hashall.rb,
lib/ergane/switch_definition.rb,
lib/ergane/command_definition.rb

Defined Under Namespace

Modules: Debug, Util Classes: CommandDefinition, Hashall, NamedBlock, SwitchDefinition, Tool

Constant Summary collapse

Help =
Class.new(StandardError)
Interrupt =
Class.new(StandardError)
VERSION =
'0.0.1'
@@active_tool =

def debug(string)

old_level = logger.level
logger.level = :debug if $debug
logger.debug(string)

ensure

logger.level = old_level

end

nil

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerObject (readonly)

Returns the value of attribute logger.



21
22
23
# File 'lib/ergane.rb', line 21

def logger
  @logger
end

Class Method Details

.activate_tool(tool) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/ergane.rb', line 48

def activate_tool(tool)
  previous_tool = @@active_tool
  @@active_tool = tool
  yield if block_given?
ensure
  @@active_tool = previous_tool
end

.active_toolObject



44
45
46
# File 'lib/ergane.rb', line 44

def active_tool
  @@active_tool
end

.extensionsObject

Show a list of available extensions to use



72
73
74
# File 'lib/ergane.rb', line 72

def extensions
  Extension.library
end

.notify(message, title: nil, sound: nil, icon: nil, group: nil) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ergane.rb', line 56

def notify(message, title: nil, sound: nil, icon: nil, group: nil)
  cmd = ['terminal-notifier']
  cmd << "-group #{Process.pid}#{group}"
  cmd << "-title #{active_tool.label}"
  cmd << "-subtitle #{title}" if title
  cmd << "-appIcon 'assets/athena md-light-shadow.png'" if icon
  cmd << "-message '#{message}'"
  cmd << "-activate 'com.apple.Terminal'" # if macos
  cmd << "-sound #{sound}" if sound
  Thread.new { `afplay /System/Library/Sounds/#{sound == true ? 'Blow' : sound}.aiff` } unless sound == false

  `#{cmd.join(' ')}`
  # Notifier.notify(title: title, message: message, image: 'assets/athena md-light-shadow.png')
end

.root(*args) ⇒ Object



23
24
25
# File 'lib/ergane.rb', line 23

def root(*args)
  (@root ||= Pathname.new(File.expand_path('../', __dir__))).join(*args)
end