sugarcube 1.7.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -1
- data/lib/all/sugarcube/log.rb +57 -0
- data/lib/{sugarcube → all/sugarcube}/look_in.rb +1 -6
- data/lib/{sugarcube-legacy → all/sugarcube-legacy}/activesupport.rb +1 -4
- data/lib/{sugarcube-numbers → all/sugarcube-numbers}/fixnum.rb +3 -3
- data/lib/{sugarcube-numbers/nsnumber.rb → all/sugarcube-numbers/numeric.rb} +1 -19
- data/lib/{sugarcube-numbers → all/sugarcube-numbers}/time.rb +2 -2
- data/lib/{sugarcube-unholy → all/sugarcube-unholy}/ivar.rb +0 -0
- data/lib/cocoa/sugarcube/log.rb +8 -0
- data/lib/{sugarcube-animations → cocoa/sugarcube-animations}/caanimation.rb +0 -0
- data/lib/{sugarcube-animations → cocoa/sugarcube-animations}/calayer.rb +0 -0
- data/lib/{sugarcube-anonymous → cocoa/sugarcube-anonymous}/anonymous.rb +0 -0
- data/lib/{sugarcube-anonymous → cocoa/sugarcube-anonymous}/anonymous_array.rb +0 -0
- data/lib/{sugarcube-attributedstring → cocoa/sugarcube-attributedstring}/nsattributedstring.rb +0 -0
- data/lib/{sugarcube-awesome → cocoa/sugarcube-awesome}/awesome_exts.rb +0 -0
- data/lib/{sugarcube-uikit → cocoa/sugarcube-cocoakit}/calayer.rb +0 -0
- data/lib/cocoa/sugarcube-cocoakit/frameable.rb +50 -0
- data/lib/{sugarcube-corelocation → cocoa/sugarcube-corelocation}/core_location.rb +0 -0
- data/lib/{sugarcube-files → cocoa/sugarcube-files}/nsarray.rb +0 -0
- data/lib/{sugarcube-files → cocoa/sugarcube-files}/nsdata.rb +0 -0
- data/lib/{sugarcube-files → cocoa/sugarcube-files}/nsdictionary.rb +0 -0
- data/lib/{sugarcube-files → cocoa/sugarcube-files}/nsstring.rb +0 -0
- data/lib/cocoa/sugarcube-files/nsstring_deprecated.rb +45 -0
- data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsarray.rb +0 -0
- data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsindexpath.rb +0 -0
- data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsindexset.rb +0 -0
- data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsorderedset.rb +0 -0
- data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsset.rb +1 -0
- data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsstring.rb +0 -0
- data/lib/{sugarcube-foundation → cocoa/sugarcube-foundation}/nsurl.rb +0 -0
- data/lib/{sugarcube-indexpath → cocoa/sugarcube-indexpath}/indexpath.rb +0 -0
- data/lib/{sugarcube-localized → cocoa/sugarcube-localized}/nserror.rb +0 -0
- data/lib/{sugarcube-localized → cocoa/sugarcube-localized}/nsstring.rb +0 -0
- data/lib/{sugarcube-notifications → cocoa/sugarcube-notifications}/notifications.rb +8 -8
- data/lib/{sugarcube-nscoder → cocoa/sugarcube-nscoder}/nscoder.rb +0 -0
- data/lib/{sugarcube-nsdata → cocoa/sugarcube-nsdata}/nsdata.rb +0 -9
- data/lib/{sugarcube-nsdata → cocoa/sugarcube-nsdata}/nsstring.rb +0 -0
- data/lib/{sugarcube-nsdata → cocoa/sugarcube-nsdata}/nsurl.rb +0 -0
- data/lib/{sugarcube-nsdate → cocoa/sugarcube-nsdate}/date_parser.rb +0 -0
- data/lib/{sugarcube-nsdate → cocoa/sugarcube-nsdate}/fixnum.rb +0 -0
- data/lib/{sugarcube-nsdate → cocoa/sugarcube-nsdate}/nsdate.rb +0 -0
- data/lib/{sugarcube-nsdate → cocoa/sugarcube-nsdate}/nsdate_delta.rb +0 -0
- data/lib/{sugarcube-nsdate → cocoa/sugarcube-nsdate}/nsnumber.rb +0 -0
- data/lib/{sugarcube-nsdate → cocoa/sugarcube-nsdate}/nsstring.rb +0 -0
- data/lib/{sugarcube-nsuserdefaults → cocoa/sugarcube-nsuserdefaults}/nsuserdefaults.rb +0 -0
- data/lib/cocoa/sugarcube-numbers/nsnumber.rb +10 -0
- data/lib/{sugarcube-numbers → cocoa/sugarcube-numbers}/nsstring.rb +0 -0
- data/lib/{sugarcube-pointer → cocoa/sugarcube-pointer}/nsarray.rb +0 -0
- data/lib/cocoa/sugarcube-repl/kernel.rb +161 -0
- data/lib/cocoa/sugarcube-repl/repl.rb +330 -0
- data/lib/cocoa/sugarcube-spritekit/sknode.rb +11 -0
- data/lib/{sugarcube-timer → cocoa/sugarcube-timer}/timer.rb +0 -0
- data/lib/{sugarcube-to_s → cocoa/sugarcube-to_s}/nserror.rb +1 -1
- data/lib/{sugarcube-to_s → cocoa/sugarcube-to_s}/nsindexpath.rb +0 -0
- data/lib/{sugarcube-to_s → cocoa/sugarcube-to_s}/nslayoutconstraint.rb +0 -0
- data/lib/{sugarcube-to_s → cocoa/sugarcube-to_s}/nsnotification.rb +1 -1
- data/lib/{sugarcube-to_s → cocoa/sugarcube-to_s}/nsset.rb +0 -0
- data/lib/{sugarcube-to_s → cocoa/sugarcube-to_s}/nsurl.rb +1 -1
- data/lib/{sugarcube → ios/sugarcube}/sugarcube_cleanup.rb +0 -0
- data/lib/{sugarcube-568 → ios/sugarcube-568}/uiimage.rb +0 -0
- data/lib/{sugarcube-animations → ios/sugarcube-animations}/animation_chain.rb +0 -0
- data/lib/{sugarcube-animations → ios/sugarcube-animations}/uiview.rb +3 -10
- data/lib/ios/sugarcube-color/fixnum.rb +30 -0
- data/lib/{sugarcube-color → ios/sugarcube-color}/nsarray.rb +5 -1
- data/lib/{sugarcube-color → ios/sugarcube-color}/nsstring.rb +5 -1
- data/lib/{sugarcube-color → ios/sugarcube-color}/symbol.rb +10 -2
- data/lib/{sugarcube-color → ios/sugarcube-color}/uicolor.rb +5 -9
- data/lib/{sugarcube-color → ios/sugarcube-color}/uiimage.rb +5 -1
- data/lib/{sugarcube-constants → ios/sugarcube-constants}/symbol.rb +3 -10
- data/lib/{sugarcube-coregraphics → ios/sugarcube-coregraphics}/core_graphics.rb +0 -0
- data/lib/{sugarcube-events → ios/sugarcube-events}/uicontrol.rb +0 -0
- data/lib/{sugarcube-events → ios/sugarcube-events}/uitextview.rb +0 -0
- data/lib/{sugarcube-factories → ios/sugarcube-factories}/nserror.rb +1 -1
- data/lib/{sugarcube-factories → ios/sugarcube-factories}/uiactionsheet.rb +0 -0
- data/lib/{sugarcube-factories/uiactivityindicator.rb → ios/sugarcube-factories/uiactivityindicatorview.rb} +0 -0
- data/lib/{sugarcube-factories → ios/sugarcube-factories}/uialertview.rb +0 -0
- data/lib/{sugarcube-factories → ios/sugarcube-factories}/uibarbuttonitem.rb +7 -2
- data/lib/{sugarcube-factories → ios/sugarcube-factories}/uibutton.rb +10 -0
- data/lib/{sugarcube-factories → ios/sugarcube-factories}/uisegmentedcontrol.rb +0 -0
- data/lib/{sugarcube-factories → ios/sugarcube-factories}/uitabbaritem.rb +0 -0
- data/lib/{sugarcube-factories → ios/sugarcube-factories}/uitableview.rb +0 -0
- data/lib/{sugarcube-factories → ios/sugarcube-factories}/uitableviewcell.rb +0 -0
- data/lib/{sugarcube-gestures → ios/sugarcube-gestures}/gestures.rb +0 -0
- data/lib/{sugarcube-image → ios/sugarcube-image}/cicolor.rb +0 -0
- data/lib/{sugarcube-image → ios/sugarcube-image}/cifilter.rb +0 -0
- data/lib/{sugarcube-image → ios/sugarcube-image}/ciimage.rb +0 -0
- data/lib/{sugarcube-image → ios/sugarcube-image}/uicolor.rb +0 -0
- data/lib/{sugarcube-image → ios/sugarcube-image}/uiimage.rb +0 -0
- data/lib/{sugarcube-modal → ios/sugarcube-modal}/modal.rb +2 -1
- data/lib/ios/sugarcube-nsdata/nsdata.rb +12 -0
- data/lib/{sugarcube-nsdata → ios/sugarcube-nsdata}/uiimage.rb +0 -0
- data/lib/ios/sugarcube-numbers/nsnumber.rb +14 -0
- data/lib/{sugarcube-pipes → ios/sugarcube-pipes}/pipes.rb +4 -4
- data/lib/ios/sugarcube-repl/repl.rb +112 -0
- data/lib/ios/sugarcube-spritekit/constants.rb +3 -0
- data/lib/{sugarcube-to_s → ios/sugarcube-to_s}/uicolor.rb +0 -0
- data/lib/{sugarcube-to_s → ios/sugarcube-to_s}/uievent.rb +14 -14
- data/lib/{sugarcube-to_s → ios/sugarcube-to_s}/uilabel.rb +1 -1
- data/lib/{sugarcube-to_s → ios/sugarcube-to_s}/uitextfield.rb +1 -1
- data/lib/ios/sugarcube-to_s/uitouch.rb +20 -0
- data/lib/{sugarcube-to_s → ios/sugarcube-to_s}/uiview.rb +7 -3
- data/lib/{sugarcube-to_s → ios/sugarcube-to_s}/uiviewcontroller.rb +0 -0
- data/lib/ios/sugarcube-uikit/frameable.rb +7 -0
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/nsattributedstring.rb +0 -0
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/nsstring.rb +6 -6
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/symbol.rb +0 -0
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uifont.rb +0 -0
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uiimage.rb +0 -0
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uilabel.rb +0 -0
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uipickerview.rb +0 -0
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uiview.rb +12 -70
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uiviewcontroller.rb +0 -0
- data/lib/{sugarcube-uikit → ios/sugarcube-uikit}/uiwebview.rb +0 -0
- data/lib/osx/sugarcube-animations/nsview.rb +117 -0
- data/lib/osx/sugarcube-appkit/frameable.rb +11 -0
- data/lib/osx/sugarcube-appkit/nsstring.rb +45 -0
- data/lib/osx/sugarcube-appkit/nsview.rb +75 -0
- data/lib/osx/sugarcube-color/fixnum.rb +30 -0
- data/lib/osx/sugarcube-color/nsarray.rb +22 -0
- data/lib/osx/sugarcube-color/nscolor.rb +218 -0
- data/lib/osx/sugarcube-color/nsimage.rb +21 -0
- data/lib/osx/sugarcube-color/nsstring.rb +24 -0
- data/lib/osx/sugarcube-color/symbol.rb +241 -0
- data/lib/osx/sugarcube-constants/symbol.rb +186 -0
- data/lib/osx/sugarcube-nsdata/nsdata.rb +8 -0
- data/lib/osx/sugarcube-nsdata/nsimage.rb +26 -0
- data/lib/osx/sugarcube-numbers/nsnumber.rb +14 -0
- data/lib/osx/sugarcube-repl/repl.rb +96 -0
- data/lib/osx/sugarcube-spritekit/constants.rb +3 -0
- data/lib/osx/sugarcube-to_s/nscolor.rb +34 -0
- data/lib/osx/sugarcube-to_s/nsview.rb +30 -0
- data/lib/sugarcube-568.rb +4 -1
- data/lib/sugarcube-all.rb +18 -5
- data/lib/sugarcube-animations.rb +6 -1
- data/lib/sugarcube-anonymous.rb +3 -1
- data/lib/{sugarcube-uifont.rb → sugarcube-appkit.rb} +7 -1
- data/lib/sugarcube-attributedstring.rb +3 -1
- data/lib/sugarcube-awesome.rb +3 -1
- data/lib/sugarcube-classic.rb +15 -5
- data/lib/sugarcube-color.rb +3 -1
- data/lib/sugarcube-common.rb +16 -5
- data/lib/sugarcube-constants.rb +3 -1
- data/lib/sugarcube-core.rb +11 -4
- data/lib/sugarcube-coregraphics.rb +3 -1
- data/lib/sugarcube-corelocation.rb +3 -1
- data/lib/sugarcube-events.rb +3 -1
- data/lib/sugarcube-factories.rb +3 -1
- data/lib/sugarcube-files.rb +3 -1
- data/lib/sugarcube-foundation.rb +3 -1
- data/lib/sugarcube-gestures.rb +4 -1
- data/lib/sugarcube-image.rb +3 -1
- data/lib/sugarcube-indexpath.rb +3 -1
- data/lib/sugarcube-legacy.rb +12 -1
- data/lib/sugarcube-localized.rb +3 -1
- data/lib/sugarcube-modal.rb +4 -1
- data/lib/sugarcube-notifications.rb +3 -1
- data/lib/sugarcube-nscoder.rb +3 -1
- data/lib/sugarcube-nsdata.rb +6 -1
- data/lib/sugarcube-nsdate.rb +7 -3
- data/lib/sugarcube-nsuserdefaults.rb +3 -1
- data/lib/sugarcube-numbers.rb +9 -1
- data/lib/sugarcube-pipes.rb +3 -1
- data/lib/sugarcube-pointer.rb +3 -1
- data/lib/sugarcube-repl.rb +9 -1
- data/lib/{sugarcube-resources.rb → sugarcube-spritekit.rb} +8 -1
- data/lib/sugarcube-timer.rb +7 -3
- data/lib/sugarcube-to_s.rb +9 -1
- data/lib/sugarcube-uikit.rb +7 -1
- data/lib/sugarcube-unholy.rb +3 -1
- data/lib/sugarcube.rb +19 -1
- data/lib/{sugarcube/version.rb → version.rb} +1 -1
- data/spec/{anonymous_spec.rb → all/anonymous_spec.rb} +3 -3
- data/spec/{caanimation_spec.rb → cocoa/caanimation_spec.rb} +0 -0
- data/spec/{calayer_spec.rb → cocoa/calayer_spec.rb} +0 -0
- data/spec/{nsarray_files_spec.rb → cocoa/nsarray_files_spec.rb} +0 -0
- data/spec/{nsdata_files_spec.rb → cocoa/nsdata_files_spec.rb} +0 -0
- data/spec/{nsdictionary_files_spec.rb → cocoa/nsdictionary_files_spec.rb} +0 -0
- data/spec/{568_spec.rb → ios/568_spec.rb} +2 -0
- data/spec/{animation_chain_spec.rb → ios/animation_chain_spec.rb} +0 -0
- data/spec/{color_components_spec.rb → ios/color_components_spec.rb} +0 -0
- data/spec/{color_other_representations_spec.rb → ios/color_other_representations_spec.rb} +0 -0
- data/spec/{color_spec.rb → ios/color_spec.rb} +38 -12
- data/spec/{core_graphics_spec.rb → ios/core_graphics_spec.rb} +0 -0
- data/spec/{core_location_spec.rb → ios/core_location_spec.rb} +0 -0
- data/spec/{date_parser_spec.rb → ios/date_parser_spec.rb} +0 -0
- data/spec/ios/factories_spec.rb +159 -0
- data/spec/{fixnum_spec.rb → ios/fixnum_spec.rb} +0 -0
- data/spec/ios/frameable_spec.rb +106 -0
- data/spec/{image_cifilters_spec.rb → ios/image_cifilters_spec.rb} +0 -0
- data/spec/{image_color_at_spec.rb → ios/image_color_at_spec.rb} +0 -0
- data/spec/{image_scale_spec.rb → ios/image_scale_spec.rb} +0 -0
- data/spec/{image_uiimage_filters_spec.rb → ios/image_uiimage_filters_spec.rb} +0 -0
- data/spec/{notification_spec.rb → ios/notification_spec.rb} +0 -0
- data/spec/{nsarray_spec.rb → ios/nsarray_spec.rb} +0 -0
- data/spec/{nsattributedstring_spec.rb → ios/nsattributedstring_spec.rb} +5 -5
- data/spec/{nscoder_spec.rb → ios/nscoder_spec.rb} +0 -0
- data/spec/{nsdata_spec.rb → ios/nsdata_spec.rb} +0 -0
- data/spec/{nsdate_delta_spec.rb → ios/nsdate_delta_spec.rb} +0 -0
- data/spec/{nsdate_spec.rb → ios/nsdate_spec.rb} +2 -2
- data/spec/{nsdate_upto_spec.rb → ios/nsdate_upto_spec.rb} +2 -2
- data/spec/{nsorderedset_spec.rb → ios/nsorderedset_spec.rb} +0 -0
- data/spec/{nsset_spec.rb → ios/nsset_spec.rb} +0 -0
- data/spec/{nsstring_files_spec.rb → ios/nsstring_files_spec.rb} +7 -0
- data/spec/{nsstring_spec.rb → ios/nsstring_spec.rb} +4 -4
- data/spec/{nsstring_timezone_spec.rb → ios/nsstring_timezone_spec.rb} +0 -0
- data/spec/{nsurl_spec.rb → ios/nsurl_spec.rb} +3 -3
- data/spec/{numeric_spec.rb → ios/numeric_spec.rb} +0 -0
- data/spec/{pipes_spec.rb → ios/pipes_spec.rb} +0 -0
- data/spec/{symbol_constants_spec.rb → ios/symbol_constants_spec.rb} +33 -24
- data/spec/{symbol_uicolor_spec.rb → ios/symbol_uicolor_spec.rb} +6 -1
- data/spec/{symbol_uifont_spec.rb → ios/symbol_uifont_spec.rb} +5 -5
- data/spec/{timer_spec.rb → ios/timer_spec.rb} +0 -0
- data/spec/{uiactionsheet_spec.rb → ios/uiactionsheet_spec.rb} +0 -0
- data/spec/{uialertview_spec.rb → ios/uialertview_spec.rb} +0 -0
- data/spec/{uibarbuttonitem_spec.rb → ios/uibarbuttonitem_spec.rb} +0 -0
- data/spec/{uicolor_spec.rb → ios/uicolor_spec.rb} +0 -0
- data/spec/{uicontrol_spec.rb → ios/uicontrol_spec.rb} +2 -2
- data/spec/{uiimage_spec.rb → ios/uiimage_spec.rb} +0 -0
- data/spec/{uilabel_spec.rb → ios/uilabel_spec.rb} +0 -0
- data/spec/{uitabbaritem_spec.rb → ios/uitabbaritem_spec.rb} +0 -0
- data/spec/{uitableviewcell_spec.rb → ios/uitableviewcell_spec.rb} +4 -4
- data/spec/{uiview_animation_spec.rb → ios/uiview_animation_spec.rb} +0 -0
- data/spec/{uiview_animation_tumble_spec.rb → ios/uiview_animation_tumble_spec.rb} +0 -0
- data/spec/{uiview_attr_updates_spec.rb → ios/uiview_attr_updates_spec.rb} +0 -0
- data/spec/{uiview_spec.rb → ios/uiview_spec.rb} +15 -45
- data/spec/{uiviewcontroller_spec.rb → ios/uiviewcontroller_spec.rb} +0 -0
- data/spec/{uiwebview_spec.rb → ios/uiwebview_spec.rb} +0 -0
- data/spec/{unholy_spec.rb → ios/unholy_spec.rb} +0 -0
- data/spec/osx/color_components_spec.rb +33 -0
- data/spec/osx/color_other_representations_spec.rb +58 -0
- data/spec/osx/color_spec.rb +123 -0
- data/spec/osx/nsview_spec.rb +114 -0
- data/spec/osx/symbol_constants_spec.rb +188 -0
- metadata +262 -246
- data/.gitignore +0 -5
- data/.travis.yml +0 -7
- data/.yardopts +0 -1
- data/Gemfile +0 -7
- data/Gemfile.lock +0 -16
- data/LICENSE +0 -26
- data/Rakefile +0 -12
- data/app/animation_chain_controller.rb +0 -12
- data/app/app_delegate.rb +0 -27
- data/app/uicontrol_controller.rb +0 -49
- data/lib/sugarcube/adjust.rb +0 -425
- data/lib/sugarcube-color/fixnum.rb +0 -22
- data/lib/sugarcube-files/nsstring_deprecated.rb +0 -45
- data/lib/sugarcube-legacy/log.rb +0 -45
- data/lib/sugarcube-legacy/symbol.rb +0 -219
- data/lib/sugarcube-osx/adjust.rb +0 -373
- data/lib/sugarcube-repl/repl.rb +0 -90
- data/lib/sugarcube-to_s/uitouch.rb +0 -20
- data/resources/Default-568h@2x.png +0 -0
- data/resources/Default.png +0 -0
- data/resources/Default@2x.png +0 -0
- data/resources/en.lproj/Localizable.strings +0 -1
- data/resources/little_square.png +0 -0
- data/resources/little_square@2x.png +0 -0
- data/resources/tall-568h@2x.png +0 -0
- data/resources/tall.png +0 -0
- data/resources/tall@2x.png +0 -0
- data/runtests +0 -3
- data/spec/sugarcube_legacy.rb +0 -59
- data/sugarcube.gemspec +0 -33
@@ -0,0 +1,123 @@
|
|
1
|
+
describe 'NSColor' do
|
2
|
+
|
3
|
+
it "should support #nscolor" do
|
4
|
+
NSColor.redColor.nscolor.should == NSColor.redColor
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should support #cgcolor" do
|
8
|
+
-> do
|
9
|
+
NSColor.redColor.cgcolor.should == NSColor.redColor.CGColor
|
10
|
+
end.should.not.raise
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should support #skcolor" do
|
14
|
+
NSColor.redColor.skcolor.should == NSColor.redColor
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should support #nscolor(alpha) method" do
|
18
|
+
NSColor.redColor.nscolor(0.5).alpha.should == 0.5
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "should have a #+(color) method" do
|
22
|
+
|
23
|
+
it 'should add white and black to make gray' do
|
24
|
+
new_color = NSColor.whiteColor + NSColor.blackColor
|
25
|
+
new_color.red.should == 0.5
|
26
|
+
new_color.green.should == 0.5
|
27
|
+
new_color.blue.should == 0.5
|
28
|
+
new_color.alpha.should == 1.0
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should add black and white to make gray' do
|
32
|
+
new_color = NSColor.blackColor + NSColor.whiteColor
|
33
|
+
new_color.red.should == 0.5
|
34
|
+
new_color.green.should == 0.5
|
35
|
+
new_color.blue.should == 0.5
|
36
|
+
new_color.alpha.should == 1.0
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should add alpha channel (white + clear)' do
|
40
|
+
new_color = NSColor.whiteColor + NSColor.clearColor
|
41
|
+
new_color.red.should == 1.0
|
42
|
+
new_color.green.should == 1.0
|
43
|
+
new_color.blue.should == 1.0
|
44
|
+
new_color.alpha.should == 0.5
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should add alpha channel (clear + white)' do
|
48
|
+
new_color = NSColor.clearColor + NSColor.whiteColor
|
49
|
+
new_color.red.should == 1.0
|
50
|
+
new_color.green.should == 1.0
|
51
|
+
new_color.blue.should == 1.0
|
52
|
+
new_color.alpha.should == 0.5
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "should have a #<<(color) method" do
|
58
|
+
it "should return white no matter what" do
|
59
|
+
new_color = NSColor.whiteColor << NSColor.blackColor
|
60
|
+
new_color.red.should == 1.0
|
61
|
+
new_color.green.should == 1.0
|
62
|
+
new_color.blue.should == 1.0
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should have no effect with black" do
|
66
|
+
new_color = NSColor.blueColor << NSColor.blackColor
|
67
|
+
new_color.red.should == 0.0
|
68
|
+
new_color.green.should == 0.0
|
69
|
+
new_color.blue.should == 1.0
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should add blue to red" do
|
73
|
+
new_color = NSColor.redColor << NSColor.blueColor
|
74
|
+
new_color.red.should == 1.0
|
75
|
+
new_color.green.should == 0.0
|
76
|
+
new_color.blue.should == 1.0
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should use opacity when adding blue to red" do
|
80
|
+
new_color = NSColor.redColor << NSColor.blueColor.colorWithAlphaComponent(0.5)
|
81
|
+
new_color.red.should == 1.0
|
82
|
+
new_color.green.should == 0.0
|
83
|
+
new_color.blue.should == 0.5
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should have a #invert method" do
|
89
|
+
:white.nscolor.invert.red.should == 0
|
90
|
+
:white.nscolor.invert.green.should == 0
|
91
|
+
:white.nscolor.invert.blue.should == 0
|
92
|
+
|
93
|
+
:black.nscolor.invert.red.should == 1
|
94
|
+
:black.nscolor.invert.green.should == 1
|
95
|
+
:black.nscolor.invert.blue.should == 1
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should have a #mix_with method" do
|
99
|
+
white = :white.nscolor
|
100
|
+
black = :black.nscolor
|
101
|
+
gray = :gray.nscolor
|
102
|
+
white.mix_with(black, 0).red.should == 1
|
103
|
+
white.mix_with(black, 0).green.should == 1
|
104
|
+
white.mix_with(black, 0).blue.should == 1
|
105
|
+
|
106
|
+
white.mix_with(black, 1).red.should == 0
|
107
|
+
white.mix_with(black, 1).green.should == 0
|
108
|
+
white.mix_with(black, 1).blue.should == 0
|
109
|
+
|
110
|
+
white.mix_with(black, 0.5).red.should == 0.5
|
111
|
+
white.mix_with(black, 0.5).green.should == 0.5
|
112
|
+
white.mix_with(black, 0.5).blue.should == 0.5
|
113
|
+
|
114
|
+
white.mix_with(black, 0.25).red.should == 0.75
|
115
|
+
white.mix_with(black, 0.25).green.should == 0.75
|
116
|
+
white.mix_with(black, 0.25).blue.should == 0.75
|
117
|
+
|
118
|
+
white.mix_with(black, 0.75).red.should == 0.25
|
119
|
+
white.mix_with(black, 0.75).green.should == 0.25
|
120
|
+
white.mix_with(black, 0.75).blue.should == 0.25
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
describe NSView do
|
2
|
+
|
3
|
+
it 'should support <<' do
|
4
|
+
view1 = NSView.new
|
5
|
+
view2 = NSView.new
|
6
|
+
view1 << view2
|
7
|
+
view2.superview.should == view1
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should support unshift' do
|
11
|
+
view1 = NSView.new
|
12
|
+
view2 = NSView.new
|
13
|
+
view1.unshift view2
|
14
|
+
view2.superview.should == view1
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should support first_responder' do
|
18
|
+
container = NSView.new
|
19
|
+
field_1 = NSTextField.new
|
20
|
+
field_2 = NSTextField.new
|
21
|
+
container << field_1
|
22
|
+
container << field_2
|
23
|
+
|
24
|
+
@window = NSWindow.new
|
25
|
+
@window.setFrame([[0, 0], [100, 100]], display: true)
|
26
|
+
container.frame = [[0, 0], [100, 100]]
|
27
|
+
field_1.frame = [[0, 50], [100, 50]]
|
28
|
+
field_2.frame = [[0, 0], [100, 50]]
|
29
|
+
@window.setContentView(container)
|
30
|
+
@window.orderFrontRegardless
|
31
|
+
|
32
|
+
field_1.becomeFirstResponder
|
33
|
+
container.first_responder.ancestorSharedWithView(field_1).should == field_1
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "should convert bounds" do
|
37
|
+
before do
|
38
|
+
@view1 = NSView.alloc.initWithFrame([[0, 0], [100, 100]])
|
39
|
+
@view2 = NSView.alloc.initWithFrame([[10, 5], [80, 90]])
|
40
|
+
@view1 << @view2
|
41
|
+
@view3 = NSView.alloc.initWithFrame([[10, 5], [60, 80]])
|
42
|
+
@view2 << @view3
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should convert_frame_to" do
|
46
|
+
frame = @view3.convert_frame_to(@view1)
|
47
|
+
frame.origin.x.should == 20
|
48
|
+
frame.origin.y.should == 10
|
49
|
+
frame.size.width.should == 60
|
50
|
+
frame.size.height.should == 80
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should convert_frame_from" do
|
54
|
+
frame = @view1.convert_frame_from(@view3)
|
55
|
+
frame.origin.x.should == 20
|
56
|
+
frame.origin.y.should == 10
|
57
|
+
frame.size.width.should == 60
|
58
|
+
frame.size.height.should == 80
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should convert_rect(to:)" do
|
62
|
+
frame = @view3.convert_rect([[1, 2], [10, 20]], to: @view1)
|
63
|
+
frame.origin.x.should == 21
|
64
|
+
frame.origin.y.should == 12
|
65
|
+
frame.size.width.should == 10
|
66
|
+
frame.size.height.should == 20
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should convert_rect(from:)" do
|
70
|
+
frame = @view1.convert_rect([[1, 2], [10, 20]], from: @view3)
|
71
|
+
frame.origin.x.should == 21
|
72
|
+
frame.origin.y.should == 12
|
73
|
+
frame.size.width.should == 10
|
74
|
+
frame.size.height.should == 20
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "should convert point" do
|
80
|
+
before do
|
81
|
+
@view1 = NSView.alloc.initWithFrame([[0, 0], [100, 100]])
|
82
|
+
@view2 = NSView.alloc.initWithFrame([[10, 5], [80, 90]])
|
83
|
+
@view1 << @view2
|
84
|
+
@view3 = NSView.alloc.initWithFrame([[10, 5], [60, 80]])
|
85
|
+
@view2 << @view3
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should convert_origin_to" do
|
89
|
+
point = @view3.convert_origin_to(@view1)
|
90
|
+
point.x.should == 20
|
91
|
+
point.y.should == 10
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should convert_origin_from" do
|
95
|
+
point = @view1.convert_origin_from(@view3)
|
96
|
+
point.x.should == 20
|
97
|
+
point.y.should == 10
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should convert_point(to:)" do
|
101
|
+
point = @view3.convert_point([1, 2], to: @view1)
|
102
|
+
point.x.should == 21
|
103
|
+
point.y.should == 12
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should convert_point(:from)" do
|
107
|
+
point = @view1.convert_point([1, 2], from: @view3)
|
108
|
+
point.x.should == 21
|
109
|
+
point.y.should == 12
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
describe "Symbol - constants" do
|
2
|
+
|
3
|
+
describe "should work" do
|
4
|
+
|
5
|
+
it 'should support `nsautoresizingmask`' do
|
6
|
+
:none.nsautoresizingmask.should == NSViewNotSizable
|
7
|
+
:flexible_left.nsautoresizingmask.should == NSViewMinXMargin
|
8
|
+
:flexible_width.nsautoresizingmask.should == NSViewWidthSizable
|
9
|
+
:flexible_right.nsautoresizingmask.should == NSViewMaxXMargin
|
10
|
+
:flexible_top.nsautoresizingmask.should == NSViewMaxYMargin
|
11
|
+
:flexible_height.nsautoresizingmask.should == NSViewHeightSizable
|
12
|
+
:flexible_bottom.nsautoresizingmask.should == NSViewMinYMargin
|
13
|
+
:fill.nsautoresizingmask.should == NSViewWidthSizable | NSViewHeightSizable
|
14
|
+
:fill_top.nsautoresizingmask.should == NSViewWidthSizable | NSViewMinYMargin
|
15
|
+
:fill_bottom.nsautoresizingmask.should == NSViewWidthSizable | NSViewMaxYMargin
|
16
|
+
:fill_left.nsautoresizingmask.should == NSViewHeightSizable | NSViewMaxXMargin
|
17
|
+
:fill_right.nsautoresizingmask.should == NSViewHeightSizable | NSViewMinXMargin
|
18
|
+
:fixed_top_left.nsautoresizingmask.should == NSViewMaxXMargin | NSViewMinYMargin
|
19
|
+
:fixed_top_middle.nsautoresizingmask.should == NSViewMinXMargin | NSViewMaxXMargin | NSViewMinYMargin
|
20
|
+
:fixed_top_right.nsautoresizingmask.should == NSViewMinXMargin | NSViewMinYMargin
|
21
|
+
:fixed_middle_left.nsautoresizingmask.should == NSViewMaxYMargin | NSViewMinYMargin | NSViewMaxXMargin
|
22
|
+
:fixed_middle.nsautoresizingmask.should == NSViewMaxYMargin | NSViewMinYMargin | NSViewMinXMargin | NSViewMaxXMargin
|
23
|
+
:fixed_middle_right.nsautoresizingmask.should == NSViewMaxYMargin | NSViewMinYMargin | NSViewMinXMargin
|
24
|
+
:fixed_bottom_left.nsautoresizingmask.should == NSViewMaxXMargin | NSViewMaxYMargin
|
25
|
+
:fixed_bottom_middle.nsautoresizingmask.should == NSViewMinXMargin | NSViewMaxXMargin | NSViewMaxYMargin
|
26
|
+
:fixed_bottom_right.nsautoresizingmask.should == NSViewMinXMargin | NSViewMaxYMargin
|
27
|
+
:float_horizontal.nsautoresizingmask.should == NSViewMinXMargin | NSViewMaxXMargin
|
28
|
+
:float_vertical.nsautoresizingmask.should == NSViewMaxYMargin | NSViewMinYMargin
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should support `nstextalignment`' do
|
32
|
+
:left.nstextalignment.should == NSLeftTextAlignment
|
33
|
+
:right.nstextalignment.should == NSRightTextAlignment
|
34
|
+
:center.nstextalignment.should == NSCenterTextAlignment
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should support `nsdatestyle`' do
|
38
|
+
:no.nsdatestyle.should == NSDateFormatterNoStyle
|
39
|
+
:none.nsdatestyle.should == NSDateFormatterNoStyle
|
40
|
+
:short.nsdatestyle.should == NSDateFormatterShortStyle
|
41
|
+
:medium.nsdatestyle.should == NSDateFormatterMediumStyle
|
42
|
+
:long.nsdatestyle.should == NSDateFormatterLongStyle
|
43
|
+
:full.nsdatestyle.should == NSDateFormatterFullStyle
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should support `nsnumberstyle`' do
|
47
|
+
:no.nsnumberstyle.should == NSNumberFormatterNoStyle
|
48
|
+
:none.nsnumberstyle.should == NSNumberFormatterNoStyle
|
49
|
+
:decimal.nsnumberstyle.should == NSNumberFormatterDecimalStyle
|
50
|
+
:currency.nsnumberstyle.should == NSNumberFormatterCurrencyStyle
|
51
|
+
:percent.nsnumberstyle.should == NSNumberFormatterPercentStyle
|
52
|
+
:scientific.nsnumberstyle.should == NSNumberFormatterScientificStyle
|
53
|
+
:spell_out.nsnumberstyle.should == NSNumberFormatterSpellOutStyle
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should support `nsbuttontype`' do
|
57
|
+
:momentary_light.nsbuttontype.should == NSMomentaryLightButton
|
58
|
+
:push_on_push_off.nsbuttontype.should == NSPushOnPushOffButton
|
59
|
+
:toggle.nsbuttontype.should == NSToggleButton
|
60
|
+
:switch.nsbuttontype.should == NSSwitchButton
|
61
|
+
:radio.nsbuttontype.should == NSRadioButton
|
62
|
+
:momentary_change.nsbuttontype.should == NSMomentaryChangeButton
|
63
|
+
:on_off.nsbuttontype.should == NSOnOffButton
|
64
|
+
:momentary_push_in.nsbuttontype.should == NSMomentaryPushInButton
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should support `nsbezelstyle`' do
|
68
|
+
:rounded.nsbezelstyle.should == NSRoundedBezelStyle
|
69
|
+
:regular_square.nsbezelstyle.should == NSRegularSquareBezelStyle
|
70
|
+
:thick_square.nsbezelstyle.should == NSThickSquareBezelStyle
|
71
|
+
:thicker_square.nsbezelstyle.should == NSThickerSquareBezelStyle
|
72
|
+
:disclosure.nsbezelstyle.should == NSDisclosureBezelStyle
|
73
|
+
:shadowless_square.nsbezelstyle.should == NSShadowlessSquareBezelStyle
|
74
|
+
:circular.nsbezelstyle.should == NSCircularBezelStyle
|
75
|
+
:textured_square.nsbezelstyle.should == NSTexturedSquareBezelStyle
|
76
|
+
:help_button.nsbezelstyle.should == NSHelpButtonBezelStyle
|
77
|
+
:small_square.nsbezelstyle.should == NSSmallSquareBezelStyle
|
78
|
+
:textured_rounded.nsbezelstyle.should == NSTexturedRoundedBezelStyle
|
79
|
+
:round_rect.nsbezelstyle.should == NSRoundRectBezelStyle
|
80
|
+
:recessed.nsbezelstyle.should == NSRecessedBezelStyle
|
81
|
+
:rounded_disclosure.nsbezelstyle.should == NSRoundedDisclosureBezelStyle
|
82
|
+
:inline.nsbezelstyle.should == NSInlineBezelStyle
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should support `nsfocusringtype`' do
|
86
|
+
:default.nsfocusringtype.should == NSFocusRingTypeDefault
|
87
|
+
:none.nsfocusringtype.should == NSFocusRingTypeNone
|
88
|
+
:exterior.nsfocusringtype.should == NSFocusRingTypeExterior
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'should support `catimingfunction`' do
|
92
|
+
:linear.catimingfunction.should == KCAMediaTimingFunctionLinear
|
93
|
+
:ease_in.catimingfunction.should == KCAMediaTimingFunctionEaseIn
|
94
|
+
:ease_out.catimingfunction.should == KCAMediaTimingFunctionEaseOut
|
95
|
+
:ease_in_out.catimingfunction.should == KCAMediaTimingFunctionEaseInEaseOut
|
96
|
+
:ease_in_ease_out.catimingfunction.should == KCAMediaTimingFunctionEaseInEaseOut
|
97
|
+
:default.catimingfunction.should == KCAMediaTimingFunctionDefault
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should support `cglinecap`' do
|
101
|
+
:butt.cglinecap.should == KCGLineCapButt
|
102
|
+
:round.cglinecap.should == KCGLineCapRound
|
103
|
+
:square.cglinecap.should == KCGLineCapSquare
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should support `cglinejoin`' do
|
107
|
+
:miter.cglinejoin.should == KCGLineJoinMiter
|
108
|
+
:round.cglinejoin.should == KCGLineJoinRound
|
109
|
+
:bevel.cglinejoin.should == KCGLineJoinBevel
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "Aliases" do
|
115
|
+
it 'should have alias for `nsautoresizingmask`' do
|
116
|
+
:none.nsautoresizemask.should == :none.nsautoresizingmask
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should have alias for `nstextalignment`' do
|
120
|
+
:left.nsalignment.should == :left.nstextalignment
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'should have alias for `nsdatestyle`' do
|
124
|
+
:no.nsdateformatterstyle.should == :no.nsdatestyle
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'should have alias for `nsnumberstyle`' do
|
128
|
+
:no.nsnumberformatterstyle.should == :no.nsnumberstyle
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'should have alias for `catimingfunction`' do
|
132
|
+
:linear.catiming.should == :linear.catimingfunction
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'should have alias for `cglinecap`' do
|
136
|
+
:butt.cglinecapstyle.should == :butt.cglinecap
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'should have alias for `cglinejoin`' do
|
140
|
+
:miter.cglinejoinstyle.should == :miter.cglinejoin
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
describe "not found" do
|
146
|
+
it 'should not find nonexistant `nsautoresizingmask`' do
|
147
|
+
should.raise(SugarCubeNotFoundException) { :definitely_doesnt_exist_i_am_really_sure_of_it.nsautoresizingmask }
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'should not find nonexistant `nstextalignment`' do
|
151
|
+
should.raise(SugarCubeNotFoundException) { :definitely_doesnt_exist_i_am_really_sure_of_it.nstextalignment }
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'should not find nonexistant `nsdatestyle`' do
|
155
|
+
should.raise(SugarCubeNotFoundException) { :definitely_doesnt_exist_i_am_really_sure_of_it.nsdatestyle }
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'should not find nonexistant `nsnumberstyle`' do
|
159
|
+
should.raise(SugarCubeNotFoundException) { :definitely_doesnt_exist_i_am_really_sure_of_it.nsnumberstyle }
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'should not find nonexistant `nsbuttontype`' do
|
163
|
+
should.raise(SugarCubeNotFoundException) { :definitely_doesnt_exist_i_am_really_sure_of_it.nsbuttontype }
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'should not find nonexistant `nsbezelstyle`' do
|
167
|
+
should.raise(SugarCubeNotFoundException) { :definitely_doesnt_exist_i_am_really_sure_of_it.nsbezelstyle }
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'should not find nonexistant `nsfocusringtype`' do
|
171
|
+
should.raise(SugarCubeNotFoundException) { :definitely_doesnt_exist_i_am_really_sure_of_it.nsfocusringtype }
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'should not find nonexistant `catimingfunction`' do
|
175
|
+
should.raise(SugarCubeNotFoundException) { :definitely_doesnt_exist_i_am_really_sure_of_it.catimingfunction }
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'should not find nonexistant `cglinecap`' do
|
179
|
+
should.raise(SugarCubeNotFoundException) { :definitely_doesnt_exist_i_am_really_sure_of_it.cglinecap }
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'should not find nonexistant `cglinejoin`' do
|
183
|
+
should.raise(SugarCubeNotFoundException) { :definitely_doesnt_exist_i_am_really_sure_of_it.cglinejoin }
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|