Class: CIJoe::Server

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Server

Returns a new instance of Server.



79
80
81
82
83
# File 'lib/cijoe/server.rb', line 79

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

Instance Attribute Details

#joeObject (readonly)

Returns the value of attribute joe.



7
8
9
# File 'lib/cijoe/server.rb', line 7

def joe
  @joe
end

Class Method Details

.project_path=(project_path) ⇒ Object



95
96
97
98
99
100
101
102
103
104
# File 'lib/cijoe/server.rb', line 95

def self.project_path=(project_path)
  user, pass = Config.cijoe(project_path).user.to_s, Config.cijoe(project_path).pass.to_s
  if user != '' && pass != ''
    use Rack::Auth::Basic do |username, password|
      [ username, password ] == [ user, pass ]
    end
    puts "Using HTTP basic auth"
  end
  set :project_path, Proc.new{project_path}
end

.rack_start(project_path) ⇒ Object



90
91
92
93
# File 'lib/cijoe/server.rb', line 90

def self.rack_start(project_path)
  set :project_path, project_path
  self.new
end

.start(host, port, project_path) ⇒ Object



85
86
87
88
# File 'lib/cijoe/server.rb', line 85

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



106
107
108
109
110
111
112
# File 'lib/cijoe/server.rb', line 106

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