MuranoCLI 3.2.1.pre.beta.4 → 3.2.1.pre.beta.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/Gemfile +4 -3
- data/HISTORY.md +826 -0
- data/Rakefile +415 -47
- data/docs/release.rst +275 -0
- data/lib/MrMurano/Account.rb +46 -47
- data/lib/MrMurano/AccountBase.rb +1 -0
- data/lib/MrMurano/Business.rb +183 -44
- data/lib/MrMurano/Config.rb +1 -0
- data/lib/MrMurano/Exchange.rb +3 -4
- data/lib/MrMurano/Solution-Services.rb +25 -7
- data/lib/MrMurano/Webservice-File.rb +5 -7
- data/lib/MrMurano/commands/business.rb +231 -24
- data/lib/MrMurano/commands/child.rb +3 -3
- data/lib/MrMurano/commands/element.rb +1 -0
- data/lib/MrMurano/commands/settings.rb +7 -0
- data/lib/MrMurano/http.rb +1 -3
- data/lib/MrMurano/progress.rb +12 -2
- data/lib/MrMurano/verbosing.rb +7 -7
- data/lib/MrMurano/version.rb +1 -1
- data/spec/Account_spec.rb +9 -0
- data/spec/ProjectFile_spec.rb +7 -9
- data/spec/Webservice-File_spec.rb +2 -1
- data/spec/cmd_business_spec.rb +1 -1
- data/spec/cmd_common.rb +75 -30
- data/spec/cmd_content_spec.rb +3 -1
- data/spec/cmd_cors_spec.rb +3 -1
- data/spec/cmd_device_spec.rb +7 -5
- data/spec/cmd_domain_spec.rb +6 -2
- data/spec/cmd_help_spec.rb +13 -6
- data/spec/cmd_init_spec.rb +19 -10
- data/spec/cmd_keystore_spec.rb +3 -1
- data/spec/cmd_link_spec.rb +5 -5
- data/spec/cmd_setting_application_spec.rb +13 -16
- data/spec/cmd_setting_product_spec.rb +14 -14
- data/spec/cmd_status_spec.rb +6 -2
- data/spec/cmd_syncdown_application_spec.rb +3 -1
- data/spec/cmd_syncdown_both_spec.rb +6 -2
- data/spec/cmd_syncdown_unit_spec.rb +3 -0
- data/spec/cmd_syncup_spec.rb +8 -4
- data/spec/cmd_usage_spec.rb +10 -2
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value 0.webmock +98 -0
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value 1.webmock +98 -0
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value No.webmock +98 -0
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value Yes.webmock +98 -0
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value bob.webmock +72 -0
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value false.webmock +98 -0
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value off.webmock +98 -0
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value on STDIN.webmock +98 -0
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value on.webmock +98 -0
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value true.webmock +98 -0
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a json array blob with STDIN.webmock +98 -0
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a json array blob.webmock +98 -0
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) an array.webmock +98 -0
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) appends an array.webmock +98 -0
- data/spec/fixtures/snapshots/murano application setting reads Webservice.cors to a file.webmock +72 -0
- data/spec/fixtures/snapshots/murano application setting reads Webservice.cors.webmock +72 -0
- data/spec/fixtures/snapshots/murano business list as json.webmock +27 -0
- data/spec/fixtures/snapshots/murano business list as table.webmock +27 -0
- data/spec/fixtures/snapshots/murano business list fewer fields.webmock +27 -0
- data/spec/fixtures/snapshots/murano business list only ids.webmock +27 -0
- data/spec/fixtures/snapshots/murano business list output to file.webmock +27 -0
- data/spec/fixtures/snapshots/murano business without project help.webmock +9 -0
- data/spec/fixtures/snapshots/murano config Needs a key.webmock +9 -0
- data/spec/fixtures/snapshots/murano config Reads a key.webmock +9 -0
- data/spec/fixtures/snapshots/murano config Removes a key.webmock +9 -0
- data/spec/fixtures/snapshots/murano config Sets a key.webmock +9 -0
- data/spec/fixtures/snapshots/murano config Sets a user key.webmock +9 -0
- data/spec/fixtures/snapshots/murano content life cycle.webmock +144 -0
- data/spec/fixtures/snapshots/murano cors sets CORS.webmock +78 -0
- data/spec/fixtures/snapshots/murano cors show CORS.webmock +64 -0
- data/spec/fixtures/snapshots/murano device activates.webmock +86 -0
- data/spec/fixtures/snapshots/murano device enables a batch.webmock +76 -0
- data/spec/fixtures/snapshots/murano device enables and lists.webmock +78 -0
- data/spec/fixtures/snapshots/murano device writes and reads.webmock +136 -0
- data/spec/fixtures/snapshots/murano domain show domain.webmock +101 -0
- data/spec/fixtures/snapshots/murano element edit unknown as unknown element.webmock +43 -0
- data/spec/fixtures/snapshots/murano element show --help.webmock +9 -0
- data/spec/fixtures/snapshots/murano element show as csv.webmock +43 -0
- data/spec/fixtures/snapshots/murano element show as default-table.webmock +43 -0
- data/spec/fixtures/snapshots/murano element show as json.webmock +43 -0
- data/spec/fixtures/snapshots/murano element show as table truncate.webmock +43 -0
- data/spec/fixtures/snapshots/murano element show as table wrap.webmock +43 -0
- data/spec/fixtures/snapshots/murano element show as yaml.webmock +43 -0
- data/spec/fixtures/snapshots/murano element show using ambiguous name.webmock +43 -0
- data/spec/fixtures/snapshots/murano element without project usage.webmock +9 -0
- data/spec/fixtures/snapshots/murano exchange with project list as json.webmock +59 -0
- data/spec/fixtures/snapshots/murano exchange with project list as table.webmock +59 -0
- data/spec/fixtures/snapshots/murano exchange with project list fewer fields.webmock +59 -0
- data/spec/fixtures/snapshots/murano exchange with project list only ids.webmock +59 -0
- data/spec/fixtures/snapshots/murano exchange with project list output to file.webmock +59 -0
- data/spec/fixtures/snapshots/murano exchange with project list purchase is already added ID.webmock +83 -0
- data/spec/fixtures/snapshots/murano exchange with project list purchase is ambiguous name.webmock +59 -0
- data/spec/fixtures/snapshots/murano exchange without project help.webmock +9 -0
- data/spec/fixtures/snapshots/murano help using commander as --help.webmock +9 -0
- data/spec/fixtures/snapshots/murano help using commander no args.webmock +9 -0
- data/spec/fixtures/snapshots/murano help using subshell no args.webmock +9 -0
- data/spec/fixtures/snapshots/murano help using subshell with --help.webmock +9 -0
- data/spec/fixtures/snapshots/murano init Won't init in HOME (gracefully).webmock +9 -0
- data/spec/fixtures/snapshots/murano init in empty directory with existing project.webmock +201 -0
- data/spec/fixtures/snapshots/murano init in empty directory without existing project.webmock +193 -0
- data/spec/fixtures/snapshots/murano init in existing project directory with ProjectFile.webmock +213 -0
- data/spec/fixtures/snapshots/murano init in existing project directory with SolutionFile 0.2.0.webmock +213 -0
- data/spec/fixtures/snapshots/murano init in existing project directory with SolutionFile 0.3.0.webmock +213 -0
- data/spec/fixtures/snapshots/murano init in existing project directory without ProjectFile.webmock +213 -0
- data/spec/fixtures/snapshots/murano keystore can call other commands.webmock +108 -0
- data/spec/fixtures/snapshots/murano keystore clearAll.webmock +124 -0
- data/spec/fixtures/snapshots/murano keystore deletes.webmock +112 -0
- data/spec/fixtures/snapshots/murano keystore gets.webmock +96 -0
- data/spec/fixtures/snapshots/murano keystore infos.webmock +96 -0
- data/spec/fixtures/snapshots/murano keystore lists.webmock +96 -0
- data/spec/fixtures/snapshots/murano link with project links and lists.webmock +149 -0
- data/spec/fixtures/snapshots/murano link with project unlinks.webmock +165 -0
- data/spec/fixtures/snapshots/murano link without project help.webmock +9 -0
- data/spec/fixtures/snapshots/murano link without project subshell vs inline using commander will not list.webmock +27 -0
- data/spec/fixtures/snapshots/murano link without project subshell vs inline using subshell will not list.webmock +27 -0
- data/spec/fixtures/snapshots/murano logs when project is setup tail log.webmock +9 -0
- data/spec/fixtures/snapshots/murano password Lists when no file.webmock +9 -0
- data/spec/fixtures/snapshots/murano password deletes a password.webmock +9 -0
- data/spec/fixtures/snapshots/murano password sets a password.webmock +9 -0
- data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a forced string value on STDIN.webmock +90 -0
- data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a forced string value.webmock +90 -0
- data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value fiftyHalf.webmock +64 -0
- data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value float 12.67.webmock +90 -0
- data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value integer 12.webmock +90 -0
- data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value on STDIN.webmock +90 -0
- data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a string value.webmock +90 -0
- data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) merges into a dictionary.webmock +90 -0
- data/spec/fixtures/snapshots/murano single sync without ProjectFile syncdown.webmock +322 -0
- data/spec/fixtures/snapshots/murano status with ProjectFile status.webmock +153 -0
- data/spec/fixtures/snapshots/murano status with Solutionfile 0.2.0 status.webmock +153 -0
- data/spec/fixtures/snapshots/murano status with Solutionfile 0.3.0 status.webmock +153 -0
- data/spec/fixtures/snapshots/murano status without ProjectFile matches file path.webmock +153 -0
- data/spec/fixtures/snapshots/murano status without ProjectFile matches route.webmock +153 -0
- data/spec/fixtures/snapshots/murano status without ProjectFile status.webmock +153 -0
- data/spec/fixtures/snapshots/murano syncdown stubbed without ProjectFile syncdown.webmock +151 -0
- data/spec/fixtures/snapshots/murano syncdown without ProjectFile syncdown.webmock +479 -0
- data/spec/fixtures/snapshots/murano syncup without ProjectFile syncup.webmock +357 -0
- data/spec/fixtures/snapshots/murano token with project list as table.webmock +9 -0
- data/spec/fixtures/snapshots/murano token without project help.webmock +9 -0
- data/spec/fixtures/snapshots/murano usage show usage.webmock +93 -0
- data/spec/spec_helper.rb +9 -3
- data/spec/webmock_snapshot.rb +296 -0
- metadata +133 -2
data/docs/release.rst
ADDED
@@ -0,0 +1,275 @@
|
|
1
|
+
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
2
|
+
Murano CLI Ruby Gem Release Guide
|
3
|
+
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
4
|
+
|
5
|
+
####################
|
6
|
+
Gem Release Overview
|
7
|
+
####################
|
8
|
+
|
9
|
+
There are currently 3 Gems that Exosite publishes to support Murano CLI.
|
10
|
+
[Current as of 2018-08-07.]
|
11
|
+
|
12
|
+
- Murano CLI (``MuranoCLI``)
|
13
|
+
|
14
|
+
- Ruby Commander (``murano-cli-rb-commander``)
|
15
|
+
|
16
|
+
- Whirly (``murano-cli-whirly``)
|
17
|
+
|
18
|
+
You will need XXX access to each gem at http://rubygems.org to be able
|
19
|
+
to publish new versions (using ``gem push``, e.g., via ``rake release``).
|
20
|
+
|
21
|
+
##############
|
22
|
+
Ruby Gem Links
|
23
|
+
##############
|
24
|
+
|
25
|
+
==========
|
26
|
+
Murano CLI
|
27
|
+
==========
|
28
|
+
|
29
|
+
http://rubygems.org/gems/MuranoCLI
|
30
|
+
|
31
|
+
===========
|
32
|
+
Hacked Gems
|
33
|
+
===========
|
34
|
+
|
35
|
+
(lb): FIXME/2018-08-07: It's entirely possible that we could get these
|
36
|
+
changes incorporated upstream by opening Pull Requests, but I haven't
|
37
|
+
wanted to manage those conversations yet. (It's too easy to fork and publish!)
|
38
|
+
|
39
|
+
- Ruby Commander fork
|
40
|
+
|
41
|
+
http://rubygems.org/gems/murano-cli-commander
|
42
|
+
|
43
|
+
- Adds support for empty string option values,
|
44
|
+
e.g., ``--option ""``.
|
45
|
+
|
46
|
+
- Whirly fork
|
47
|
+
|
48
|
+
http://rubygems.org/gems/murano-cli-whirly
|
49
|
+
|
50
|
+
- Fixes width calculation to not count ANSI color codes. Otherwise,
|
51
|
+
too many spaces might be printed to clear the line, erroneously
|
52
|
+
creating a line break (and pushing the progress up a line, when
|
53
|
+
it should instead remain on its current line).
|
54
|
+
|
55
|
+
########################
|
56
|
+
Gem Release Instructions
|
57
|
+
########################
|
58
|
+
|
59
|
+
===================================
|
60
|
+
Murano CLI Gem Release Instructions
|
61
|
+
===================================
|
62
|
+
|
63
|
+
- Ensure tests pass.
|
64
|
+
|
65
|
+
- Bump the version, if not already done.
|
66
|
+
|
67
|
+
Manually: Open ``lib/MrMurano/version.rb``, edit, commit, push, etc.
|
68
|
+
|
69
|
+
Automated: Use a rake task to bump the version, discussed below.
|
70
|
+
|
71
|
+
- a). If you're working on a feature and want to release a pre-release
|
72
|
+
gem, you can just change the version in your branch.
|
73
|
+
|
74
|
+
Choose one of the following rake tasks to run:
|
75
|
+
|
76
|
+
.. code-block:: sh
|
77
|
+
|
78
|
+
# Increment just the beta number:
|
79
|
+
rake bump:beta
|
80
|
+
|
81
|
+
# Or, increment the patch number, and start a fresh beta version:
|
82
|
+
rake bump:patch
|
83
|
+
|
84
|
+
# Or, increment the minor number, and start a fresh patch.beta version:
|
85
|
+
rake bump:minor
|
86
|
+
|
87
|
+
# Or, increment the major number, and start a fresh minor.patch.beta version:
|
88
|
+
rake bump:major
|
89
|
+
|
90
|
+
- Incorporate the version bump in the PR for the feature on which
|
91
|
+
you're working. Once the feature in merged to develop, you can
|
92
|
+
move to step #3 and make the pre-release.
|
93
|
+
|
94
|
+
- b). If you're instead ready to prepare a real release, bump the version
|
95
|
+
on the develop branch:
|
96
|
+
|
97
|
+
.. code-block:: sh
|
98
|
+
|
99
|
+
# Or, drop the beta version, and prepare an official release:
|
100
|
+
rake bump:release
|
101
|
+
|
102
|
+
- Follow the URL printed by the rake task and open a PR for
|
103
|
+
the version bump. Approve it, merge the change, and delete
|
104
|
+
the release branch.
|
105
|
+
|
106
|
+
- Kick off the Gem release builder.
|
107
|
+
|
108
|
+
- a.) To prepare a pre-release Gem from the ``develop`` branch, run:
|
109
|
+
|
110
|
+
.. code-block:: sh
|
111
|
+
|
112
|
+
rake package:develop
|
113
|
+
|
114
|
+
- b.) To prepare an official release Gem from the ``master`` branch, run:
|
115
|
+
|
116
|
+
.. code-block:: sh
|
117
|
+
|
118
|
+
rake package:master
|
119
|
+
|
120
|
+
You'll be directed
|
121
|
+
|
122
|
+
- Copy the Gem locally, and upload it to the official Gem repository.
|
123
|
+
|
124
|
+
.. code-block:: sh
|
125
|
+
|
126
|
+
rake package:publish
|
127
|
+
|
128
|
+
Deprecated Resources
|
129
|
+
--------------------
|
130
|
+
|
131
|
+
Build project on old Jenkins server (2018-08-07: no longer used, but still alive):
|
132
|
+
|
133
|
+
https://build.exosite.com/view/MuranoCLI/job/MrMurano%20Gem%20Release/
|
134
|
+
|
135
|
+
Old Travic-CI project, from when project was public:
|
136
|
+
|
137
|
+
https://travis-ci.org/exosite/MuranoCLI
|
138
|
+
|
139
|
+
==============================================
|
140
|
+
Forked Ruby Commander Gem Release Instructions
|
141
|
+
==============================================
|
142
|
+
|
143
|
+
First, set the current version, and the version about to be released.
|
144
|
+
|
145
|
+
.. code-block:: sh
|
146
|
+
|
147
|
+
WAS_VERS='4.4.6'
|
148
|
+
CUR_VERS='4.4.10'
|
149
|
+
|
150
|
+
Next, prepare the branch, and then test, build and publish.
|
151
|
+
|
152
|
+
.. code-block:: sh
|
153
|
+
|
154
|
+
cd /exo/clients/exosite/MuranoCLIs/murano-cli-commander
|
155
|
+
git co feature/empty_arg_support
|
156
|
+
|
157
|
+
git fetch commander-rb
|
158
|
+
git rebase commander-rb/master
|
159
|
+
|
160
|
+
/bin/sed -i -r \
|
161
|
+
"s/^ VERSION = '${WAS_VERS}'.freeze$/ VERSION = '${CUR_VERS}'.freeze/" \
|
162
|
+
lib/murano-cli-commander/version.rb
|
163
|
+
git diff lib/murano-cli-commander/version.rb
|
164
|
+
|
165
|
+
git add lib/murano-cli-commander/version.rb
|
166
|
+
git ci -m "Version ${CUR_VERS}"
|
167
|
+
|
168
|
+
# If you need to delete an existing tag of the same name, try:
|
169
|
+
# git tag -d "v${CUR_VERS}"
|
170
|
+
|
171
|
+
# Tag the version. `rake release` also does this.
|
172
|
+
git tag -a "v${CUR_VERS}" -m "Version ${CUR_VERS}" feature/empty_arg_support
|
173
|
+
git push origin "v${CUR_VERS}"
|
174
|
+
|
175
|
+
# Test it.
|
176
|
+
rake spec
|
177
|
+
|
178
|
+
# Build it.
|
179
|
+
rake build
|
180
|
+
|
181
|
+
# Publish it (to Rubygems).
|
182
|
+
rake release
|
183
|
+
|
184
|
+
If you need to pull a bad release, yank it.
|
185
|
+
|
186
|
+
WARNING: You will never again be able to publish another release using the same version.
|
187
|
+
|
188
|
+
.. code-block:: sh
|
189
|
+
|
190
|
+
$ gem yank murano-cli-commander -v ${CUR_VERS}
|
191
|
+
|
192
|
+
##########################################
|
193
|
+
Troubleshooting Gem Release/Publish Issues
|
194
|
+
##########################################
|
195
|
+
|
196
|
+
===================================================================
|
197
|
+
Gem Remove / Gem Purge / Remove Release / Kill Release Instructions
|
198
|
+
===================================================================
|
199
|
+
|
200
|
+
Yank/Remove/Unpublish Gem Version
|
201
|
+
---------------------------------
|
202
|
+
|
203
|
+
You can ``gem yank <gem-name> -v <gem-vers>`` to remove a published gem.
|
204
|
+
|
205
|
+
- Delete the gem from Rubygems.org using ``gem yank``.
|
206
|
+
|
207
|
+
See below for installation instructions.
|
208
|
+
|
209
|
+
- You should also delete any corresponding archive managed by the repo,
|
210
|
+
i.e., at ``https://github.com/exosite/<gem-name>/releases``.
|
211
|
+
|
212
|
+
https://github.com/exosite/MuranoCLI/releases
|
213
|
+
|
214
|
+
https://github.com/exosite/murano-cli-commander/releases
|
215
|
+
|
216
|
+
https://github.com/exosite/murano-cli-whirly/releases
|
217
|
+
|
218
|
+
- Click the **release name** (*not the Edit button*)
|
219
|
+
and there you'll find the Delete option.
|
220
|
+
|
221
|
+
- Caveat/Beware!: You cannot republish a yanked Gem!
|
222
|
+
|
223
|
+
E.g.,
|
224
|
+
|
225
|
+
.. code-block:: sh
|
226
|
+
|
227
|
+
$ gem yank my-gem -v 1.0.0
|
228
|
+
|
229
|
+
$ rake release
|
230
|
+
# my-gem 1.0.0 built to pkg/my-gem-1.0.0.gem.
|
231
|
+
# Tag v1.1.0 has already been created.
|
232
|
+
# rake aborted!
|
233
|
+
# Pushing gem to https://rubygems.org...
|
234
|
+
# Repushing of gem versions is not allowed.
|
235
|
+
# Please use `gem yank` to remove bad gem releases.
|
236
|
+
# /home/user/.gem/ruby/2.3.3/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
|
237
|
+
# Tasks: TOP => release => release:rubygem_push
|
238
|
+
# (See full trace by running task with --trace)
|
239
|
+
|
240
|
+
Install ``gemcutter`` (``gem yank``)
|
241
|
+
------------------------------------
|
242
|
+
|
243
|
+
Prerequisites::
|
244
|
+
|
245
|
+
gem update --system
|
246
|
+
gem install gemcutter
|
247
|
+
|
248
|
+
OUTPUT::
|
249
|
+
|
250
|
+
Fetching: gemcutter-0.7.1.gem (100%)
|
251
|
+
********************************************************************************
|
252
|
+
|
253
|
+
Thanks for installing Gemcutter! You can now run:
|
254
|
+
|
255
|
+
gem push merged into RubyGems 1.3.6
|
256
|
+
gem owner merged into RubyGems 1.3.6
|
257
|
+
gem webhook register urls to be pinged when gems are pushed
|
258
|
+
gem yank remove a specific version of a gem from RubyGemgem.org
|
259
|
+
|
260
|
+
********************************************************************************
|
261
|
+
Successfully installed gemcutter-0.7.1
|
262
|
+
Parsing documentation for gemcutter-0.7.1
|
263
|
+
Installing ri documentation for gemcutter-0.7.1
|
264
|
+
Done installing documentation for gemcutter after 0 seconds
|
265
|
+
1 gem installed
|
266
|
+
|
267
|
+
Delete/Remove/Revoke Published Ruby Gem, e.g.,::
|
268
|
+
|
269
|
+
gem yank MuranoCLI -v 3.2.0
|
270
|
+
|
271
|
+
OUTPUT::
|
272
|
+
|
273
|
+
Yanking gem from https://rubygems.org...
|
274
|
+
Successfully deleted gem: MuranoCLI (3.2.0)
|
275
|
+
|
data/lib/MrMurano/Account.rb
CHANGED
@@ -16,12 +16,14 @@ module MrMurano
|
|
16
16
|
include AccountBase
|
17
17
|
include Verbose
|
18
18
|
|
19
|
-
def businesses(bid: nil, name: nil, fuzzy: nil,
|
19
|
+
def businesses(bid: nil, name: nil, fuzzy: nil, detailed: nil, networks: nil)
|
20
20
|
# Ask user for name and password, if not saved to config and password files.
|
21
21
|
login_info if user.empty?
|
22
22
|
raise 'Missing user?!' if user.empty?
|
23
23
|
|
24
24
|
MrMurano::Verbose.whirly_start 'Fetching Businesses...'
|
25
|
+
# (lb): FIXME: This endpoint should be moved to class User eventually
|
26
|
+
# (when User is finally implemented).
|
25
27
|
bizes = get('user/' + user + '/membership/')
|
26
28
|
MrMurano::Verbose.whirly_stop
|
27
29
|
return [] unless bizes.is_a?(Array) && bizes.any?
|
@@ -29,76 +31,70 @@ module MrMurano
|
|
29
31
|
# 2017-06-30: The data for each message contains a :bizid, :role, and :name.
|
30
32
|
# :role is probably generally "owner".
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
match_bid_name_fuzzy!(bizes, bid, name, fuzzy)
|
35
|
+
|
36
|
+
if detailed || networks
|
37
|
+
bizes = add_business_details(bizes, detailed: detailed, networks: networks)
|
38
|
+
end
|
39
|
+
|
40
|
+
if networks
|
41
|
+
# Sort results by network status, then name.
|
42
|
+
sort_by_networks(bizes)
|
36
43
|
else
|
37
|
-
# Sort results.
|
38
|
-
match_bid_name_fuzzy!(bizes, bid, name, fuzzy)
|
44
|
+
# Sort results by name.
|
39
45
|
bizes.sort_by!(&:name)
|
40
46
|
end
|
41
47
|
end
|
42
48
|
|
43
49
|
# ---------------------------------------------------------------------
|
44
50
|
|
45
|
-
def
|
46
|
-
# Get network information
|
47
|
-
bizes_without_network = []
|
48
|
-
bizes_unconfigured = []
|
51
|
+
def sort_by_networks(bizes)
|
49
52
|
bizes_in_network = []
|
50
|
-
|
53
|
+
bizes_unconfigured = []
|
54
|
+
bizes_without_network = []
|
51
55
|
|
52
|
-
MrMurano::Verbose.whirly_start 'Fetching Network Information...'
|
53
56
|
bizes.each do |biz|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
network_enabled = business_tier[:features][:network]
|
58
|
-
|
59
|
-
if network_enabled # Parents of business networks
|
60
|
-
add_network_info_parent!(biz, bizes_in_network, bizes_unconfigured)
|
61
|
-
else # check if the biz is a child of a network
|
62
|
-
maybe_add_network_info_child!(biz, bizes_without_network, bizes_in_network)
|
63
|
-
end
|
57
|
+
classify_business_by_network(
|
58
|
+
biz, bizes_in_network, bizes_unconfigured, bizes_without_network
|
59
|
+
)
|
64
60
|
end
|
65
|
-
MrMurano::Verbose.whirly_stop
|
66
61
|
|
67
62
|
# Assemble the master list so that confgured networks are on top, followed
|
68
63
|
# by unconfigured networks, followed by non-network businesses
|
69
|
-
all_bizes
|
70
|
-
all_bizes.concat(
|
71
|
-
all_bizes.concat(
|
64
|
+
all_bizes = []
|
65
|
+
all_bizes.concat(bizes_in_network.sort_by! { |biz| biz.meta[:network_name] })
|
66
|
+
all_bizes.concat(bizes_unconfigured.sort_by!(&:name))
|
67
|
+
all_bizes.concat(bizes_without_network.sort_by!(&:name))
|
72
68
|
end
|
73
69
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
biz[:network] = network_name
|
70
|
+
def classify_business_by_network(
|
71
|
+
biz, bizes_in_network, bizes_unconfigured, bizes_without_network
|
72
|
+
)
|
73
|
+
case biz.network_status
|
74
|
+
when :parent_configured
|
80
75
|
bizes_in_network.push(biz)
|
81
|
-
|
82
|
-
biz[:network] = '--Not configured yet--'
|
76
|
+
when :parent_unconfigured
|
83
77
|
bizes_unconfigured.push(biz)
|
78
|
+
when :child_configured
|
79
|
+
bizes_in_network.push(biz)
|
80
|
+
when :child_unconfigured
|
81
|
+
bizes_without_network.push(biz)
|
82
|
+
else
|
83
|
+
assert(false)
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
87
|
# ---------------------------------------------------------------------
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
biz
|
92
|
-
bizes_without_network.push(biz)
|
93
|
-
else
|
94
|
-
biz[:network_relationship] = 'child'
|
95
|
-
biz[:network] = owner[:network][:name]
|
96
|
-
bizes_in_network.push(biz)
|
88
|
+
|
89
|
+
def add_business_details(bizes, detailed: nil, networks: nil)
|
90
|
+
bizes.each do |biz|
|
91
|
+
biz.overview(detailed: detailed, networks: networks)
|
97
92
|
end
|
98
93
|
end
|
99
94
|
|
100
95
|
# ---------------------------------------------------------------------
|
101
|
-
|
96
|
+
|
97
|
+
# Filter Businesses (e.g., used by the `business find` command).
|
102
98
|
def match_bid_name_fuzzy!(bizes, bid, name, fuzzy)
|
103
99
|
match_bid = ensure_array(bid)
|
104
100
|
match_name = ensure_array(name)
|
@@ -109,8 +105,9 @@ module MrMurano
|
|
109
105
|
match_bid.include?(biz[:bizid]) ||
|
110
106
|
match_name.include?(biz[:name]) ||
|
111
107
|
match_fuzzy.any? do |term|
|
112
|
-
|
113
|
-
|
108
|
+
(
|
109
|
+
(biz[:name] =~ /#{Regexp.escape(term)}/i) ||
|
110
|
+
(biz[:bizid] =~ /#{Regexp.escape(term)}/i)
|
114
111
|
)
|
115
112
|
end
|
116
113
|
)
|
@@ -144,10 +141,12 @@ module MrMurano
|
|
144
141
|
# ---------------------------------------------------------------------
|
145
142
|
|
146
143
|
def new_business(name)
|
144
|
+
assert(False) # Not called.
|
147
145
|
post('business/', name: name)
|
148
146
|
end
|
149
147
|
|
150
148
|
def delete_business(id)
|
149
|
+
assert(False) # Not called.
|
151
150
|
delete("business/#{id}")
|
152
151
|
end
|
153
152
|
end
|
data/lib/MrMurano/AccountBase.rb
CHANGED
@@ -63,6 +63,7 @@ module MrMurano
|
|
63
63
|
# Do not prompt for password if using token.
|
64
64
|
if !MrMurano::HttpAuthed.instance.logging_on && $cfg['auth.scheme-token']
|
65
65
|
token = MrMurano::HttpAuthed.instance.token_resolve
|
66
|
+
# (lb): FIXME/2018-08-09: These appears to be missing a return value...!
|
66
67
|
return unless token.to_s.empty?
|
67
68
|
end
|
68
69
|
password = MrMurano::HttpAuthed.instance.password_get_or_ask(
|