Class: CIQuantum::Server

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/ciquantum/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.



119
120
121
122
123
124
# File 'lib/ciquantum/server.rb', line 119

def initialize(*args)
  super
  check_project
  @quantum = CIQuantum.new(settings.project_path)
  @quantum.shared_path = settings.public_folder
end

Instance Attribute Details

#quantumObject (readonly)

Returns the value of attribute quantum.



15
16
17
# File 'lib/ciquantum/server.rb', line 15

def quantum
  @quantum
end

Class Method Details

.project_path=(project_path) ⇒ Object



139
140
141
# File 'lib/ciquantum/server.rb', line 139

def self.project_path=(project_path)
  set :project_path, Proc.new{project_path}, true
end

.rack_start(project_path) ⇒ Object



134
135
136
137
# File 'lib/ciquantum/server.rb', line 134

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

.start(host, port, project_path) ⇒ Object



126
127
128
129
130
131
132
# File 'lib/ciquantum/server.rb', line 126

def self.start(host, port, project_path)
  git_path = File.join(project_path, ".git")
  FileUtils.cp_r settings.public_folder, git_path
  set :project_path, project_path
  set :public_folder, "#{git_path}/public"
  CIQuantum::Server.run! :host => host, :port => port
end

Instance Method Details

#check_projectObject



143
144
145
146
147
148
149
# File 'lib/ciquantum/server.rb', line 143

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