Class: MrMurano::Solution
- Inherits:
-
SolutionBase
- Object
- SolutionBase
- MrMurano::Solution
- Defined in:
- lib/MrMurano/Solution.rb
Direct Known Subclasses
Constant Summary
Constants included from Verbose
Verbose::TABULARIZE_DATA_FORMAT_ERROR
Constants included from SolutionId
MrMurano::SolutionId::INVALID_API_ID, MrMurano::SolutionId::UNEXPECTED_TYPE_OR_ERROR_MSG
Constants included from AccountBase
AccountBase::LOGIN_ADVICE, AccountBase::LOGIN_NOTICE
Instance Attribute Summary collapse
-
#biz ⇒ Object
A reference to the business account object.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#name ⇒ Object
readonly
The Solution @name.
Attributes included from SolutionId
Instance Method Summary collapse
-
#cfg_key_id ⇒ Object
*** Solution utils.
- #cfg_key_name ⇒ Object
- #domain ⇒ Object
- #info ⇒ Object
- #info_safe ⇒ Object
-
#initialize(api_id = nil) ⇒ Solution
constructor
A new instance of Solution.
- #list ⇒ Object
- #log ⇒ Object
- #managed? ⇒ Boolean
- #must_not_be_managed! ⇒ Object
- #name_validate_help ⇒ Object
- #name_validate_regex ⇒ Object
- #pretty_desc(add_type: false, raw_url: false) ⇒ Object
- #quoted_name ⇒ Object
- #service ⇒ Object
-
#serviceconfig(query = nil) ⇒ Object
See also Solution-ServiceConfig.rb’s ServiceBase, which calls same endpoint.
-
#set_name(name = nil) ⇒ Object
FIXME/Rubocop/2017-07-02: Style/AccessorMethodName Rename set_name, perhaps to apply_name? rubocop:disable Style/AccessorMethodName.
-
#set_name!(name) ⇒ Object
FIXME/Rubocop/2017-07-02: Style/AccessorMethodName Or maybe no.
- #type ⇒ Object
- #type_name ⇒ Object
- #usage ⇒ Object
- #valid? ⇒ Boolean
- #valid_name? ⇒ Boolean
-
#version ⇒ Object
*** Network calls.
Methods inherited from SolutionBase
Methods included from SyncUpDown
#config_vars_decode, #config_vars_encode, #debug_print_localitems, #diff_download, #diff_item_write, #docmp, #download, #ignore?, #ignoring, #localitems, #locallist, #locallist_add_item, #locallist_complain_missing, #locallist_mark_seen, #location, #match, #remove, #remove_or_clear, #removelocal, #resolve_config_var_usage!, #resurrect_undeletables, #searchFor, #syncdown_after, #syncdown_before, #synckey, #syncup_after, #syncup_before, #to_remote_items, #tolocalname, #tolocalpath, #update_mtime, #upload
Methods included from Verbose
ask_yes_no, #ask_yes_no, #assert, assert, cmd_confirm_delete!, #cmd_confirm_delete!, debug, #debug, dump_file_json, dump_file_plain, dump_file_yaml, #dump_output_file, #error, error, #error_file_format!, fancy_ticks, #fancy_ticks, #load_file_json, #load_file_plain, #load_file_yaml, #load_input_file, outf, #outf, #outformat_engine, #pluralize?, pluralize?, #prepare_hash_csv, #read_hashf!, #tabularize, tabularize, verbose, #verbose, warning, #warning, #whirly_interject, whirly_interject, #whirly_linger, whirly_linger, #whirly_msg, whirly_msg, #whirly_pause, whirly_pause, #whirly_start, whirly_start, #whirly_stop, whirly_stop, #whirly_unpause, whirly_unpause
Methods included from SyncCore
#debug_selected, #dodiff, #dodiff_build_cmd, #dodiff_cull_tempfile_paths, #dodiff_do_diff, #dodiff_download_remote, #dodiff_flexible, #dodiff_header_aware, #dodiff_local_to_tempfile, #dodiff_prepare_local_and_diff, #dodiff_resolve_localname, #dodiff_tempfile_paths, #filter_solution, #init_mods_and_chgs_arrs, #item_dirty_set_status, #item_local_there_merged, #item_merged_diff_status, #item_merged_set_status, #item_select_selected!, #items_classify_and_find_duplicates, #items_cull_clashes!, #items_lists, #items_log_duplicates, #items_log_duplicates_there_local, #items_mods_and_chgs!, #items_new_and_old!, #select_selected!, #sort_by_name, #status, #sync_update_progress, #syncable_validate_api_id, #syncdown, #syncdown_item, #syncup, #syncup_item
Methods included from SyncAllowed
#download_item_allowed, #remove_item_allowed, #removelocal_item_allowed, #sync_item_allowed, #upload_item_allowed
Methods included from SolutionId
#affirm_valid, #api_id?, #endpoint, #init_api_id!, #valid_api_id?
Methods included from AccountBase
#add_headers, #ask_for_password!, #ask_for_user!, #cfg_clear_user_and_business, #credentials_reset, #get, #invalidate_token, #login_info, #logout, #must_prompt_if_logged_off!, #token, #token_reset, #verify_cfg_auth!, #verify_cfg_auth_persist, #verify_cfg_auth_scheme!, #verify_cfg_auth_ttl, #verify_set, warn_configfile_env_maybe
Methods included from Http
#add_headers, #curldebug, curldebug_after, curldebug_elapsed, curldebug_log, #delete, #endpoint, #get, #host, #http, #http_reset, #isJSON, #json_opts, #patch, #post, #postf, #put, #showHttpError, #user, #workit, #workit_response
Constructor Details
#initialize(api_id = nil) ⇒ Solution
Returns a new instance of Solution.
87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/MrMurano/Solution.rb', line 87 def initialize(api_id=nil) = api_id if api_id.is_a?(Hash) # TODO: Deprecate usage of solution.apiId from BizAPI, migrate to solution.sid # Bizapi is currently returning both values set to the same thing. api_id = api_id[:sid] || api_id[:api_id] || api_id[:apiId] if api_id.is_a?(Hash) super(api_id) set_name @meta = {} @valid = false self. = unless .nil? @soln_services = nil @soln_svc_cfgs = {} end |
Instance Attribute Details
#biz ⇒ Object
A reference to the business account object.
105 106 107 |
# File 'lib/MrMurano/Solution.rb', line 105 def biz @biz end |
#meta ⇒ Object
Returns the value of attribute meta.
107 108 109 |
# File 'lib/MrMurano/Solution.rb', line 107 def @meta end |
#name ⇒ Object (readonly)
The Solution @name.
102 103 104 |
# File 'lib/MrMurano/Solution.rb', line 102 def name @name end |
Instance Method Details
#cfg_key_id ⇒ Object
*** Solution utils
170 171 172 |
# File 'lib/MrMurano/Solution.rb', line 170 def cfg_key_id "#{type}.id" end |
#cfg_key_name ⇒ Object
174 175 176 |
# File 'lib/MrMurano/Solution.rb', line 174 def cfg_key_name "#{type}.name" end |
#domain ⇒ Object
221 222 223 |
# File 'lib/MrMurano/Solution.rb', line 221 def domain @meta[:domain] end |
#info ⇒ Object
124 125 126 |
# File 'lib/MrMurano/Solution.rb', line 124 def info get end |
#info_safe ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/MrMurano/Solution.rb', line 128 def info_safe @suppress_error = true resp = get if resp.is_a?(Hash) && !resp.key?(:error) self. = resp @valid_api_id = true else self. = {} @valid_api_id = false end @suppress_error = false end |
#list ⇒ Object
141 142 143 144 145 146 147 |
# File 'lib/MrMurano/Solution.rb', line 141 def list get('/') # MAYBE/2017-08-17: # ret = get('/') # return [] unless ret.is_a?(Array) # sort_by_name(ret) end |
#log ⇒ Object
153 154 155 |
# File 'lib/MrMurano/Solution.rb', line 153 def log get('/logs') end |
#managed? ⇒ Boolean
225 226 227 |
# File 'lib/MrMurano/Solution.rb', line 225 def managed? @meta[:managed] end |
#must_not_be_managed! ⇒ Object
307 308 309 310 311 |
# File 'lib/MrMurano/Solution.rb', line 307 def must_not_be_managed! return unless managed? error 'Specified command cannot be run against managed solution.' exit 1 end |
#name_validate_help ⇒ Object
303 304 305 |
# File 'lib/MrMurano/Solution.rb', line 303 def name_validate_help '' end |
#name_validate_regex ⇒ Object
299 300 301 |
# File 'lib/MrMurano/Solution.rb', line 299 def name_validate_regex /^$/ end |
#pretty_desc(add_type: false, raw_url: false) ⇒ Object
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/MrMurano/Solution.rb', line 229 def pretty_desc(add_type: false, raw_url: false) # [lb] would normally put presentation code elsewhere (i.e., model # classes should not be formatting output), but this seems okay. desc = '' desc += "#{type.to_s.capitalize}: " if add_type name = !self.name.empty? && self.name || '~Unnamed~' api_id = !self.api_id.empty? && self.api_id || '~No-ID~' desc += "#{Rainbow(name).underline} <#{api_id}>" if domain desc += ' ' desc += 'https://' unless raw_url desc += domain end desc end |
#quoted_name ⇒ Object
283 284 285 286 287 288 289 |
# File 'lib/MrMurano/Solution.rb', line 283 def quoted_name if @name.to_s.empty? '' else fancy_ticks(@name) end end |
#service ⇒ Object
157 158 159 160 |
# File 'lib/MrMurano/Solution.rb', line 157 def service return @soln_services unless @soln_services.nil? @soln_services = get('/service') end |
#serviceconfig(query = nil) ⇒ Object
See also Solution-ServiceConfig.rb’s ServiceBase, which calls same endpoint.
163 164 165 166 |
# File 'lib/MrMurano/Solution.rb', line 163 def serviceconfig(query=nil) return @soln_svc_cfgs[query] unless @soln_svc_cfgs[query].nil? @soln_svc_cfgs[query] = get('/serviceconfig', query) end |
#set_name(name = nil) ⇒ Object
FIXME/Rubocop/2017-07-02: Style/AccessorMethodName
Rename set_name, perhaps to apply_name?
rubocop:disable Style/AccessorMethodName
261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/MrMurano/Solution.rb', line 261 def set_name(name=nil) # Use duck typing instead of `is_a? String` to be more duck-like. if name.respond_to?(:to_str) && name != '' @name = name # FIXME/Rubocop/2017-07-02: Double-negation @valid_name = !@name.match(name_validate_regex).nil? else @name = '' @valid_name = false end end |
#set_name!(name) ⇒ Object
FIXME/Rubocop/2017-07-02: Style/AccessorMethodName
Or maybe no. Cannot create method `def name!=(name)` and I [lb]
kinda like the bang!. You could call it apply_name!, perhaps.
276 277 278 279 280 281 |
# File 'lib/MrMurano/Solution.rb', line 276 def set_name!(name) raise 'Expecting name, not nothing' unless name && name != '' raise MrMurano::ConfigError.new(name_validate_help) unless name.match(name_validate_regex) @name = name @valid_name = true end |
#type ⇒ Object
245 246 247 248 249 250 251 252 |
# File 'lib/MrMurano/Solution.rb', line 245 def type # info() doesn't return :type. So get from class name, e.g., # if soln.class == 'MrMurano::Product', type is :product. #self.class.to_s.gsub(/^.*::/, '') #raise 'Not implemented' # Return, e.g., :application or :product. self.class.to_s.gsub(/^.*::/, '').downcase.to_sym end |
#type_name ⇒ Object
254 255 256 |
# File 'lib/MrMurano/Solution.rb', line 254 def type_name type.to_s.capitalize end |
#usage ⇒ Object
149 150 151 |
# File 'lib/MrMurano/Solution.rb', line 149 def usage get('/usage') end |
#valid? ⇒ Boolean
291 292 293 |
# File 'lib/MrMurano/Solution.rb', line 291 def valid? @valid_api_id && @valid_name end |
#valid_name? ⇒ Boolean
295 296 297 |
# File 'lib/MrMurano/Solution.rb', line 295 def valid_name? @valid_name end |
#version ⇒ Object
*** Network calls
120 121 122 |
# File 'lib/MrMurano/Solution.rb', line 120 def version get('/version') end |