Module: Skynet
- Extended by:
- Skynet
- Included in:
- Skynet
- Defined in:
- lib/skynet-core.rb,
lib/skynet-core/harvest.rb,
lib/skynet-core/cyberdyne.rb,
lib/skynet-core/db/hippocampus.rb
Defined Under Namespace
Classes: ApplicationLoadError, Cyberdyne, Harvest, Queue
Instance Attribute Summary collapse
-
#_app_config ⇒ Object
readonly
Returns the value of attribute _app_config.
-
#_database_config ⇒ Object
readonly
Returns the value of attribute _database_config.
-
#_queue ⇒ Object
readonly
Returns the value of attribute _queue.
Class Method Summary collapse
- .app_config ⇒ Object
- .database_config ⇒ Object
- .env ⇒ Object
-
.load_config ⇒ Object
def bundle return :locked if File.exist?(root(‘.bundle/environment.rb’)) return :unlocked if File.exist?(root(“Gemfile”)) end.
-
.load_dependencies(*paths) ⇒ Object
(also: load_dependency)
Attempts to load all dependency libs that we need.
- .queue ⇒ Object
- .require_dependencies(*paths) ⇒ Object (also: require_dependency)
- .root(*args) ⇒ Object
-
.set_encoding ⇒ Object
Default encoding to UTF8 if it has not already been set to something else.
Instance Attribute Details
#_app_config ⇒ Object (readonly)
Returns the value of attribute _app_config.
16 17 18 |
# File 'lib/skynet-core.rb', line 16 def _app_config @_app_config end |
#_database_config ⇒ Object (readonly)
Returns the value of attribute _database_config.
16 17 18 |
# File 'lib/skynet-core.rb', line 16 def _database_config @_database_config end |
#_queue ⇒ Object (readonly)
Returns the value of attribute _queue.
16 17 18 |
# File 'lib/skynet-core.rb', line 16 def _queue @_queue end |
Class Method Details
.app_config ⇒ Object
54 55 56 |
# File 'lib/skynet-core.rb', line 54 def app_config @_app_config ||= set_app_config end |
.database_config ⇒ Object
58 59 60 |
# File 'lib/skynet-core.rb', line 58 def database_config @_database_config ||= set_database_config end |
.env ⇒ Object
23 24 25 |
# File 'lib/skynet-core.rb', line 23 def env @_env ||= SKYNET_ENV.to_s.downcase.to_sym end |
.load_config ⇒ Object
def bundle
return :locked if File.exist?(root('.bundle/environment.rb'))
return :unlocked if File.exist?(root("Gemfile"))
end
46 47 48 49 50 51 52 |
# File 'lib/skynet-core.rb', line 46 def load_config app_config database_config raise "Config files not found" if @_app_config.nil? || @_database_config.nil? !@_app_config.nil? end |
.load_dependencies(*paths) ⇒ Object Also known as: load_dependency
Attempts to load all dependency libs that we need. If you use this method we can perform correctly a Padrino.reload!
99 100 101 102 103 |
# File 'lib/skynet-core.rb', line 99 def load_dependencies(*paths) paths.each do |path| Dir[path].each { |file| load(file) } end end |
.queue ⇒ Object
62 63 64 |
# File 'lib/skynet-core.rb', line 62 def queue @_queue ||= load_queue_database end |
.require_dependencies(*paths) ⇒ Object Also known as: require_dependency
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/skynet-core.rb', line 66 def require_dependencies(*paths) # Extract all files to load files = paths.map { |path| Dir[path] }.flatten while files.present? # We need a size to make sure things are loading size_at_start = files.size # List of errors and failed files errors, failed = [], [] # Now we try to require our dependencies files.each do |file| begin require file files.delete(file) rescue Exception => e errors << e failed << files end end # Stop processing if nothing loads or if everything has loaded raise errors.last if files.size == size_at_start && files.present? break if files.empty? end end |
.root(*args) ⇒ Object
27 28 29 |
# File 'lib/skynet-core.rb', line 27 def root(*args) File.(File.join(SKYNET_ROOT, *args)) end |
.set_encoding ⇒ Object
Default encoding to UTF8 if it has not already been set to something else.
33 34 35 36 37 38 |
# File 'lib/skynet-core.rb', line 33 def set_encoding unless RUBY_VERSION >= '1.9' $KCODE = 'U' if $KCODE == 'NONE' || $KCODE.blank? end nil end |