module BubbleWrap

Provides a module to store global states

Provides a nice DSL for interacting with the standard UIImagePickerController

Usage example:

class ExampleViewController < UIViewController

include BubbleWrap::KVO

def viewDidLoad
    @label = UILabel.alloc.initWithFrame [[20,20],[280,44]]
    @label.text = ""
    view.addSubview @label

    observe(@label, :text) do |old_value, new_value|
        puts "Changed #{old_value} to #{new_value}"
    end
end

end

@see developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html#//apple_ref/doc/uid/10000177i

Persistence module built on top of NSUserDefaults

Provides a nice DSL for interacting with the standard CLLocationManager

Provides a nice DSL for interacting with the standard CMMotionManager from CoreMotion

Asynchronous and non blocking RSS Parser based on NSXMLParser. The parser will progressively parse a feed and yield each item to the provided block.

The parser can also trigger delegate methods, you can define the following delegate method on the receiving object: def when_parser_initializes; end def when_parser_parses; end def when_parser_is_done; end def when_parser_errors; end

@see developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html

@usage example:

feed = RSSParser.new(URL)
feed.delegate = self
feed.parse do |item|
  print item.link
end
def when_parser_is_done
  App.alert('parsing complete')
end

Make sure that Both BubbleWrap and BW are defined. This file is depended on by everything else in BubbleWrap, so don't stuff anything in here unless you know why you're doing it.

Stupid hack because the RubyMotion dependency detection has a bug.

Constants

LOADER_PRESENT
MIN_MOTION_VERSION
SETTINGS
VERSION

Public Class Methods

debug=(val) click to toggle source
# File motion/shortcut.rb, line 8
def self.debug=(val)
  BubbleWrap::SETTINGS[:debug] = val
end
debug?() click to toggle source
# File motion/shortcut.rb, line 12
def self.debug?
  BubbleWrap::SETTINGS[:debug]
end
set_version(version) click to toggle source
# File spec/motion/util/deprecated_spec.rb, line 23
def self.set_version(version)
  define_singleton_method("version") do
    version
  end
end
use_weak_callbacks=(val) click to toggle source
# File motion/shortcut.rb, line 16
def self.use_weak_callbacks=(val)
  BubbleWrap::SETTINGS[:use_weak_callbacks] = val
end
use_weak_callbacks?() click to toggle source
# File motion/shortcut.rb, line 20
def self.use_weak_callbacks?
  BubbleWrap::SETTINGS[:use_weak_callbacks]
end

Public Instance Methods

after_config(config) click to toggle source
# File lib/bubble-wrap/loader.rb, line 49
def after_config(config)
  return unless ::BubbleWrap::Requirement.frameworks.include?("CoreLocation")
  BubbleWrap.require_ios do
    ios8_files = 'motion/ios/8/location_constants.rb'
    if config.send(:deployment_target).to_f >= 8.0
      ::BubbleWrap.require(ios8_files)
      before_config(config)
    else
      config.files = config.files.reject {|s|
        s.include?(ios8_files)
      }
    end
  end
end
before_config(app) click to toggle source
# File lib/bubble-wrap/loader.rb, line 43
def before_config(app)
  app.files = ::BubbleWrap::Requirement.files(app.files)
  app.files_dependencies ::BubbleWrap::Requirement.files_dependencies
  app.frameworks = ::BubbleWrap::Requirement.frameworks(app.frameworks)
end
create_uuid() click to toggle source
# File motion/core.rb, line 31
def create_uuid
  uuid = CFUUIDCreate(nil)
  CFUUIDCreateString(nil, uuid)
end
localized_string(key, value=nil) click to toggle source
# File motion/core.rb, line 22
def localized_string(key, value=nil)
  NSBundle.mainBundle.localizedStringForKey(key, value:value, table:nil)
end
p(arg) click to toggle source

I had issues with p on the device, this is a temporary workaround

# File motion/core.rb, line 27
def p(arg)
  NSLog arg.inspect
end
require(file_spec, &block) click to toggle source
# File lib/bubble-wrap/loader.rb, line 23
def require(file_spec, &block)
  Requirement.scan(caller.first, file_spec, &block)
end
require_ios(requirement = nil, &callback) click to toggle source
# File lib/bubble-wrap/loader.rb, line 27
def require_ios(requirement = nil, &callback)
  if !Motion::Project::App.osx?
    callback.call
  else
    puts "bubble-wrap/#{requirement} requires iOS to use." if requirement
  end
end
require_osx(requirement = nil, &callback) click to toggle source
# File lib/bubble-wrap/loader.rb, line 35
def require_osx(requirement = nil, &callback)
  if Motion::Project::App.osx?
    callback.call
  else
    puts "bubble-wrap/#{requirement} requires OS X to use." if requirement
  end
end
rgb_color(r,g,b) click to toggle source

@return [UIcolor]

# File motion/core.rb, line 5
def rgb_color(r,g,b)
  rgba_color(r,g,b,1)
end
rgba_color(r,g,b,a) click to toggle source

@return [UIcolor]

# File motion/core.rb, line 10
def rgba_color(r,g,b,a)
  r,g,b = [r,g,b].map { |i| i / 255.0}
  if a > 1.0
    a = a / 255.0
  end
  if App.osx?
    NSColor.colorWithDeviceRed(r, green: g, blue: b, alpha: a)
  else
    UIColor.colorWithRed(r, green: g, blue:b, alpha:a)
  end
end
root() click to toggle source
# File lib/bubble-wrap/loader.rb, line 19
def root
  File.expand_path('../../../', __FILE__)
end
version() click to toggle source
# File motion/shortcut.rb, line 24
def version
  BubbleWrap::VERSION
end