Class: TingYun::Support::LocalEnvironment

Inherits:
Object
  • Object
show all
Defined in:
lib/ting_yun/support/local_environment.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLocalEnvironment

Returns a new instance of LocalEnvironment.



13
14
15
16
17
18
19
20
21
22
# File 'lib/ting_yun/support/local_environment.rb', line 13

def initialize
  # Extend self with any any submodules of LocalEnvironment.  These can override
  # the discover methods to discover new framworks and dispatchers.
  TingYun::Support::LocalEnvironment.constants.each do | const |
    mod = TingYun::Support::LocalEnvironment.const_get const
    self.extend mod if mod.instance_of? Module
  end
  @discovered_dispatcher = nil
  discover_dispatcher
end

Class Method Details

.find_class_in_object_space(klass) ⇒ Object

Runs through all the objects in ObjectSpace to find the first one that match the provided class



26
27
28
29
30
31
32
33
# File 'lib/ting_yun/support/local_environment.rb', line 26

def self.find_class_in_object_space(klass)
  if TingYun::Support::LanguageSupport.object_space_usable?
    ObjectSpace.each_object(klass) do |x|
      return x
    end
  end
  return nil
end

Instance Method Details

#discovered_dispatcherObject



8
9
10
11
# File 'lib/ting_yun/support/local_environment.rb', line 8

def discovered_dispatcher
  discover_dispatcher unless @discovered_dispatcher
  @discovered_dispatcher
end

#executableObject



180
181
182
# File 'lib/ting_yun/support/local_environment.rb', line 180

def executable
  File.basename($0)
end

#to_sObject

outputs a human-readable description



174
175
176
177
178
# File 'lib/ting_yun/support/local_environment.rb', line 174

def to_s
  s = "LocalEnvironment["
  s << ";dispatcher=#{@discovered_dispatcher}" if @discovered_dispatcher
  s << "]"
end