rubymotion-community / sugarcube

Some sugar for your cocoa. RubyMotion helpers.
Other
422 stars 66 forks source link

base64 (#to_base64 and ##from_base64) support on NSString and NSData. #185

Closed colinta closed 9 years ago

colinta commented 9 years ago

e.g. 'testing' == NSString.from_base64('testing'.to_base64) or 'testing' == NSString.from_base64('testing'.to_base64(NSUnicodeStringEncoding), NSUnicodeStringEncoding)

@markrickert @jamonholmgren Would you guys mind taking a quick glance, or maybe running the specs?

markrickert commented 9 years ago

I'm getting some unrelated failures locally, but the base64 spec looks good. i might add something to the specs like:

testing = "Testing something to and from base64"
NSString.from_base64(testing.to_base64).should == testing

Just to verify encoding and decoding

markrickert commented 9 years ago

http://hipbyte.myjetbrains.com/youtrack/issue/RM-730 This should fix some of the CLLocation2d issues, hopefully.

jamonholmgren commented 9 years ago

Running specs now.

jamonholmgren commented 9 years ago
NoMethodError: undefined method `latitude' for #<CLLocationCoordinate2D:0x11338d150>
    core_location.rb:33:in `distance_to:': CoreLocation - should calculate distance in miles
    spec.rb:316:in `block in run_spec_block'
    spec.rb:459:in `execute_block'
    spec.rb:316:in `run_spec_block'
    spec.rb:331:in `run'

NoMethodError: undefined method `latitude' for #<CLLocationCoordinate2D:0x1123ddd90>
    core_location.rb:33:in `distance_to:': CoreLocation - should calculate distance in kilometers
    spec.rb:316:in `block in run_spec_block'
    spec.rb:459:in `execute_block'
    spec.rb:316:in `run_spec_block'
    spec.rb:331:in `run'

NoMethodError: undefined method `base64' for much longer test:NSConcreteMutableData
    spec.rb:316:in `block in run_spec_block': base64 - should convert nsstring data to base64
    spec.rb:459:in `execute_block'
    spec.rb:316:in `run_spec_block'
    spec.rb:331:in `run'

NoMethodError: undefined method `base64' for #<NSConcreteMutableData:0x1123aaaa0>
    spec.rb:316:in `block in run_spec_block': base64 - should convert image data (PNG) to base64
    spec.rb:459:in `execute_block'
    spec.rb:316:in `run_spec_block'
    spec.rb:331:in `run'

Bacon::Error: #<ImmediateRef:0x115ba06a0 <NSIndexPath: 0xc000000000018056> {length = 2, path = 1 - 3}>.==(1) failed
    spec.rb:745:in `satisfy:': NSIndexPath - should have to_ary
    spec.rb:759:in `method_missing:'
    spec.rb:316:in `block in run_spec_block'
    spec.rb:459:in `execute_block'
    spec.rb:316:in `run_spec_block'
    spec.rb:331:in `run'

1494 specifications (3184 requirements), 1 failures, 4 errors
colinta commented 9 years ago

The CLLocation errors are expected, the undefined method "base64" is not... I'll check on that.

On Jan 23, 2015, at 8:17 PM, Jamon Holmgren notifications@github.com wrote:

NoMethodError: undefined method latitude' for #<CLLocationCoordinate2D:0x11338d150> core_location.rb:33:indistance_to:': CoreLocation - should calculate distance in miles spec.rb:316:in block in run_spec_block' spec.rb:459:inexecute_block' spec.rb:316:in run_spec_block' spec.rb:331:inrun'

NoMethodError: undefined method latitude' for #<CLLocationCoordinate2D:0x1123ddd90> core_location.rb:33:indistance_to:': CoreLocation - should calculate distance in kilometers spec.rb:316:in block in run_spec_block' spec.rb:459:inexecute_block' spec.rb:316:in run_spec_block' spec.rb:331:inrun'

NoMethodError: undefined method base64' for much longer test:NSConcreteMutableData spec.rb:316:inblock in run_spec_block': base64 - should convert nsstring data to base64 spec.rb:459:in execute_block' spec.rb:316:inrun_spec_block' spec.rb:331:in `run'

NoMethodError: undefined method base64' for #<NSConcreteMutableData:0x1123aaaa0> spec.rb:316:inblock in run_spec_block': base64 - should convert image data (PNG) to base64 spec.rb:459:in execute_block' spec.rb:316:inrun_spec_block' spec.rb:331:in `run'

Bacon::Error: #<ImmediateRef:0x115ba06a0 <NSIndexPath: 0xc000000000018056> {length = 2, path = 1 - 3}>.==(1) failed spec.rb:745:in satisfy:': NSIndexPath - should have to_ary spec.rb:759:inmethod_missing:' spec.rb:316:in block in run_spec_block' spec.rb:459:inexecute_block' spec.rb:316:in run_spec_block' spec.rb:331:inrun'

1494 specifications (3184 requirements), 1 failures, 4 errors \ Reply to this email directly or view it on GitHub.

colinta commented 9 years ago

Fixed! I forgot that, long ago, I had added specs to nsdata_specs. I fixed & moved those to base64_specs.

colinta commented 9 years ago

Ran all the specs again, and looks good. Thanks for checking it out, guys! Available in 3.1.1 (3.1.0 had files I didn't intend to include - I should have gemspec filter out files that aren't tracked in git!)

jamonholmgren commented 9 years ago

:+1: