sugarcube 0.7.9 → 0.8
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.
- data/LICENSE +1 -1
- data/README.md +12 -0
- data/lib/sugarcube/array.rb +8 -0
- data/lib/sugarcube/nsindexpath.rb +18 -0
- data/lib/sugarcube/nsstring.rb +20 -4
- data/lib/sugarcube/uiview.rb +2 -2
- data/lib/sugarcube/version.rb +1 -1
- data/sugarcube.gemspec +8 -6
- metadata +16 -14
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -31,6 +31,15 @@ don't even *drink* coffee, if you can imagine that... All I'm saying is: to each
|
|
31
31
|
their own. You should checkout [BubbleWrap][] for another take on
|
32
32
|
Cocoa-wrappage.
|
33
33
|
|
34
|
+
**CONTRIBUTIONS**
|
35
|
+
|
36
|
+
SugarCube started out as a [Fusionbox][] project (see the
|
37
|
+
[announcement][fusionbox announcement]), but as its popularity increased, the
|
38
|
+
decision was made to offer it to the rubymotion community, in the spirit of
|
39
|
+
open-source and collaboration. It is a great compliment to [teacup][],
|
40
|
+
especially when paired with [sweettea][]!
|
41
|
+
|
42
|
+
|
34
43
|
Installation
|
35
44
|
============
|
36
45
|
|
@@ -621,3 +630,6 @@ Quick wrapper for `CFUUIDCreate()` and `CFUUIDCreateString()`. Identical to the
|
|
621
630
|
|
622
631
|
[BubbleWrap]: https://github.com/rubymotion/BubbleWrap
|
623
632
|
[sweettea]: https://github.com/colinta/sweettea
|
633
|
+
[teacup]: https://github.com/rubymotion/teacup
|
634
|
+
[Fusionbox]: http://www.fusionbox.com/
|
635
|
+
[fusionbox announcement]: http://fusionbox.org/projects/rubymotion-sugarcube/
|
data/lib/sugarcube/array.rb
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
class Array
|
2
2
|
|
3
|
+
def === other
|
4
|
+
return other === self if other.is_a? NSIndexPath
|
5
|
+
ret = super
|
6
|
+
puts("=============== array.rb at line 6 ===============
|
7
|
+
returning super: #{ret.inspect}")
|
8
|
+
ret
|
9
|
+
end
|
10
|
+
|
3
11
|
def to_pointer(type)
|
4
12
|
ret = Pointer.new(type, self.length)
|
5
13
|
self.each_index do |i|
|
@@ -8,4 +8,22 @@ class NSIndexPath
|
|
8
8
|
end
|
9
9
|
a
|
10
10
|
end
|
11
|
+
|
12
|
+
def === other
|
13
|
+
return true if super
|
14
|
+
|
15
|
+
if other.is_a? Enumerable
|
16
|
+
ret = true
|
17
|
+
path = self.to_a
|
18
|
+
other.each do |val|
|
19
|
+
unless val === path.shift
|
20
|
+
ret = false
|
21
|
+
break
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
return ret
|
26
|
+
end
|
27
|
+
return false
|
28
|
+
end
|
11
29
|
end
|
data/lib/sugarcube/nsstring.rb
CHANGED
@@ -4,12 +4,30 @@ class NSString
|
|
4
4
|
@url ||= NSURL.alloc.initWithString(self)
|
5
5
|
end
|
6
6
|
|
7
|
+
def escape_url
|
8
|
+
CFURLCreateStringByAddingPercentEscapes(
|
9
|
+
nil,
|
10
|
+
self,
|
11
|
+
nil,
|
12
|
+
"!*'();:@&=+$,/?%#[]",
|
13
|
+
CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
def unescape_url
|
18
|
+
CFURLCreateStringByReplacingPercentEscapes(
|
19
|
+
nil,
|
20
|
+
self,
|
21
|
+
""
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
7
25
|
def uiimage
|
8
|
-
|
26
|
+
UIImage.imageNamed(self)
|
9
27
|
end
|
10
28
|
|
11
29
|
def uiimageview
|
12
|
-
|
30
|
+
(self.uiimage and self.uiimage.uiimageview or UIImageView.alloc.initWithImage(nil))
|
13
31
|
end
|
14
32
|
|
15
33
|
def uifont(size=UIFont.systemFontSize)
|
@@ -19,11 +37,9 @@ class NSString
|
|
19
37
|
|
20
38
|
def uicolor(alpha=nil)
|
21
39
|
if self[0,1] == '#'
|
22
|
-
# #fff
|
23
40
|
if self.length == 4
|
24
41
|
return (self[1] * 2 + self[2] * 2 + self[3] * 2).to_i(16).uicolor(alpha)
|
25
42
|
end
|
26
|
-
# else
|
27
43
|
return self[1..-1].to_i(16).uicolor(alpha)
|
28
44
|
end
|
29
45
|
|
data/lib/sugarcube/uiview.rb
CHANGED
@@ -39,7 +39,7 @@ class UIView
|
|
39
39
|
|
40
40
|
UIView.animateWithDuration(duration,
|
41
41
|
delay: options[:delay] || 0,
|
42
|
-
options: options[:options] ||
|
42
|
+
options: options[:options] || UIViewAnimationOptionCurveEaseInOut,
|
43
43
|
animations: proc{
|
44
44
|
self.layer.opacity = options[:opacity] || 0
|
45
45
|
|
@@ -77,7 +77,7 @@ class UIView
|
|
77
77
|
|
78
78
|
UIView.animateWithDuration(duration,
|
79
79
|
delay: options[:delay] || 0,
|
80
|
-
options: options[:options] ||
|
80
|
+
options: options[:options] || UIViewAnimationOptionCurveEaseInOut,
|
81
81
|
animations: proc{
|
82
82
|
f = self.frame
|
83
83
|
f.origin = SugarCube::CoreGraphics::Point(position)
|
data/lib/sugarcube/version.rb
CHANGED
data/sugarcube.gemspec
CHANGED
@@ -5,22 +5,24 @@ Gem::Specification.new do |gem|
|
|
5
5
|
gem.name = 'sugarcube'
|
6
6
|
gem.version = SugarCube::Version
|
7
7
|
|
8
|
-
gem.authors = ['Colin Thomas-Arnold', '
|
9
|
-
gem.email = ['
|
8
|
+
gem.authors = ['Colin Thomas-Arnold', 'Fusionbox']
|
9
|
+
gem.email = ['colinta@gmail.com']
|
10
10
|
gem.summary = %{Extensions for Ruby to make Rubymotion development more enjoyable, and hopefully more rubyesque!}
|
11
11
|
gem.description = <<-DESC
|
12
|
+
=== Description
|
13
|
+
|
12
14
|
CocoaTouch/iOS is a *verbose* framework. These extensions hope to make
|
13
15
|
development in rubymotion more enjoyable by tacking "UI" methods onto the
|
14
16
|
base classes (String, Fixnum, Float). With sugarcube, you can create a
|
15
17
|
color from an integer or symbol, or create a UIFont or UIImage from a
|
16
18
|
string.
|
17
19
|
|
18
|
-
Some UI classes are opened up as well, like adding the
|
19
|
-
UIView instance, instead of view.addSubview(subview)
|
20
|
-
idiomatic: view << subview
|
20
|
+
Some UI classes are opened up as well, like adding the +<<+ operator to a
|
21
|
+
+UIView+ instance, instead of +view.addSubview(subview)+, you can use the more
|
22
|
+
idiomatic: +view << subview+.
|
21
23
|
DESC
|
22
24
|
|
23
|
-
gem.homepage = 'https://github.com/
|
25
|
+
gem.homepage = 'https://github.com/rubymotion/sugarcube'
|
24
26
|
|
25
27
|
gem.files = `git ls-files`.split($\)
|
26
28
|
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sugarcube
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.8'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Colin Thomas-Arnold
|
9
|
-
-
|
9
|
+
- Fusionbox
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-08-
|
13
|
+
date: 2012-08-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
17
|
-
requirement: &
|
17
|
+
requirement: &70254474709740 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70254474709740
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rspec
|
28
|
-
requirement: &
|
28
|
+
requirement: &70254474709080 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,9 +33,11 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
37
|
-
description: ! '
|
38
|
-
|
36
|
+
version_requirements: *70254474709080
|
37
|
+
description: ! '=== Description
|
38
|
+
|
39
|
+
|
40
|
+
CocoaTouch/iOS is a *verbose* framework. These extensions hope to make
|
39
41
|
|
40
42
|
development in rubymotion more enjoyable by tacking "UI" methods onto the
|
41
43
|
|
@@ -46,15 +48,15 @@ description: ! 'CocoaTouch/iOS is a *verbose* framework. These extensions hope
|
|
46
48
|
string.
|
47
49
|
|
48
50
|
|
49
|
-
Some UI classes are opened up as well, like adding the
|
51
|
+
Some UI classes are opened up as well, like adding the +<<+ operator to a
|
50
52
|
|
51
|
-
UIView instance, instead of view.addSubview(subview)
|
53
|
+
+UIView+ instance, instead of +view.addSubview(subview)+, you can use the more
|
52
54
|
|
53
|
-
idiomatic: view << subview
|
55
|
+
idiomatic: +view << subview+.
|
54
56
|
|
55
57
|
'
|
56
58
|
email:
|
57
|
-
-
|
59
|
+
- colinta@gmail.com
|
58
60
|
executables: []
|
59
61
|
extensions: []
|
60
62
|
extra_rdoc_files: []
|
@@ -97,7 +99,7 @@ files:
|
|
97
99
|
- lib/sugarcube/uuid.rb
|
98
100
|
- lib/sugarcube/version.rb
|
99
101
|
- sugarcube.gemspec
|
100
|
-
homepage: https://github.com/
|
102
|
+
homepage: https://github.com/rubymotion/sugarcube
|
101
103
|
licenses: []
|
102
104
|
post_install_message:
|
103
105
|
rdoc_options: []
|