Sha256: 487aa13e343590da8a21ba27eab48205494e8308c7fdf2c1efede5dbd6fe6364

Contents?: true

Size: 1.23 KB

Versions: 9

Compression:

Stored size: 1.23 KB

Contents

module KPM
  module SystemProxy
    module EntropyAvailable
      class << self

        def fetch
          entropy_available = nil
          if OS.windows?
            entropy_available = fetch_windows
          elsif OS.linux?
            entropy_available = fetch_linux
          elsif OS.mac?
            entropy_available = fetch_mac
          end

          entropy_available
        end

        def get_labels
          labels = [{:label => :entropy},
                    {:label => :value}]
          labels
        end

        private
          def fetch_linux
            entropy_available_data = `cat /proc/sys/kernel/random/entropy_avail 2>&1`.gsub("\n",'')
            entropy_available = get_hash(entropy_available_data)
            entropy_available
          end

          def fetch_mac
            entropy_available = get_hash('-')
            entropy_available
          end

          def fetch_windows
            entropy_available = get_hash('-')
            entropy_available
          end

          def get_hash(data)
            entropy_available = Hash.new
            entropy_available['entropy_available'] = {:entropy => 'available', :value => data}

            entropy_available
          end

      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
kpm-0.7.2 lib/kpm/system_helpers/entropy_available.rb
kpm-0.7.1 lib/kpm/system_helpers/entropy_available.rb
kpm-0.7.0 lib/kpm/system_helpers/entropy_available.rb
kpm-0.6.5 lib/kpm/system_helpers/entropy_available.rb
kpm-0.6.4 lib/kpm/system_helpers/entropy_available.rb
kpm-0.6.3 lib/kpm/system_helpers/entropy_available.rb
kpm-0.6.2 lib/kpm/system_helpers/entropy_available.rb
kpm-0.6.1 lib/kpm/system_helpers/entropy_available.rb
kpm-0.6.0 lib/kpm/system_helpers/entropy_available.rb