Sha256: 6e7527b31f5abe8cc5504d81f67d16e1170a4c72598dac823734a28f80d836f2

Contents?: true

Size: 1.33 KB

Versions: 37

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

class ProjectService
  class << self
    def describe_project(project, output_format)
      json_format?(output_format) ? output_in_json(project) : output_in_pretty_format(project)
    end

    def select_active_deployments(project)
      project[:deployments].select { |deployment| deployment[:state] == 'active' }
    end

    private

    def json_format?(output_format)
      output_format == 'json'
    end

    def output_in_json(data)
      Uffizzi.ui.say(data.to_json)
    end

    def output_in_pretty_format(project)
      Uffizzi.ui.say("Project name: #{project[:name]}")
      Uffizzi.ui.say("Project slug: #{project[:slug]}")
      Uffizzi.ui.say("Description: #{project[:description]}".strip)
      Uffizzi.ui.say("Account name: #{project[:account][:name]}".strip)
      Uffizzi.ui.say("Created: #{project[:created_at]}")
      default_compose = project[:default_compose].nil? ? nil : project[:default_compose][:source]
      Uffizzi.ui.say("Default compose: #{default_compose}".strip)
      Uffizzi.ui.say('Previews:')
      project[:deployments].each do |deployment|
        Uffizzi.ui.say("  - deployment-#{deployment[:id]} (https://#{deployment[:preview_url]})")
      end
      Uffizzi.ui.say('Secrets:')
      project[:secrets].each do |secret|
        Uffizzi.ui.say("  - #{secret}")
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
uffizzi-cli-2.4.11 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.4.10 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.4.9 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.4.8 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.4.7 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.4.6 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.4.5 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.4.4 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.4.3 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.4.2 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.4.1 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.4.0 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.3.4 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.3.3 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.3.2 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.3.1 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.3.0 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.2.2 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.2.1 lib/uffizzi/services/project_service.rb
uffizzi-cli-2.2.0 lib/uffizzi/services/project_service.rb