geektool_kit 0.2.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 251852bdbd5bb3008b5ff05760e77f5db14bd1f9
4
+ data.tar.gz: 0b49cf671e0c61e3ed018f78c758dcb8b60873b6
5
+ SHA512:
6
+ metadata.gz: 4d47bedaeb1445a66f9a52ba2a3b0e83ee63da24ed10d55b1de53256ea3ed13102b7bc9bc0b22e11db5511179b8de76dcae9a87287e76798e4b06a126f5aadc9
7
+ data.tar.gz: 08b45cf0d855f46b90246d79d0a87365494c471766124c15503b8bb67238ac20bf5ce3ef8d61ad3312c9230e95a6dc49799cabac4b3cb581dea534d3c89add92
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in geektool_kit.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 “Rob
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # GeektoolKit
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'geektool_kit'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install geektool_kit
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/geektool_kit/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new('spec')
6
+
7
+ task :default => :spec
data/bin/geektool_kit ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'geektool_kit'
4
+ require 'thor'
5
+ require 'yaml'
6
+
7
+ class MyCLI < Thor
8
+
9
+ BASE_FOLDER = File.expand_path "~/geektool_kit"
10
+ CONFIG_FILE = File.join(BASE_FOLDER, 'config.yml')
11
+
12
+ desc "setup", "Sets up the geektool_kit folder"
13
+ def setup
14
+ Dir.mkdir BASE_FOLDER unless Dir.exists? BASE_FOLDER
15
+
16
+ settings = {}
17
+ if File.exists? CONFIG_FILE
18
+ settings = YAML::load_file(CONFIG_FILE)
19
+ end
20
+
21
+ add_default_settings settings
22
+ File.open(CONFIG_FILE, 'w') {|f| f.write settings.to_yaml }
23
+ end
24
+
25
+ no_commands do
26
+ def add_default_settings settings
27
+ defaults = {}
28
+
29
+ defaults.each {|key, value| settings[key] = value unless settings.has_key? key }
30
+ settings.delete_if { |key, value| defaults[key].nil? }
31
+ end
32
+ end
33
+ end
34
+
35
+ MyCLI.start(ARGV)
data/bin/gk_cal ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'geektool_kit'
4
+
5
+ puts GeektoolKit::Cal.display
data/bin/gk_cpu_meter ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'geektool_kit'
4
+
5
+ title = "Top CPU processes"
6
+ max_lines = 10
7
+ args = ARGV
8
+
9
+ while !args.first.nil? do
10
+ case args.first.downcase
11
+ when "-t"
12
+ title = args[1] unless args[1].nil?
13
+
14
+ when "-l"
15
+ max_lines = args[1].to_i unless args[1].nil?
16
+
17
+ else
18
+ puts "arg '#{args.first}' not recognized (value: '#{args[1]}')"
19
+ end
20
+
21
+ args = args.drop 2
22
+
23
+ end
24
+
25
+
26
+ puts "#{title}\n"
27
+ counter = 0
28
+ total = 0
29
+ GeektoolKit::CpuRecord.get_records.sort.each do |record|
30
+
31
+ break if counter == 5 || total == max_lines
32
+
33
+ puts record.create_display_text
34
+ total += 1
35
+ end
data/bin/gk_mem_meter ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'geektool_kit'
4
+
5
+ title = "Top RAM processes"
6
+ max_lines = 10
7
+ args = ARGV
8
+
9
+ while !args.first.nil? do
10
+ case args.first.downcase
11
+ when "-t"
12
+ title = args[1] unless args[1].nil?
13
+
14
+ when "-l"
15
+ max_lines = args[1].to_i unless args[1].nil?
16
+
17
+ else
18
+ puts "arg '#{args.first}' not recognized (value: '#{args[1]}')"
19
+ end
20
+
21
+ args = args.drop 2
22
+
23
+ end
24
+
25
+ puts "#{title}\n"
26
+ counter = 0
27
+ total = 0
28
+
29
+ GeektoolKit::MemRecord.get_records.sort.each do |record|
30
+
31
+ break if counter == 5 || total == max_lines
32
+
33
+ puts record.create_display_text
34
+ total += 1
35
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'geektool_kit/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "geektool_kit"
8
+ spec.version = GeektoolKit::VERSION
9
+ spec.authors = ["Rob Kitson"]
10
+ spec.email = ["robk@robkitson.net"]
11
+ spec.summary = %q{A rubygem for generating and running geeklets.}
12
+ spec.description = %q{A rubygem for generating and running geeklets.}
13
+ spec.homepage = "https://github.com/robKitson/geektool_kit"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "rspec-mocks"
25
+
26
+ spec.add_runtime_dependency "thor", ["= 0.19.1"]
27
+ end
@@ -0,0 +1,9 @@
1
+ require "geektool_kit/version"
2
+
3
+ require "geektool_kit/cal"
4
+ require "geektool_kit/colors"
5
+ require "geektool_kit/cpu_record"
6
+ require "geektool_kit/mem_record"
7
+
8
+ module GeektoolKit
9
+ end
@@ -0,0 +1,21 @@
1
+
2
+ module GeektoolKit
3
+ class Cal
4
+
5
+ def self.get_data
6
+ `cal`
7
+ end
8
+
9
+ def self.get_day
10
+ Time.now.day.to_s
11
+ end
12
+
13
+ def self.display
14
+ cal = get_data
15
+ output = ""
16
+ cal.gsub(/(?<leading>\s)(?<date>#{get_day})(?<trailing>\s)/) {|match| output = cal.gsub(match, "#{$~[:leading]}#{Colors.GREEN}#{$~[:date]}#{Colors.RESET}#{$~[:trailing]}")}
17
+ output
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,38 @@
1
+ class Colors
2
+
3
+ def self.RED
4
+ "\033[31m"
5
+ end
6
+
7
+ def self.GREEN
8
+ "\033[32m"
9
+ end
10
+
11
+ def self.YELLOW
12
+ "\033[33m"
13
+ end
14
+
15
+ def self.BLUE
16
+ "\033[34m"
17
+ end
18
+
19
+ def self.MAGENTA
20
+ "\033[35m"
21
+ end
22
+
23
+ def self.CYAN
24
+ "\033[36m"
25
+ end
26
+
27
+ def self.WHITE
28
+ "\033[37m"
29
+ end
30
+
31
+ def self.DEFAULT
32
+ "\033[0;39m"
33
+ end
34
+
35
+ def self.RESET
36
+ "\033[0m"
37
+ end
38
+ end
@@ -0,0 +1,72 @@
1
+ require 'geektool_kit/line_formatter'
2
+
3
+ module GeektoolKit
4
+ class CpuRecord
5
+ include GeektoolKit::LineFormatter
6
+
7
+ NORMAL_RANGE = 0..9
8
+ ELEVATED_RANGE = 10..19
9
+ WARNING_RANGE = 20..29
10
+ CRITICAL_RANGE = 30..200
11
+
12
+ attr_accessor :name
13
+ attr_accessor :percent
14
+
15
+ def initialize line
16
+
17
+ self.name = line[:name].strip
18
+ self.percent = line[:percent].to_f
19
+ end
20
+
21
+ def is_valid?
22
+ !self.name.nil? && !self.percent.nil?
23
+ end
24
+
25
+ def is_consequential?
26
+ !percent.nil? && percent.to_i > 1
27
+ end
28
+
29
+ def color
30
+ case percent.to_i
31
+ when NORMAL_RANGE then Colors.DEFAULT
32
+ when ELEVATED_RANGE then Colors.CYAN
33
+ when WARNING_RANGE then Colors.YELLOW
34
+ when CRITICAL_RANGE then Colors.RED
35
+ else Colors.RED
36
+ end
37
+ end
38
+
39
+ def print
40
+ puts "#{color}#{create_display_text}#{Colors.RESET}"
41
+ end
42
+
43
+ def <=> other
44
+ return other.percent <=> self.percent
45
+ end
46
+
47
+ def create_percent_display_text precision = 1
48
+ "#{"%.#{precision}f" % percent}%"
49
+ end
50
+
51
+ def create_display_text max_width = 30
52
+ create_line name, create_percent_display_text, max_width
53
+ end
54
+
55
+ def self.get_data
56
+ %x{ps -arcwwwxo "command %cpu"}
57
+ end
58
+
59
+ def self.get_records
60
+
61
+ data = self.get_data.split("\n")
62
+
63
+ records = []
64
+ data.each do |d|
65
+ matches = /(?<name>.*)\s+(?<percent>\d{1,}\.\d+)/.match(d)
66
+ records << CpuRecord.new(matches) unless matches.nil?
67
+ end
68
+
69
+ return records
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,12 @@
1
+
2
+ module GeektoolKit
3
+ module LineFormatter
4
+
5
+ def create_line left_side, right_side = "", max_width = 30
6
+
7
+ size_to_fill = max_width - 1 - right_side.size
8
+ left_side[0..size_to_fill-1].ljust(size_to_fill+1, " ") + right_side
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,61 @@
1
+ require 'geektool_kit/line_formatter'
2
+
3
+ module GeektoolKit
4
+ class MemRecord
5
+ include GeektoolKit::LineFormatter
6
+
7
+ BYTES_IN_A_MEG = 1048576
8
+
9
+ attr_accessor :name
10
+ attr_accessor :bytes
11
+
12
+ def initialize line
13
+ self.name = line[:name].strip
14
+ self.bytes = line[:bytes].to_i * 1024
15
+ end
16
+
17
+ def <=> other
18
+ return other.bytes <=> self.bytes
19
+ end
20
+
21
+ def create_memory_display_text precision = 2
22
+ get_display_value(precision) + get_display_unit
23
+ end
24
+
25
+ def create_display_text max_width = 30
26
+ create_line name, create_memory_display_text, max_width
27
+ end
28
+
29
+ def self.get_data
30
+ %x{ps -arcwwwxo "command rss" -m}
31
+ end
32
+
33
+ def self.get_records
34
+
35
+ data = self.get_data.split("\n")
36
+
37
+ records = []
38
+ data.each do |d|
39
+ matches = /(?<name>.*)\s(?<bytes>\d+)/.match(d)
40
+ records << MemRecord.new(matches) unless matches.nil?
41
+ end
42
+
43
+ return records
44
+ end
45
+
46
+
47
+ private
48
+
49
+ def get_display_unit
50
+ bytes / BYTES_IN_A_MEG >= 1024 ? "G" : "M"
51
+ end
52
+
53
+ def get_display_value precision = 2
54
+ result = bytes.to_f / BYTES_IN_A_MEG
55
+ if (result >= 1024)
56
+ result /= 1024
57
+ end
58
+ "%.#{precision}f" % result
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,3 @@
1
+ module GeektoolKit
2
+ VERSION = "0.2.0"
3
+ end
data/spec/cal_spec.rb ADDED
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ describe GeektoolKit::Cal do
4
+
5
+ before(:all) do
6
+ @plain_month = " October 2014\nSu Mo Tu We Th Fr Sa\n 1 2 3 4\n 5 6 7 8 9 10 11\n12 13 14 15 16 17 18\n19 20 21 22 23 24 25\n26 27 28 29 30 31\n\n"
7
+ end
8
+
9
+ it "should highlight the 1st when it's the 1st" do
10
+
11
+ allow(GeektoolKit::Cal).to receive(:get_data).and_return(@plain_month)
12
+ allow(GeektoolKit::Cal).to receive(:get_day).and_return(1)
13
+
14
+ output = GeektoolKit::Cal.display
15
+
16
+ expect(output).to eq " October 2014\nSu Mo Tu We Th Fr Sa\n \e[32m1\e[0m 2 3 4\n 5 6 7 8 9 10 11\n12 13 14 15 16 17 18\n19 20 21 22 23 24 25\n26 27 28 29 30 31\n\n"
17
+ end
18
+
19
+ it "should highlight the 5th when it's the 5th" do
20
+
21
+ allow(GeektoolKit::Cal).to receive(:get_data).and_return(@plain_month)
22
+ allow(GeektoolKit::Cal).to receive(:get_day).and_return(5)
23
+
24
+ output = GeektoolKit::Cal.display
25
+
26
+ expect(output).to eq " October 2014\nSu Mo Tu We Th Fr Sa\n 1 2 3 4\n \e[32m5\e[0m 6 7 8 9 10 11\n12 13 14 15 16 17 18\n19 20 21 22 23 24 25\n26 27 28 29 30 31\n\n"
27
+ end
28
+
29
+ it "should highlight the 13th when it's the 13th" do
30
+
31
+ allow(GeektoolKit::Cal).to receive(:get_data).and_return(@plain_month)
32
+ allow(GeektoolKit::Cal).to receive(:get_day).and_return(13)
33
+
34
+ output = GeektoolKit::Cal.display
35
+
36
+ expect(output).to eq " October 2014\nSu Mo Tu We Th Fr Sa\n 1 2 3 4\n 5 6 7 8 9 10 11\n12 \e[32m13\e[0m 14 15 16 17 18\n19 20 21 22 23 24 25\n26 27 28 29 30 31\n\n"
37
+ end
38
+
39
+ it "should highlight the 25th when it's the 13th" do
40
+
41
+ allow(GeektoolKit::Cal).to receive(:get_data).and_return(@plain_month)
42
+ allow(GeektoolKit::Cal).to receive(:get_day).and_return(25)
43
+
44
+ output = GeektoolKit::Cal.display
45
+
46
+ expect(output).to eq " October 2014\nSu Mo Tu We Th Fr Sa\n 1 2 3 4\n 5 6 7 8 9 10 11\n12 13 14 15 16 17 18\n19 20 21 22 23 24 \e[32m25\e[0m\n26 27 28 29 30 31\n\n"
47
+ end
48
+
49
+ it "should highlight the 31st when it's the 31st" do
50
+
51
+ allow(GeektoolKit::Cal).to receive(:get_data).and_return(@plain_month)
52
+ allow(GeektoolKit::Cal).to receive(:get_day).and_return(31)
53
+
54
+ output = GeektoolKit::Cal.display
55
+
56
+ expect(output).to eq " October 2014\nSu Mo Tu We Th Fr Sa\n 1 2 3 4\n 5 6 7 8 9 10 11\n12 13 14 15 16 17 18\n19 20 21 22 23 24 25\n26 27 28 29 30 \e[32m31\e[0m\n\n"
57
+ end
58
+ end
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ describe GeektoolKit::CpuRecord do
4
+
5
+ before(:all) do
6
+
7
+ @big_record = GeektoolKit::CpuRecord.new({name:"big process", percent:78.2})
8
+ @small_record = GeektoolKit::CpuRecord.new({name:"small proecess that has a long name", percent:1.1})
9
+ end
10
+
11
+ describe "creating records from input" do
12
+ it "should return 8 records when 8 are provided" do
13
+
14
+ output = "COMMAND %CPU\nWindowServer 13.2\nMail 11.5\nGoogle Chrome He 7.7\nSpotify 3.8\ncoreaudiod 1.8\nTerminal 1.3\nSpringBoard 1.2\ndiscoveryd 1.1\n"
15
+
16
+ allow(GeektoolKit::CpuRecord).to receive(:get_data).and_return(output)
17
+
18
+ records = GeektoolKit::CpuRecord.get_records
19
+
20
+ expect(records.count).to be 8
21
+ end
22
+
23
+ it "should return 1 records when 1 is provided" do
24
+
25
+ output = "WindowServer 13.2"
26
+
27
+ allow(GeektoolKit::CpuRecord).to receive(:get_data).and_return(output)
28
+
29
+ records = GeektoolKit::CpuRecord.get_records
30
+
31
+ expect(records.count).to be 1
32
+ expect(records[0].name).to eq "WindowServer"
33
+ expect(records[0].percent).to be 13.2
34
+ end
35
+ end
36
+
37
+ describe "sorting" do
38
+ it "should sort by number of bytes (descending)" do
39
+
40
+ list = [@small_record, @big_record]
41
+ list.sort!
42
+
43
+ expect(list.first).to be @big_record
44
+ expect(list.last).to be @small_record
45
+ end
46
+ end
47
+
48
+ describe "create_memory_display_text" do
49
+ it "should work for small record" do
50
+ expect(@small_record.create_percent_display_text).to eq "1.1%"
51
+ end
52
+
53
+ it "should work for big record" do
54
+ expect(@big_record.create_percent_display_text).to eq "78.2%"
55
+ end
56
+ end
57
+
58
+ describe "create_display_text" do
59
+ it "should work for small record" do
60
+ expect(@small_record.create_display_text).to eq "small proecess that has a 1.1%"
61
+ end
62
+
63
+ it "should work for big record" do
64
+ expect(@big_record.create_display_text).to eq "big process 78.2%"
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+
3
+ describe GeektoolKit::MemRecord do
4
+
5
+ before(:all) do
6
+
7
+ @big_record = GeektoolKit::MemRecord.new({name:"big process", bytes:2000000000/1024})
8
+ @small_record = GeektoolKit::MemRecord.new({name:"small proecess that has a long name", bytes:10000000/1024})
9
+ end
10
+
11
+ describe "creating records from input" do
12
+ it "should return 8 records when 8 are provided" do
13
+
14
+ output = "COMMAND RSS\nGoogle Chrome 119920\nSkype 101352\nGoogle Chrome He 99492\nTweetbot 88788\nEvernote 87756\nSystemUIServer 77464\nGoogle Chrome He 76056\nGoogle Chrome He 74828"
15
+
16
+ allow(GeektoolKit::MemRecord).to receive(:get_data).and_return(output)
17
+
18
+ records = GeektoolKit::MemRecord.get_records
19
+
20
+ expect(records.count).to be 8
21
+ end
22
+
23
+ it "should return 1 records when 1 is provided" do
24
+
25
+ output = "Google Chrome 119920"
26
+
27
+ allow(GeektoolKit::MemRecord).to receive(:get_data).and_return(output)
28
+
29
+ records = GeektoolKit::MemRecord.get_records
30
+
31
+ expect(records.count).to be 1
32
+ expect(records[0].name).to eq "Google Chrome"
33
+ expect(records[0].bytes).to be 122798080
34
+ end
35
+ end
36
+
37
+ describe "sorting" do
38
+ it "should sort by number of bytes (descending)" do
39
+
40
+ list = [@small_record, @big_record]
41
+ list.sort!
42
+
43
+ expect(list.first).to be @big_record
44
+ expect(list.last).to be @small_record
45
+ end
46
+ end
47
+
48
+ describe "get_unit" do
49
+ it "should return M when less than a gig" do
50
+ actual = @small_record.send(:get_display_unit)
51
+ expect(actual).to eq "M"
52
+ end
53
+
54
+ it "should return G when more than a gig" do\
55
+ actual = @big_record.send(:get_display_unit)
56
+ expect(actual).to eq "G"
57
+ end
58
+ end
59
+
60
+ describe "get_display_value" do
61
+ it "should return display value for megs" do
62
+ actual = @small_record.send(:get_display_value)
63
+ expect(actual).to eq "9.54"
64
+ end
65
+
66
+ it "should return display value for gigs" do
67
+ actual = @big_record.send(:get_display_value)
68
+ expect(actual).to eq "1.86"
69
+ end
70
+ end
71
+
72
+ describe "create_memory_display_text" do
73
+ it "should work for megs" do
74
+ expect(@small_record.create_memory_display_text).to eq "9.54M"
75
+ end
76
+
77
+ it "should work for gigs" do
78
+ expect(@big_record.create_memory_display_text).to eq "1.86G"
79
+ end
80
+ end
81
+
82
+ describe "create_display_text" do
83
+
84
+ it "should work for megs" do
85
+ expect(@small_record.create_display_text).to eq "small proecess that has 9.54M"
86
+ end
87
+
88
+ it "should work for gigs" do
89
+ expect(@big_record.create_display_text).to eq "big process 1.86G"
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ ROOT = Pathname(File.expand_path(File.join(File.dirname(__FILE__), '..')))
5
+ $LOAD_PATH << File.join(ROOT, 'lib')
6
+ $LOAD_PATH << File.join(ROOT, 'lib', 'geektool_kit')
7
+ require File.join(ROOT, 'lib', 'geektool_kit.rb')
8
+
9
+ Bundler.setup
10
+
11
+ RSpec.configure do |config|
12
+
13
+ config.color = true
14
+ config.formatter = :documentation # :progress, :html, :textmate
15
+ end
16
+
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: geektool_kit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Rob Kitson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
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: rspec-mocks
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
+ - !ruby/object:Gem::Dependency
70
+ name: thor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 0.19.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 0.19.1
83
+ description: A rubygem for generating and running geeklets.
84
+ email:
85
+ - robk@robkitson.net
86
+ executables:
87
+ - geektool_kit
88
+ - gk_cal
89
+ - gk_cpu_meter
90
+ - gk_mem_meter
91
+ extensions: []
92
+ extra_rdoc_files: []
93
+ files:
94
+ - .gitignore
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/geektool_kit
100
+ - bin/gk_cal
101
+ - bin/gk_cpu_meter
102
+ - bin/gk_mem_meter
103
+ - geektool_kit.gemspec
104
+ - lib/geektool_kit.rb
105
+ - lib/geektool_kit/cal.rb
106
+ - lib/geektool_kit/colors.rb
107
+ - lib/geektool_kit/cpu_record.rb
108
+ - lib/geektool_kit/line_formatter.rb
109
+ - lib/geektool_kit/mem_record.rb
110
+ - lib/geektool_kit/version.rb
111
+ - spec/cal_spec.rb
112
+ - spec/cpu_record_spec.rb
113
+ - spec/mem_record_spec.rb
114
+ - spec/spec_helper.rb
115
+ homepage: https://github.com/robKitson/geektool_kit
116
+ licenses:
117
+ - MIT
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.0.14
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: A rubygem for generating and running geeklets.
139
+ test_files:
140
+ - spec/cal_spec.rb
141
+ - spec/cpu_record_spec.rb
142
+ - spec/mem_record_spec.rb
143
+ - spec/spec_helper.rb