rubymotion-community / BubbleWrap

Cocoa wrappers and helpers for RubyMotion (Ruby for iOS and OS X) - Making Cocoa APIs more Ruby like, one API at a time. Fork away and send your pull requests
Other
1.18k stars 208 forks source link

Adds BW::Persistence.all to retrieve all keys and values stored as a hash. #377

Closed markrickert closed 10 years ago

markrickert commented 10 years ago

This excludes all non-bubble-wrap created persistence items.

Includes passing test.

(main)> NSUserDefaults.standardUserDefaults.dictionaryRepresentation
=> {
    "AppleLocale"=>"en_US", 
    "WebKitKerningAndLigaturesEnabledByDefault"=>true, 
    "AppleLanguages"=>["en", "fr", "de", "zh-Hans", "zh-Hant", "ja", "nl", "it", "es", "es-MX", "ko", "pt", "pt-PT", "da", "fi", "nb", "sv", "ru", "pl", "tr", "uk", "ar", "hr", "cs", "el", "he", "ro", "sk", "th", "id", "ms", "en-GB", "en-AU", "ca", "hu", "vi"],
    "AppleKeyboardsExpanded"=>1, 
    "AppleKeyboards"=>["en_US@hw=US;sw=QWERTY", "en_US@hw=US;sw=QWERTY"], 
    "UIDisableLegacyTextView"=>true, 
    "NSLanguages"=>["en", "fr", "de", "zh-Hans", "zh-Hant", "ja", "nl", "it", "es", "es-MX", "ko", "pt", "pt-PT", "da", "fi", "nb", "sv", "ru", "pl", "tr", "uk", "ar", "hr", "cs", "el", "he", "ro", "sk", "th", "id", "ms", "en-GB", "en-AU", "ca", "hu", "vi"],
    "NSInterfaceStyle"=>"macintosh", 
    "AppleITunesStoreItemKinds"=>["artist", "eBook"]
}
(main)> BW::Persistence.all
=> {}
(main)> BW::Persistence['test'] = 'RubyMotion'
=> "RubyMotion"
(main)> BW::Persistence['test2'] = 'Mark'
=> "Mark"
(main)> BW::Persistence[:test3] = 'Rickert'
=> "Rickert"
(main)> BW::Persistence.all
=> {"test3"=>"Rickert", "test"=>"RubyMotion", "test2"=>"Mark"}
(main)> NSUserDefaults.standardUserDefaults.dictionaryRepresentation
=> {
    "AppleLocale"=>"en_US", 
    "WebKitKerningAndLigaturesEnabledByDefault"=>true, 
    "AppleLanguages"=>["en", "fr", "de", "zh-Hans", "zh-Hant", "ja", "nl", "it", "es", "es-MX", "ko", "pt", "pt-PT", "da", "fi", "nb", "sv", "ru", "pl", "tr", "uk", "ar", "hr", "cs", "el", "he", "ro", "sk", "th", "id", "ms", "en-GB", "en-AU", "ca", "hu", "vi"],
    "AppleKeyboardsExpanded"=>1, 
    "AppleKeyboards"=>["en_US@hw=US;sw=QWERTY", "en_US@hw=US;sw=QWERTY"], 
    "UIDisableLegacyTextView"=>true, 
    "NSLanguages"=>["en", "fr", "de", "zh-Hans", "zh-Hant", "ja", "nl", "it", "es", "es-MX", "ko", "pt", "pt-PT", "da", "fi", "nb", "sv", "ru", "pl", "tr", "uk", "ar", "hr", "cs", "el", "he", "ro", "sk", "th", "id", "ms", "en-GB", "en-AU", "ca", "hu", "vi"],
    "NSInterfaceStyle"=>"macintosh", 
    "AppleITunesStoreItemKinds"=>["artist", "eBook"]
    "io.bubblewrap.testSuite_test3"=>"Rickert", 
    "io.bubblewrap.testSuite_test"=>"RubyMotion", 
    "io.bubblewrap.testSuite_test2"=>"Mark"
}
markrickert commented 10 years ago

Weird that it failed... my test passed - https://travis-ci.org/rubymotion/BubbleWrap/builds/25275292#L696-L697

markrickert commented 10 years ago

Reran travis and it's passing now. fickle, fickle Travis.

clayallsopp commented 10 years ago

So it goes lol. Want to add a line about it to the README?

markrickert commented 10 years ago

Added example to the readme.