Module: Ufo::Util
- Included in:
- DSL::Helper, Destroy, Docker::Builder, Docker::Cleaner, Docker::Pusher, Ecr::Cleaner, Scale, Ship, Task, Tasks::Register
- Defined in:
- lib/ufo/util.rb
Instance Method Summary collapse
-
#default_cluster ⇒ Object
The default cluster normally defaults to the Ufo.env value.
-
#default_params ⇒ Object
Naming it default_params because params is too commonly used in ufo.
- #display_params(options) ⇒ Object
- #execute(command, local_options = {}) ⇒ Object
- #pretty_time(total_seconds) ⇒ Object
-
#settings ⇒ Object
Keys are strings for simplicity.
Instance Method Details
#default_cluster ⇒ Object
The default cluster normally defaults to the Ufo.env value. But it can be overriden by ufo/settings.yml cluster
More info: ufoships.com/docs/settings/
9 10 11 |
# File 'lib/ufo/util.rb', line 9 def default_cluster settings["cluster"] || Ufo.env end |
#default_params ⇒ Object
Naming it default_params because params is too commonly used in ufo. Param keys must be symbols for the aws-sdk calls.
20 21 22 |
# File 'lib/ufo/util.rb', line 20 def default_params @default_params ||= Param.new.data.deep_symbolize_keys end |
#display_params(options) ⇒ Object
49 50 51 |
# File 'lib/ufo/util.rb', line 49 def display_params() puts YAML.dump(.deep_stringify_keys) end |
#execute(command, local_options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ufo/util.rb', line 24 def execute(command, ={}) if @options[:noop] && ![:live] say "NOOP: #{command}" result = true # always success with no noop for specs else if [:use_system] result = system(command) else result = `#{command}` end end result end |
#pretty_time(total_seconds) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/ufo/util.rb', line 39 def pretty_time(total_seconds) minutes = (total_seconds / 60) % 60 seconds = total_seconds % 60 if total_seconds < 60 "#{seconds.to_i}s" else "#{minutes.to_i}m #{seconds.to_i}s" end end |