Sha256: 3ff9be73e988739cd3f3f32318b885b084ebc947a600c42fe563822888584483

Contents?: true

Size: 753 Bytes

Versions: 11

Compression:

Stored size: 753 Bytes

Contents

module Ufo
  module Util
    def execute(command, local_options={})
      if @options[:noop] && !local_options[:live]
        say "NOOP: #{command}"
        result = true # always success with no noop for specs
      else
        if local_options[:use_system]
          result = system(command)
        else
          result = `#{command}`
        end
      end
      result
    end

    # http://stackoverflow.com/questions/4175733/convert-duration-to-hoursminutesseconds-or-similar-in-rails-3-or-ruby
    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
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ufo-3.3.2 lib/ufo/util.rb
ufo-3.3.1 lib/ufo/util.rb
ufo-3.3.0 lib/ufo/util.rb
ufo-3.2.2 lib/ufo/util.rb
ufo-3.2.1 lib/ufo/util.rb
ufo-3.2.0 lib/ufo/util.rb
ufo-3.1.2 lib/ufo/util.rb
ufo-3.1.1 lib/ufo/util.rb
ufo-3.1.0 lib/ufo/util.rb
ufo-3.0.1 lib/ufo/util.rb
ufo-3.0.0 lib/ufo/util.rb