Class: GitCheckCI::Server

Inherits:
Object
  • Object
show all
Includes:
Silencer
Defined in:
lib/git-check-ci/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Silencer

#silencing

Constructor Details

#initialize(options = {}) ⇒ Server

Returns a new instance of Server.



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/git-check-ci/server.rb', line 16

def initialize(options = {})
  @dir      = options[:dir] || Dir.pwd
  @interval = options[:interval] || 60.0
  @checker  = Checker.new(:dir => @dir)
  @config   = @checker.config

  @appgroup = Daemons::ApplicationGroup.new(
    app_name,
    :multiple => false, :dir => tmpdir.to_s, :dir_mode => :normal
  )
  @app = @appgroup.new_application(:mode => :proc, :proc => method(:worker))
end

Instance Attribute Details

#outfileObject (readonly)

path where the results are stored



14
15
16
# File 'lib/git-check-ci/server.rb', line 14

def outfile
  @outfile
end

Instance Method Details

#running?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/git-check-ci/server.rb', line 56

def running?
  @app.running?
end

#start(options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/git-check-ci/server.rb', line 30

def start(options = {})
  return unless @config.is_git_dir?
  return if @app.running?
  work # once manually so we're pretty sure the server loop will work
  @app.start
  sleep 0.1 until @app.pid.pid
  unless options[:quiet]
    @app.started
    puts "project #{@config.ci.project}"
  end
  nil
end

#stop(options = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/git-check-ci/server.rb', line 44

def stop(options = {})
  return unless @config.is_git_dir?
  return unless @app.running?
  if options[:quiet]
    silencing($stdout) { @app.stop }
  else
    @app.stop
  end
  nil
end