Sha256: 63d80f5d821373e4c7cf2ead4a5d9e8ac2326ea127e35dd14971d442ce1c46d9

Contents?: true

Size: 1.18 KB

Versions: 114

Compression:

Stored size: 1.18 KB

Contents

module CF::App
  module Sync
    def apply_changes(app)
      app.memory = megabytes(input[:memory]) if input.has?(:memory)
      app.total_instances = input[:instances] if input.has?(:instances)
      app.command = input[:command] if input.has?(:command)
      app.buildpack = input[:buildpack] if input.has?(:buildpack)
    end

    def display_changes(app)
      return unless app.changed?

      line "Changes:"

      indented do
        app.changes.each do |attr, (old, new)|
          line "#{c(attr, :name)}: #{diff_str(attr, old)} -> #{diff_str(attr, new)}"
        end
      end
    end

    def commit_changes(app)
      if app.changed?
        with_progress("Updating #{c(app.name, :name)}") do
          wrap_message_format_errors do
            app.update!
          end
        end
      end

      if input[:restart] && app.started?
        invoke :restart, :app => app
      end
    end

    private

    def diff_str(attr, val)
      case attr
      when :memory
        human_mb(val)
      when :command, :buildpack
        "'#{val}'"
      else
        val
      end
    end

    def bool(b)
      if b
        c("true", :yes)
      else
        c("false", :no)
      end
    end
  end
end

Version data entries

114 entries across 114 versions & 2 rubygems

Version Path
cf-5.4.7 lib/cf/cli/app/push/sync.rb
cf-5.4.7.rc1 lib/cf/cli/app/push/sync.rb
cf-5.4.5 lib/cf/cli/app/push/sync.rb
cf-5.4.4 lib/cf/cli/app/push/sync.rb
trucker-cli-0.0.3 lib/cf/cli/app/push/sync.rb
cf-5.4.3 lib/cf/cli/app/push/sync.rb
cf-5.4.2 lib/cf/cli/app/push/sync.rb
trucker-cli-0.0.2 lib/cf/cli/app/push/sync.rb
trucker-cli-0.0.1 lib/cf/cli/app/push/sync.rb
cf-5.4.1 lib/cf/cli/app/push/sync.rb
cf-5.4.1.rc1 lib/cf/cli/app/push/sync.rb
cf-5.4.0 lib/cf/cli/app/push/sync.rb
cf-5.3.1 lib/cf/cli/app/push/sync.rb
cf-5.3.0 lib/cf/cli/app/push/sync.rb
cf-5.2.2 lib/cf/cli/app/push/sync.rb
cf-5.2.1.rc15 lib/cf/cli/app/push/sync.rb
cf-5.2.1.rc14 lib/cf/cli/app/push/sync.rb
cf-5.2.1.rc13 lib/cf/cli/app/push/sync.rb
cf-5.2.1.rc12 lib/cf/cli/app/push/sync.rb
cf-5.2.1.rc11 lib/cf/cli/app/push/sync.rb