iStats 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4a03b4b826a3677a7d9a4cfe1a2e4cb4d82a5be
4
- data.tar.gz: 9b75eaf35c248fce0c9d1edcc36e9ed1735bab05
3
+ metadata.gz: f6d54c5c804c54fed0d04f31076a0aaa8ba12dfe
4
+ data.tar.gz: 622027f040ac6ae403c3d1001701a75e8732c9dd
5
5
  SHA512:
6
- metadata.gz: d412be9240b14e9c977e0490b480a44d5dfcb2d3b1301b70db1025d80e1f67f31b2b1682757eaf369d09e3fe94fcb70b78e9dd17c66e3f81ce7e42279fcfa54c
7
- data.tar.gz: 2865be544f5d2202e2dedc54acf8de8fefb908e5fc36a2ff7ff9dc9fab0b83c8bf8bd4e533238b9caa972d2257619fca07621da17d085d4ff520d6e255040f6e
6
+ metadata.gz: 74ffa8f9e3b78f50e6fcb767ead6f877ef1c133ba1c7822b56541d5b19700797f2f3227879ec75b1871c6f1aa10ed0754ba65d75cb668023d8c24876406689b5
7
+ data.tar.gz: 69c8d8d52003bfa4432765e59390c71f619d55336cc266fe65a4cc51515b31bf959a982de37092e022ef16cc2e5aeb92b4f5385c9fbd88e650eba9b6e7279014
data/README.md CHANGED
@@ -23,27 +23,32 @@ If you are running an older version of OS X and the install fails you might want
23
23
  ```
24
24
  - iStats: help ---------------------------------------------------
25
25
 
26
- istats --help This help text
27
- istats --version Print current version
28
-
29
- istats all Print all stats
30
- istats cpu Print all CPU stats
31
- istats cpu [temp | temperature] Print CPU temperature
32
- istats fan Print all fan stats
33
- istats fan [speed] Print fan speed
34
- istats battery Print all battery stats
35
- istats battery [health] Print battery health
36
- istats battery [cycle_count | cc] Print battery cycle count info
37
- istats battery [temp | temperature] Print battery temperature
38
- istats battery [time | remain] Print battery time remaining
39
- istats battery [charge] Print battery charge
40
- istats battery [capacity] Print battery capacity info
41
-
42
- istats scan Scans and print temperatures
43
- istats scan [key] Print single SMC temperature key
44
- istats enable [key | all] Enables key
45
- istats disable [key | all] Disable key
46
- istats list List available keys
26
+ istats --help This help text
27
+ istats --version Print current version
28
+
29
+ # Commands
30
+ istats all Print all stats
31
+ istats cpu Print all CPU stats
32
+ istats cpu [temp | temperature] Print CPU temperature
33
+ istats fan Print all fan stats
34
+ istats fan [speed] Print fan speed
35
+ istats battery Print all battery stats
36
+ istats battery [health] Print battery health
37
+ istats battery [time | remain] Print battery time remaining
38
+ istats battery [cycle_count | cc] Print battery cycle count info
39
+ istats battery [temp | temperature] Print battery temperature
40
+ istats battery [charge] Print battery charge
41
+ istats battery [capacity] Print battery capacity info
42
+
43
+ istats scan Scans and print temperatures
44
+ istats scan [key] Print single SMC temperature key
45
+ istats enable [key | all] Enables key
46
+ istats disable [key | all] Disable key
47
+ istats list List available keys
48
+
49
+ # Arguments
50
+ --no-graphs Don't display sparklines graphs
51
+ -f, --fahrenheit Display temperatures in fahrenheit
47
52
 
48
53
  for more help see: https://github.com/Chris911/iStats
49
54
  ```
@@ -17,6 +17,7 @@ require 'iStats/battery'
17
17
  require 'iStats/extra'
18
18
  require 'iStats/smc'
19
19
  require 'iStats/settings'
20
+ require 'iStats/utils'
20
21
 
21
22
  module IStats
22
23
  def self.options
@@ -99,7 +99,7 @@ module IStats
99
99
  # Get the battery temperature
100
100
  #
101
101
  def battery_temperature
102
- puts "Battery temp: #{get_battery_temp.round(2)}#{Symbols.degree}C "
102
+ puts "Battery temp: #{Printer.format_temperature(get_battery_temp)} "
103
103
  end
104
104
 
105
105
  # Get the battery health
@@ -26,6 +26,7 @@ module IStats
26
26
  #
27
27
  def setup(options)
28
28
  Printer.disable_graphs unless options[:display_graphs]
29
+ Printer.set_temperature_scale options[:temperature_scale]
29
30
  end
30
31
 
31
32
  # Delegate command to proper class
@@ -81,7 +82,7 @@ module IStats
81
82
  #
82
83
  # returns nothing
83
84
  def parse_options
84
- options = {:display_graphs => true}
85
+ options = {:display_graphs => true, :temperature_scale => 'celcius'}
85
86
 
86
87
  opt_parser = OptionParser.new do |opts|
87
88
  opts.on('-v', '--version', 'Print Version') do
@@ -97,6 +98,10 @@ module IStats
97
98
  opts.on('--no-graphs', 'Don\'t display graphs') do
98
99
  options[:display_graphs] = false
99
100
  end
101
+
102
+ opts.on('-f', '--fahrenheit', 'Display temperatures in fahrenheit') do
103
+ options[:temperature_scale] = 'fahrenheit'
104
+ end
100
105
  end
101
106
 
102
107
  begin
@@ -144,6 +149,7 @@ module IStats
144
149
 
145
150
  # Arguments
146
151
  --no-graphs Don't display sparklines graphs
152
+ -f, --fahrenheit Display temperatures in fahrenheit
147
153
 
148
154
  for more help see: https://github.com/Chris911/iStats
149
155
  ".gsub(/^ {8}/, '') # strip the first eight spaces of every line
@@ -30,7 +30,7 @@ module IStats
30
30
  def cpu_temperature
31
31
  t = get_cpu_temp
32
32
  thresholds = [50, 68, 80, 90]
33
- puts "CPU temp: #{t}#{Symbols.degree}C " + Printer.gen_sparkline(t, thresholds)
33
+ puts "CPU temp: #{Printer.format_temperature(t)} #{Printer.gen_sparkline(t, thresholds)}"
34
34
  end
35
35
  end
36
36
  end
@@ -46,14 +46,14 @@ module IStats
46
46
  end
47
47
  end
48
48
 
49
- # Pretty print sensor tempaerature
49
+ # Pretty print sensor temperature
50
50
  def display_temp(key, sensor, display)
51
51
  t = SMC.is_key_supported(key).round(2);
52
52
  thresholds = sensor['thresholds'][1..-2].split(/, /).map { |s| s.to_i }
53
53
  if (display)
54
- puts "#{key} #{t}#{Symbols.degree}C \t" + Printer.gen_sparkline(t, thresholds) + " #{sensor['name']}"
54
+ puts "#{key} #{Printer.format_temperature(t)} \t#{Printer.gen_sparkline(t, thresholds)} #{sensor['name']}"
55
55
  else
56
- puts "#{key} #{sensor['name']} temp: #{t}#{Symbols.degree}C " + Printer.gen_sparkline(t, thresholds)
56
+ puts "#{key} #{sensor['name']} temp: #{Printer.format_temperature(t)} #{Printer.gen_sparkline(t, thresholds)}"
57
57
  end
58
58
  end
59
59
  end
@@ -1,6 +1,7 @@
1
1
  module IStats
2
2
  class Printer
3
3
  @display_graphs = true
4
+ @temperature_scale = 'celcius'
4
5
 
5
6
  class << self
6
7
  include IStats::Color
@@ -9,6 +10,10 @@ module IStats
9
10
  @display_graphs = false
10
11
  end
11
12
 
13
+ def set_temperature_scale(scale)
14
+ @temperature_scale = scale
15
+ end
16
+
12
17
  # Create colored sparkline
13
18
  # value - The stat value
14
19
  # thresholds - must be an array of size 4 containing the threshold values
@@ -37,6 +42,18 @@ module IStats
37
42
  end
38
43
  end
39
44
  end
45
+
46
+ # Pretty print temperature values.
47
+ # Also converts the value to the class temperature_scale.
48
+ #
49
+ # Returns the temperature string.
50
+ def format_temperature(temperature)
51
+ if @temperature_scale == 'celcius'
52
+ "#{temperature.round(2)}#{Symbols.degree}C"
53
+ else
54
+ "#{Utils.to_fahrenheit(temperature).round(2)}#{Symbols.degree}F"
55
+ end
56
+ end
40
57
  end
41
58
  end
42
59
  end
@@ -112,7 +112,7 @@ module IStats
112
112
 
113
113
  Settings.addSensor(key, sensors)
114
114
 
115
- puts "#{key} #{sensors['name']} #{t}#{Symbols.degree}C " + Printer.gen_sparkline(t, sensors['thresholds'])
115
+ puts "#{key} #{sensors['name']} #{Printer.format_temperature(t)} #{Printer.gen_sparkline(t, sensors['thresholds'])}"
116
116
  end
117
117
  }
118
118
  }
@@ -0,0 +1,12 @@
1
+ module IStats
2
+ module Utils
3
+ extend self
4
+
5
+ # Converts a temperature value in celcius to fahrenheit.
6
+ #
7
+ # Returns the temperature in fahrenheit.
8
+ def to_fahrenheit(temperature)
9
+ (temperature * (9.0 / 5.0)) + 32
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module IStats
2
- VERSION = '1.3.0'
2
+ VERSION = '1.4.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iStats
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris911
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-10 00:00:00.000000000 Z
11
+ date: 2016-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sparkr
@@ -111,6 +111,7 @@ files:
111
111
  - lib/iStats/settings.rb
112
112
  - lib/iStats/smc.rb
113
113
  - lib/iStats/symbols.rb
114
+ - lib/iStats/utils.rb
114
115
  - lib/iStats/version.rb
115
116
  homepage: https://github.com/Chris911/iStats
116
117
  licenses: