MuranoCLI 2.2.4 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.agignore +3 -0
  3. data/.gitignore +18 -1
  4. data/.rubocop.yml +222 -0
  5. data/.trustme.sh +185 -0
  6. data/.trustme.vim +24 -0
  7. data/Gemfile +23 -4
  8. data/LICENSE.txt +1 -1
  9. data/MuranoCLI.gemspec +43 -8
  10. data/README.markdown +9 -11
  11. data/Rakefile +187 -143
  12. data/TODO.taskpaper +2 -2
  13. data/bin/murano +51 -52
  14. data/docs/basic_example.rst +436 -0
  15. data/docs/completions/murano_completion-bash +3484 -0
  16. data/docs/demo.md +32 -32
  17. data/docs/develop.rst +391 -0
  18. data/lib/MrMurano.rb +21 -7
  19. data/lib/MrMurano/Account.rb +159 -174
  20. data/lib/MrMurano/Business.rb +381 -0
  21. data/lib/MrMurano/Config-Migrate.rb +32 -26
  22. data/lib/MrMurano/Config.rb +407 -128
  23. data/lib/MrMurano/Content.rb +191 -0
  24. data/lib/MrMurano/Gateway.rb +489 -0
  25. data/lib/MrMurano/Keystore.rb +48 -0
  26. data/lib/MrMurano/Passwords.rb +103 -0
  27. data/lib/MrMurano/ProjectFile.rb +121 -79
  28. data/lib/MrMurano/ReCommander.rb +114 -10
  29. data/lib/MrMurano/Setting.rb +90 -0
  30. data/lib/MrMurano/Solution-ServiceConfig.rb +89 -45
  31. data/lib/MrMurano/Solution-Services.rb +461 -166
  32. data/lib/MrMurano/Solution-Users.rb +70 -31
  33. data/lib/MrMurano/Solution.rb +372 -13
  34. data/lib/MrMurano/SolutionId.rb +73 -0
  35. data/lib/MrMurano/SyncRoot.rb +137 -0
  36. data/lib/MrMurano/SyncUpDown.rb +594 -284
  37. data/lib/MrMurano/Webservice-Cors.rb +71 -0
  38. data/lib/MrMurano/Webservice-Endpoint.rb +234 -0
  39. data/lib/MrMurano/Webservice-File.rb +193 -0
  40. data/lib/MrMurano/Webservice.rb +51 -0
  41. data/lib/MrMurano/commands.rb +18 -15
  42. data/lib/MrMurano/commands/business.rb +300 -6
  43. data/lib/MrMurano/commands/completion-bash.erb +166 -0
  44. data/lib/MrMurano/commands/{zshcomplete.erb → completion-zsh.erb} +0 -0
  45. data/lib/MrMurano/commands/completion.rb +76 -39
  46. data/lib/MrMurano/commands/config.rb +108 -44
  47. data/lib/MrMurano/commands/content.rb +115 -72
  48. data/lib/MrMurano/commands/cors.rb +29 -14
  49. data/lib/MrMurano/commands/devices.rb +286 -0
  50. data/lib/MrMurano/commands/domain.rb +52 -12
  51. data/lib/MrMurano/commands/gb.rb +24 -9
  52. data/lib/MrMurano/commands/globals.rb +64 -0
  53. data/lib/MrMurano/commands/init.rb +377 -155
  54. data/lib/MrMurano/commands/keystore.rb +92 -82
  55. data/lib/MrMurano/commands/link.rb +300 -0
  56. data/lib/MrMurano/commands/login.rb +74 -11
  57. data/lib/MrMurano/commands/logs.rb +63 -32
  58. data/lib/MrMurano/commands/mock.rb +57 -29
  59. data/lib/MrMurano/commands/password.rb +57 -39
  60. data/lib/MrMurano/commands/postgresql.rb +127 -94
  61. data/lib/MrMurano/commands/settings.rb +203 -0
  62. data/lib/MrMurano/commands/show.rb +79 -38
  63. data/lib/MrMurano/commands/solution.rb +423 -5
  64. data/lib/MrMurano/commands/solution_picker.rb +547 -0
  65. data/lib/MrMurano/commands/status.rb +195 -61
  66. data/lib/MrMurano/commands/sync.rb +78 -39
  67. data/lib/MrMurano/commands/timeseries.rb +71 -55
  68. data/lib/MrMurano/commands/tsdb.rb +113 -87
  69. data/lib/MrMurano/commands/usage.rb +57 -15
  70. data/lib/MrMurano/hash.rb +100 -10
  71. data/lib/MrMurano/http.rb +187 -43
  72. data/lib/MrMurano/makePretty.rb +16 -14
  73. data/lib/MrMurano/optparse.rb +2178 -0
  74. data/lib/MrMurano/progress.rb +138 -0
  75. data/lib/MrMurano/schema/resource-v1.0.0.yaml +32 -0
  76. data/lib/MrMurano/template/projectFile.murano.erb +16 -13
  77. data/lib/MrMurano/verbosing.rb +166 -29
  78. data/lib/MrMurano/version.rb +30 -1
  79. data/spec/Account-Passwords_spec.rb +21 -4
  80. data/spec/Account_spec.rb +69 -146
  81. data/spec/Business_spec.rb +290 -0
  82. data/spec/ConfigFile_spec.rb +1 -0
  83. data/spec/ConfigMigrate_spec.rb +12 -8
  84. data/spec/Config_spec.rb +40 -34
  85. data/spec/Content_spec.rb +363 -0
  86. data/spec/GatewayBase_spec.rb +54 -0
  87. data/spec/GatewayDevice_spec.rb +321 -0
  88. data/spec/GatewayResource_spec.rb +266 -0
  89. data/spec/GatewaySettings_spec.rb +120 -0
  90. data/spec/Http_spec.rb +18 -8
  91. data/spec/Mock_spec.rb +2 -2
  92. data/spec/ProjectFile_spec.rb +25 -14
  93. data/spec/Setting_spec.rb +110 -0
  94. data/spec/Solution-ServiceConfig_spec.rb +44 -5
  95. data/spec/Solution-ServiceEventHandler_spec.rb +23 -14
  96. data/spec/Solution-ServiceModules_spec.rb +47 -37
  97. data/spec/Solution-UsersRoles_spec.rb +10 -8
  98. data/spec/Solution_spec.rb +17 -8
  99. data/spec/SyncRoot_spec.rb +46 -20
  100. data/spec/SyncUpDown_spec.rb +437 -201
  101. data/spec/Verbosing_spec.rb +12 -4
  102. data/spec/{Solution-Cors_spec.rb → Webservice-Cors_spec.rb} +23 -20
  103. data/spec/{Solution-Endpoint_spec.rb → Webservice-Endpoint_spec.rb} +43 -41
  104. data/spec/{Solution-File_spec.rb → Webservice-File_spec.rb} +44 -33
  105. data/spec/Webservice-Setting_spec.rb +89 -0
  106. data/spec/_workspace.rb +4 -4
  107. data/spec/cmd_business_spec.rb +9 -4
  108. data/spec/cmd_common.rb +44 -1
  109. data/spec/cmd_content_spec.rb +43 -17
  110. data/spec/cmd_cors_spec.rb +4 -4
  111. data/spec/cmd_device_spec.rb +61 -16
  112. data/spec/cmd_domain_spec.rb +29 -6
  113. data/spec/cmd_init_spec.rb +281 -126
  114. data/spec/cmd_keystore_spec.rb +3 -3
  115. data/spec/cmd_link_spec.rb +98 -0
  116. data/spec/cmd_password_spec.rb +1 -1
  117. data/spec/cmd_setting_application_spec.rb +260 -0
  118. data/spec/cmd_setting_product_spec.rb +220 -0
  119. data/spec/cmd_status_spec.rb +223 -114
  120. data/spec/cmd_syncdown_spec.rb +115 -35
  121. data/spec/cmd_syncup_spec.rb +68 -15
  122. data/spec/cmd_usage_spec.rb +35 -8
  123. data/spec/fixtures/dumped_config +6 -4
  124. data/spec/fixtures/gateway_resource_files/resources.notyaml +12 -0
  125. data/spec/fixtures/gateway_resource_files/resources.yaml +13 -0
  126. data/spec/fixtures/gateway_resource_files/resources_invalid.yaml +13 -0
  127. data/spec/fixtures/mrmuranorc_deleted_bob +0 -2
  128. data/spec/fixtures/product_spec_files/lightbulb.yaml +20 -13
  129. data/spec/fixtures/{syncable_content → syncable_conflict}/services/devdata.lua +1 -1
  130. data/spec/fixtures/{syncable_content → syncable_conflict}/services/timers.lua +0 -0
  131. data/spec/spec_helper.rb +5 -0
  132. metadata +262 -171
  133. data/bin/mr +0 -8
  134. data/lib/MrMurano/Product-1P-Device.rb +0 -145
  135. data/lib/MrMurano/Product-Resources.rb +0 -205
  136. data/lib/MrMurano/Product.rb +0 -358
  137. data/lib/MrMurano/Solution-Cors.rb +0 -47
  138. data/lib/MrMurano/Solution-Endpoint.rb +0 -191
  139. data/lib/MrMurano/Solution-File.rb +0 -166
  140. data/lib/MrMurano/commands/assign.rb +0 -57
  141. data/lib/MrMurano/commands/businessList.rb +0 -45
  142. data/lib/MrMurano/commands/product.rb +0 -14
  143. data/lib/MrMurano/commands/productCreate.rb +0 -39
  144. data/lib/MrMurano/commands/productDelete.rb +0 -33
  145. data/lib/MrMurano/commands/productDevice.rb +0 -87
  146. data/lib/MrMurano/commands/productDeviceIdCmds.rb +0 -89
  147. data/lib/MrMurano/commands/productList.rb +0 -45
  148. data/lib/MrMurano/commands/productWrite.rb +0 -27
  149. data/lib/MrMurano/commands/solutionCreate.rb +0 -41
  150. data/lib/MrMurano/commands/solutionDelete.rb +0 -34
  151. data/lib/MrMurano/commands/solutionList.rb +0 -45
  152. data/spec/ProductBase_spec.rb +0 -113
  153. data/spec/ProductContent_spec.rb +0 -162
  154. data/spec/ProductResources_spec.rb +0 -329
  155. data/spec/Product_1P_Device_spec.rb +0 -202
  156. data/spec/Product_1P_RPC_spec.rb +0 -175
  157. data/spec/Product_spec.rb +0 -153
  158. data/spec/Solution-ServiceDevice_spec.rb +0 -176
  159. data/spec/cmd_assign_spec.rb +0 -51
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e73fc277539519b2b36d38f2d86a67bd106779e2
4
- data.tar.gz: f715f1075a208806e9ff2f9e989f154f312bfde8
3
+ metadata.gz: f5b5bb74dbabc6127f0fe9e054b41b218b64964d
4
+ data.tar.gz: c2e188788986effcfd60c676d3950df224ee6935
5
5
  SHA512:
6
- metadata.gz: 552129eb3e4167a498cd8ad76910fa9efd1793cc1b96331542956009c5e18eacdede1a27bd3017b2d10b77e7aa6add683609459c40ff8bf107b864e23a8cb85d
7
- data.tar.gz: 351343bca4f083fbb75ca4452a5878c43268943ea25c905d8d73f55b7de954442c12124eb1e1fe2a18fa2dc04d000fb7596e5cc7dfe6391d43338fb964f98f41
6
+ metadata.gz: e309c8cb7301754d9e58b8ad007a1d3bef23167dbf9370002a9d76874539da9028199ac004f80b84afa2ccb61026836bdc3368579d4e0a2f1d411fe20a7ab087
7
+ data.tar.gz: 059dcf12cc97380afa732316ba860dc96f2c814cb85fd30533ecf3d31c781d05cfce8a80b7b6324ffa65272721b0fe0fa01c683aa4771c9d690526054923cb06
data/.agignore CHANGED
@@ -11,3 +11,6 @@ Gemfile.lock
11
11
  # 2017-05-12: Testing!
12
12
  *.out
13
13
 
14
+ rspec-*.html
15
+ *.rspec.html
16
+
data/.gitignore CHANGED
@@ -7,7 +7,6 @@ cookies
7
7
  .jiramulerc
8
8
  .yardoc/
9
9
  tags
10
- mr.exe
11
10
 
12
11
  xcuserdata
13
12
  Pods/
@@ -30,3 +29,21 @@ test.*
30
29
  .Trashes
31
30
 
32
31
  Gemfile.lock
32
+
33
+ # For "Debugging in Ruby 2"
34
+ # https://github.com/deivid-rodriguez/byebug
35
+ .byebug_history
36
+
37
+ # For `chruby` and `rvm` Ruby versioning
38
+ # .ruby-version
39
+ .ruby-version
40
+ .bundle/
41
+
42
+ # For `rake test` using a test .murano config
43
+ .murano.test
44
+
45
+ .rake_tasks~
46
+
47
+ # Output from .trustme.vim and .trustme.sh
48
+ .rake_build.out
49
+
@@ -0,0 +1,222 @@
1
+ # Last Modified: 2017.08.17 /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
5
+
6
+ # USAGE:
7
+ #
8
+ # cd /exo/clients/exosite/MuranoCLI
9
+ # rubocop -D -c .rubocop.yml
10
+
11
+ # "Incorrect indentation detected (column X instead of Y)."
12
+ Layout/CommentIndentation:
13
+ Enabled: false
14
+
15
+ # "Missing space after #."
16
+ Layout/LeadingCommentSpace:
17
+ Enabled: false
18
+
19
+ # "Surrounding space missing in default value assignment."
20
+ Layout/SpaceAroundEqualsInParameterDefault:
21
+ EnforcedStyle: no_space
22
+
23
+ # "1 trailing blank lines detected."
24
+ Layout/TrailingBlankLines:
25
+ Enabled: false
26
+
27
+ # "Script file murano doesn't have execute permission."
28
+ Lint/ScriptPermission:
29
+ Exclude:
30
+ - 'bin/murano'
31
+
32
+ # "Assignment Branch Condition size for XXX is too high."
33
+ # http://wiki.c2.com/?AbcMetric
34
+ Metrics/AbcSize:
35
+ Enabled: false
36
+
37
+ # Configuration parameters: CountComments, ExcludedMethods.
38
+ Metrics/BlockLength:
39
+ Enabled: false
40
+ #Max: 500
41
+
42
+ # "Avoid more than 3 levels of block nesting."
43
+ Metrics/BlockNesting:
44
+ Enabled: false
45
+
46
+ # "Class has too many lines."
47
+ Metrics/ClassLength:
48
+ Enabled: false
49
+
50
+ # "Cyclomatic complexity for XXX is too high."
51
+ Metrics/CyclomaticComplexity:
52
+ Enabled: false
53
+
54
+ Metrics/MethodLength:
55
+ Enabled: false
56
+
57
+ # "Module has too many lines."
58
+ Metrics/ModuleLength:
59
+ Enabled: false
60
+
61
+ # "Avoid parameter lists longer than 5 parameters."
62
+ Metrics/ParameterLists:
63
+ Enabled: false
64
+
65
+ # Perceived complexity for XXXX is too high."
66
+ Metrics/PerceivedComplexity:
67
+ Enabled: false
68
+
69
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
70
+ # URISchemes: http, https
71
+ Metrics/LineLength:
72
+ Enabled: false
73
+
74
+ # "Use only ascii symbols in comments."
75
+ Style/AsciiComments:
76
+ Enabled: false
77
+
78
+ # "Missing top-level class documentation comment."
79
+ Style/Documentation:
80
+ Enabled: false
81
+
82
+ # "Use the return of the conditional for variable assignment and comparison."
83
+ # http://www.rubydoc.info/github/bbatsov/RuboCop/RuboCop/Cop/Style/ConditionalAssignment
84
+ Style/ConditionalAssignment:
85
+ EnforcedStyle: assign_inside_condition
86
+
87
+ # "Put empty method definitions on a single line."
88
+ # You can do, e.g.,
89
+ # def my_method(some_var) end
90
+ # except you cannot do
91
+ # def my_method end
92
+ # but instead have to do
93
+ # def my_method() end
94
+ # which then breaks another rule, Style/DefWithParentheses!
95
+ Style/EmptyMethod:
96
+ Enabled: false
97
+
98
+ # "The name of this source file (Xxxxxxx.rb) should use snake_case."
99
+ Style/FileName:
100
+ Exclude:
101
+ - 'Gemfile'
102
+ - 'MuranoCLI.gemspec'
103
+ - 'Rakefile'
104
+ - 'lib/MrMurano.rb'
105
+ - 'lib/MrMurano/Account.rb'
106
+ - 'lib/MrMurano/Business.rb'
107
+ - 'lib/MrMurano/Config-Migrate.rb'
108
+ - 'lib/MrMurano/Config.rb'
109
+ - 'lib/MrMurano/Content.rb'
110
+ - 'lib/MrMurano/Gateway.rb'
111
+ - 'lib/MrMurano/Keystore.rb'
112
+ - 'lib/MrMurano/Mock.rb'
113
+ - 'lib/MrMurano/Passwords.rb'
114
+ - 'lib/MrMurano/ProjectFile.rb'
115
+ - 'lib/MrMurano/ReCommander.rb'
116
+ - 'lib/MrMurano/Setting.rb'
117
+ - 'lib/MrMurano/Solution-ServiceConfig.rb'
118
+ - 'lib/MrMurano/Solution-Services.rb'
119
+ - 'lib/MrMurano/Solution-Users.rb'
120
+ - 'lib/MrMurano/Solution.rb'
121
+ - 'lib/MrMurano/SolutionId.rb'
122
+ - 'lib/MrMurano/SubCmdGroupContext.rb'
123
+ - 'lib/MrMurano/SyncRoot.rb'
124
+ - 'lib/MrMurano/SyncUpDown.rb'
125
+ - 'lib/MrMurano/Webservice-Cors.rb'
126
+ - 'lib/MrMurano/Webservice-Endpoint.rb'
127
+ - 'lib/MrMurano/Webservice-File.rb'
128
+ - 'lib/MrMurano/Webservice.rb'
129
+
130
+ # FIXME/2017-06-30: We should fix this one... put $cfg in MrMurano class.
131
+ # "Do not introduce global variables."
132
+ Style/GlobalVars:
133
+ Enabled: false
134
+
135
+ # "Use remaining.positive? instead of remaining > 0."
136
+ # However, Numeric.positive? does not exist in Ruby 2 or 2.2.
137
+ Style/NumericPredicate:
138
+ Enabled: false
139
+
140
+ # "Provide an exception class and message as arguments to raise."
141
+ Style/RaiseArgs:
142
+ EnforcedStyle: compact
143
+
144
+ # "Don't use parentheses around a literal."
145
+ # How else do you split long lines, eh? E.g.,
146
+ # unbelievably_long_variable_name = (
147
+ # "Some very long sentence about being a very long sentence."
148
+ # )
149
+ Style/RedundantParentheses:
150
+ Enabled: false
151
+
152
+ # "Use // around regular expression."
153
+ # "Use %r around regular expression."
154
+ #Style/RegexpLiteral:
155
+ # # If "slashes" or "mixed":
156
+ # # snake_case = /^[\dA-Z_]+$/
157
+ # # If "percent_r":
158
+ # # snake_case = %r{^[\dA-Z_]+$}
159
+ # #EnforcedStyle: percent_r
160
+ # EnforcedStyle: slashes
161
+
162
+ # "Avoid comma after the last parameter of a method call."
163
+ # FIXME/2017-06-30: Is this okay?
164
+ Style/TrailingCommaInArguments:
165
+ Enabled: false
166
+
167
+ # "Avoid comma after the last item of a hash."
168
+ Style/TrailingCommaInLiteral:
169
+ # Rather than disable, tweak for multiline lists, so Rubocop will
170
+ # still tell you not to use trailing comma in single-line list.
171
+ EnforcedStyleForMultiline: "consistent_comma"
172
+
173
+ # "Use safe navigation (&.) instead of checking if an object exists before
174
+ # calling the method."
175
+ #
176
+ # - "The Safe Navigation Operator (&.) in Ruby"
177
+ # http://mitrev.net/ruby/2015/11/13/the-operator-in-ruby/
178
+ #
179
+ # The safe nav op was only added in Ruby 2.3.0, and we support 2.0.
180
+ Style/SafeNavigation:
181
+ Enabled: false
182
+
183
+ AllCops:
184
+ Include:
185
+ - 'bin/murano'
186
+ # These are included by default:
187
+ #- '**/Gemfile'
188
+ - '**/Rakefile'
189
+ #- 'MuranoCLI.gemspec'
190
+ # FIXME/2017-07-25: Finishing linting all the files!
191
+ # These files have not been linted since Rubocop was adopted.
192
+ Exclude:
193
+ # HINT: You can use regexp in this list.
194
+ #- !ruby/regexp /old_and_unused\.rb$/
195
+ #
196
+ # 2017-07-25: It's probably not worth our time to lint the spec tests.
197
+ # 2017-07-31: 7735 offenses in the Spec tests -- not worth it to fix!!
198
+ - 'spec/**/*'
199
+ #
200
+ # Not sure if the templates are included by default or not, but ignore.
201
+ - 'lib/MrMurano/commands/completion-bash.erb'
202
+ - 'lib/MrMurano/commands/completion-zsh.erb'
203
+ #
204
+ # 2017-08-16: Ug.
205
+ - 'lib/MrMurano/optparse.rb'
206
+ #
207
+ # FIXME/2017-07-25: Finish linting these files, and delete from this list.
208
+ # ✗ 2017-07-31: 943 offenses herein these 26 files.
209
+ # ✓ 2017-08-16: 420 offenses herein these 15 files.
210
+ - 'lib/MrMurano/Content.rb'
211
+ - 'lib/MrMurano/Mock.rb'
212
+ - 'lib/MrMurano/Setting.rb'
213
+ - 'lib/MrMurano/SubCmdGroupContext.rb'
214
+ - 'lib/MrMurano/Webservice-Endpoint.rb'
215
+ - 'lib/MrMurano/Webservice-File.rb'
216
+ - 'lib/MrMurano/hash.rb'
217
+ - 'lib/MrMurano/http.rb'
218
+ - 'lib/MrMurano/makePretty.rb'
219
+ - 'lib/MrMurano/commands/business.rb'
220
+ - 'lib/MrMurano/commands/cors.rb'
221
+ - 'lib/MrMurano/commands/settings.rb'
222
+
@@ -0,0 +1,185 @@
1
+ #!/bin/bash
2
+ # Last Modified: 2017.08.16
3
+ # vim:tw=0:ts=2:sw=2:et:norl:spell
4
+
5
+ # WHAT: A Continuous Integration (CI) script for kicking the build
6
+ # whenever a ruby file within the project is saved.
7
+ #
8
+ # It's Async-safe!
9
+
10
+ # USAGE: If you have Vim, check out the Dubsacks Vim plugin:
11
+ #
12
+ # https://github.com/landonb/dubs_edit_juice
13
+ #
14
+ # which automatically looks for a .trustme.vim above
15
+ # any file you load into a buffer.
16
+ #
17
+ # You can install the plugin or just copy the BufEnter
18
+ # autocmd that loads for the .trustme.vim file, from:
19
+ #
20
+ # plugin/dubs_edit_juice.vim
21
+ #
22
+ # Or, if you're not using Vim, wire this shell script
23
+ # to be called on file save however you are able to
24
+ # do that.
25
+ #
26
+ # Maybe check out inotifywait:
27
+ #
28
+ # https://linux.die.net/man/1/inotifywait
29
+ #
30
+ # NOTE: On Vim, if you're using the project.vim plugin, you'll need
31
+ # to add a reference to the script from the directory entry.
32
+ # Otherwise, when you double-click files in the project window
33
+ # to open them, the BufEnter event doesn't trigger properly.
34
+ # E.g.,
35
+ #
36
+ # MURANO_CLI=/exo/clients/exosite/MuranoCLI filter=".* *" in=".trustme.vim" {
37
+ # .agignore
38
+ # # ...
39
+ # }
40
+ #
41
+ # MONITOR: All script output gets writ to a file. Use a terminal to tail it:
42
+ #
43
+ # tail -F .rake_build.out
44
+
45
+ # MEH: Need to enable errexit?
46
+ #set +x
47
+
48
+ OUT_FILE=".rake_build.out"
49
+
50
+ #local DONE_FILE=".trustme.done"
51
+ LOCK_DIR=".trustme.lock"
52
+ PID_FILE="${LOCK_DIR}/.build.pid"
53
+ LOCK_KILL=".trustme.kill"
54
+
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
62
+
63
+ trap death SIGINT
64
+
65
+ function annoucement() {
66
+ echo >> ${OUT_FILE}
67
+ echo "###################################################################" >> ${OUT_FILE}
68
+ echo $1 >> ${OUT_FILE}
69
+ echo "###################################################################" >> ${OUT_FILE}
70
+ echo >> ${OUT_FILE}
71
+ }
72
+
73
+ function death() {
74
+ echo "death!" >> ${OUT_FILE}
75
+ annoucement "DEATH! ☠☠☠"
76
+ exit 1
77
+ }
78
+
79
+ function lock_kill_or_die() {
80
+ local build_it=false
81
+ # 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
104
+ fi
105
+ else
106
+ echo "build locked, but not kill. but no pid? whatever, we'll take it!"
107
+ fi
108
+ else
109
+ echo "build locked, but not kill. but builder has not started, bye" >> ${OUT_FILE}
110
+ exit
111
+ fi
112
+ else
113
+ echo "all locked, party over, man!" >> ${OUT_FILE}
114
+ exit
115
+ fi
116
+ else
117
+ echo "WARNING: could not mkdir ‘${LOCK_DIR}’ and it does not exist, later!" >> ${OUT_FILE}
118
+ exit
119
+ fi
120
+ }
121
+ lock_kill_or_die
122
+
123
+ function prepare_to_build() {
124
+ echo "$$" > ${PID_FILE}
125
+ [[ -d ${LOCK_KILL} ]] && rmdir ${LOCK_KILL}
126
+
127
+ #/bin/rm ${DONE_FILE}
128
+ #/bin/rm ${OUT_FILE}
129
+ touch ${OUT_FILE}
130
+ truncate -s 0 ${OUT_FILE}
131
+ }
132
+ prepare_to_build
133
+
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}
142
+
143
+ function build_it() {
144
+ annoucement "BUILD IT"
145
+ rake build &>> ${OUT_FILE} && \
146
+ gem install -i $(ruby -rubygems -e 'puts Gem.dir') \
147
+ pkg/MuranoCLI-$(ruby -e 'require "/exo/clients/exosite/MuranoCLI/lib/MrMurano/version.rb"; puts MrMurano::VERSION').gem \
148
+ &>> ${OUT_FILE}
149
+ }
150
+ build_it
151
+
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"
161
+ rubocop -D -c .rubocop.yml &>> ${OUT_FILE}
162
+ }
163
+ lint_it
164
+
165
+ function rspec_it() {
166
+ annoucement "RSPEC IT"
167
+ rake rspec &>> ${OUT_FILE}
168
+ }
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
+ time_n=$(date +%s.%N)
175
+ time_elapsed=$(echo "$time_n - $time_0" | bc -l)
176
+ annoucement "DONE!"
177
+ echo "Build finished at $(date '+%H:%M:%S') on $(date '+%Y-%m-%d') in $time_elapsed secs." >> ${OUT_FILE}
178
+
179
+ #touch ${DONE_FILE}
180
+
181
+ trap - SIGINT
182
+
183
+ /bin/rm ${PID_FILE}
184
+ rmdir ${LOCK_DIR}
185
+