Class: CIJoe::Server

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/cijoe/server.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Server

Returns a new instance of Server.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/cijoe/server.rb', line 53

def initialize(*args)
  super
  check_project
  @joe = CIJoe.new(options.project_path)

  # example .gitconfig:
  # [cijoe]
  #   notifier = CIJoe::Campfire
  #
  # or
  # [cijoe]
  #   notifier = CIJoe::Gmail
  #
  # this also gives you the option of running CI Joe without any notifier at all.

  eval(Config.cijoe.notifier.to_s).activate unless Config.cijoe.notifier.nil?
end

Class Method Details

.start(host, port, project_path) ⇒ Object



71
72
73
74
# File 'lib/cijoe/server.rb', line 71

def self.start(host, port, project_path)
  set :project_path, project_path
  CIJoe::Server.run! :host => host, :port => port
end

Instance Method Details

#check_projectObject



76
77
78
79
80
81
82
# File 'lib/cijoe/server.rb', line 76

def check_project
  if options.project_path.nil? || !File.exists?(File.expand_path(options.project_path))
    puts "Whoops! I need the path to a Git repo."
    puts "  $ git clone [email protected]:username/project.git project"
    abort "  $ cijoe project"
  end
end