sugarcube 0.20.18 → 0.20.19

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sugarcube (0.20.18)
4
+ sugarcube (0.20.19)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1266,17 +1266,23 @@ Makes it easy to post a notification to some or all objects.
1266
1266
 
1267
1267
  ```ruby
1268
1268
  # this one is handy, I think:
1269
- "my notification".post_notification # => NSNotificationCenter.defaultCenter.postNotificationName("my notification", object:nil)
1270
- "my notification".post_notification(obj) # => NSNotificationCenter.defaultCenter.postNotificationName("my notification", object:obj)
1271
- "my notification".post_notification(obj, user: 'dict') # => NSNotificationCenter.defaultCenter.postNotificationName("my notification", object:obj, userInfo:{user: 'dict'})
1269
+ MyNotification = "my notification"
1270
+ MyNotification.post_notification # => NSNotificationCenter.defaultCenter.postNotificationName(MyNotification, object:nil)
1271
+ MyNotification.post_notification(obj) # => NSNotificationCenter.defaultCenter.postNotificationName(MyNotification, object:obj)
1272
+ MyNotification.post_notification(obj, user: 'dict') # => NSNotificationCenter.defaultCenter.postNotificationName(MyNotification, object:obj, userInfo:{user: 'dict'})
1273
+
1274
+ # you can access the userInfo dictionary directly from the notification
1275
+ def notified(notification)
1276
+ notification[:user] # => 'dict'
1277
+ end
1272
1278
 
1273
1279
  # very similar to add or remove an observer
1274
- "my notification".add_observer(observer, :method_name)
1275
- "my notification".add_observer(observer, :method_name, object)
1280
+ MyNotification.add_observer(observer, :method_name)
1281
+ MyNotification.add_observer(observer, :method_name, object)
1276
1282
 
1277
1283
  # remove the observer
1278
- "my notification".remove_observer(observer)
1279
- "my notification".remove_observer(observer, object)
1284
+ MyNotification.remove_observer(observer)
1285
+ MyNotification.remove_observer(observer, object)
1280
1286
  ```
1281
1287
 
1282
1288
  NSTimer
@@ -1,3 +1,12 @@
1
+ class NSNotification
2
+
3
+ def [](key)
4
+ userInfo[key]
5
+ end
6
+
7
+ end
8
+
9
+
1
10
  class NSString
2
11
 
3
12
  def post_notification(object=nil, user_info=nil)
@@ -426,6 +426,7 @@ class UIView
426
426
  subviews.each do |subview|
427
427
  CGContextSaveGState(context)
428
428
  CGContextTranslateCTM(context, subview.frame.origin.x, subview.frame.origin.y)
429
+ # CGContextConcatCTM(subview.layer.affineTransform)
429
430
  subview.layer.renderInContext(context)
430
431
  CGContextRestoreGState(context)
431
432
  end
@@ -433,6 +434,7 @@ class UIView
433
434
  UIGraphicsEndImageContext()
434
435
  else
435
436
  UIGraphicsBeginImageContextWithOptions(bounds.size, false, scale)
437
+ # CGContextConcatCTM(layer.affineTransform)
436
438
  layer.renderInContext(UIGraphicsGetCurrentContext())
437
439
  image = UIGraphicsGetImageFromCurrentImageContext()
438
440
  UIGraphicsEndImageContext()
@@ -0,0 +1,7 @@
1
+ class UIWebView
2
+
3
+ def eval_js(str)
4
+ self.stringByEvaluatingJavaScriptFromString str
5
+ end
6
+
7
+ end
@@ -1,3 +1,3 @@
1
1
  module SugarCube
2
- Version = '0.20.18'
2
+ Version = '0.20.19'
3
3
  end
@@ -17,6 +17,7 @@ class NotificationsTester
17
17
  @notification = notification
18
18
  @object = notification.object
19
19
  end
20
+
20
21
  end
21
22
 
22
23
  describe "Notifications" do
@@ -46,6 +47,14 @@ describe "Notifications" do
46
47
  @notification_tester_object.object.should == @object
47
48
  end
48
49
 
50
+ it "should send userInfo" do
51
+ @notification.post_notification(@object, key: :value)
52
+ @notification_tester_object.notified?.should == true
53
+ @notification_tester_object.notification.should != nil
54
+ @notification_tester_object.object.should == @object
55
+ @notification_tester_object.notification[:key].should == :value
56
+ end
57
+
49
58
  after do
50
59
  @notification.remove_observer(@notification_tester)
51
60
  @notification.remove_observer(@notification_tester_object, @object)
@@ -0,0 +1,11 @@
1
+ describe "UIWebView" do
2
+
3
+ [["1 + 1", "2"],
4
+ ["null", ""],
5
+ ["(function(x) { return x * x; })(4)", "16"]].each do |str, expected|
6
+ it "should eval '#{str}'" do
7
+ UIWebView.alloc.init.eval_js(str).should == expected
8
+ end
9
+ end
10
+
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sugarcube
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.18
4
+ version: 0.20.19
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-04-28 00:00:00.000000000 Z
16
+ date: 2013-04-29 00:00:00.000000000 Z
17
17
  dependencies: []
18
18
  description: ! '== Description
19
19
 
@@ -123,6 +123,7 @@ files:
123
123
  - lib/sugarcube/uitextview.rb
124
124
  - lib/sugarcube/uiview.rb
125
125
  - lib/sugarcube/uiviewcontroller.rb
126
+ - lib/sugarcube/uiwebview.rb
126
127
  - lib/sugarcube/uuid.rb
127
128
  - lib/sugarcube/version.rb
128
129
  - resources/Default-568h@2x.png
@@ -176,6 +177,7 @@ files:
176
177
  - spec/uiview_attr_updates_spec.rb
177
178
  - spec/uiview_spec.rb
178
179
  - spec/uiviewcontroller_spec.rb
180
+ - spec/uiwebview_spec.rb
179
181
  - spec/unholy_spec.rb
180
182
  - sugarcube.gemspec
181
183
  homepage: https://github.com/rubymotion/sugarcube
@@ -245,4 +247,5 @@ test_files:
245
247
  - spec/uiview_attr_updates_spec.rb
246
248
  - spec/uiview_spec.rb
247
249
  - spec/uiviewcontroller_spec.rb
250
+ - spec/uiwebview_spec.rb
248
251
  - spec/unholy_spec.rb