Class: StackatoApplicationInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/conan/stackato.rb

Instance Method Summary collapse

Constructor Details

#initialize(list_json, base_name, active_urls, inactive_urls, options) ⇒ StackatoApplicationInfo

Returns a new instance of StackatoApplicationInfo.



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/conan/stackato.rb', line 211

def initialize(list_json, base_name, active_urls, inactive_urls, options)
  app_list = JSON.parse(list_json)

  active_app_names = []
  inactive_app_names = []

  app_list.each do |app_hash|
    if !(app_hash.has_key? 'name' and app_hash.has_key? 'uris')
      raise "Stackato list json is malformed: " + list_json
    end

    app_name = app_hash['name']
    app_uris = app_hash['uris']

    if app_name.start_with? base_name
      if app_uris.sort == active_urls.sort
        active_app_names << app_name
      elsif app_uris.sort == inactive_urls.sort
        inactive_app_names << app_name
      else
        unless options[:stfu]
          raise "Stackato app '#{app_name}' needs to be mapped exclusively to either the active or inactive set of URLs. Please reconcile before continuing."
        end
      end
    end
  end

  if active_app_names.length > 1
    raise "More than one app is mapped to the active URL(s). Please reconcile before continuing."
  end
  if inactive_app_names.length > 1
    raise "More than one app is mapped to the inactive URL(s). Please reconcile before continuing."
  end

  # These will be set to nil if no app is found, which is OK
  @active_app_name = active_app_names.first
  @inactive_app_name = inactive_app_names.first
end

Instance Method Details

#active_app_nameObject



250
251
252
# File 'lib/conan/stackato.rb', line 250

def active_app_name
  @active_app_name
end

#inactive_app_nameObject



254
255
256
# File 'lib/conan/stackato.rb', line 254

def inactive_app_name
  @inactive_app_name
end