confetti 0.7.16 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- confetti (0.7.16)
4
+ confetti (0.8.0)
5
5
  mustache (~> 0.11.2)
6
6
 
7
7
  GEM
@@ -19,7 +19,6 @@ require 'typedset'
19
19
  require 'confetti/version'
20
20
  require 'confetti/error'
21
21
  require 'confetti/helpers'
22
- require 'confetti/phonegap'
23
22
 
24
23
  require 'confetti/template'
25
24
  require 'confetti/templates/base'
@@ -37,6 +36,9 @@ require 'confetti/templates/windows_phone7_manifest'
37
36
 
38
37
  require 'confetti/template_helper'
39
38
 
39
+ require 'confetti/config/classes'
40
+ require 'confetti/phonegap/plugin'
41
+ require 'confetti/phonegap'
40
42
  require 'confetti/config'
41
43
  require 'confetti/config/feature'
42
44
  require 'confetti/config/image'
@@ -4,17 +4,11 @@ module Confetti
4
4
  include PhoneGap
5
5
  self.extend TemplateHelper
6
6
 
7
- class XMLError < Confetti::Error ; end
8
-
9
- class FileError < Confetti::Error ; end
10
-
11
- class FiletypeError < Confetti::Error ; end
12
-
13
7
  attr_accessor :package, :version_string, :version_code, :description,
14
8
  :height, :width, :plist_icon_set
15
9
  attr_reader :author, :viewmodes, :name, :license, :content,
16
10
  :icon_set, :feature_set, :preference_set, :xml_doc,
17
- :splash_set, :plist_icon_set, :access_set
11
+ :splash_set, :plist_icon_set, :access_set, :plugin_set
18
12
 
19
13
  generate_and_write :android_manifest, :android_strings, :webos_appinfo,
20
14
  :ios_info, :symbian_wrt_info, :blackberry_widgets_config,
@@ -32,15 +26,6 @@ module Confetti
32
26
  end
33
27
  end
34
28
 
35
- # classes that represent child elements
36
- Author = Class.new Struct.new(:name, :href, :email)
37
- Name = Class.new Struct.new(:name, :shortname)
38
- License = Class.new Struct.new(:text, :href)
39
- Content = Class.new Struct.new(:src, :type, :encoding)
40
- Feature = Class.new Struct.new(:name, :required)
41
- Preference = Class.new Struct.new(:name, :value, :readonly)
42
- Access = Class.new Struct.new(:origin, :subdomains, :browserOnly)
43
-
44
29
  def initialize(*args)
45
30
  @author = Author.new
46
31
  @name = Name.new
@@ -52,6 +37,7 @@ module Confetti
52
37
  @splash_set = TypedSet.new Image
53
38
  @preference_set = TypedSet.new Preference
54
39
  @access_set = TypedSet.new Access
40
+ @plugin_set = TypedSet.new Plugin # defined in PhoneGap module
55
41
  @viewmodes = []
56
42
 
57
43
  if args.length > 0 && is_file?(args.first)
@@ -116,6 +102,14 @@ module Confetti
116
102
  when "splash"
117
103
  next if attr["src"].nil? or attr["src"].empty?
118
104
  @splash_set << Image.new(attr["src"], attr["height"], attr["width"], attr)
105
+ when "plugin"
106
+ next if attr["name"].nil? or attr["name"].empty?
107
+ plugin = Plugin.new(attr["name"], attr["version"])
108
+ ele.each_element('param') do |param|
109
+ p_attr = param.attributes
110
+ plugin.param_set << Param.new(p_attr["name"], p_attr["value"])
111
+ end
112
+ @plugin_set << plugin
119
113
  end
120
114
  end
121
115
  end
@@ -0,0 +1,17 @@
1
+ module Confetti
2
+ class Config
3
+ class XMLError < Confetti::Error ; end
4
+ class FileError < Confetti::Error ; end
5
+ class FiletypeError < Confetti::Error ; end
6
+
7
+ # classes that represent child elements
8
+ Author = Class.new Struct.new(:name, :href, :email)
9
+ Name = Class.new Struct.new(:name, :shortname)
10
+ License = Class.new Struct.new(:text, :href)
11
+ Content = Class.new Struct.new(:src, :type, :encoding)
12
+ Feature = Class.new Struct.new(:name, :required)
13
+ Preference = Class.new Struct.new(:name, :value, :readonly)
14
+ Access = Class.new Struct.new(:origin, :subdomains, :browserOnly)
15
+ Param = Class.new Struct.new(:name, :value)
16
+ end
17
+ end
@@ -3,8 +3,6 @@ module Confetti
3
3
  class Feature
4
4
  attr_reader :param_set
5
5
 
6
- Param = Class.new
7
-
8
6
  def initialize(name, src)
9
7
  @param_set = TypedSet.new Param
10
8
  super name, src
@@ -1,7 +1,6 @@
1
1
  module Confetti
2
2
  module PhoneGap
3
3
  PHONEGAP_APIS = %w{camera notification geolocation media contacts file network}
4
- Plugin = Class.new Struct.new(:name, :version)
5
4
 
6
5
  def add_stock_phonegap_apis
7
6
  PHONEGAP_APIS.each do |api|
@@ -25,7 +24,9 @@ module Confetti
25
24
  end
26
25
  end
27
26
 
28
- def plugins
27
+ # deprecated in favor of gap:plugin tags
28
+ # still supported for ChildBrowser
29
+ def legacy_plugins
29
30
  p_name = /http:\/\/plugins[.]phonegap[.]com\/([^\/]*)\/([^\/]*)/
30
31
 
31
32
  # find features corresponding to plugins
@@ -0,0 +1,12 @@
1
+ module Confetti
2
+ module PhoneGap
3
+ class Plugin < Struct.new(:name, :version)
4
+ attr_reader :param_set
5
+
6
+ def initialize(name, src)
7
+ @param_set = TypedSet.new Confetti::Config::Param
8
+ super name, src
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module Confetti
2
- VERSION = "0.7.16"
2
+ VERSION = "0.8.0"
3
3
  end
@@ -20,8 +20,8 @@ describe Confetti::Config::Feature do
20
20
  @feature.param_set.should be_a TypedSet
21
21
  end
22
22
 
23
- it "should make the param_set set typed to Confetti::Config::Feature::Param" do
24
- @feature.param_set.set_class.should be Confetti::Config::Feature::Param
23
+ it "should make the param_set set typed to Confetti::Config::Param" do
24
+ @feature.param_set.set_class.should be Confetti::Config::Param
25
25
  end
26
26
 
27
27
  it "should not allow the param_set to be clobbered" do
@@ -129,6 +129,14 @@ describe Confetti::Config do
129
129
  }
130
130
  }.should raise_error
131
131
  end
132
+
133
+ it "has a plugin_set field, that is a TypedSet" do
134
+ @config.plugin_set.should be_a TypedSet
135
+ end
136
+
137
+ it "plugin_set should be typed to plugin objects" do
138
+ @config.plugin_set.set_class.should be Confetti::Config::Plugin
139
+ end
132
140
  end
133
141
 
134
142
  describe "#initialize with file" do
@@ -391,6 +399,52 @@ describe Confetti::Config do
391
399
  end
392
400
  end
393
401
  end
402
+
403
+ describe "plugins" do
404
+ before do
405
+ @config = Confetti::Config.new
406
+ @config.populate_from_xml(fixture_dir + "/config-plugins.xml")
407
+ @plugins = @config.plugin_set
408
+ end
409
+
410
+ it "should populate the plugin set" do
411
+ @plugins.size.should be 3
412
+ end
413
+
414
+ describe "plugin set created" do
415
+ before do
416
+ @child = @plugins.detect { |a| a.name == "ChildBrowser" }
417
+ @push = @plugins.detect { |a| a.name == "PushNotifications" }
418
+ @fbconnect = @plugins.detect { |a| a.name == "FBConnect" }
419
+ end
420
+
421
+ it "should set the version properties correctly" do
422
+ @child.version.should be_nil
423
+ @push.version.should == "~2.0"
424
+ @fbconnect.version.should == "~1"
425
+ end
426
+
427
+ describe "params" do
428
+ it "should be empty when none are specified" do
429
+ @child.param_set.should be_empty
430
+ @push.param_set.should be_empty
431
+ end
432
+
433
+ it "should be populated when specified" do
434
+ @fbconnect.param_set.size.should == 2
435
+ end
436
+
437
+ it "should be populated correctly" do
438
+ params = @fbconnect.param_set
439
+ key = params.detect { |pm| pm.name == "APIKey" }
440
+ secret = params.detect { |pm| pm.name == "APISecret" }
441
+
442
+ key.value.should == "SOMEKEY"
443
+ secret.value.should == "SOMESECRET"
444
+ end
445
+ end
446
+ end
447
+ end
394
448
  end
395
449
 
396
450
  describe "config generation" do
@@ -0,0 +1,60 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <widget xmlns = "http://www.w3.org/ns/widgets"
3
+ xmlns:gap = "http://phonegap.com/ns/1.0"
4
+ id = "com.alunny.confetti"
5
+ version = "1.0.0">
6
+
7
+ <name>Confetti Sample App</name>
8
+
9
+ <description>
10
+ This is a sample config.xml for integration testing with Confetti
11
+ </description>
12
+
13
+ <license href="http://www.opensource.org/licenses/mit-license.php">The MIT License
14
+
15
+ Copyright (c) 2011 Andrew Lunny
16
+
17
+ Permission is hereby granted, free of charge, to any person obtaining a copy
18
+ of this software and associated documentation files (the &quot;Software&quot;), to deal
19
+ in the Software without restriction, including without limitation the rights
20
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
+ copies of the Software, and to permit persons to whom the Software is
22
+ furnished to do so, subject to the following conditions:
23
+
24
+ The above copyright notice and this permission notice shall be included in
25
+ all copies or substantial portions of the Software.
26
+
27
+ THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
33
+ THE SOFTWARE.</license>
34
+
35
+ <author href="http://alunny.github.com"
36
+ email="alunny@gmail.com">
37
+ Andrew Lunny
38
+ </author>
39
+
40
+ <icon src="icon.png" height="150" width="200" />
41
+
42
+ <gap:splash src="mainsplash.png" height="480" width="360" />
43
+
44
+ <preference name="universal" value="true"/>
45
+ <preference name="phonegap-version" value="1.3.0"/>
46
+
47
+ <feature name="http://api.phonegap.com/1.0/geolocation" required="true"/>
48
+ <feature name="http://api.phonegap.com/1.0/camera" required="true"/>
49
+ <feature name="http://api.phonegap.com/1.0/notification" required="true"/>
50
+
51
+ <access origin="*" />
52
+
53
+ <gap:plugin name="ChildBrowser" />
54
+ <gap:plugin name="PushNotifications" version="~2.0" />
55
+
56
+ <gap:plugin name="FBConnect" version="~1" >
57
+ <param name="APIKey" value="SOMEKEY" />
58
+ <param name="APISecret" value="SOMESECRET" />
59
+ </gap:plugin>
60
+ </widget>
@@ -30,7 +30,7 @@ describe Confetti::PhoneGap do
30
30
  end
31
31
  end
32
32
 
33
- describe "#plugins" do
33
+ describe "#legacy_plugins" do
34
34
  before do
35
35
  @obj.feature_set = []
36
36
  childbrowser = "http://plugins.phonegap.com/ChildBrowser/1.0.1"
@@ -44,17 +44,17 @@ describe Confetti::PhoneGap do
44
44
  end
45
45
 
46
46
  it "should return an array with 2 entries" do
47
- @obj.plugins.length.should be 2
47
+ @obj.legacy_plugins.length.should be 2
48
48
  end
49
49
 
50
50
  it "should return an array with 2 Plugin objects" do
51
- @obj.plugins.first.should be_a Confetti::PhoneGap::Plugin
52
- @obj.plugins.last.should be_a Confetti::PhoneGap::Plugin
51
+ @obj.legacy_plugins.first.should be_a Confetti::PhoneGap::Plugin
52
+ @obj.legacy_plugins.last.should be_a Confetti::PhoneGap::Plugin
53
53
  end
54
54
 
55
55
  it "should return the right data as plugins" do
56
- childbrowser = @obj.plugins.first
57
- fbconnect = @obj.plugins.last
56
+ childbrowser = @obj.legacy_plugins.first
57
+ fbconnect = @obj.legacy_plugins.last
58
58
 
59
59
  childbrowser.name.should == "ChildBrowser"
60
60
  childbrowser.version.should == "1.0.1"
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Confetti::PhoneGap::Plugin do
4
+ before do
5
+ @child = Confetti::PhoneGap::Plugin.new("ChildBrowser", "~2.0")
6
+ end
7
+
8
+ it "should have a readable and writable name field" do
9
+ lambda { @child.name = "MediaBrowser" }.should_not raise_error
10
+ @child.name.should == "MediaBrowser"
11
+ end
12
+
13
+ it "should have a readable and writable version field" do
14
+ lambda { @child.version = "1.0" }.should_not raise_error
15
+ @child.version.should == "1.0"
16
+ end
17
+
18
+ describe "parameter set" do
19
+ it "should have a param_set field, that is a TypedSet" do
20
+ @child.param_set.should be_a TypedSet
21
+ end
22
+
23
+ it "should make the param_set set typed to Confetti::Config::Param" do
24
+ @child.param_set.set_class.should be Confetti::Config::Param
25
+ end
26
+
27
+ it "should not allow the param_set to be clobbered" do
28
+ lambda {
29
+ @child.param_set = { :accuracy => 2.0 }
30
+ }.should raise_error
31
+ end
32
+ end
33
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 7
8
- - 16
9
- version: 0.7.16
7
+ - 8
8
+ - 0
9
+ version: 0.8.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Andrew Lunny
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-05-29 00:00:00 -07:00
19
+ date: 2012-06-08 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -66,11 +66,13 @@ files:
66
66
  - confetti.gemspec
67
67
  - lib/confetti.rb
68
68
  - lib/confetti/config.rb
69
+ - lib/confetti/config/classes.rb
69
70
  - lib/confetti/config/feature.rb
70
71
  - lib/confetti/config/image.rb
71
72
  - lib/confetti/error.rb
72
73
  - lib/confetti/helpers.rb
73
74
  - lib/confetti/phonegap.rb
75
+ - lib/confetti/phonegap/plugin.rb
74
76
  - lib/confetti/template.rb
75
77
  - lib/confetti/template_helper.rb
76
78
  - lib/confetti/templates/android_manifest.mustache
@@ -120,6 +122,7 @@ files:
120
122
  - spec/fixtures/config-icons-custom-attribs.xml
121
123
  - spec/fixtures/config-icons.xml
122
124
  - spec/fixtures/config-long-desc.xml
125
+ - spec/fixtures/config-plugins.xml
123
126
  - spec/fixtures/config.xml
124
127
  - spec/fixtures/config_fullscreen.xml
125
128
  - spec/fixtures/config_legacy.xml
@@ -144,6 +147,7 @@ files:
144
147
  - spec/helpers_spec.rb
145
148
  - spec/integration_spec.rb
146
149
  - spec/phonegap_spec.rb
150
+ - spec/plugin_spec.rb
147
151
  - spec/spec_helper.rb
148
152
  - spec/template_spec.rb
149
153
  - spec/templates/android_manifest_spec.rb
@@ -212,6 +216,7 @@ test_files:
212
216
  - spec/fixtures/config-icons-custom-attribs.xml
213
217
  - spec/fixtures/config-icons.xml
214
218
  - spec/fixtures/config-long-desc.xml
219
+ - spec/fixtures/config-plugins.xml
215
220
  - spec/fixtures/config.xml
216
221
  - spec/fixtures/config_fullscreen.xml
217
222
  - spec/fixtures/config_legacy.xml
@@ -236,6 +241,7 @@ test_files:
236
241
  - spec/helpers_spec.rb
237
242
  - spec/integration_spec.rb
238
243
  - spec/phonegap_spec.rb
244
+ - spec/plugin_spec.rb
239
245
  - spec/spec_helper.rb
240
246
  - spec/template_spec.rb
241
247
  - spec/templates/android_manifest_spec.rb