Module: DZEN

Defined in:
lib/dzen.rb,
lib/dzen/base.rb,
lib/dzen/macros.rb,
lib/dzen/helpers.rb

Defined Under Namespace

Modules: Helpers, Macros Classes: Base, Default, Terminal

Constant Summary collapse

VERSION =
'0.0.1'
@@app_file =
lambda do
  ignore = [
    /lib\/dzen.*\.rb/,   # Library
    /\(.*\)/,            # Generated code
    /custom_require\.rb/ # RubyGems require
  ]
   path = caller.map { |line| line.split(/:\d/, 2).first }.find do |file|
    next if ignore.any? { |pattern| file =~ pattern }
    file
  end
   path || $0
end.call

Class Method Summary collapse

Class Method Details

.app_fileObject

File name of the application file. Inspired by Sinatra



28
29
30
# File 'lib/dzen.rb', line 28

def self.app_file
  @@app_file
end

.run?Boolean

Runs application if application file is the script being executed

Returns:

  • (Boolean)


35
36
37
# File 'lib/dzen.rb', line 35

def self.run?
  self.app_file == $0
end