Top Level Namespace

Defined Under Namespace

Modules: ChangedRpmFilesHelper, Machinery Classes: AnalyzeConfigFileDiffsTask, Autoyast, BuildTask, Cli, CompareTask, ConfigBase, ConfigTask, CopyTask, CurrentUser, DeployTask, ElementFilter, ExportTask, Exporter, FileValidator, Filter, FilterOptionParser, GenerateHtmlTask, Hint, Html, InspectTask, Inspector, JsonValidationErrorCleaner, JsonValidator, KiwiConfig, ListTask, LocalSystem, LoggedCheetah, Manifest, Migration, MountPoints, RemoteSystem, RemoveTask, Renderer, Rpm, ScopeFileStore, ShowTask, System, SystemDescription, SystemDescriptionMemoryStore, SystemDescriptionStore, Tarball, UpgradeFormatTask, ValidateTask, Zypper

Instance Method Summary collapse

Instance Method Details

#number_to_human_size(s) ⇒ Object

Copyright © 2013-2015 SUSE LLC

This program is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, contact SUSE LLC.

To contact SUSE about this file by physical or electronic mail, you may find current contact information at www.suse.com



18
19
20
21
22
23
24
25
26
# File 'lib/renderer_helper.rb', line 18

def number_to_human_size(s)
  unit = %W(B KiB MiB GiB TiB)
  i = s.to_i

  exp = i != 0 ? Math.log(i, 1024).floor : 0
  value = (i / 1024.0 ** exp).round(1)

  "#{"%g" % value} #{unit[exp]}"
end

#with_c_locale(&block) ⇒ Object



24
25
26
# File 'lib/helper.rb', line 24

def with_c_locale(&block)
  with_env "LC_ALL" => "C", &block
end

#with_env(env) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/helper.rb', line 28

def with_env(env)
  # ENV isn't a Hash, but a weird Hash-like object. Calling #to_hash on it
  # will copy its items into a newly created Hash instance. This approach
  # ensures that any modifications of ENV won't affect the stored value.
  saved_env = ENV.to_hash
  begin
    ENV.replace(saved_env.merge(env))
    yield
  ensure
    ENV.replace(saved_env)
  end
end