Class: CiInACan::Cli::Files

Inherits:
Object
  • Object
show all
Defined in:
lib/ci_in_a_can/cli/files.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/ci_in_a_can/cli/files.rb', line 9

def id
  @id
end

#rootObject

Returns the value of attribute root.



9
10
11
# File 'lib/ci_in_a_can/cli/files.rb', line 9

def root
  @root
end

Class Method Details

.for(id, root) ⇒ Object



11
12
13
# File 'lib/ci_in_a_can/cli/files.rb', line 11

def self.for id, root
  new(id: id, root: root)
end

Instance Method Details

#rake_fileObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ci_in_a_can/cli/files.rb', line 15

def rake_file
<<EOF
#!/usr/bin/env rake

desc "Start #{@id}"
task :start do
  location = File.expand_path(File.dirname(__FILE__))
  system "ruby service/service.rb start"
  system "ruby web/stay_alive.rb start"
end

desc "Stop #{@id}"
task :stop do
  location = File.expand_path(File.dirname(__FILE__))
  system "ruby service/service.rb stop"
end
EOF
end

#service_fileObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/ci_in_a_can/cli/files.rb', line 62

def service_file
  <<EOF
require 'ci_in_a_can'
require 'daemons'

this_directory = File.expand_path(File.dirname(__FILE__) + '/../')

eval("CiInACan.results_location = '\#{this_directory}' + '/results'")

::Daemons.run_proc('#{@id}_ci_server') do
  loop do
    options = {
          access_token:      ENV['GITHUB_AUTH_TOKEN'],
          working_location:  this_directory + "/repos",
          watching_location: this_directory + "/jobs",
          site_url:          ENV['SITE_URL']
        }
    CiInACan::Daemon.start options
    sleep
  end
end
EOF
end

#web_daemonObject



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ci_in_a_can/cli/files.rb', line 34

def web_daemon
<<EOF
require 'daemons'

this_directory = File.expand_path(File.dirname(__FILE__))

::Daemons.run_proc('#{@id}_ci_web') do
  loop do
    exec "cd \#{this_directory};rackup -p 80"
  end
end
EOF
end

#web_fileObject



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/ci_in_a_can/cli/files.rb', line 48

def web_file
  <<EOF
require 'ci_in_a_can'

this_directory = File.expand_path(File.dirname(__FILE__) + '/../')

eval("CiInACan::Web.jobs_location = '\#{this_directory}' + '/jobs'")
eval("CiInACan.results_location = '\#{this_directory}' + '/results'")

use CiInACan::Sinatra
run Sinatra::Application
EOF
end