Module: Syntropy

Defined in:
lib/syntropy.rb,
lib/syntropy/app.rb,
lib/syntropy/errors.rb,
lib/syntropy/module.rb,
lib/syntropy/router.rb,
lib/syntropy/rpc_api.rb,
lib/syntropy/version.rb,
lib/syntropy/side_run.rb,
lib/syntropy/file_watch.rb,
lib/syntropy/connection_pool.rb,
lib/syntropy/request_extensions.rb

Defined Under Namespace

Modules: RequestExtensions, SideRun Classes: App, ConnectionPool, Error, Module, ModuleLoader, RPCAPI, Router, ValidationError

Constant Summary collapse

Status =
Qeweney::Status
GREEN =
"\e[32m"
CLEAR =
"\e[0m"
YELLOW =
"\e[33m"
(
  "\n"\
  "  #{GREEN}\n"\
  "  #{GREEN} ooo\n"\
  "  #{GREEN}ooooo\n"\
  "  #{GREEN} ooo vvv       #{CLEAR}Syntropy - a web framework for Ruby\n"\
  "  #{GREEN}  o vvvvv     #{CLEAR}--------------------------------------\n"\
  "  #{GREEN}  #{YELLOW}|#{GREEN}  vvv o    #{CLEAR}https://github.com/noteflakes/syntropy\n"\
  "  #{GREEN} :#{YELLOW}|#{GREEN}:::#{YELLOW}|#{GREEN}::#{YELLOW}|#{GREEN}:\n"\
  "#{YELLOW}+++++++++++++++++++++++++++++++++++++++++++++++++++++++++\e[0m\n\n"
)
VERSION =
'0.7'

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.machineObject

Returns the value of attribute machine.



20
21
22
# File 'lib/syntropy.rb', line 20

def machine
  @machine
end

Class Method Details

.file_watch(machine, *roots, period: 0.1, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/syntropy/file_watch.rb', line 4

def self.file_watch(machine, *roots, period: 0.1, &block)
  raise 'Missing root paths' if roots.empty?

  require 'listen'

  queue = Thread::Queue.new
  listener = Listen.to(*roots) do |modified, added, removed|
    modified.each { queue.push([:modified, it]) }
    added.each    { queue.push([:added, it]) }
    removed.each  { queue.push([:removed, it]) }
  end
  listener.start

  loop do
    machine.sleep(period) while queue.empty?
    event, fn = queue.shift
    block.call(event, fn)
  end
rescue StandardError => e
  p e
  p e.backtrace
ensure
  listener.stop
end

.side_run(&block) ⇒ Object



22
23
24
25
26
# File 'lib/syntropy.rb', line 22

def side_run(&block)
  raise 'Syntropy.machine not set' if !@machine

  SideRun.call(@machine, &block)
end

Instance Method Details

#colorize(color_code) ⇒ Object



29
30
31
# File 'lib/syntropy.rb', line 29

def colorize(color_code)
  "\e[#{color_code}m#{self}\e[0m"
end