host 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,6 +31,12 @@ module Host
31
31
  @info[TOTAL_PROCESSES]
32
32
  end
33
33
 
34
+ # Refreshes your load average information, reading from +/proc/loadavg+
35
+ # once again
36
+ def refresh
37
+ get_loadinfo
38
+ end
39
+
34
40
 
35
41
  private
36
42
 
@@ -11,22 +11,33 @@ module Host
11
11
 
12
12
  # Just sugar. Equivalent to Host::Memory.get('MemTotal') with
13
13
  # implicit transformation to integer (in kB)
14
- def total
14
+ # You can pass it a boolean option. If +true+, information will be
15
+ # reloaded. Defaults to +false+. Equivalent to:
16
+ # Host::Memory.refresh.total
17
+ def total(refresh=false)
18
+ get_meminfo if refresh
15
19
  as_integer @info[:MemTotal]
16
20
  end
17
21
 
18
22
  # Sugar. Equivalent to Host::Memory.get('MemFree') with implicit
19
- # transformation to integer (in kB)
20
- def free
23
+ # transformation to integer (in kB).
24
+ def free(refresh=false)
25
+ get_meminfo if refresh
21
26
  as_integer @info[:MemFree]
22
27
  end
23
28
 
24
29
  # Sugar. Equivalent to Host::Memory.get('Buffers') with implicit
25
30
  # transformation to integer (in kB)
26
- def buffers
31
+ def buffers(refresh=false)
32
+ get_meminfo if refresh
27
33
  as_integer @info[:Buffers]
28
34
  end
29
35
 
36
+ # Refreshes your memory information, reading +/proc/meminfo+ once again
37
+ def refresh
38
+ get_meminfo
39
+ end
40
+
30
41
  # Retrieves specific information for the given key (as some exotic
31
42
  # information in +/proc/meminfo+, for instance).
32
43
  def get(key)
@@ -53,6 +53,12 @@ module Host
53
53
  @current_core && @current_core[key.to_sym]
54
54
  end
55
55
 
56
+ # Refreshes your processor information, reading from +/proc/cpuinfo+ once
57
+ # again
58
+ def refresh
59
+ get_cpuinfo
60
+ end
61
+
56
62
  private
57
63
 
58
64
  # Opens +/proc/cpuinfo+ and parses it, filling the info hash
data/lib/host/memory.rb CHANGED
@@ -15,8 +15,8 @@ module Host
15
15
  #
16
16
  # Example usage:
17
17
  #
18
- # Host::Memory.total #=> "4023256 kB"
19
- # Host::Memory.free #=> "2115874 kB"
18
+ # Host::Memory.total #=> 4023256
19
+ # Host::Memory.free #=> 2115874
20
20
  # # For specific information (as in +/proc/meminfo+ for instance),
21
21
  # # you can use the +get+ method
22
22
  # Host::Memory.get('KernelStack') #=> "1080 kB"
data/lib/host/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Host
4
4
 
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
 
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: host
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-11-17 00:00:00.000000000 Z
14
+ date: 2011-11-20 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: ! " Host is a symple library for accessing your host system information
17
17
  in runtime.\n It allows you to get CPU and memory usage, the load average and
@@ -63,7 +63,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
63
  version: '0'
64
64
  segments:
65
65
  - 0
66
- hash: -218894262273159718
66
+ hash: -699765582844184843
67
67
  required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  none: false
69
69
  requirements: