Module: Shatter

Defined in:
lib/shatter/service/base.rb,
lib/shatter.rb,
lib/shatter/util.rb,
lib/shatter/config.rb,
lib/shatter/version.rb,
lib/shatter/web/server.rb,
lib/shatter/web/application.rb,
lib/shatter/service/function.rb,
lib/shatter/service/discovery.rb,
lib/shatter/service/response_pool.rb,
lib/shatter/service/service_definition.rb

Overview

Server Side of the drb

Defined Under Namespace

Modules: Service, Util, Web Classes: Config, Error

Constant Summary collapse

RELOAD_RW_LOCK =

Your code goes hereā€¦

Concurrent::ReadWriteLock.new
VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.config(&block) ⇒ Object



31
32
33
34
35
# File 'lib/shatter.rb', line 31

def self.config(&block)
  block.call(Config) and return if block_given?

  Config
end


63
64
65
66
# File 'lib/shatter.rb', line 63

def self.link_definitions
  Shatter::Service::Base.service_definition = ServiceDefinition if Object.const_defined?("ServiceDefinition")
  Shatter::Web::Server.application = Application if Object.const_defined?("Application")
end

.loadObject



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/shatter.rb', line 50

def self.load
  # @loader = Zeitwerk::Loader.for_gem
  @loader = Zeitwerk::Loader.new
  @loader.tag = File.basename(__FILE__, ".rb")
  @loader.inflector = Zeitwerk::GemInflector.new(__FILE__)
  Config.autoload_paths.each do |path|
    @loader.push_dir(File.expand_path(path, root))
  end
  @loader.enable_reloading
  @loader.setup # ready!
  link_definitions
end

.load_environmentObject



41
42
43
# File 'lib/shatter.rb', line 41

def self.load_environment
  require "#{Shatter.root}/config/environment.rb"
end

.loaderObject



37
38
39
# File 'lib/shatter.rb', line 37

def self.loader
  @loader
end

.loggerObject



27
28
29
# File 'lib/shatter.rb', line 27

def self.logger
  Util::Logger.instance
end

.reloadObject



45
46
47
48
# File 'lib/shatter.rb', line 45

def self.reload
  @loader.reload
  link_definitions
end

.rootObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/shatter.rb', line 15

def self.root
  current = Dir.pwd
  root_dir = nil

  while current.size >= 1 && root_dir.nil?
    root_dir = current if Dir.children(current).include?("Gemfile")
    current = File.expand_path("..", current) if root_dir.nil?
    Dir.new(current)
  end
  root_dir
end