Class: GitCheckCI::Shell
- Inherits:
-
Thor
- Object
- Thor
- GitCheckCI::Shell
- Includes:
- Thor::Actions
- Defined in:
- lib/git-check-ci/shell.rb
Instance Method Summary collapse
- #check(hash = nil) ⇒ Object
- #init ⇒ Object
- #server_start ⇒ Object
- #server_status ⇒ Object
- #server_stop ⇒ Object
- #setup ⇒ Object
Instance Method Details
#check(hash = nil) ⇒ Object
13 14 15 16 |
# File 'lib/git-check-ci/shell.rb', line 13 def check(hash = nil) Checker.new.check_and_save(hash) $stdout.puts Config.ci.response.to_s end |
#init ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/git-check-ci/shell.rb', line 66 def init puts %q[ _git_ci_color() { git config ci.color 2>&1 || true } _git_ci_status() { # exit early if not in a git repository git status > /dev/null 2>&1 || return # exit early if no project is configured git config ci.project > /dev/null 2>&1 || { echo '?' ; return ; } # spawn a server if no recent updates last_checked=$(git config ci.last-checked || echo 0) now=$(date +%s) let "delta = $now - $last_checked" test $delta -gt 120 && { git check-ci server_start & } # try to return a status git config ci.status 2> /dev/null || echo '?' } GitCheckCI() { echo "*** GitCheckCI is deprecated, use _git_ci_status" _git_ci_status } ] end |
#server_start ⇒ Object
45 46 47 |
# File 'lib/git-check-ci/shell.rb', line 45 def server_start Server.new.start end |
#server_status ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/git-check-ci/shell.rb', line 56 def server_status if Server.new.running? say "Server is running" else say "Server is not running" end end |
#server_stop ⇒ Object
51 52 53 |
# File 'lib/git-check-ci/shell.rb', line 51 def server_stop Server.new.stop end |
#setup ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/git-check-ci/shell.rb', line 19 def setup Server.new.stop @config = Config.new ask_for @config.ci.url, "What is the URL of your CI server?" ask_for @config.ci.project, "What is the name of the project you're checking?" ask_for @config.ci.login, "If the server requires a login, what should I use?" unless @config.ci.login.empty? ask_for @config.ci.password, "with which passphrase?" end puts say "Setup is now complete. Doing a test run." @config.ci.status = nil Checker.new.check_and_save if @config.ci.status.empty? say "Sorry, but something went wrong. Try checking connectivity and your setup.", :yellow else say "All good! Now the 'check' and 'fast-check' commands should work.", :green end @config.ci.last_checked = nil end |