mem-watcher 0.1.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 713b8aaab622178d7c8f41b764d94891474d9de5
4
- data.tar.gz: d90f43a695d928bee081471b91190529e6ea8116
3
+ metadata.gz: 1d5539f142b2196064f76e7da54dde157158c5b0
4
+ data.tar.gz: 196496153213ed964b4ec88fade521e1866200cf
5
5
  SHA512:
6
- metadata.gz: 076d7bfdd6b6ca6e4a2cf7f0cad48a115ddd8132886abf14ea77a1afb6501056bfae845243e15f578800ea27d2a9940ea66f2257108111cead65da8c5fc78ded
7
- data.tar.gz: 2c96a3f2d67bd535bd3ec5cbba0aa0335d550b43d239c4a8594de1e3b83e8e3c8e5db0eb972056ddfebdf97067e7b4d6d72b78423ae91000a074817ebca6a67e
6
+ metadata.gz: 99b25b855a8c975388c92be58ad71b24e637a53538166175189b423b279fc263d7e3ccc6e100d653fd80be4b3543e2b79ed6693db6039fef70fea5e9fa100588
7
+ data.tar.gz: d1e590660331f522b85e428acc77cb2e695d8056db5bc321d309ce173eee14bceb529e43dbbba943fb5708fab6a7e78369fd405a059cb75aab1a08f922b4854f
data/README.md CHANGED
@@ -31,7 +31,7 @@ MemWatcher.watch(env: [ "development", "test" ])
31
31
  If you want to attach the view to another view, provide it:
32
32
 
33
33
  ```ruby
34
- MemWatcher.watch(parent_view: "development")
34
+ MemWatcher.watch(parent_view: @my_other_view)
35
35
  ```
36
36
 
37
37
  ### Caveats
@@ -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 `display_on:` view or access to the window in your AppDelegate via a `window` accessor.")
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
- label.text = "Loading..."
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([[ 10, 10 ], [ 50, 24 ]])
47
- l.backgroundColor = UIColor.colorWithWhite(1.0, alpha:0.5)
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.1.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-01 00:00:00.000000000 Z
11
+ date: 2015-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake