MuranoCLI 3.2.0.beta.1 → 3.2.0.beta.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -1
  3. data/.trustme.plugin +137 -0
  4. data/.trustme.sh +217 -117
  5. data/.trustme.vim +9 -3
  6. data/Gemfile +9 -3
  7. data/MuranoCLI.gemspec +8 -5
  8. data/Rakefile +1 -0
  9. data/dockers/Dockerfile.2.2.9 +6 -3
  10. data/dockers/Dockerfile.2.3.6 +6 -3
  11. data/dockers/Dockerfile.2.4.3 +6 -3
  12. data/dockers/Dockerfile.2.5.0 +6 -3
  13. data/dockers/Dockerfile.GemRelease +10 -8
  14. data/dockers/Dockerfile.m4 +23 -5
  15. data/dockers/docker-test.sh +65 -28
  16. data/docs/completions/murano_completion-bash +751 -57
  17. data/docs/develop.rst +10 -9
  18. data/lib/MrMurano/AccountBase.rb +95 -6
  19. data/lib/MrMurano/Commander-Entry.rb +9 -4
  20. data/lib/MrMurano/Config-Migrate.rb +2 -0
  21. data/lib/MrMurano/Config.rb +94 -26
  22. data/lib/MrMurano/Content.rb +1 -1
  23. data/lib/MrMurano/Exchange.rb +77 -42
  24. data/lib/MrMurano/Gateway.rb +1 -1
  25. data/lib/MrMurano/HttpAuthed.rb +20 -7
  26. data/lib/MrMurano/Logs.rb +10 -1
  27. data/lib/MrMurano/ProjectFile.rb +1 -1
  28. data/lib/MrMurano/ReCommander.rb +129 -73
  29. data/lib/MrMurano/Solution-ServiceConfig.rb +18 -11
  30. data/lib/MrMurano/Solution-Services.rb +78 -50
  31. data/lib/MrMurano/Solution-Users.rb +1 -1
  32. data/lib/MrMurano/Solution.rb +13 -63
  33. data/lib/MrMurano/SyncUpDown-Core.rb +185 -77
  34. data/lib/MrMurano/SyncUpDown-Item.rb +29 -4
  35. data/lib/MrMurano/SyncUpDown.rb +11 -11
  36. data/lib/MrMurano/Webservice-Cors.rb +1 -1
  37. data/lib/MrMurano/Webservice-Endpoint.rb +28 -17
  38. data/lib/MrMurano/Webservice-File.rb +103 -43
  39. data/lib/MrMurano/commands/domain.rb +1 -0
  40. data/lib/MrMurano/commands/element.rb +585 -0
  41. data/lib/MrMurano/commands/exchange.rb +211 -204
  42. data/lib/MrMurano/commands/gb.rb +1 -0
  43. data/lib/MrMurano/commands/globals.rb +17 -7
  44. data/lib/MrMurano/commands/init.rb +115 -101
  45. data/lib/MrMurano/commands/keystore.rb +1 -1
  46. data/lib/MrMurano/commands/logs.rb +2 -1
  47. data/lib/MrMurano/commands/postgresql.rb +17 -7
  48. data/lib/MrMurano/commands/service.rb +572 -0
  49. data/lib/MrMurano/commands/show.rb +7 -3
  50. data/lib/MrMurano/commands/solution.rb +2 -1
  51. data/lib/MrMurano/commands/solution_picker.rb +31 -15
  52. data/lib/MrMurano/commands/status.rb +205 -169
  53. data/lib/MrMurano/commands/sync.rb +70 -38
  54. data/lib/MrMurano/commands/token.rb +59 -14
  55. data/lib/MrMurano/commands/usage.rb +1 -0
  56. data/lib/MrMurano/commands.rb +2 -0
  57. data/lib/MrMurano/hash.rb +91 -0
  58. data/lib/MrMurano/http.rb +55 -6
  59. data/lib/MrMurano/makePretty.rb +47 -0
  60. data/lib/MrMurano/optparse.rb +60 -45
  61. data/lib/MrMurano/variegated/TruthyFalsey.rb +48 -0
  62. data/lib/MrMurano/variegated/ruby_dig.rb +64 -0
  63. data/lib/MrMurano/verbosing.rb +113 -3
  64. data/lib/MrMurano/version.rb +1 -1
  65. data/spec/Account_spec.rb +34 -20
  66. data/spec/Business_spec.rb +12 -9
  67. data/spec/Config_spec.rb +7 -1
  68. data/spec/Content_spec.rb +17 -1
  69. data/spec/GatewayBase_spec.rb +5 -2
  70. data/spec/GatewayDevice_spec.rb +4 -2
  71. data/spec/GatewayResource_spec.rb +4 -1
  72. data/spec/GatewaySettings_spec.rb +4 -1
  73. data/spec/HttpAuthed_spec.rb +73 -0
  74. data/spec/Http_spec.rb +32 -35
  75. data/spec/ProjectFile_spec.rb +1 -1
  76. data/spec/Solution-ServiceConfig_spec.rb +4 -1
  77. data/spec/Solution-ServiceEventHandler_spec.rb +6 -3
  78. data/spec/Solution-ServiceModules_spec.rb +4 -1
  79. data/spec/Solution-UsersRoles_spec.rb +4 -1
  80. data/spec/Solution_spec.rb +4 -1
  81. data/spec/SyncUpDown_spec.rb +1 -1
  82. data/spec/Webservice-Cors_spec.rb +4 -1
  83. data/spec/Webservice-Endpoint_spec.rb +9 -6
  84. data/spec/Webservice-File_spec.rb +17 -4
  85. data/spec/Webservice-Setting_spec.rb +6 -2
  86. data/spec/_workspace.rb +2 -0
  87. data/spec/cmd_common.rb +42 -13
  88. data/spec/cmd_content_spec.rb +17 -7
  89. data/spec/cmd_device_spec.rb +1 -1
  90. data/spec/cmd_domain_spec.rb +2 -2
  91. data/spec/cmd_element_spec.rb +400 -0
  92. data/spec/cmd_exchange_spec.rb +2 -2
  93. data/spec/cmd_init_spec.rb +59 -25
  94. data/spec/cmd_keystore_spec.rb +6 -3
  95. data/spec/cmd_link_spec.rb +10 -5
  96. data/spec/cmd_logs_spec.rb +1 -1
  97. data/spec/cmd_setting_application_spec.rb +18 -15
  98. data/spec/cmd_setting_product_spec.rb +7 -7
  99. data/spec/cmd_status_spec.rb +27 -17
  100. data/spec/cmd_syncdown_application_spec.rb +30 -3
  101. data/spec/cmd_syncdown_both_spec.rb +72 -18
  102. data/spec/cmd_syncup_spec.rb +71 -5
  103. data/spec/cmd_token_spec.rb +2 -2
  104. data/spec/cmd_usage_spec.rb +2 -2
  105. data/spec/dry_run_formatter.rb +27 -0
  106. data/spec/fixtures/dumped_config +8 -0
  107. data/spec/fixtures/exchange_element/element-show.json +1 -0
  108. data/spec/fixtures/exchange_element/swagger-mur-6407__10k.yaml +282 -0
  109. data/spec/fixtures/exchange_element/swagger-mur-6407__20k.yaml +588 -0
  110. data/spec/variegated_TruthyFalsey_spec.rb +29 -0
  111. metadata +51 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb061c736e0642412756d2b964e8dc05a5955863beaa0c94cd5b9cd1f77fd7a6
4
- data.tar.gz: d94b914a08a3679c09332d9ade3533d6e9bc350ba9b84656f50890834cf34dcf
3
+ metadata.gz: aee0c62e2b43c3677482ff5962c744efeb602e2a889aec33f4c25318e14b24d7
4
+ data.tar.gz: 626bc2a19f7a9d5dccc4943b3710ec75f4b7dcaf75aedb2e8d216f300bc42129
5
5
  SHA512:
6
- metadata.gz: ccfa0f6a460dd6510919cc82d5482485dc16c88ccf0feb9af2f06408dd07ab6b22526f215aa4f63445264a866f08cad15c4ded3c7b75d8e179ce7d2a60e4900e
7
- data.tar.gz: c684535687d90509380929e5e5f014d7e2e1706f20b25560d077e8e58e19c457d7ff027de9c3d0b4ebb72a1e4d5646d2abb3c5e3c9ac477ae6828a0a6c25c9ce
6
+ metadata.gz: 6cc99cff39c92cbcce0b368bc5cf665eee0d1a296fb62ebed9002fe52b64e5aaa919dfa0696893be838b292f9d275cfa5c387db9befd8327123fa3980b8d4d18
7
+ data.tar.gz: 8b7234f489e517edc073ce7386426f19f376d04fe8e5694fb60396903a2c2c0f4cecd1452f36835d668e72fd3bfd1355beadb76b22f6132fd60ac906b21161d1
data/.rubocop.yml CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  # USAGE:
8
8
  #
9
- # cd /exo/clients/exosite/MuranoCLI
9
+ # cd /path/to/MuranoCLI
10
10
  # rubocop -D -c .rubocop.yml
11
11
 
12
12
  # "Incorrect indentation detected (column X instead of Y)."
@@ -152,6 +152,7 @@ Style/FileName:
152
152
  - 'lib/MrMurano/Webservice-Endpoint.rb'
153
153
  - 'lib/MrMurano/Webservice-File.rb'
154
154
  - 'lib/MrMurano/Webservice.rb'
155
+ - 'lib/MrMurano/variegated/TruthyFalsey.rb'
155
156
  - 'spec/Account-Passwords_spec.rb'
156
157
  - 'spec/Account_spec.rb'
157
158
  - 'spec/Business_spec.rb'
@@ -164,6 +165,7 @@ Style/FileName:
164
165
  - 'spec/GatewayResource_spec.rb'
165
166
  - 'spec/GatewaySettings_spec.rb'
166
167
  - 'spec/Http_spec.rb'
168
+ - 'spec/HttpAuthed_spec.rb'
167
169
  - 'spec/MakePretties_spec.rb'
168
170
  - 'spec/Mock_spec.rb'
169
171
  - 'spec/ProjectFile_spec.rb'
@@ -180,6 +182,7 @@ Style/FileName:
180
182
  - 'spec/Webservice-Endpoint_spec.rb'
181
183
  - 'spec/Webservice-File_spec.rb'
182
184
  - 'spec/Webservice-Setting_spec.rb'
185
+ - 'spec/variegated_TruthyFalsey_spec.rb'
183
186
 
184
187
  # FIXME/2017-06-30: We should fix this one... put $cfg in MrMurano class.
185
188
  # "Do not introduce global variables."
data/.trustme.plugin ADDED
@@ -0,0 +1,137 @@
1
+ #!/bin/bash
2
+ # vim:tw=0:ts=2:sw=2:et:norl:spell:ft=sh
3
+
4
+ assign_globals() {
5
+ assign_globals_
6
+ }
7
+
8
+ init_it() {
9
+ init_it_
10
+
11
+ if [[ -f ${HOME}/.fries/lib/ruby_util.sh ]]; then
12
+ source ${HOME}/.fries/lib/ruby_util.sh
13
+ else
14
+ say 'Missing ruby_util.sh and chruby'
15
+ exit 1
16
+ fi
17
+ # FIXME/2017-12-01: Make this more flexible? Allow many versions??
18
+ # Redirect "Monkey patching!" output.
19
+ chruby 2.3.3 &> /dev/null
20
+ }
21
+
22
+ lang_it() {
23
+ lang_it_
24
+ }
25
+
26
+ build_it() {
27
+ build_it_
28
+
29
+ say "- cwd : $(pwd)"
30
+ say "- ruby -v : $(ruby -v)"
31
+ say "- rubocop -v : $(rubocop -v)"
32
+ #say "- cmd rubocop: $(command -v rubocop)"
33
+ say
34
+
35
+ local projpath="/exo/clients/exosite/MuranoCLIs"
36
+ rake build &>> ${OUT_FILE} && \
37
+ gem install -i $(ruby -rubygems -e 'puts Gem.dir') \
38
+ pkg/MuranoCLI-$(\
39
+ ruby -e "
40
+ require \"${projpath}/active+MuranoCLI/lib/MrMurano/version.rb\";
41
+ puts MrMurano::VERSION
42
+ "
43
+ ).gem \
44
+ &>> ${OUT_FILE} 2>&1 &
45
+ wait_maybe_fail
46
+
47
+ say '' true
48
+ }
49
+
50
+ lint_it() {
51
+ lint_it_
52
+
53
+ rubocop -D -c .rubocop.yml &>> ${OUT_FILE}
54
+
55
+ say '' true
56
+ }
57
+
58
+ test_it() {
59
+ test_it_
60
+ # MEH/2017-12-06: The tests take a number of seconds to run, so skipping.
61
+ return
62
+
63
+ rake rspec &>> ${OUT_FILE}
64
+
65
+ say '' true
66
+ }
67
+
68
+ ctags_it() {
69
+ ctags_it_
70
+
71
+ local ctags_out=$( { \
72
+ ctags -R \
73
+ --exclude=coverage \
74
+ --exclude=docs \
75
+ --exclude=pkg \
76
+ --exclude=report \
77
+ --verbose=yes \
78
+ ; \
79
+ } 2>&1 )
80
+ if [[ $? -ne 0 ]]; then
81
+ say
82
+ say 'ctags FAILED!'
83
+ say '                    '
84
+ say
85
+ say "${ctags_out}"
86
+ say
87
+ say '                    '
88
+ say
89
+ fi
90
+ /bin/ls -la tags >> "${OUT_FILE}"
91
+
92
+ say '' true
93
+ }
94
+
95
+ wait_maybe_fail_pre_exit() {
96
+ if ``command -v notify-send >/dev/null 2>&1``; then
97
+ # 2018-03-12 13:23: Whatever, I cannot test this, why is it so hard to
98
+ # make the build fail??
99
+ notify-send \
100
+ -u critical \
101
+ -i "${HOME}/.waffle/home/Pictures/Landonb-Bitmoji-Game.Over.png" \
102
+ 'Murano CLI Build Failed!' \
103
+ "Error: ${wait_for_what}"
104
+ fi
105
+ }
106
+
107
+ wait_maybe_fail_success() {
108
+ if ``command -v notify-send >/dev/null 2>&1``; then
109
+ #notify-send -i face-wink -t 1234 \
110
+ # 'Build Success!' 'Murano CLI says, "Woot woot!!"'
111
+ # 2018-03-19: 1234 msec. is a tad too long. Something quicker,
112
+ # so I can train myself to ignore if it's a blip in the corner of my eye.
113
+ # Just make sure your mouse into over popup, or it won't go away!
114
+ # Hahaha, at 333 msec. it's basically a flash on the screen...
115
+ # in that case, there's probably a better way to implement this!
116
+ notify-send \
117
+ -t 333 \
118
+ -u normal \
119
+ -i '/home/landonb/.waffle/home/Pictures/Landonb-Bitmoji-Thumbs.Up.png' \
120
+ 'Build Success!' \
121
+ 'Murano CLI says, "Woot woot!!"'
122
+ fi
123
+ }
124
+ wait_maybe_fail_success() {
125
+ # 2018-03-19 18:04: This just gets better!
126
+ # sudo apt-get install xcalib
127
+ ##xcalib -invert -alter
128
+ #xcalib -alter -invert
129
+ # xcalib, because of X, only works on the first monitor!
130
+ # 2018-04-12: But I found a solution that works on all!!
131
+ /srv/opt/bin/xrandr-invert-colors.bin
132
+ sleep 0.075
133
+ ##xcalib -invert -alter
134
+ #xcalib -alter -invert
135
+ /srv/opt/bin/xrandr-invert-colors.bin
136
+ }
137
+
data/.trustme.sh CHANGED
@@ -1,10 +1,7 @@
1
1
  #!/bin/bash
2
2
  # vim:tw=0:ts=2:sw=2:et:norl:spell
3
3
 
4
- # WHAT: A Continuous Integration (CI) script for kicking the build
5
- # whenever a ruby file within the project is saved.
6
- #
7
- # It's Async-safe!
4
+ # WHAT: A Continuous Integration (CI) script that's async-safe.
8
5
 
9
6
  # USAGE: If you have Vim, check out the Dubsacks Vim plugin:
10
7
  #
@@ -18,73 +15,152 @@
18
15
  #
19
16
  # plugin/dubs_edit_juice.vim
20
17
  #
21
- # Or, if you're not using Vim, wire this shell script
22
- # to be called on file save however you are able to
23
- # do that.
18
+ # To wire it yourself instead, check out inotifywait:
19
+ #
20
+ # https://linux.die.net/man/1/inotifywait
21
+ #
22
+ # Ubuntu users can install from Aptitude
23
+ #
24
+ # apt-get install inotify-tools
25
+ #
26
+ # and then watch files from a shell script, e.g.,
24
27
  #
25
- # Maybe check out inotifywait:
28
+ # inotifywait \
29
+ # -mr \
30
+ # --timefmt '%d/%m/%y %H:%M' \
31
+ # --format '%T %w %f %e' \
32
+ # -e close_write /path/to/project \
33
+ # | while read date time dir file events; do
34
+ # /path/to/project/.trustme.sh
35
+ # done
26
36
  #
27
- # https://linux.die.net/man/1/inotifywait
37
+ # NOTE: On Vim, if you're using the project.vim plugin, you'll need
38
+ # to add a reference to the script from the directory entry.
39
+ # Otherwise, when you double-click files in the project window
40
+ # to open them, the BufEnter event doesn't trigger properly.
41
+ # E.g.,
28
42
  #
29
- # NOTE: On Vim, if you're using the project.vim plugin, you'll need
30
- # to add a reference to the script from the directory entry.
31
- # Otherwise, when you double-click files in the project window
32
- # to open them, the BufEnter event doesn't trigger properly.
33
- # E.g.,
43
+ # MY_PROJ=/path/to/proj in=".trustme.vim" filter=".* *" {
44
+ # # ...
45
+ # }
34
46
  #
35
- # MURANO_CLI=/exo/clients/exosite/MuranoCLIs/active+MuranoCLI filter=".* *" in=".trustme.vim" {
36
- # .agignore
37
- # # ...
38
- # }
47
+ # WATCH: All script output gets writ to a file. Use a terminal to tail it:
39
48
  #
40
- # MONITOR: All script output gets writ to a file. Use a terminal to tail it:
49
+ # tail -F .trustme.log
41
50
  #
42
- # tail -F .trustme.log
43
-
44
- # MEH: Need to enable errexit?
45
- #set +x
46
-
47
- OUT_FILE=".trustme.log"
48
-
49
- #local DONE_FILE=".trustme.done"
50
- LOCK_DIR=".trustme.lock"
51
- KILL_DIR=".trustme.kill"
52
- PID_FILE=".trustme.pid"
53
- # Hrm. The bang might not work without
54
- KILL_BIN=".trustme.kill!"
55
-
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}"
51
+ # TEST: From one terminal:
52
+ #
53
+ # tail -F .trustme.log
54
+ #
55
+ # From another terminal:
56
+ #
57
+ # TRUSTME_VERBOSE=true DUBS_TRUST_ME_ON_SAVE=1 ./.trustme.sh
58
+
59
+ source_plugin() {
60
+ # This script is run relative to Vim's working directory,
61
+ # so be deliberate about paths.
62
+ # ${BASH_SOURCE[0]} should be the absolute path to this script.
63
+ # If you add libraries to the trust_me source, source it:
64
+ # TRUSTME_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
65
+ # source "${TRUSTME_DIR}/file"
66
+ PROJECT_DIR=$(dirname -- "${BASH_SOURCE[0]}")
67
+ DOTFILENAME=${TRUSTME_BASENAME:-.trustme}
68
+
69
+ source_color
70
+
71
+ PROJ_PLUGIN="${PROJECT_DIR}/${DOTFILENAME}.plugin"
72
+ if [[ ! -f "${PROJ_PLUGIN}" ]]; then
73
+ say "No project plugin! Nothing to do. Hint: Create and edit: ${PROJ_PLUGIN}"
74
+ exit 1
75
+ fi
76
+ source "${PROJ_PLUGIN}"
77
+ }
78
+
79
+ source_color() {
80
+ local color_util='color_util.sh'
81
+ local color_path="${color_util}"
82
+ # If the /user/home/.fries/lib path is on $PATH, you can just source it.
83
+ if ! source "${color_path}" &> /dev/null; then
84
+ # But if it's not on $PATH, see if this script is a symlink, in which
85
+ # case color_util.sh is also part of this file's owning repo.
86
+ if [[ -h "${BASH_SOURCE[0]}" ]]; then
87
+ color_path="$(dirname $(readlink -f ${BASH_SOURCE[0]}))/${color_util}"
88
+ fi
89
+ if ! source "${color_path}" &> /dev/null; then
90
+ >&2 echo "Unable to find and source ${color_util}. You're missing out!"
91
+ fi
92
+ fi
93
+ }
94
+
95
+ assign_globals_() {
96
+ OUT_FILE="${PROJECT_DIR}/${DOTFILENAME}.log"
97
+
98
+ LOCK_DIR="${PROJECT_DIR}/${DOTFILENAME}.lock"
99
+ KILL_DIR="${PROJECT_DIR}/${DOTFILENAME}.kill"
100
+ PID_FILE="${PROJECT_DIR}/${DOTFILENAME}.pid"
101
+ # Hrm. The bang might not work without
102
+ KILL_BIN="${PROJECT_DIR}/${DOTFILENAME}.kill!"
103
+
104
+ # DEVS: You may want to set this, e.g., to 1, or to 300, depending on
105
+ # how heavy your CI is. If it's a lot of CPU, set a longer delay.
106
+ BUILD_DELAY_SECS=${TRUSTME_DELAYSECS:-0}
107
+
108
+ # FIXME: Add an --arg parser, and add a --verbose/-V flag.
109
+ TRUSTME_VERBOSE=${TRUSTME_VERBOSE:-false}
110
+ }
111
+
112
+ assign_globals() {
113
+ assign_globals_
114
+ }
74
115
 
75
116
  say() {
76
- echo "$1" >> "${OUT_FILE}"
117
+ FORCE_ECHO=${2:-false}
118
+ # Restrict newlines to no more than 2 in a row.
119
+ TRUSTME_SAID_NEWLINE=${TRUSTME_SAID_NEWLINE:-false}
120
+ if ${FORCE_ECHO} || ! ${TRUSTME_SAID_NEWLINE} || [[ ("$1" != "") ]]; then
121
+ # Use -e so colors are included.
122
+ echo -e "$1" >> "${OUT_FILE}"
123
+ fi
124
+ if [[ "$1" != "" ]]; then
125
+ TRUSTME_SAID_NEWLINE=false
126
+ else
127
+ TRUSTME_SAID_NEWLINE=true
128
+ fi
129
+ }
130
+
131
+ verbose() {
132
+ ${TRUSTME_VERBOSE} && say "$@"
77
133
  }
78
134
 
79
135
  announcement() {
136
+ local slugline="$2"
137
+ local bordelimiter="${3-#}"
138
+ local hlit="${4-${FG_REG}${BG_MAROON}}"
139
+ #local hlit="${4-${FG_REG}${BG_MAROON}${FONT_LINE}}"
80
140
  say
81
- say "###################################################################"
141
+ local bord=$(repeat_char ${bordelimiter} 67)
142
+ local norm="${FONT_NORM}"
143
+ say "${hlit}${bord}${norm}"
82
144
  say "$1"
83
- say "###################################################################"
84
- [[ "$2" != '' ]] && say "$2"
145
+ say "${hlit}${bord}${norm}"
146
+ [[ "${slugline}" != '' ]] && say "${slugline}"
85
147
  say
86
148
  }
87
149
 
150
+ verbose_announcement() {
151
+ ${TRUSTME_VERBOSE} && announcement "$@"
152
+ }
153
+
154
+ repeat_char() {
155
+ [[ -z $1 ]] && >&2 echo 'repeat_char: expecting 1st arg: character to repeat' && return 1
156
+ [[ -z $2 ]] && >&2 echo 'repeat_char: expecting 2nd arg: num. of repetitions' && return 1
157
+ # Bash expands {1..n} so the command becomes:
158
+ # printf '=%.0s' 1 2 3 4 ... 100
159
+ # Where printf's format is =%.0s which means that it will always
160
+ # print a single '=' no matter what argument it is given.
161
+ printf "$1"'%.s' $(eval "echo {1.."$(($2))"}")
162
+ }
163
+
88
164
  death() {
89
165
  if [[ -n ${WAIT_PID} ]]; then
90
166
  say "Sub-killing ‘${WAIT_PID}’"
@@ -98,14 +174,14 @@ death() {
98
174
  exit 1
99
175
  }
100
176
 
101
- # FIXME/2017-09-28: Move this and other common fcns. to home-fries?
102
177
  lock_kill_die() {
103
178
  say "Desperately Seeking Lock on $(date)..."
104
179
  [[ "$1" == true ]] && local AFTER_WAIT=true || local AFTER_WAIT=false
105
180
  local build_it=false
106
181
  # mkdir is atomic. Isn't that nice.
107
182
  if $(mkdir "${LOCK_DIR}" 2> /dev/null); then
108
- say "Scored the lock!"
183
+ say "- Scored the lock!"
184
+ say
109
185
  kill_other ${AFTER_WAIT} true
110
186
  elif [[ -d "${LOCK_DIR}" ]]; then
111
187
  if ! ${AFTER_WAIT}; then
@@ -187,81 +263,95 @@ lock_kill_or_die() {
187
263
  lock_kill_die true
188
264
  }
189
265
 
266
+ # ===
267
+
268
+ wait_maybe_fail_pre_exit() {
269
+ : # no-op
270
+ }
271
+
272
+ wait_maybe_fail_success() {
273
+ : # no-op
274
+ }
275
+
276
+ wait_maybe_fail() {
277
+ WAIT_PID=$!
278
+ wait ${WAIT_PID}
279
+ local wait_for_what=$?
280
+ if [[ ${wait_for_what} -ne 0 ]]; then
281
+ say "ERROR: See previous error: we sniffed a ${wait_for_what}!"
282
+ wait_maybe_fail_pre_exit
283
+ exit ${wait_for_what}
284
+ fi
285
+ wait_maybe_fail_success
286
+ WAIT_PID=
287
+ }
288
+
190
289
  prepare_to_build() {
290
+ #/bin/rm "${DONE_FILE}"
291
+ #/bin/rm "${OUT_FILE}"
191
292
  rmdir "${KILL_DIR}"
192
293
  say
193
294
  say "See you on the other side!"
295
+ say
194
296
  touch "${OUT_FILE}"
195
297
  truncate -s 0 "${OUT_FILE}"
298
+ say '' true
299
+ }
300
+
301
+ # ***
302
+
303
+ init_it_() {
304
+ announcement "INIT IT"
196
305
  }
197
306
 
198
307
  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
308
+ init_it_
206
309
  }
207
310
 
208
- lang_it() {
311
+ lang_it_() {
209
312
  announcement "LANG IT"
210
313
  }
211
314
 
212
- build_it() {
315
+ lang_it() {
316
+ lang_it_
317
+ }
318
+
319
+ build_it_() {
213
320
  announcement "BUILD IT"
321
+ }
214
322
 
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}
323
+ build_it() {
324
+ build_it_
325
+ }
219
326
 
220
- local projpath="/exo/clients/exosite/MuranoCLIs"
221
- rake build &>> ${OUT_FILE} && \
222
- gem install -i $(ruby -rubygems -e 'puts Gem.dir') \
223
- pkg/MuranoCLI-$( \
224
- ruby -e "require \"${projpath}/active+MuranoCLI/lib/MrMurano/version.rb\"; \
225
- puts MrMurano::VERSION"\
226
- ).gem \
227
- &>> ${OUT_FILE}
327
+ lint_it_() {
328
+ announcement "LINT IT"
228
329
  }
229
330
 
230
331
  lint_it() {
231
- announcement "LINT IT"
232
- rubocop -D -c .rubocop.yml &>> ${OUT_FILE}
332
+ lint_it_
233
333
  }
234
334
 
235
- rspec_it() {
236
- announcement "RSPEC IT"
237
- rake rspec &>> ${OUT_FILE}
335
+ test_it_() {
336
+ announcement "TEST IT"
238
337
  }
239
338
 
240
- ctags_it() {
339
+ test_it() {
340
+ test_it_
341
+ }
342
+
343
+ ctags_it_() {
241
344
  announcement "CTAGS IT"
242
- local ctags_out=$( { \
243
- ctags -R \
244
- --exclude=coverage \
245
- --exclude=docs \
246
- --exclude=pkg \
247
- --exclude=report \
248
- --verbose=yes \
249
- ; \
250
- } 2>&1 )
251
- if [[ $? -ne 0 ]]; then
252
- say
253
- say 'ctags FAILED!'
254
- say '                    '
255
- say
256
- say "${ctags_out}"
257
- say
258
- say '                    '
259
- say
260
- fi
261
- /bin/ls -la tags >> ${OUT_FILE}
262
345
  }
263
346
 
347
+ ctags_it() {
348
+ ctags_it_
349
+ }
350
+
351
+ # ***
352
+
264
353
  drop_locks() {
354
+ # FIXME/2017-10-03: Riddle me this: is a two-fer rmdir atomic like a 1 dir?
265
355
  rmdir "${LOCK_DIR}" "${KILL_DIR}"
266
356
  }
267
357
 
@@ -271,11 +361,16 @@ remove_pid_files() {
271
361
  }
272
362
 
273
363
  main() {
364
+ source_plugin
365
+
366
+ # MAYBE: This call is redundant. Do we need to call it again here? Or should we delete first call?
367
+ assign_globals
368
+
274
369
  # We're called on both save, and on simple buffer enter.
275
370
  if [[ ${DUBS_TRUST_ME_ON_SAVE} != 1 ]]; then
276
371
  # We've got nothing to do on simple buffer enter...
277
- announcement "DUBS_TRUST_ME_ON_FILE: ${DUBS_TRUST_ME_ON_FILE}"
278
- say "Nothing to do on open"
372
+ verbose_announcement "DUBS_TRUST_ME_ON_FILE: ${DUBS_TRUST_ME_ON_FILE}"
373
+ verbose "Nothing to do on open"
279
374
  exit 1
280
375
  fi
281
376
 
@@ -290,18 +385,17 @@ main() {
290
385
  # Get the lock.
291
386
  lock_or_die
292
387
 
293
- say "‘$$’ has the lock"
388
+ say "- ‘$$’ has the lock"
294
389
  echo "$$" > "${PID_FILE}"
295
390
  echo "kill -s SIGUSR1 $$" > "${KILL_BIN}"
296
391
  chmod 755 "${KILL_BIN}"
297
392
 
298
- # Always build tags.
393
+ # Ctags builder. Before the build. In case BUILD_DELAY_SECS is a while.
299
394
  ctags_it
300
395
 
301
396
  announcement "WAITING ON BUILD" "Countdown: ${BUILD_DELAY_SECS} secs..."
302
397
 
303
398
  # Defer the build!
304
- # FIXME/2017-10-03: Riddle me this: is a two-fer rmdir atomic?
305
399
  drop_locks
306
400
  # The trap on SIGUSR1 only fires when this script is active and
307
401
  # not blocked on a subshell. And sleep is it's own command, so we
@@ -315,12 +409,14 @@ main() {
315
409
  # Or just wait.
316
410
  wait
317
411
 
318
- say "Ready to build..."
412
+ say "READY TO BUILD..."
319
413
  say
320
414
 
321
415
  # Get the lock.
322
416
  lock_kill_or_die
323
417
 
418
+ say "BUILDING!"
419
+
324
420
  if ${TESTING:-false}; then
325
421
  drop_locks
326
422
  remove_pid_files
@@ -331,12 +427,12 @@ main() {
331
427
  prepare_to_build
332
428
 
333
429
  time_0=$(date +%s.%N)
334
- #say # Put newline after "tail: .rake_build.out: file truncated"
335
430
  announcement "WARMING UP"
336
431
  say "Build started at $(date '+%Y-%m-%d_%H-%M-%S')"
337
- say "cwd: $(pwd)"
432
+ verbose
433
+ verbose "- Cwd: $(pwd)"
338
434
 
339
- #lang_it
435
+ lang_it
340
436
 
341
437
  build_it
342
438
  function test_concurrency() {
@@ -345,19 +441,23 @@ main() {
345
441
  # DEVs: Wanna test CTRL-C more easily by keeping the script alive longer?
346
442
  # Then uncomment this.
347
443
  #test_concurrency
444
+ # A fancy, colorful "Built!" message, meant to be easy to spot.
445
+ say "${FG_LIME}$(repeat_char '>' 67)${FONT_NORM}"
446
+ say "${FG_LIME}$(repeat_char '|' 67) BUILT!${FONT_NORM}"
447
+ say "${FG_LIME}$(repeat_char '<' 67) ${FONT_NORM}"
348
448
 
349
449
  lint_it
350
450
 
351
- # MEH/2017-12-06: The tests take a number of seconds to run, so skipping.
352
- #test_it
451
+ # 2017-10-02: I think testing takes too long, and saving often just means constant churn.
452
+
453
+ # Unit tests.
454
+ test_it
353
455
 
354
456
  time_n=$(date +%s.%N)
355
457
  time_elapsed=$(echo "$time_n - $time_0" | bc -l)
356
458
  announcement "DONE!"
357
459
  say "Build finished at $(date '+%H:%M:%S') on $(date '+%Y-%m-%d') in ${time_elapsed} secs."
358
460
 
359
- #touch "${DONE_FILE}"
360
-
361
461
  trap - SIGUSR1
362
462
 
363
463
  remove_pid_files
data/.trustme.vim CHANGED
@@ -4,6 +4,11 @@
4
4
 
5
5
  "echomsg "You've been Vimmed! at " . expand('%')
6
6
 
7
+ " 2017-11-08: I had wanted to use autocmd, I guess, to have tags
8
+ " apply to just files within a project, but that's not working so
9
+ " well -- this plugin might be triggered by BufEnter, so the tags=
10
+ " wouldn't get set until the user re-enters the buffer...
11
+
7
12
  " @% is same as expand('%'), which for some miraculous reason
8
13
  " is the path relative to this file??
9
14
  "autocmd BufWrite *.rb echomsg "Hooray! at " . expand('%')
@@ -11,11 +16,12 @@
11
16
 
12
17
  " Use an autocmd group so it's easy to delete the group,
13
18
  " since every time we call autocmd, the command is appended,
14
- " and this file gets sourced every switch to a corresponding
19
+ " and this file gets sourced on every switch to a corresponding
15
20
  " project buffer.
16
21
  "augroup trustme
17
22
  " " Remove! all trustme autocommands.
18
23
  " autocmd! trustme
24
+ "
19
25
  " "autocmd BufWrite *.rb silent !touch TOUCH
20
26
  " "autocmd BufWrite <buffer> echom "trustme is hooked!"
21
27
  " " MEH/2017-08-02: This won't hook bin/murano.
@@ -42,8 +48,8 @@ if !exists("g:DUBS_TRUST_ME_ON_SAVE")
42
48
  endif
43
49
 
44
50
  let s:cmd = '!' .
45
- \ ' DUBS_TRUST_ME_ON_FILE=' . g:DUBS_TRUST_ME_ON_FILE .
46
- \ ' DUBS_TRUST_ME_ON_SAVE=' . g:DUBS_TRUST_ME_ON_SAVE .
51
+ \ ' DUBS_TRUST_ME_ON_FILE=' . shellescape(g:DUBS_TRUST_ME_ON_FILE) .
52
+ \ ' DUBS_TRUST_ME_ON_SAVE=' . shellescape(g:DUBS_TRUST_ME_ON_SAVE) .
47
53
  \ ' /exo/clients/exosite/exosite-murcli/.trustme.sh &'
48
54
  silent exec s:cmd
49
55