MuranoCLI 3.0.7 → 3.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.ignore +1 -1
  4. data/.rubocop.yml +10 -5
  5. data/.trustme.sh +272 -106
  6. data/.trustme.vim +20 -1
  7. data/Gemfile +7 -5
  8. data/LICENSE.txt +14 -15
  9. data/MuranoCLI.gemspec +7 -5
  10. data/Rakefile +5 -5
  11. data/bin/murano +4 -4
  12. data/lib/MrMurano/Account.rb +13 -8
  13. data/lib/MrMurano/Business.rb +6 -7
  14. data/lib/MrMurano/Commander-Entry.rb +5 -5
  15. data/lib/MrMurano/Config-Migrate.rb +4 -4
  16. data/lib/MrMurano/Config.rb +27 -6
  17. data/lib/MrMurano/Content.rb +5 -5
  18. data/lib/MrMurano/Exchange-Element.rb +4 -4
  19. data/lib/MrMurano/Exchange.rb +4 -4
  20. data/lib/MrMurano/Gateway.rb +22 -11
  21. data/lib/MrMurano/Keystore.rb +4 -4
  22. data/lib/MrMurano/Logs.rb +87 -0
  23. data/lib/MrMurano/Mock.rb +5 -4
  24. data/lib/MrMurano/Passwords.rb +4 -5
  25. data/lib/MrMurano/ProjectFile.rb +4 -4
  26. data/lib/MrMurano/ReCommander.rb +4 -4
  27. data/lib/MrMurano/Setting.rb +5 -5
  28. data/lib/MrMurano/Settings-HttpService.rb +9 -6
  29. data/lib/MrMurano/Solution-ServiceConfig.rb +5 -5
  30. data/lib/MrMurano/Solution-Services.rb +76 -50
  31. data/lib/MrMurano/Solution-Users.rb +5 -4
  32. data/lib/MrMurano/Solution.rb +6 -6
  33. data/lib/MrMurano/SolutionId.rb +4 -4
  34. data/lib/MrMurano/SubCmdGroupContext.rb +4 -4
  35. data/lib/MrMurano/SyncAllowed.rb +4 -4
  36. data/lib/MrMurano/SyncRoot.rb +5 -5
  37. data/lib/MrMurano/SyncUpDown-Core.rb +515 -0
  38. data/lib/MrMurano/SyncUpDown-Item.rb +159 -0
  39. data/lib/MrMurano/SyncUpDown.rb +120 -688
  40. data/lib/MrMurano/Webservice-Cors.rb +4 -4
  41. data/lib/MrMurano/Webservice-Endpoint.rb +9 -6
  42. data/lib/MrMurano/Webservice-File.rb +5 -4
  43. data/lib/MrMurano/Webservice.rb +5 -5
  44. data/lib/MrMurano/commands/business.rb +4 -4
  45. data/lib/MrMurano/commands/completion.rb +6 -6
  46. data/lib/MrMurano/commands/config.rb +7 -5
  47. data/lib/MrMurano/commands/content.rb +5 -4
  48. data/lib/MrMurano/commands/cors.rb +4 -4
  49. data/lib/MrMurano/commands/devices.rb +6 -6
  50. data/lib/MrMurano/commands/domain.rb +4 -4
  51. data/lib/MrMurano/commands/exchange.rb +4 -4
  52. data/lib/MrMurano/commands/gb.rb +4 -4
  53. data/lib/MrMurano/commands/globals.rb +12 -4
  54. data/lib/MrMurano/commands/init.rb +5 -4
  55. data/lib/MrMurano/commands/keystore.rb +4 -4
  56. data/lib/MrMurano/commands/link.rb +4 -4
  57. data/lib/MrMurano/commands/login.rb +4 -4
  58. data/lib/MrMurano/commands/logs.rb +229 -76
  59. data/lib/MrMurano/commands/mock.rb +4 -4
  60. data/lib/MrMurano/commands/password.rb +4 -4
  61. data/lib/MrMurano/commands/postgresql.rb +4 -4
  62. data/lib/MrMurano/commands/settings.rb +4 -4
  63. data/lib/MrMurano/commands/show.rb +4 -4
  64. data/lib/MrMurano/commands/solution.rb +4 -4
  65. data/lib/MrMurano/commands/solution_picker.rb +4 -4
  66. data/lib/MrMurano/commands/status.rb +12 -4
  67. data/lib/MrMurano/commands/sync.rb +4 -4
  68. data/lib/MrMurano/commands/timeseries.rb +4 -4
  69. data/lib/MrMurano/commands/tsdb.rb +6 -7
  70. data/lib/MrMurano/commands/usage.rb +4 -4
  71. data/lib/MrMurano/commands.rb +4 -4
  72. data/lib/MrMurano/hash.rb +5 -5
  73. data/lib/MrMurano/http.rb +26 -22
  74. data/lib/MrMurano/makePretty.rb +194 -10
  75. data/lib/MrMurano/optparse.rb +1 -1
  76. data/lib/MrMurano/orderedhash.rb +1 -1
  77. data/lib/MrMurano/progress.rb +4 -4
  78. data/lib/MrMurano/verbosing.rb +6 -6
  79. data/lib/MrMurano/version.rb +5 -5
  80. data/lib/MrMurano.rb +7 -4
  81. data/spec/Account-Passwords_spec.rb +4 -4
  82. data/spec/Account_spec.rb +4 -4
  83. data/spec/Business_spec.rb +4 -4
  84. data/spec/ConfigFile_spec.rb +4 -4
  85. data/spec/ConfigMigrate_spec.rb +5 -4
  86. data/spec/Config_spec.rb +5 -4
  87. data/spec/Content_spec.rb +5 -4
  88. data/spec/GatewayBase_spec.rb +4 -4
  89. data/spec/GatewayDevice_spec.rb +4 -4
  90. data/spec/GatewayResource_spec.rb +5 -4
  91. data/spec/GatewaySettings_spec.rb +4 -4
  92. data/spec/Http_spec.rb +4 -4
  93. data/spec/MakePretties_spec.rb +20 -20
  94. data/spec/Mock_spec.rb +4 -4
  95. data/spec/ProjectFile_spec.rb +4 -4
  96. data/spec/Setting_spec.rb +4 -4
  97. data/spec/Solution-ServiceConfig_spec.rb +4 -4
  98. data/spec/Solution-ServiceEventHandler_spec.rb +5 -4
  99. data/spec/Solution-ServiceModules_spec.rb +5 -4
  100. data/spec/Solution-UsersRoles_spec.rb +5 -4
  101. data/spec/Solution_spec.rb +4 -4
  102. data/spec/SyncRoot_spec.rb +4 -4
  103. data/spec/SyncUpDown_spec.rb +67 -21
  104. data/spec/Verbosing_spec.rb +12 -10
  105. data/spec/Webservice-Cors_spec.rb +4 -4
  106. data/spec/Webservice-Endpoint_spec.rb +5 -4
  107. data/spec/Webservice-File_spec.rb +5 -4
  108. data/spec/Webservice-Setting_spec.rb +4 -4
  109. data/spec/_workspace.rb +4 -4
  110. data/spec/cmd_business_spec.rb +4 -5
  111. data/spec/cmd_common.rb +51 -20
  112. data/spec/cmd_config_spec.rb +4 -5
  113. data/spec/cmd_content_spec.rb +4 -5
  114. data/spec/cmd_cors_spec.rb +4 -5
  115. data/spec/cmd_device_spec.rb +5 -6
  116. data/spec/cmd_domain_spec.rb +4 -5
  117. data/spec/cmd_exchange_spec.rb +4 -5
  118. data/spec/cmd_help_spec.rb +4 -5
  119. data/spec/cmd_init_spec.rb +16 -35
  120. data/spec/cmd_keystore_spec.rb +4 -5
  121. data/spec/cmd_link_spec.rb +11 -12
  122. data/spec/cmd_logs_spec.rb +162 -0
  123. data/spec/cmd_password_spec.rb +4 -5
  124. data/spec/cmd_setting_application_spec.rb +4 -5
  125. data/spec/cmd_setting_product_spec.rb +4 -5
  126. data/spec/cmd_status_spec.rb +44 -81
  127. data/spec/cmd_syncdown_application_spec.rb +7 -10
  128. data/spec/cmd_syncdown_both_spec.rb +10 -25
  129. data/spec/cmd_syncup_spec.rb +31 -37
  130. data/spec/cmd_usage_spec.rb +4 -5
  131. data/spec/fixtures/dumped_config +1 -0
  132. data/spec/fixtures/websocket/logs_blather.rb +27 -0
  133. data/spec/fixtures/websocket/logs_faker.rb +153 -0
  134. data/spec/fixtures/websocket/simple_connection.rb +45 -0
  135. data/spec/fixtures/websocket/simple_options.rb +77 -0
  136. data/spec/fixtures/websocket/simple_server.rb +69 -0
  137. data/spec/fixtures/websocket/wss-echo.rb +48 -0
  138. data/spec/fixtures/websocket/wss-fake-logs.rb +20 -0
  139. metadata +55 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42ba380e8b5ca16f20f06bee796bff578db09bcd
4
- data.tar.gz: e7d33d39b2814804f583cc7e5a8a70762f229be2
3
+ metadata.gz: 3724b5391071776bfe44190b14ad244788ff94b7
4
+ data.tar.gz: f7a7825838b2143194871519fd109b00701ac361
5
5
  SHA512:
6
- metadata.gz: b8c9c36f36761f164fcf748e66af4684f7da5fe881967aee2244cae28aadff565937148476cedc8f88e1b0cb5f47e4ce442e5b1b684d83277d5fff19c4ae571f
7
- data.tar.gz: def44224a4a21c19e0f0961580291d4b5990dc0a37c5d8f347aaab0a09cd79365958ab4b3942e569032ec720f412baf10bb0f114e2ca365efe0a1c49ab6d8ca9
6
+ metadata.gz: e92ac9179d3a3444d9a8a283ab94f85e576d88e5bcae6f7b947d2401b588bb8fd4ca67cd7d31817a7cdadec1488aefc6ae0b966afe45aaba944a611571f8b8d2
7
+ data.tar.gz: 9fba7a0956161da7105417580bd9aa79c0372b61e3883318a184dd8a17ea01aeafc4e9c2f89e299cc4cf1f68b9c92ca89c1fd8013380a458a9e9c45dd1ee92bd
data/.gitignore CHANGED
@@ -45,5 +45,5 @@ Gemfile.lock
45
45
  .rake_tasks~
46
46
 
47
47
  # Output from .trustme.vim and .trustme.sh
48
- .rake_build.out
48
+ .trustme.log
49
49
 
data/.ignore CHANGED
@@ -11,7 +11,7 @@ tags
11
11
 
12
12
  # 2017-05-12: Testing!
13
13
  *.out
14
- .rake_build.out
14
+ .trustme.log
15
15
  curldebug.out
16
16
 
17
17
  rspec-*.html
data/.rubocop.yml CHANGED
@@ -1,7 +1,8 @@
1
- # Last Modified: 2017.09.12 /coding: utf-8
2
- # Copyright © 2016-2017 Exosite LLC.
3
- # License: MIT. See LICENSE.txt.
4
- # vim:tw=0:ts=2:sw=2:et:ai
1
+ # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
+ # License: PROPRIETARY. See LICENSE.txt.
3
+ # Unauthorized copying of this file is strictly prohibited.
4
+ # frozen_string_literal: true
5
+ # vim:tw=0:ts=2:sw=2:et:ai
5
6
 
6
7
  # USAGE:
7
8
  #
@@ -110,7 +111,7 @@ Style/EmptyMethod:
110
111
  Enabled: false
111
112
 
112
113
  # "The name of this source file (Xxxxxxx.rb) should use snake_case."
113
- Style/FileName:
114
+ Naming/FileName:
114
115
  Exclude:
115
116
  - 'Gemfile'
116
117
  - 'MuranoCLI.gemspec'
@@ -127,11 +128,13 @@ Style/FileName:
127
128
  - 'lib/MrMurano/Exchange-Element.rb'
128
129
  - 'lib/MrMurano/Gateway.rb'
129
130
  - 'lib/MrMurano/Keystore.rb'
131
+ - 'lib/MrMurano/Logs.rb'
130
132
  - 'lib/MrMurano/Mock.rb'
131
133
  - 'lib/MrMurano/Passwords.rb'
132
134
  - 'lib/MrMurano/ProjectFile.rb'
133
135
  - 'lib/MrMurano/ReCommander.rb'
134
136
  - 'lib/MrMurano/Setting.rb'
137
+ - 'lib/MrMurano/Settings-HttpService.rb'
135
138
  - 'lib/MrMurano/Solution-ServiceConfig.rb'
136
139
  - 'lib/MrMurano/Solution-Services.rb'
137
140
  - 'lib/MrMurano/Solution-Users.rb'
@@ -141,6 +144,8 @@ Style/FileName:
141
144
  - 'lib/MrMurano/SyncAllowed.rb'
142
145
  - 'lib/MrMurano/SyncRoot.rb'
143
146
  - 'lib/MrMurano/SyncUpDown.rb'
147
+ - 'lib/MrMurano/SyncUpDown-Core.rb'
148
+ - 'lib/MrMurano/SyncUpDown-Item.rb'
144
149
  - 'lib/MrMurano/Webservice-Cors.rb'
145
150
  - 'lib/MrMurano/Webservice-Endpoint.rb'
146
151
  - 'lib/MrMurano/Webservice-File.rb'
data/.trustme.sh CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # Last Modified: 2017.09.20
3
2
  # vim:tw=0:ts=2:sw=2:et:norl:spell
4
3
 
5
4
  # WHAT: A Continuous Integration (CI) script for kicking the build
@@ -40,159 +39,326 @@
40
39
  #
41
40
  # MONITOR: All script output gets writ to a file. Use a terminal to tail it:
42
41
  #
43
- # tail -F .rake_build.out
42
+ # tail -F .trustme.log
44
43
 
45
44
  # MEH: Need to enable errexit?
46
45
  #set +x
47
46
 
48
- OUT_FILE=".rake_build.out"
47
+ OUT_FILE=".trustme.log"
49
48
 
50
49
  #local DONE_FILE=".trustme.done"
51
50
  LOCK_DIR=".trustme.lock"
52
- PID_FILE="${LOCK_DIR}/.build.pid"
53
- LOCK_KILL=".trustme.kill"
51
+ KILL_DIR=".trustme.kill"
52
+ PID_FILE=".trustme.pid"
53
+ # Hrm. The bang might not work without
54
+ KILL_BIN=".trustme.kill!"
54
55
 
55
- if [[ -f ${HOME}/.fries/lib/ruby_util.sh ]]; then
56
- source ${HOME}/.fries/lib/ruby_util.sh
57
- else
58
- echo 'Missing ruby_util.sh and chruby' >> ${OUT_FILE}
59
- exit 1
60
- fi
61
- chruby 2.3.3
56
+ # 2017-10-03: Don't build immediately after every save. If you like to
57
+ # code a little, save, code a little save, repeat, then always running
58
+ # the builder (a) gets annoying to see constantly churning, if you keep
59
+ # a terminal on it; and (b) runs the CPU hot, because eslint. So avoid
60
+ # building too frequently.
61
+ # LATER/2017-10-03: CLI options for this script? It keeps growing!
62
+ # For now, hardcode.
63
+ #BUILD_DELAY_SECS=300
64
+ #BUILD_DELAY_SECS=90
65
+ #BUILD_DELAY_SECS=13
66
+ #BUILD_DELAY_SECS=5
67
+ #BUILD_DELAY_SECS=1
68
+ BUILD_DELAY_SECS=0
69
+
70
+ # This script is run relative to Vim's working directory, so be deliberate about paths.
71
+ # ${BASH_SOURCE[0]} should be the absolute path to this script.
72
+ TRUSTME_DIR=$(dirname -- "${BASH_SOURCE[0]}")
73
+ OUT_FILE="${TRUSTME_DIR}/${OUT_FILE}"
62
74
 
63
- trap death SIGINT
75
+ say() {
76
+ echo "$1" >> "${OUT_FILE}"
77
+ }
64
78
 
65
- function annoucement() {
66
- echo >> ${OUT_FILE}
67
- echo "###################################################################" >> ${OUT_FILE}
68
- echo $1 >> ${OUT_FILE}
69
- echo "###################################################################" >> ${OUT_FILE}
70
- echo >> ${OUT_FILE}
79
+ announcement() {
80
+ say
81
+ say "###################################################################"
82
+ say "$1"
83
+ say "###################################################################"
84
+ [[ "$2" != '' ]] && say "$2"
85
+ say
71
86
  }
72
87
 
73
- function death() {
74
- echo "death!" >> ${OUT_FILE}
75
- annoucement "DEATH! ☠☠☠"
88
+ death() {
89
+ if [[ -n ${WAIT_PID} ]]; then
90
+ say "Sub-killing ‘${WAIT_PID}’"
91
+ kill -s 9 ${WAIT_PID}
92
+ fi
93
+ # The other script waits for us to cleanup the PID file.
94
+ remove_pid_files
95
+ # Note that output gets interleaved with the killing process,
96
+ # so keep this to one line (don't use `announcement`).
97
+ say "☠☠☠ DEATH! ☠☠☠ ‘$$’ is now dead"
76
98
  exit 1
77
99
  }
78
100
 
79
- function lock_kill_or_die() {
101
+ # FIXME/2017-09-28: Move this and other common fcns. to home-fries?
102
+ lock_kill_die() {
103
+ say "Desperately Seeking Lock on $(date)..."
104
+ [[ "$1" == true ]] && local AFTER_WAIT=true || local AFTER_WAIT=false
80
105
  local build_it=false
81
106
  # mkdir is atomic. Isn't that nice.
82
- if $(mkdir ${LOCK_DIR} 2> /dev/null); then
83
- # The first, or only instance to be running. Run the build.
84
- echo "first one here!" >> ${OUT_FILE}
85
- elif [[ -d ${LOCK_DIR} ]]; then
86
- # There's a build going on. Should we kill it?
87
- if $(mkdir ${LOCK_KILL} 2> /dev/null); then
88
- if [[ -f ${PID_FILE} ]]; then
89
- local build_pid=$(cat ${PID_FILE})
90
- if [[ ${build_pid} != '' ]]; then
91
- echo "build locked, but not the kill! time for mischiefs" >> ${OUT_FILE}
92
- # Yeah! We get to kill a process!
93
- annoucement "Killing it!"
94
- kill -s SIGINT ${build_pid} &>> ${OUT_FILE}
95
- if [[ $? -ne 0 ]]; then
96
- echo "Kill failed! on pid ‘${build_pid}’" >> ${OUT_FILE}
97
- # So, what happened? Did the build complete?
98
- # Should we just move along? Probably...
99
- # Get the name of the process. If it still exists, die.
100
- if [[ $(ps -p ${build_pid} -o comm=) != '' ]]; then
101
- echo "WARNING: but process still exists!"
102
- exit
103
- fi
107
+ if $(mkdir "${LOCK_DIR}" 2> /dev/null); then
108
+ say "Scored the lock!"
109
+ kill_other ${AFTER_WAIT} true
110
+ elif [[ -d "${LOCK_DIR}" ]]; then
111
+ if ! ${AFTER_WAIT}; then
112
+ # There's another script waiting to build, or a build going on.
113
+ # Kill it if you can.
114
+ say "Could not lock, but can still kill!"
115
+ kill_other ${AFTER_WAIT} false
116
+ else
117
+ # This script got the lock earlier, released it, and slept, and now
118
+ # it cannot get the lock...
119
+ say "i waited for you but you locked me out"
120
+ exit
121
+ fi
122
+ else
123
+ announcement "WARNING: could not mkdir ‘${LOCK_DIR}’ and it does not exist, later!"
124
+ exit
125
+ fi
126
+ }
127
+
128
+ kill_other() {
129
+ [[ "$1" == true ]] && local AFTER_WAIT=true || local AFTER_WAIT=false
130
+ [[ "$2" == true ]] && local OUR_LOCK=true || local OUR_LOCK=false
131
+ if $(mkdir "${KILL_DIR}" 2> /dev/null); then
132
+ if [[ -f "${PID_FILE}" ]]; then
133
+ local build_pid=$(cat "${PID_FILE}")
134
+ if ${AFTER_WAIT}; then
135
+ if [[ "$$" != "${build_pid}" ]]; then
136
+ echo "Panic, jerks! The build_pid is not our PID! ${build_pid} != $$"
137
+ exit
138
+ fi
139
+ elif [[ "${build_pid}" != '' ]]; then
140
+ #say "Locked the kill directory! time for mischiefs"
141
+ say "Killing ‘${build_pid}’"
142
+ # Process, your time has come.
143
+ kill -s SIGUSR1 "${build_pid}" &>> "${OUT_FILE}"
144
+ if [[ $? -ne 0 ]]; then
145
+ say "Kill failed! On PID ‘${build_pid}’"
146
+ # So, what happened? Did the build complete?
147
+ # Should we just move along? Probably...
148
+ # Get the name of the process. If it still exists, die.
149
+ if [[ $(ps -p "${build_pid}" -o comm=) != '' ]]; then
150
+ say "Said process still exists!"
151
+ exit
104
152
  fi
153
+ # The process is a ghost.
154
+ remove_pid_files
105
155
  else
106
- echo "build locked, but not kill. but no pid? whatever, we'll take it!"
156
+ # Wait for the other trustme to clean up.
157
+ WAIT_PATIENCE=10
158
+ sleep 0.1
159
+ while [[ -f "${PID_FILE}" ]]; do
160
+ say "Waiting on PID ${build_pid} to cleanup..."
161
+ sleep 0.5
162
+ WAIT_PATIENCE=$((WAIT_PATIENCE - 1))
163
+ [[ ${WAIT_PATIENCE} -eq 0 ]] && echo "Done waiting!" && exit
164
+ done
107
165
  fi
108
166
  else
109
- echo "build locked, but not kill. but builder has not started, bye" >> ${OUT_FILE}
110
- exit
167
+ say "WARNING: Empty PID file? Whatever, we'll take it!"
111
168
  fi
112
- else
113
- echo "all locked, party over, man!" >> ${OUT_FILE}
169
+ elif ! ${OUR_LOCK}; then
170
+ # This is after waiting, which seems weird, eh.
171
+ say "Kill okay without build lock, but no PID file. Is someone tinkering?"
114
172
  exit
173
+ else
174
+ say "Got the build lock and kill lock, and there's no PID. Fresh powder!"
115
175
  fi
116
176
  else
117
- echo "WARNING: could not mkdir ‘${LOCK_DIR}’ and it does not exist, later!" >> ${OUT_FILE}
177
+ say "Someone else has the kill lock. We're boned!"
118
178
  exit
119
179
  fi
120
180
  }
121
- lock_kill_or_die
122
181
 
123
- function prepare_to_build() {
124
- echo "$$" > ${PID_FILE}
125
- [[ -d ${LOCK_KILL} ]] && rmdir ${LOCK_KILL}
182
+ lock_or_die() {
183
+ lock_kill_die false
184
+ }
185
+
186
+ lock_kill_or_die() {
187
+ lock_kill_die true
188
+ }
189
+
190
+ prepare_to_build() {
191
+ rmdir "${KILL_DIR}"
192
+ say
193
+ say "See you on the other side!"
194
+ touch "${OUT_FILE}"
195
+ truncate -s 0 "${OUT_FILE}"
196
+ }
197
+
198
+ init_it() {
199
+ if [[ -f ${HOME}/.fries/lib/ruby_util.sh ]]; then
200
+ source ${HOME}/.fries/lib/ruby_util.sh
201
+ else
202
+ echo 'Missing ruby_util.sh and chruby' >> ${OUT_FILE}
203
+ exit 1
204
+ fi
205
+ chruby 2.3.3
206
+ }
126
207
 
127
- #/bin/rm ${DONE_FILE}
128
- #/bin/rm ${OUT_FILE}
129
- touch ${OUT_FILE}
130
- truncate -s 0 ${OUT_FILE}
208
+ lang_it() {
209
+ announcement "LANG IT"
131
210
  }
132
- prepare_to_build
133
211
 
134
- time_0=$(date +%s.%N)
135
- #echo >> ${OUT_FILE} # Put newline after "tail: .rake_build.out: file truncated"
136
- annoucement "WARMING UP"
137
- echo "Build started at $(date '+%Y-%m-%d_%H-%M-%S')" >> ${OUT_FILE}
138
- echo "cwd: $(pwd)" >> ${OUT_FILE}
139
- echo "- ruby -v: $(ruby -v)" >> ${OUT_FILE}
140
- echo "- rubocop -v: $(rubocop -v)" >> ${OUT_FILE}
141
- #echo "- cmd rubocop: $(command -v rubocop)" >> ${OUT_FILE}
212
+ build_it() {
213
+ announcement "BUILD IT"
214
+
215
+ echo "cwd: $(pwd)" >> ${OUT_FILE}
216
+ echo "- ruby -v: $(ruby -v)" >> ${OUT_FILE}
217
+ echo "- rubocop -v: $(rubocop -v)" >> ${OUT_FILE}
218
+ #echo "- cmd rubocop: $(command -v rubocop)" >> ${OUT_FILE}
142
219
 
143
- function build_it() {
144
- annoucement "BUILD IT"
145
220
  rake build &>> ${OUT_FILE} && \
146
221
  gem install -i $(ruby -rubygems -e 'puts Gem.dir') \
147
222
  pkg/MuranoCLI-$(ruby -e 'require "/exo/clients/exosite/MuranoCLI/lib/MrMurano/version.rb"; puts MrMurano::VERSION').gem \
148
223
  &>> ${OUT_FILE}
149
224
  }
150
- build_it
151
225
 
152
- function test_concurrency() {
153
- for i in $(seq 1 5); do build_it; done
154
- }
155
- # DEVs: Wanna test CTRL-C more easily by keeping the script alive longer?
156
- # Then uncomment this.
157
- #test_concurrency
158
-
159
- function lint_it() {
160
- annoucement "LINT IT"
226
+ lint_it() {
227
+ announcement "LINT IT"
161
228
  rubocop -D -c .rubocop.yml &>> ${OUT_FILE}
162
229
  }
163
- lint_it
164
230
 
165
- function rspec_it() {
166
- annoucement "RSPEC IT"
231
+ rspec_it() {
232
+ announcement "RSPEC IT"
167
233
  rake rspec &>> ${OUT_FILE}
168
234
  }
169
- # This is probably not the best idea,
170
- # especially if your tests use the same
171
- # business as you do when developing.
172
- #rspec_it
173
-
174
- function ctags_it() {
175
- annoucement "CTAGS IT"
176
- ctags -R \
177
- --exclude=coverage \
178
- --exclude=docs \
179
- --exclude=pkg \
180
- --exclude=report \
181
- --exclude=spec \
182
- --verbose=yes
235
+
236
+ ctags_it() {
237
+ announcement "CTAGS IT"
238
+ local ctags_out=$( { \
239
+ ctags -R \
240
+ --exclude=coverage \
241
+ --exclude=docs \
242
+ --exclude=pkg \
243
+ --exclude=report \
244
+ --verbose=yes \
245
+ ; \
246
+ } 2>&1 )
247
+ if [[ $? -ne 0 ]]; then
248
+ say
249
+ say 'ctags FAILED!'
250
+ say '                    '
251
+ say
252
+ say "${ctags_out}"
253
+ say
254
+ say '                    '
255
+ say
256
+ fi
183
257
  /bin/ls -la tags >> ${OUT_FILE}
184
258
  }
185
- ctags_it
186
259
 
187
- time_n=$(date +%s.%N)
188
- time_elapsed=$(echo "$time_n - $time_0" | bc -l)
189
- annoucement "DONE!"
190
- echo "Build finished at $(date '+%H:%M:%S') on $(date '+%Y-%m-%d') in $time_elapsed secs." >> ${OUT_FILE}
260
+ drop_locks() {
261
+ rmdir "${LOCK_DIR}" "${KILL_DIR}"
262
+ }
263
+
264
+ remove_pid_files() {
265
+ /bin/rm "${PID_FILE}"
266
+ /bin/rm "${KILL_BIN}"
267
+ }
268
+
269
+ main() {
270
+ # We're called on both save, and on simple buffer enter.
271
+ if [[ ${DUBS_TRUST_ME_ON_SAVE} != 1 ]]; then
272
+ # We've got nothing to do on simple buffer enter...
273
+ announcement "DUBS_TRUST_ME_ON_FILE: ${DUBS_TRUST_ME_ON_FILE}"
274
+ say "Nothing to do on open"
275
+ exit 1
276
+ fi
277
+
278
+ trap death SIGUSR1
279
+
280
+ say
281
+ say " 󷎟 󲁹 󲁭 󲁨 🚷 🐧 🐨 🐫 🐬 🐰 🐳 🐎 "
282
+ announcement " ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎"
283
+
284
+ init_it
285
+
286
+ # Get the lock.
287
+ lock_or_die
288
+
289
+ say "‘$$’ has the lock"
290
+ echo "$$" > "${PID_FILE}"
291
+ echo "kill -s SIGUSR1 $$" > "${KILL_BIN}"
292
+ chmod 755 "${KILL_BIN}"
293
+
294
+ # Always build tags.
295
+ ctags_it
296
+
297
+ announcement "WAITING ON BUILD" "Countdown: ${BUILD_DELAY_SECS} secs..."
298
+
299
+ # Defer the build!
300
+ # FIXME/2017-10-03: Riddle me this: is a two-fer rmdir atomic?
301
+ drop_locks
302
+ # The trap on SIGUSR1 only fires when this script is active and
303
+ # not blocked on a subshell. And sleep is it's own command, so we
304
+ # background it.
305
+ sleep ${BUILD_DELAY_SECS} &
306
+ # Fortunately, we can use the Bash wait command, which does not
307
+ # block signals.
308
+ # Get the process ID of the last command.
309
+ # LPID=$!
310
+ # wait ${LPID}
311
+ # Or just wait.
312
+ wait
191
313
 
192
- #touch ${DONE_FILE}
314
+ say "Ready to build..."
315
+ say
193
316
 
194
- trap - SIGINT
317
+ # Get the lock.
318
+ lock_kill_or_die
319
+
320
+ if ${TESTING:-false}; then
321
+ drop_locks
322
+ remove_pid_files
323
+ say "DONE! (ONLY TESTING)"
324
+ exit
325
+ fi
326
+
327
+ prepare_to_build
328
+
329
+ time_0=$(date +%s.%N)
330
+ #say # Put newline after "tail: .rake_build.out: file truncated"
331
+ announcement "WARMING UP"
332
+ say "Build started at $(date '+%Y-%m-%d_%H-%M-%S')"
333
+ say "cwd: $(pwd)"
334
+
335
+ #lang_it
336
+
337
+ build_it
338
+ function test_concurrency() {
339
+ for i in $(seq 1 5); do build_it; done
340
+ }
341
+ # DEVs: Wanna test CTRL-C more easily by keeping the script alive longer?
342
+ # Then uncomment this.
343
+ #test_concurrency
344
+
345
+ lint_it
346
+
347
+ # MEH/2017-12-06: The tests take a number of seconds to run, so skipping.
348
+ #test_it
349
+
350
+ time_n=$(date +%s.%N)
351
+ time_elapsed=$(echo "$time_n - $time_0" | bc -l)
352
+ announcement "DONE!"
353
+ say "Build finished at $(date '+%H:%M:%S') on $(date '+%Y-%m-%d') in ${time_elapsed} secs."
354
+
355
+ #touch "${DONE_FILE}"
356
+
357
+ trap - SIGUSR1
358
+
359
+ remove_pid_files
360
+ rmdir "${LOCK_DIR}"
361
+ }
195
362
 
196
- /bin/rm ${PID_FILE}
197
- rmdir ${LOCK_DIR}
363
+ main "$@"
198
364