iStats 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eb1369240f2072354581bb573ebdf407a0c682c8
4
+ data.tar.gz: 91c09bc2abbc4d05d7dd48df2fb9bf20c3bfaa3b
5
+ SHA512:
6
+ metadata.gz: 9dbae4ef3143f68b138e521d94d7e02f30a93729da29e166c4ea94943b53d769de7491b876155a9d826e9828c59b4603211ff5755d2a247705069bc5fd6a4a87
7
+ data.tar.gz: ed89de2bd78b55d1dc23134f6f32674445f7c3ee05f56777df299e34337bb2bed3eb94c1b1c61a0bcaf8a43e8e9bf8b6bd1b6b2871983999bcf347128819c058
data/.gitignore ADDED
@@ -0,0 +1,34 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in iStats.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ iStats (0.0.1)
5
+ sparkr
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ rake (10.2.2)
11
+ rake-compiler (0.9.2)
12
+ rake
13
+ sparkr (0.4.1)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ bundler (~> 1.3)
20
+ iStats!
21
+ rake
22
+ rake-compiler
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Christophe Naud-Dulude
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ iStats
2
+ ======
3
+
4
+ Quick attempt at writing a Ruby wrapper for a small C library that interacts with the IOKit library (apple) to get the CPU temperature.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'iStats'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install iStats
19
+
20
+ ## Usage
21
+
22
+ TODO: Write usage instructions here
23
+
24
+ ## Contributing
25
+
26
+ 1. Fork it
27
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
28
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
29
+ 4. Push to the branch (`git push origin my-new-feature`)
30
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/extensiontask'
3
+
4
+ Rake::ExtensionTask.new 'osx_stats' do |ext|
5
+ ext.lib_dir = 'lib/osx_stats'
6
+ end
data/bin/istats ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
5
+
6
+ require 'istats'
7
+
8
+ IStats::Command.execute(*ARGV)
@@ -0,0 +1,11 @@
1
+ require 'mkmf'
2
+
3
+ extension_name = 'osx_stats'
4
+
5
+ CONFIG['LDSHARED'] << ' -framework IOKit '
6
+
7
+ # The destination
8
+ dir_config(extension_name)
9
+
10
+ # Do the work
11
+ create_makefile(extension_name)
@@ -0,0 +1,191 @@
1
+ /*
2
+ * Apple System Management Control (SMC) Tool
3
+ * Copyright (C) 2006 devnull
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * as published by the Free Software Foundation; either version 2
8
+ * of the License, or (at your option) any later version.
9
+
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
+ */
19
+
20
+ #include <stdio.h>
21
+ #include <string.h>
22
+ #include <IOKit/IOKitLib.h>
23
+
24
+ #include "smc.h"
25
+
26
+ static io_connect_t conn;
27
+
28
+ UInt32 _strtoul(char *str, int size, int base)
29
+ {
30
+ UInt32 total = 0;
31
+ int i;
32
+
33
+ for (i = 0; i < size; i++)
34
+ {
35
+ if (base == 16)
36
+ total += str[i] << (size - 1 - i) * 8;
37
+ else
38
+ total += (unsigned char) (str[i] << (size - 1 - i) * 8);
39
+ }
40
+ return total;
41
+ }
42
+
43
+ void _ultostr(char *str, UInt32 val)
44
+ {
45
+ str[0] = '\0';
46
+ sprintf(str, "%c%c%c%c",
47
+ (unsigned int) val >> 24,
48
+ (unsigned int) val >> 16,
49
+ (unsigned int) val >> 8,
50
+ (unsigned int) val);
51
+ }
52
+
53
+ kern_return_t SMCOpen(void)
54
+ {
55
+ kern_return_t result;
56
+ mach_port_t masterPort;
57
+ io_iterator_t iterator;
58
+ io_object_t device;
59
+
60
+ result = IOMasterPort(MACH_PORT_NULL, &masterPort);
61
+
62
+ CFMutableDictionaryRef matchingDictionary = IOServiceMatching("AppleSMC");
63
+ result = IOServiceGetMatchingServices(masterPort, matchingDictionary, &iterator);
64
+ if (result != kIOReturnSuccess)
65
+ {
66
+ printf("Error: IOServiceGetMatchingServices() = %08x\n", result);
67
+ return 1;
68
+ }
69
+
70
+ device = IOIteratorNext(iterator);
71
+ IOObjectRelease(iterator);
72
+ if (device == 0)
73
+ {
74
+ printf("Error: no SMC found\n");
75
+ return 1;
76
+ }
77
+
78
+ result = IOServiceOpen(device, mach_task_self(), 0, &conn);
79
+ IOObjectRelease(device);
80
+ if (result != kIOReturnSuccess)
81
+ {
82
+ printf("Error: IOServiceOpen() = %08x\n", result);
83
+ return 1;
84
+ }
85
+
86
+ return kIOReturnSuccess;
87
+ }
88
+
89
+ kern_return_t SMCClose()
90
+ {
91
+ return IOServiceClose(conn);
92
+ }
93
+
94
+
95
+ kern_return_t SMCCall(int index, SMCKeyData_t *inputStructure, SMCKeyData_t *outputStructure)
96
+ {
97
+ size_t structureInputSize;
98
+ size_t structureOutputSize;
99
+
100
+ structureInputSize = sizeof(SMCKeyData_t);
101
+ structureOutputSize = sizeof(SMCKeyData_t);
102
+
103
+ #if MAC_OS_X_VERSION_10_5
104
+ return IOConnectCallStructMethod( conn, index,
105
+ // inputStructure
106
+ inputStructure, structureInputSize,
107
+ // ouputStructure
108
+ outputStructure, &structureOutputSize );
109
+ #else
110
+ return IOConnectMethodStructureIStructureO( conn, index,
111
+ structureInputSize, /* structureInputSize */
112
+ &structureOutputSize, /* structureOutputSize */
113
+ inputStructure, /* inputStructure */
114
+ outputStructure); /* ouputStructure */
115
+ #endif
116
+
117
+ }
118
+
119
+ kern_return_t SMCReadKey(UInt32Char_t key, SMCVal_t *val)
120
+ {
121
+ kern_return_t result;
122
+ SMCKeyData_t inputStructure;
123
+ SMCKeyData_t outputStructure;
124
+
125
+ memset(&inputStructure, 0, sizeof(SMCKeyData_t));
126
+ memset(&outputStructure, 0, sizeof(SMCKeyData_t));
127
+ memset(val, 0, sizeof(SMCVal_t));
128
+
129
+ inputStructure.key = _strtoul(key, 4, 16);
130
+ inputStructure.data8 = SMC_CMD_READ_KEYINFO;
131
+
132
+ result = SMCCall(KERNEL_INDEX_SMC, &inputStructure, &outputStructure);
133
+ if (result != kIOReturnSuccess)
134
+ return result;
135
+
136
+ val->dataSize = outputStructure.keyInfo.dataSize;
137
+ _ultostr(val->dataType, outputStructure.keyInfo.dataType);
138
+ inputStructure.keyInfo.dataSize = val->dataSize;
139
+ inputStructure.data8 = SMC_CMD_READ_BYTES;
140
+
141
+ result = SMCCall(KERNEL_INDEX_SMC, &inputStructure, &outputStructure);
142
+ if (result != kIOReturnSuccess)
143
+ return result;
144
+
145
+ memcpy(val->bytes, outputStructure.bytes, sizeof(outputStructure.bytes));
146
+
147
+ return kIOReturnSuccess;
148
+ }
149
+
150
+ double SMCGetTemperature(char *key)
151
+ {
152
+ SMCVal_t val;
153
+ kern_return_t result;
154
+
155
+ result = SMCReadKey(key, &val);
156
+ if (result == kIOReturnSuccess) {
157
+ // read succeeded - check returned value
158
+ if (val.dataSize > 0) {
159
+ if (strcmp(val.dataType, DATATYPE_SP78) == 0) {
160
+ // convert fp78 value to temperature
161
+ int intValue = (val.bytes[0] * 256 + val.bytes[1]) >> 2;
162
+ return intValue / 64.0;
163
+ }
164
+ }
165
+ }
166
+ // read failed
167
+ return 0.0;
168
+ }
169
+
170
+ // int main(int argc, char *argv[])
171
+ // {
172
+ // SMCOpen();
173
+ // printf("%0.1f°C\n", SMCGetTemperature(SMC_KEY_CPU_TEMP));
174
+ // SMCClose();
175
+ //
176
+ // return 0;
177
+ // }
178
+
179
+ VALUE CPU_STATS = Qnil;
180
+ void Init_osx_stats() {
181
+ CPU_STATS = rb_define_module("CPU_STATS");
182
+ rb_define_method(CPU_STATS, "get_cpu_temp", method_get_cpu_temp, 0);
183
+ }
184
+
185
+ VALUE method_get_cpu_temp(VALUE self) {
186
+ SMCOpen();
187
+ double temp = SMCGetTemperature(SMC_KEY_CPU_TEMP);
188
+ SMCClose();
189
+
190
+ return rb_float_new(temp);
191
+ }
@@ -0,0 +1,97 @@
1
+ /*
2
+ * Apple System Management Control (SMC) Tool
3
+ * Copyright (C) 2006 devnull
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * as published by the Free Software Foundation; either version 2
8
+ * of the License, or (at your option) any later version.
9
+
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
+ */
19
+
20
+ #ifndef __SMC_H__
21
+ #define __SMC_H__
22
+ #include "ruby.h"
23
+ #endif
24
+
25
+ #define VERSION "0.01"
26
+
27
+ #define KERNEL_INDEX_SMC 2
28
+
29
+ #define SMC_CMD_READ_BYTES 5
30
+ #define SMC_CMD_WRITE_BYTES 6
31
+ #define SMC_CMD_READ_INDEX 8
32
+ #define SMC_CMD_READ_KEYINFO 9
33
+ #define SMC_CMD_READ_PLIMIT 11
34
+ #define SMC_CMD_READ_VERS 12
35
+
36
+ #define DATATYPE_FPE2 "fpe2"
37
+ #define DATATYPE_UINT8 "ui8 "
38
+ #define DATATYPE_UINT16 "ui16"
39
+ #define DATATYPE_UINT32 "ui32"
40
+ #define DATATYPE_SP78 "sp78"
41
+
42
+ // key values
43
+ #define SMC_KEY_CPU_TEMP "TC0P"
44
+
45
+
46
+ typedef struct {
47
+ char major;
48
+ char minor;
49
+ char build;
50
+ char reserved[1];
51
+ UInt16 release;
52
+ } SMCKeyData_vers_t;
53
+
54
+ typedef struct {
55
+ UInt16 version;
56
+ UInt16 length;
57
+ UInt32 cpuPLimit;
58
+ UInt32 gpuPLimit;
59
+ UInt32 memPLimit;
60
+ } SMCKeyData_pLimitData_t;
61
+
62
+ typedef struct {
63
+ UInt32 dataSize;
64
+ UInt32 dataType;
65
+ char dataAttributes;
66
+ } SMCKeyData_keyInfo_t;
67
+
68
+ typedef char SMCBytes_t[32];
69
+
70
+ typedef struct {
71
+ UInt32 key;
72
+ SMCKeyData_vers_t vers;
73
+ SMCKeyData_pLimitData_t pLimitData;
74
+ SMCKeyData_keyInfo_t keyInfo;
75
+ char result;
76
+ char status;
77
+ char data8;
78
+ UInt32 data32;
79
+ SMCBytes_t bytes;
80
+ } SMCKeyData_t;
81
+
82
+ typedef char UInt32Char_t[5];
83
+
84
+ typedef struct {
85
+ UInt32Char_t key;
86
+ UInt32 dataSize;
87
+ UInt32Char_t dataType;
88
+ SMCBytes_t bytes;
89
+ } SMCVal_t;
90
+
91
+
92
+ // prototypes
93
+ void Init_osx_stats();
94
+ VALUE method_get_cpu_temp(VALUE self);
95
+ double SMCGetTemperature(char *key);
96
+ kern_return_t SMCSetFanRpm(char *key, int rpm);
97
+ int SMCGetFanRpm(char *key);
data/iStats.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ require 'rake'
3
+
4
+ lib = File.expand_path('../lib', __FILE__)
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+ require 'iStats/version'
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = "iStats"
10
+ spec.version = IStats::VERSION
11
+ spec.authors = ["Chris911"]
12
+ spec.email = ["christophe.naud.dulude@gmail.com"]
13
+ spec.description = "Stats for your mac"
14
+ spec.summary = "Stats for your mac"
15
+ spec.homepage = "https://github.com/Chris911/iStats"
16
+ spec.license = "MIT"
17
+
18
+ spec.files = `git ls-files`.split($/)
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.extensions = Rake::FileList["ext/**/extconf.rb"]
24
+
25
+ spec.add_dependency "sparkr"
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.3"
28
+ spec.add_development_dependency "rake"
29
+ spec.add_development_dependency "rake-compiler"
30
+ end
data/lib/iStats.rb ADDED
@@ -0,0 +1,18 @@
1
+ # Extensions (C libs)
2
+ require 'osx_stats/osx_stats'
3
+
4
+ # Gems
5
+ require 'optparse'
6
+ require 'sparkr'
7
+
8
+ # Internal
9
+ require 'iStats/version'
10
+ require 'iStats/color'
11
+ require 'iStats/command'
12
+ require 'iStats/cpu'
13
+
14
+ module IStats
15
+ def self.options
16
+ @options ||= {}
17
+ end
18
+ end
@@ -0,0 +1,54 @@
1
+ module IStats
2
+ # Color collects some methods for colorizing terminal output.
3
+ # Thanks to https://github.com/holman
4
+ module Color
5
+ extend self
6
+
7
+ CODES = {
8
+ :reset => "\e[0m",
9
+
10
+ :green => "\e[32m",
11
+ :light_yellow => "\e[93m",
12
+ :yellow => "\e[33m",
13
+ :red => "\e[31m",
14
+ :flash_red => "\e[31;5m"
15
+ }
16
+
17
+ # Tries to enable Windows support if on that platform.
18
+ #
19
+ # Returns nothing.
20
+ def self.included(other)
21
+ if RUBY_PLATFORM =~ /win32/ || RUBY_PLATFORM =~ /mingw32/
22
+ require 'Win32/Console/ANSI'
23
+ end
24
+ rescue LoadError
25
+ # Oh well, we tried.
26
+ end
27
+
28
+ # Wraps the given string in ANSI color codes
29
+ #
30
+ # string - The String to wrap.
31
+ # color_code - The String representing he ANSI color code
32
+ #
33
+ # Examples
34
+ #
35
+ # colorize("Boom!", :magenta)
36
+ # # => "\e[35mBoom!\e[0m"
37
+ #
38
+ # Returns the wrapped String unless the the platform is windows and
39
+ # does not have Win32::Console, in which case, returns the String.
40
+ def colorize(string, color_code)
41
+ if !defined?(Win32::Console) && !!(RUBY_PLATFORM =~ /win32/ || RUBY_PLATFORM =~ /mingw32/)
42
+ # looks like this person doesn't have Win32::Console and is on windows
43
+ # just return the uncolorized string
44
+ return string
45
+ end
46
+ "#{CODES[color_code] || color_code}#{string}#{CODES[:reset]}"
47
+ end
48
+
49
+ # Set up shortcut methods to all the codes define in CODES.
50
+ self.class_eval(CODES.keys.reject {|color| color == :reset }.map do |color|
51
+ "def #{color}(string); colorize(string, :#{color}); end"
52
+ end.join("\n"))
53
+ end
54
+ end
@@ -0,0 +1,86 @@
1
+ module IStats
2
+ # Main point of entry for `istats` command-line tool
3
+ class Command
4
+ class << self
5
+ include IStats::Color
6
+
7
+ def execute(*args)
8
+ # Default command is 'all'
9
+ category = args.empty? ? 'all' : args.shift
10
+ stat = args.empty? ? 'all' : args.shift
11
+
12
+ parse_options
13
+ delegate(category, stat)
14
+ end
15
+
16
+ def delegate(category, stat)
17
+ case category
18
+ when 'all'
19
+ all
20
+ when 'cpu'
21
+ Cpu.delegate stat
22
+ else
23
+ help("Unknown category: #{category}")
24
+ end
25
+ end
26
+
27
+ def all
28
+ # Exec all
29
+ Cpu.all
30
+ end
31
+
32
+ # Public: Parse extra options
33
+ #
34
+ # returns nothing
35
+ def parse_options
36
+ o = OptionParser.new do |opts|
37
+ opts.on('-v', '--version', 'Print Version') do
38
+ puts "iStats v#{IStats::VERSION}"
39
+ quit
40
+ end
41
+ opts.on('-h', '--help', 'Print Help') do
42
+ help
43
+ quit
44
+ end
45
+ end
46
+ begin
47
+ o.parse!
48
+ rescue OptionParser::MissingArgument => e
49
+ help e.message
50
+ quit
51
+ rescue OptionParser::InvalidOption => e
52
+ help e.message
53
+ quit
54
+ end
55
+ end
56
+
57
+ # Public: Prints help.
58
+ #
59
+ # Returns nothing.
60
+ def help(error = nil)
61
+ text =
62
+ " #{error.nil? ? '' : red("\n[Error] #{error}\n")}
63
+ - iStats: help ---------------------------------------------------
64
+
65
+ istats --help This help text
66
+ istats --version Print current version
67
+
68
+ istats all Print all stats
69
+ istats cpu Print all CPU stats
70
+ istats cpu [temp | temperature] Print CPU temperature
71
+
72
+ for more help see: https://github.com/Chris911/iStats
73
+ ".gsub(/^ {8}/, '') # strip the first eight spaces of every line
74
+
75
+ puts text
76
+ end
77
+
78
+ # Public: Quit / Exit program
79
+ #
80
+ # Returns nothing
81
+ def quit
82
+ exit(1)
83
+ end
84
+ end
85
+ end
86
+ end
data/lib/iStats/cpu.rb ADDED
@@ -0,0 +1,47 @@
1
+ module IStats
2
+ # CPU Stats
3
+ # Extend CPU_STATS C module (ext/osx_stats/smc.c)
4
+ class Cpu
5
+ extend CPU_STATS
6
+ class << self
7
+ include IStats::Color
8
+
9
+ def delegate(stat)
10
+ case stat
11
+ when 'all'
12
+ all
13
+ when 'temp', 'temperature'
14
+ cpu_temperature
15
+ else
16
+ Command.help "Unknown stat for CPU: #{stat}"
17
+ end
18
+ end
19
+
20
+ def all
21
+ cpu_temperature
22
+ end
23
+
24
+ def cpu_temperature
25
+ t = get_cpu_temp
26
+ message = "CPU temp: #{t}°C "
27
+ list = [0, 30, 55, 80, 100, 130]
28
+ sparkline = Sparkr.sparkline(list) do |tick, count, index|
29
+ if index.between?(0, 5) and t > 90
30
+ flash_red(tick)
31
+ elsif index.between?(0, 1)
32
+ green(tick)
33
+ elsif index.between?(2, 3) and t > 50
34
+ light_yellow(tick)
35
+ elsif index == 4 and t > 70
36
+ yellow(tick)
37
+ elsif index == 5 and t > 80
38
+ red(tick)
39
+ else
40
+ tick
41
+ end
42
+ end
43
+ puts message + sparkline
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ module IStats
2
+ VERSION = '0.0.1'
3
+ end
Binary file
@@ -0,0 +1,5 @@
1
+ require './osx_stats'
2
+
3
+ include CPU_STATS
4
+
5
+ puts get_cpu_temp
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: iStats
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Chris911
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sparkr
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake-compiler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Stats for your mac
70
+ email:
71
+ - christophe.naud.dulude@gmail.com
72
+ executables:
73
+ - istats
74
+ extensions:
75
+ - ext/osx_stats/extconf.rb
76
+ extra_rdoc_files: []
77
+ files:
78
+ - .gitignore
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE
82
+ - README.md
83
+ - Rakefile
84
+ - bin/istats
85
+ - ext/osx_stats/extconf.rb
86
+ - ext/osx_stats/smc.c
87
+ - ext/osx_stats/smc.h
88
+ - iStats.gemspec
89
+ - lib/iStats.rb
90
+ - lib/iStats/color.rb
91
+ - lib/iStats/command.rb
92
+ - lib/iStats/cpu.rb
93
+ - lib/iStats/version.rb
94
+ - lib/osx_stats/osx_stats.bundle
95
+ - lib/osx_stats/test.rb
96
+ homepage: https://github.com/Chris911/iStats
97
+ licenses:
98
+ - MIT
99
+ metadata: {}
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 2.0.3
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: Stats for your mac
120
+ test_files: []