Module: Confetti::PhoneGap

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

Constant Summary collapse

PHONEGAP_APIS =
%w{camera notification geolocation media contacts file network}
Plugin =
Class.new Struct.new(:name, :version)

Instance Method Summary collapse

Instance Method Details

#add_stock_phonegap_apisObject



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

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

#phonegap_versionObject



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

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

#phonegap_version=(v) ⇒ Object



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

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

#pluginsObject



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

def 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