Module: Cline

Defined in:
lib/cline.rb,
lib/cline/client.rb,
lib/cline/server.rb,
lib/cline/command.rb,
lib/cline/version.rb,
lib/cline/configure.rb,
lib/cline/notify_io.rb,
lib/cline/notification.rb,
lib/cline/scheduled_job.rb

Defined Under Namespace

Modules: Collectors, NotifyIO Classes: Client, Command, Configure, Notification, ScheduledJob, Server

Constant Summary collapse

VERSION =
'1.0.1'
OutStreams =
NotifyIO

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.collectorsObject



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

def collectors
  @collectors ||= []
end

.jobsObject



39
40
41
# File 'lib/cline.rb', line 39

def jobs
  @jobs ||= []
end

.loggerObject

Returns the value of attribute logger.



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

def logger
  @logger
end

.notifications_limitObject

Returns the value of attribute notifications_limit.



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

def notifications_limit
  @notifications_limit
end

.notify_ioObject



58
59
60
# File 'lib/cline.rb', line 58

def notify_io
  @notify_io == $stdout ? stdout : @notify_io
end

Class Method Details

.bootObject



27
28
29
30
31
32
33
# File 'lib/cline.rb', line 27

def boot
  mkdir_if_needed
  load_config_if_exists
  load_default_config

  self
end

.cline_dirObject



23
24
25
# File 'lib/cline.rb', line 23

def cline_dir
  "#{ENV['HOME']}/.cline"
end

.configure(&block) ⇒ Object



6
7
8
9
# File 'lib/cline/configure.rb', line 6

def self.configure(&block)
  configure = Configure.new
  block ? block[configure] : configure
end

.establish_database_connectionObject



43
44
45
46
47
48
# File 'lib/cline.rb', line 43

def establish_database_connection
  require 'active_record'

  ActiveRecord::Base.logger = logger
  ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: %(#{cline_dir}/cline.sqlite3), timeout: 10000, pool: 10
end

.load_config_if_existsObject



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

def load_config_if_exists
  config_file = "#{cline_dir}/config"

  load config_file if File.exist?(config_file)
end

.load_default_configObject



68
69
70
71
72
# File 'lib/cline.rb', line 68

def load_default_config
  @logger              ||= default_logger
  @notify_io           ||= stdout
  @notifications_limit ||= nil
end

.stderrObject



54
55
56
# File 'lib/cline.rb', line 54

def stderr
  Thread.current[:stderr] || $stderr
end

.stdoutObject



50
51
52
# File 'lib/cline.rb', line 50

def stdout
  Thread.current[:stdout] || $stdout
end