sugarcube 3.5.0 → 4.0.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
- SHA1:
3
- metadata.gz: 19287c88598dd0086ec1cc07a160a663deb94f25
4
- data.tar.gz: '085dc95c41fca4414a9df3461aa1a50bc40fb9a1'
2
+ SHA256:
3
+ metadata.gz: 525bee7443997247ce40ef9b565b1e88bbf830968f8dd7159b65b34f2db8ea65
4
+ data.tar.gz: df06188beb5ed2d875530b912255a7a4cff36eeb6bd6f7f01c64a39097f43c81
5
5
  SHA512:
6
- metadata.gz: b130f44edc637cfe2c74a4d124b2019ed24ed69084c879688294135f085716b31b57bd1b541c194302b0dd8445e70866260969ef77a6008cf62259b73f95427c
7
- data.tar.gz: ad1770a014a8635baebe718413db4636471454b08784c04256839cba88b5eb38f7b96e22b81b7c7a8ba272a0842a937b951d59e96ccf66f5f3d37d46b37004f5
6
+ metadata.gz: 1afdfd31581d0bdcf25b932d6abf4fd1d477501021327039bc9431d14e26f60179a31f1a7e384542697352977dfc2c94e68f5fc216c95bd5c995c00531f05328
7
+ data.tar.gz: ec2fd8153567f360136d11aa001509c0e22497d1a075ca9ed6ceb7be0dcab35330db1a19a430676f63048502c330562a88b74f04a9aa42d30a4f33722937e6f4
@@ -0,0 +1,10 @@
1
+ module SugarCube
2
+ # Evaluating javascript from string
3
+ module WebView
4
+
5
+ def eval_js(str, &block)
6
+ self.evaluateJavaScript(str, completionHandler:->(id, error){ block.call(id, error) })
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ class WKWebView
2
+ include SugarCube::WebView
3
+ end
@@ -1,4 +1,4 @@
1
- class UIView
1
+ class NSView
2
2
 
3
3
  class << self
4
4
 
@@ -45,7 +45,7 @@ class UIView
45
45
  self.layerContentsRedrawPolicy = NSViewLayerContentsRedrawOnSetNeedsDisplay
46
46
  end
47
47
 
48
- UIView.animate(options, &animations)
48
+ NSView.animate(options, &animations)
49
49
  return self
50
50
  end
51
51
 
@@ -0,0 +1,3 @@
1
+ class WKWebView
2
+ include SugarCube::WebView
3
+ end
@@ -11,3 +11,7 @@ end
11
11
  Motion::Project::App.pre_setup do |app|
12
12
  SugarCube.add_app_files(app, 'sugarcube-animations')
13
13
  end
14
+
15
+ Motion::Project::App.post_setup do |app|
16
+ app.frameworks += %w{QuartzCore}
17
+ end
@@ -9,3 +9,7 @@ SugarCube.cocoa_only!('attributedstring')
9
9
  Motion::Project::App.pre_setup do |app|
10
10
  SugarCube.add_app_files(app, 'sugarcube-attributedstring')
11
11
  end
12
+
13
+ Motion::Project::App.post_setup do |app|
14
+ app.frameworks += %w{CoreText}
15
+ end
@@ -0,0 +1,15 @@
1
+ unless defined?(Motion::Project::Config)
2
+ raise "The sugarcube gem must be required within a RubyMotion project Rakefile."
3
+ end
4
+
5
+
6
+ require 'sugarcube'
7
+ SugarCube.cocoa_only!('webkit')
8
+
9
+ Motion::Project::App.pre_setup do |app|
10
+ SugarCube.add_app_files(app, 'sugarcube-webkit')
11
+ end
12
+
13
+ Motion::Project::App.post_setup do |app|
14
+ app.frameworks += %w{WebKit}
15
+ end
@@ -1,3 +1,3 @@
1
1
  module SugarCube
2
- Version = '3.5.0'
2
+ Version = '4.0.0'
3
3
  end
@@ -3,7 +3,7 @@ describe 'Base64' do
3
3
  describe 'UIImage' do
4
4
 
5
5
  it 'should convert image data (PNG) to base64' do
6
- 'test'.uiimage.nsdata.to_base64.should == 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAHgCAIAAADrGJBNAAAAAXNSR0IArs4c6QAAABxpRE9UAAAAAgAAAAAAAADwAAAAKAAAAPAAAADwAAAAS9r5uVEAAAAXSURBVEgNYrhrxMAwikfDYDQNDMk0AAAAAP//6TQa9AAAABVJREFUY7hrxMAwikfDYDQNDMk0AACNnfwwqs717AAAAABJRU5ErkJggg=='
6
+ 'test'.uiimage.nsdata.to_base64.should == 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAHgCAIAAADrGJBNAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAAaADAAQAAAABAAAB4AAAAAAnyqA0AAAAHGlET1QAAAACAAAAAAAAAPAAAAAoAAAA8AAAAPAAAABL2vm5UQAAABdJREFUSA1iuGvEwDCKR8NgNA0MyTQAAAAA///pNBr0AAAAFUlEQVRjuGvEwDCKR8NgNA0MyTQAAI2d/DCqzvXsAAAAAElFTkSuQmCC'
7
7
  end
8
8
 
9
9
  end
@@ -0,0 +1,37 @@
1
+ describe "Sugarcube::WebView" do
2
+
3
+ describe WKWebView do
4
+ tests UIViewController
5
+
6
+ before do
7
+ @view = UIView.alloc.initWithFrame([[1,2],[3,4]])
8
+ controller.view.addSubview(@view)
9
+
10
+ @webview = WKWebView.alloc.init
11
+ @view << @webview
12
+
13
+ @webview.eval_js('') {|id, error| ;; } # NOOP
14
+ end
15
+
16
+ after do
17
+ @view = @webview = nil
18
+ end
19
+
20
+ [["1 + 1", 2.0],
21
+ ["null", nil],
22
+ ["(function(x) { return x * x; })(4)", 16.0]].each do |str, expected|
23
+ it "should eval '#{str}'" do
24
+ @res = ''
25
+
26
+ @webview.eval_js(str) do |id, error|
27
+ @res = id
28
+ end
29
+
30
+ wait 5.0 do
31
+ @res.should == expected
32
+ end
33
+ end
34
+ end
35
+
36
+ end
37
+ 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: 3.5.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin T.A. Gray
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2018-12-17 00:00:00.000000000 Z
15
+ date: 2020-02-25 00:00:00.000000000 Z
16
16
  dependencies: []
17
17
  description: |
18
18
  == Description
@@ -98,6 +98,7 @@ files:
98
98
  - lib/cocoa/sugarcube-to_s/nsurl.rb
99
99
  - lib/cocoa/sugarcube-ui/calayer.rb
100
100
  - lib/cocoa/sugarcube-ui/frameable.rb
101
+ - lib/cocoa/sugarcube-webkit/wkwebview.rb
101
102
  - lib/cocoa/sugarcube/log.rb
102
103
  - lib/ios/sugarcube-568/uiimage.rb
103
104
  - lib/ios/sugarcube-animations/animation_chain.rb
@@ -158,7 +159,7 @@ files:
158
159
  - lib/ios/sugarcube-ui/uipickerview.rb
159
160
  - lib/ios/sugarcube-ui/uiview.rb
160
161
  - lib/ios/sugarcube-ui/uiviewcontroller.rb
161
- - lib/ios/sugarcube-ui/uiwebview.rb
162
+ - lib/ios/sugarcube-webkit/wkwebview.rb
162
163
  - lib/osx/sugarcube-animations/nsview.rb
163
164
  - lib/osx/sugarcube-attributedstring/nsattributedstring.rb
164
165
  - lib/osx/sugarcube-color/fixnum.rb
@@ -181,6 +182,7 @@ files:
181
182
  - lib/osx/sugarcube-ui/nsstring.rb
182
183
  - lib/osx/sugarcube-ui/nsview.rb
183
184
  - lib/osx/sugarcube-ui/symbol.rb
185
+ - lib/osx/sugarcube-webkit/wkwebview.rb
184
186
  - lib/sugarcube-568.rb
185
187
  - lib/sugarcube-all.rb
186
188
  - lib/sugarcube-animations.rb
@@ -220,6 +222,7 @@ files:
220
222
  - lib/sugarcube-ui.rb
221
223
  - lib/sugarcube-uikit.rb
222
224
  - lib/sugarcube-unholy.rb
225
+ - lib/sugarcube-webkit.rb
223
226
  - lib/sugarcube.rb
224
227
  - lib/sugarcube_pre_setup.rb
225
228
  - lib/version.rb
@@ -291,8 +294,8 @@ files:
291
294
  - spec/ios/uiview_attr_updates_spec.rb
292
295
  - spec/ios/uiview_spec.rb
293
296
  - spec/ios/uiviewcontroller_spec.rb
294
- - spec/ios/uiwebview_spec.rb
295
297
  - spec/ios/unholy_spec.rb
298
+ - spec/ios/wkwebview_spec.rb
296
299
  - spec/osx/base64_spec.rb
297
300
  - spec/osx/color_components_spec.rb
298
301
  - spec/osx/color_other_representations_spec.rb
@@ -321,8 +324,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
321
324
  - !ruby/object:Gem::Version
322
325
  version: '0'
323
326
  requirements: []
324
- rubyforge_project:
325
- rubygems_version: 2.5.2.3
327
+ rubygems_version: 3.0.6
326
328
  signing_key:
327
329
  specification_version: 4
328
330
  summary: Extensions for Ruby to make Rubymotion development more enjoyable, and hopefully
@@ -344,7 +346,6 @@ test_files:
344
346
  - spec/ios/color_other_representations_spec.rb
345
347
  - spec/ios/nsdate_upto_spec.rb
346
348
  - spec/ios/image_uiimage_filters_spec.rb
347
- - spec/ios/uiwebview_spec.rb
348
349
  - spec/ios/nsstring_files_spec.rb
349
350
  - spec/ios/nsorderedset_spec.rb
350
351
  - spec/ios/nsdata_spec.rb
@@ -373,6 +374,7 @@ test_files:
373
374
  - spec/ios/image_scale_spec.rb
374
375
  - spec/ios/color_spec.rb
375
376
  - spec/ios/uiimage_spec.rb
377
+ - spec/ios/wkwebview_spec.rb
376
378
  - spec/ios/color_components_spec.rb
377
379
  - spec/ios/fixnum_spec.rb
378
380
  - spec/ios/uifont_spec.rb
@@ -1,7 +0,0 @@
1
- class UIWebView
2
-
3
- def eval_js(str)
4
- self.stringByEvaluatingJavaScriptFromString str
5
- end
6
-
7
- end
@@ -1,11 +0,0 @@
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