Class: CiInACan::Web
- Inherits:
-
Object
- Object
- CiInACan::Web
- Defined in:
- lib/ci_in_a_can/web.rb
Class Attribute Summary collapse
-
.jobs_location ⇒ Object
Returns the value of attribute jobs_location.
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
-
#session ⇒ Object
Returns the value of attribute session.
Instance Method Summary collapse
- #assert_that_the_new_build_is_valid ⇒ Object
- #logged_in? ⇒ Boolean
- #login_page ⇒ Object
- #show_a_list_of_the_runs ⇒ Object
- #show_the_repo_edit_form ⇒ Object
- #show_the_test_result ⇒ Object
- #show_the_test_result_in_json ⇒ Object
- #start_a_new_build ⇒ Object
- #submit_a_passphrase ⇒ Object
- #update_repo_details ⇒ Object
- #write_a_file_with(params) ⇒ Object
Class Attribute Details
.jobs_location ⇒ Object
Returns the value of attribute jobs_location.
10 11 12 |
# File 'lib/ci_in_a_can/web.rb', line 10 def jobs_location @jobs_location end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
7 8 9 |
# File 'lib/ci_in_a_can/web.rb', line 7 def params @params end |
#session ⇒ Object
Returns the value of attribute session.
7 8 9 |
# File 'lib/ci_in_a_can/web.rb', line 7 def session @session end |
Instance Method Details
#assert_that_the_new_build_is_valid ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/ci_in_a_can/web.rb', line 66 def assert_that_the_new_build_is_valid capture = params[:captures].first.split('/') api_key = capture.pop id = capture.join('/') repo = CiInACan::Repo.find id raise 'Could not find this repo' unless repo raise 'Invalid API Key' unless repo.api_key == api_key end |
#logged_in? ⇒ Boolean
25 26 27 28 |
# File 'lib/ci_in_a_can/web.rb', line 25 def logged_in? return false if session[:passphrase].to_s == '' session[:passphrase] == ENV['PASSPHRASE'] end |
#login_page ⇒ Object
13 14 15 |
# File 'lib/ci_in_a_can/web.rb', line 13 def login_page CiInACan::ViewModels::LoginForm.new.to_html end |
#show_a_list_of_the_runs ⇒ Object
43 44 45 |
# File 'lib/ci_in_a_can/web.rb', line 43 def show_a_list_of_the_runs CiInACan::ViewModels::AListOfRuns.new(CiInACan::Run.all.to_a).to_html end |
#show_the_repo_edit_form ⇒ Object
30 31 32 33 34 |
# File 'lib/ci_in_a_can/web.rb', line 30 def show_the_repo_edit_form id = params[:captures].first repo = CiInACan::Repo.find(id) || CiInACan::Repo.new(id: id) CiInACan::ViewModels::RepoForm.new(repo).to_html end |
#show_the_test_result ⇒ Object
47 48 49 50 |
# File 'lib/ci_in_a_can/web.rb', line 47 def show_the_test_result test_result = CiInACan::TestResult.find(params[:id]) test_result.to_html end |
#show_the_test_result_in_json ⇒ Object
21 22 23 |
# File 'lib/ci_in_a_can/web.rb', line 21 def show_the_test_result_in_json CiInACan::TestResult.find(params[:id]).to_json end |
#start_a_new_build ⇒ Object
36 37 38 39 40 41 |
# File 'lib/ci_in_a_can/web.rb', line 36 def start_a_new_build assert_that_the_new_build_is_valid write_a_file_with params params.to_json end |
#submit_a_passphrase ⇒ Object
17 18 19 |
# File 'lib/ci_in_a_can/web.rb', line 17 def submit_a_passphrase session[:passphrase] = params[:passphrase] end |
#update_repo_details ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/ci_in_a_can/web.rb', line 52 def update_repo_details CiInACan::Repo.create(id: params[:captures].first, build_commands: params[:commands].gsub("\r\n", "\n") .split("\n") .map { |x| x.strip } .select { |x| x != '' } ) end |
#write_a_file_with(params) ⇒ Object
60 61 62 63 64 |
# File 'lib/ci_in_a_can/web.rb', line 60 def write_a_file_with params data = params.to_json file = "#{self.class.jobs_location}/#{UUID.new.generate}.json" CiInACan::FileSystem.create_file file, data end |