Module: Confetti::PhoneGap

Included in:
Config
Defined in:
lib/confetti/phonegap.rb,
lib/confetti/phonegap/plugin.rb

Defined Under Namespace

Classes: Plugin

Constant Summary collapse

PHONEGAP_APIS =
%w{camera notification geolocation media contacts file network}

Instance Method Summary collapse

Instance Method Details

#add_stock_phonegap_apisObject



5
6
7
8
9
10
# File 'lib/confetti/phonegap.rb', line 5

def add_stock_phonegap_apis
  PHONEGAP_APIS.each do |api|
    api_name = "http://api.phonegap.com/1.0/#{ api }"
    self.feature_set << Confetti::Config::Feature.new(api_name, nil)
  end
end

#legacy_pluginsObject

deprecated in favor of gap:plugin tags still supported for ChildBrowser



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/confetti/phonegap.rb', line 29

def legacy_plugins
  p_name = /http:\/\/plugins[.]phonegap[.]com\/([^\/]*)\/([^\/]*)/

  # find features corresponding to plugins
  plugin_features = self.feature_set.select do |f|
    !f.name.nil? && f.name.match(p_name)
  end

  # turn matching features into plugins
  plugin_features.map do |f|
    matches = f.name.match(p_name)
    Plugin.new(matches[1], matches[2])
  end
end

#phonegap_versionObject



12
13
14
# File 'lib/confetti/phonegap.rb', line 12

def phonegap_version
  self.preference("phonegap-version").to_s
end

#phonegap_version=(v) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/confetti/phonegap.rb', line 16

def phonegap_version= v
  pref = self.preference_obj("phonegap-version")

  if pref.nil?
    pref = Confetti::Config::Preference.new("phonegap-version", v)
    self.preference_set << pref
  else
    pref.value = v
  end
end