eventmachine-distributed-notification 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -13,3 +13,4 @@
13
13
  @end
14
14
 
15
15
  VALUE createInstanceFromObserver(Observer *obs);
16
+ VALUE getRubyValueFromId(id thing);
@@ -33,7 +33,9 @@
33
33
  VALUE hash = rb_hash_new();
34
34
 
35
35
  for(id key in userInfo) {
36
- rb_hash_aset(hash, rb_str_new2([[key description] UTF8String]), rb_str_new2([[[userInfo objectForKey:key] description] UTF8String]));
36
+ rb_hash_aset(hash,
37
+ rb_str_new2([[key description] UTF8String]),
38
+ getRubyValueFromId([userInfo objectForKey:key]));
37
39
  }
38
40
 
39
41
  rb_funcall(handler, rb_intern("notify"), 2, aName, hash);
@@ -63,6 +65,33 @@ void cObserverNative_free(void *ptr) {
63
65
  free(ptr);
64
66
  }
65
67
 
68
+ VALUE getRubyValueFromId(id thing) {
69
+ VALUE result;
70
+
71
+ if([thing isKindOfClass:[NSNumber class]]) {
72
+ if(strcmp([thing objCType], @encode(BOOL)) == 0)
73
+ result = thing ? Qtrue : Qfalse;
74
+ else if(strcmp([thing objCType], @encode(int)) == 0)
75
+ result = INT2NUM([thing intValue]);
76
+ else if(strcmp([thing objCType], @encode(unsigned int)) == 0)
77
+ result = INT2NUM([thing unsignedIntValue]);
78
+ else if(strcmp([thing objCType], @encode(long)) == 0)
79
+ result = INT2NUM([thing longValue]);
80
+ else if(strcmp([thing objCType], @encode(float)) == 0)
81
+ result = rb_float_new([thing floatValue]);
82
+ else if(strcmp([thing objCType], @encode(double)) == 0)
83
+ result = rb_float_new([thing doubleValue]);
84
+ else
85
+ result = INT2NUM([thing longLongValue]);
86
+ } else if([thing isKindOfClass:[NSNumber class]]) {
87
+ result = rb_str_new2([thing UTF8String]);
88
+ } else {
89
+ result = rb_str_new2([[thing description] UTF8String]);
90
+ }
91
+
92
+ return result;
93
+ }
94
+
66
95
  VALUE createInstanceFromObserver(Observer *obs) {
67
96
  struct ObserverObject *obj;
68
97
 
@@ -6,10 +6,11 @@ require 'eventmachine'
6
6
  require 'appscript'
7
7
 
8
8
  class Watcher < EM::DistributedNotificationWatch
9
- attr_accessor :value
9
+ attr_accessor :value, :user_info
10
10
 
11
11
  def notify(name, user_info)
12
12
  @value = name
13
+ @user_info = user_info
13
14
  end
14
15
  end
15
16
 
@@ -51,6 +52,7 @@ describe EventMachine::DistributedNotificationWatch do
51
52
  }
52
53
 
53
54
  watcher.value.should_not be_nil
55
+ watcher.user_info['Total Time'].should be_kind_of(Fixnum)
54
56
  end
55
57
  end
56
58
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventmachine-distributed-notification
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-23 00:00:00.000000000 Z
12
+ date: 2012-03-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
16
- requirement: &70335005352760 !ruby/object:Gem::Requirement
16
+ requirement: &70278625507360 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70335005352760
24
+ version_requirements: *70278625507360
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70335005351700 !ruby/object:Gem::Requirement
27
+ requirement: &70278625505040 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.8.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70335005351700
35
+ version_requirements: *70278625505040
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rdoc
38
- requirement: &70335005349700 !ruby/object:Gem::Requirement
38
+ requirement: &70278625517900 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '3.12'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70335005349700
46
+ version_requirements: *70278625517900
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &70335005361320 !ruby/object:Gem::Requirement
49
+ requirement: &70278625514980 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.1.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70335005361320
57
+ version_requirements: *70278625514980
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: jeweler
60
- requirement: &70335005359260 !ruby/object:Gem::Requirement
60
+ requirement: &70278625511060 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.8.3
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70335005359260
68
+ version_requirements: *70278625511060
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rb-appscript
71
- requirement: &70335005357780 !ruby/object:Gem::Requirement
71
+ requirement: &70278625526100 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70335005357780
79
+ version_requirements: *70278625526100
80
80
  description: An EventMachine extension to watch OSX's Distributed Notification, posted
81
81
  by iTunes etc.
82
82
  email: youpy@buycheapviagraonlinenow.com
@@ -123,7 +123,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  segments:
125
125
  - 0
126
- hash: 1148266853853813151
126
+ hash: 3735464898048564235
127
127
  required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  none: false
129
129
  requirements: