mem-watcher 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/mem-watcher/mem-watcher.rb +14 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d5539f142b2196064f76e7da54dde157158c5b0
|
4
|
+
data.tar.gz: 196496153213ed964b4ec88fade521e1866200cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99b25b855a8c975388c92be58ad71b24e637a53538166175189b423b279fc263d7e3ccc6e100d653fd80be4b3543e2b79ed6693db6039fef70fea5e9fa100588
|
7
|
+
data.tar.gz: d1e590660331f522b85e428acc77cb2e695d8056db5bc321d309ce173eee14bceb529e43dbbba943fb5708fab6a7e78369fd405a059cb75aab1a08f922b4854f
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
class MemWatcher
|
2
|
+
attr_accessor :memory
|
3
|
+
attr_accessor :cpu
|
2
4
|
|
3
5
|
def self.watch(args={})
|
4
6
|
new.watch(args)
|
@@ -8,10 +10,11 @@ class MemWatcher
|
|
8
10
|
return false unless correct_env?(args)
|
9
11
|
parent_view = args[:parent_view] if args[:parent_view]
|
10
12
|
parent_view ||= UIApplication.sharedApplication.delegate.window if UIApplication.sharedApplication.delegate.respond_to?(:window)
|
11
|
-
parent_view || abort("MemWatcher needs a `
|
13
|
+
parent_view || abort("MemWatcher needs a `parent_view:` view or access to the window in your AppDelegate via a `window` accessor.")
|
12
14
|
parent_view.addSubview label
|
13
|
-
|
15
|
+
print "Starting MemWatcher..."
|
14
16
|
start_watcher
|
17
|
+
puts "done."
|
15
18
|
end
|
16
19
|
|
17
20
|
private
|
@@ -23,8 +26,10 @@ class MemWatcher
|
|
23
26
|
|
24
27
|
def start_watcher
|
25
28
|
every 1 do
|
26
|
-
cpu, memory = cpu_memory
|
27
|
-
label.text = "#{memory} MB #{cpu}%"
|
29
|
+
self.cpu, self.memory = cpu_memory
|
30
|
+
label.text = "#{self.memory} MB #{self.cpu}%"
|
31
|
+
label.sizeToFit
|
32
|
+
label.superview.bringSubviewToFront(label)
|
28
33
|
end
|
29
34
|
end
|
30
35
|
|
@@ -43,9 +48,12 @@ class MemWatcher
|
|
43
48
|
|
44
49
|
def label
|
45
50
|
@label ||= begin
|
46
|
-
l = UILabel.alloc.initWithFrame([[
|
47
|
-
l.backgroundColor = UIColor.colorWithWhite(1.0, alpha:0.
|
51
|
+
l = UILabel.alloc.initWithFrame([[ 5, 20 ], [ 50, 24 ]])
|
52
|
+
l.backgroundColor = UIColor.colorWithWhite(1.0, alpha: 0.8)
|
53
|
+
l.layer.cornerRadius = 5
|
54
|
+
l.layer.masksToBounds = true
|
48
55
|
l.font = UIFont.systemFontOfSize(10.0)
|
56
|
+
l.text = "Loading..."
|
49
57
|
l.sizeToFit
|
50
58
|
l
|
51
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mem-watcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamon Holmgren
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|