sugarcube 0.15.5 → 0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +30 -0
- data/Rakefile +1 -0
- data/lib/sugarcube-unholy.rb +23 -0
- data/lib/sugarcube-unholy/ivar.rb +25 -0
- data/lib/sugarcube/nsdate.rb +16 -0
- data/lib/sugarcube/version.rb +1 -1
- data/spec/nsdata_spec.rb +11 -0
- data/spec/nsdate_spec.rb +8 -0
- data/spec/unholy_spec.rb +19 -0
- metadata +8 -2
data/README.md
CHANGED
@@ -1376,3 +1376,33 @@ view.on_press # use system defaults
|
|
1376
1376
|
view.on_press(1.5) # duration
|
1377
1377
|
view.on_press(duration: 1.5, taps: 1, fingers: 1)
|
1378
1378
|
```
|
1379
|
+
|
1380
|
+
Unholy
|
1381
|
+
--------
|
1382
|
+
|
1383
|
+
These methods are just about as opinionated as they get - even more than the RoR
|
1384
|
+
additions. They are not included by default, so please don't freak out about
|
1385
|
+
them. I add them here because I don't think anyone will notice if I do, and I
|
1386
|
+
use these everywhere. :poop:
|
1387
|
+
|
1388
|
+
### `ivar`
|
1389
|
+
|
1390
|
+
###### Rackfile
|
1391
|
+
|
1392
|
+
```ruby
|
1393
|
+
require 'sugarcube-unholy'
|
1394
|
+
```
|
1395
|
+
|
1396
|
+
###### Elsewhere
|
1397
|
+
|
1398
|
+
```ruby
|
1399
|
+
class Baz ; end
|
1400
|
+
foo = Baz.new
|
1401
|
+
|
1402
|
+
# (:symbol || 'string').ivar
|
1403
|
+
foo.instance_variable_set(:bar.ivar, value) # => foo.instance_variable_set(:@bar, value)
|
1404
|
+
foo.instance_variable_set(var_name.ivar, value) # => foo.instance_variable_set("@#{var_name}", value)
|
1405
|
+
|
1406
|
+
# (:symbol || 'string').cvar
|
1407
|
+
Baz.class_variable_set(var_name.cvar, value) # => Baz.class_variable_set("@@#{var_name}", value)
|
1408
|
+
```
|
data/Rakefile
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
unless defined?(Motion::Project::Config)
|
2
|
+
raise "The sugarcube gem must be required within a RubyMotion project Rakefile."
|
3
|
+
end
|
4
|
+
|
5
|
+
|
6
|
+
Motion::Project::App.setup do |app|
|
7
|
+
# scans app.files until it finds app/ (the default)
|
8
|
+
# if found, it inserts just before those files, otherwise it will insert to
|
9
|
+
# the end of the list
|
10
|
+
insert_point = 0
|
11
|
+
app.files.each_index do |index|
|
12
|
+
file = app.files[index]
|
13
|
+
if file =~ /^(?:\.\/)?app\//
|
14
|
+
# found app/, so stop looking
|
15
|
+
break
|
16
|
+
end
|
17
|
+
insert_point = index + 1
|
18
|
+
end
|
19
|
+
|
20
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'sugarcube-unholy/**/*.rb')).reverse.each do |file|
|
21
|
+
app.files.insert(insert_point, file)
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Some Symbol additions to make my life easier
|
2
|
+
class Symbol
|
3
|
+
|
4
|
+
def ivar
|
5
|
+
self.to_s.ivar
|
6
|
+
end
|
7
|
+
|
8
|
+
def cvar
|
9
|
+
self.to_s.cvar
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
class NSString
|
16
|
+
|
17
|
+
def ivar
|
18
|
+
"@#{self}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def cvar
|
22
|
+
"@@#{self}"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/lib/sugarcube/nsdate.rb
CHANGED
@@ -131,6 +131,22 @@ class NSDate
|
|
131
131
|
return self + time_interval
|
132
132
|
end
|
133
133
|
|
134
|
+
# (main)> t = Time.new
|
135
|
+
# => 2012-09-27 11:29:12 +0900
|
136
|
+
# (main)> t.start_of_month
|
137
|
+
# => 2012-09-01 00:00:00 +0900
|
138
|
+
def start_of_month
|
139
|
+
return self.start_of_day.delta(days:1 - day)
|
140
|
+
end
|
141
|
+
|
142
|
+
# (main)> t = Time.new
|
143
|
+
# => 2012-09-27 11:29:12 +0900
|
144
|
+
# (main)> t.end_of_month
|
145
|
+
# => 2012-10-01 00:00:00 +0900
|
146
|
+
def end_of_month
|
147
|
+
return self.end_of_day.delta(days:days_in_month - day)
|
148
|
+
end
|
149
|
+
|
134
150
|
def days_in_month
|
135
151
|
NSCalendar.currentCalendar.rangeOfUnit(NSDayCalendarUnit, inUnit:NSMonthCalendarUnit, forDate:self).length
|
136
152
|
end
|
data/lib/sugarcube/version.rb
CHANGED
data/spec/nsdata_spec.rb
ADDED
data/spec/nsdate_spec.rb
CHANGED
@@ -73,6 +73,14 @@ describe "NSDate" do
|
|
73
73
|
@date.end_of_day.datetime_array.should == [2013, 1, 3, 0, 0, 0]
|
74
74
|
end
|
75
75
|
|
76
|
+
it "should have an NSDate#start_of_month method" do
|
77
|
+
@date.start_of_month.datetime_array.should == [2013, 1, 1, 0, 0, 0]
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should have an NSDate#end_of_month method" do
|
81
|
+
@date.end_of_month.datetime_array.should == [2013, 2, 1, 0, 0, 0]
|
82
|
+
end
|
83
|
+
|
76
84
|
it "should have an NSDate#days_in_month method" do
|
77
85
|
@date.days_in_month.should == 31
|
78
86
|
NSDate.from_components(year:2013, month:2, day:1).days_in_month.should == 28
|
data/spec/unholy_spec.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
describe "Sanity" do
|
2
|
+
|
3
|
+
it "should have Symbol#ivar" do
|
4
|
+
:name.ivar.should == '@name'
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should have String#ivar" do
|
8
|
+
'another'.ivar.should == '@another'
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should have Symbol#cvar" do
|
12
|
+
:name.cvar.should == '@@name'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have String#cvar" do
|
16
|
+
'another'.cvar.should == '@@another'
|
17
|
+
end
|
18
|
+
|
19
|
+
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.
|
4
|
+
version: '0.16'
|
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-02-
|
16
|
+
date: 2013-02-06 00:00:00.000000000 Z
|
17
17
|
dependencies: []
|
18
18
|
description: ! '== Description
|
19
19
|
|
@@ -52,6 +52,8 @@ files:
|
|
52
52
|
- lib/sugarcube-568/uiimage.rb
|
53
53
|
- lib/sugarcube-gestures.rb
|
54
54
|
- lib/sugarcube-gestures/gestures.rb
|
55
|
+
- lib/sugarcube-unholy.rb
|
56
|
+
- lib/sugarcube-unholy/ivar.rb
|
55
57
|
- lib/sugarcube.rb
|
56
58
|
- lib/sugarcube/adjust.rb
|
57
59
|
- lib/sugarcube/calayer.rb
|
@@ -122,6 +124,7 @@ files:
|
|
122
124
|
- spec/notification_spec.rb
|
123
125
|
- spec/nsarray_spec.rb
|
124
126
|
- spec/nscoder_spec.rb
|
127
|
+
- spec/nsdata_spec.rb
|
125
128
|
- spec/nsdate_spec.rb
|
126
129
|
- spec/nsdate_upto_spec.rb
|
127
130
|
- spec/nsstring_files_spec.rb
|
@@ -132,6 +135,7 @@ files:
|
|
132
135
|
- spec/uiimage_scale_spec.rb
|
133
136
|
- spec/uiview_animation_spec.rb
|
134
137
|
- spec/uiview_spec.rb
|
138
|
+
- spec/unholy_spec.rb
|
135
139
|
- sugarcube.gemspec
|
136
140
|
homepage: https://github.com/rubymotion/sugarcube
|
137
141
|
licenses: []
|
@@ -168,6 +172,7 @@ test_files:
|
|
168
172
|
- spec/notification_spec.rb
|
169
173
|
- spec/nsarray_spec.rb
|
170
174
|
- spec/nscoder_spec.rb
|
175
|
+
- spec/nsdata_spec.rb
|
171
176
|
- spec/nsdate_spec.rb
|
172
177
|
- spec/nsdate_upto_spec.rb
|
173
178
|
- spec/nsstring_files_spec.rb
|
@@ -178,4 +183,5 @@ test_files:
|
|
178
183
|
- spec/uiimage_scale_spec.rb
|
179
184
|
- spec/uiview_animation_spec.rb
|
180
185
|
- spec/uiview_spec.rb
|
186
|
+
- spec/unholy_spec.rb
|
181
187
|
has_rdoc:
|