confetti 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/lib/confetti/config.rb +18 -8
- data/lib/confetti/version.rb +1 -1
- data/spec/config/config_image_spec.rb +22 -0
- data/spec/config_spec.rb +43 -8
- data/spec/fixtures/config-icons-custom-attribs.xml +2 -0
- data/spec/fixtures/config.xml +3 -0
- metadata +7 -7
- data/spec/config/config_icon_spec.rb +0 -22
data/Gemfile.lock
CHANGED
data/lib/confetti/config.rb
CHANGED
@@ -6,7 +6,8 @@ module Confetti
|
|
6
6
|
|
7
7
|
attr_accessor :package, :version, :description, :height, :width
|
8
8
|
attr_reader :author, :viewmodes, :name, :license, :content,
|
9
|
-
:icon_set, :feature_set, :preference_set, :xml_doc
|
9
|
+
:icon_set, :feature_set, :preference_set, :xml_doc,
|
10
|
+
:splash_set
|
10
11
|
|
11
12
|
generate_and_write :android_manifest, :android_strings, :webos_appinfo,
|
12
13
|
:ios_info, :symbian_wrt_info, :blackberry_widgets_config
|
@@ -16,7 +17,7 @@ module Confetti
|
|
16
17
|
Name = Class.new Struct.new(:name, :shortname)
|
17
18
|
License = Class.new Struct.new(:text, :href)
|
18
19
|
Content = Class.new Struct.new(:src, :type, :encoding)
|
19
|
-
|
20
|
+
Image = Class.new Struct.new(:src, :height, :width, :extras)
|
20
21
|
Feature = Class.new Struct.new(:name, :required)
|
21
22
|
Preference = Class.new Struct.new(:name, :value, :readonly)
|
22
23
|
|
@@ -25,8 +26,9 @@ module Confetti
|
|
25
26
|
@name = Name.new
|
26
27
|
@license = License.new
|
27
28
|
@content = Content.new
|
28
|
-
@icon_set = TypedSet.new
|
29
|
+
@icon_set = TypedSet.new Image
|
29
30
|
@feature_set = TypedSet.new Feature
|
31
|
+
@splash_set = TypedSet.new Image
|
30
32
|
@preference_set = TypedSet.new Preference
|
31
33
|
@viewmodes = []
|
32
34
|
|
@@ -61,11 +63,11 @@ module Confetti
|
|
61
63
|
when "description"
|
62
64
|
@description = ele.text.strip
|
63
65
|
when "icon"
|
64
|
-
extras = attr
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
@
|
66
|
+
extras = grab_extras attr
|
67
|
+
@icon_set << Image.new(attr["src"], attr["height"], attr["width"], extras)
|
68
|
+
when "splash"
|
69
|
+
extras = grab_extras attr
|
70
|
+
@splash_set << Image.new(attr["src"], attr["height"], attr["width"], extras)
|
69
71
|
when "feature"
|
70
72
|
@feature_set << Feature.new(attr["name"], attr["required"])
|
71
73
|
when "license"
|
@@ -81,5 +83,13 @@ module Confetti
|
|
81
83
|
def biggest_icon
|
82
84
|
@icon_set.max { |a,b| a.width.to_i <=> b.width.to_i }
|
83
85
|
end
|
86
|
+
|
87
|
+
def grab_extras(attributes)
|
88
|
+
extras = attributes.keys.inject({}) do |hash, key|
|
89
|
+
hash[key] = attributes[key] unless Image.public_instance_methods.include? key
|
90
|
+
hash
|
91
|
+
end
|
92
|
+
extras
|
93
|
+
end
|
84
94
|
end
|
85
95
|
end
|
data/lib/confetti/version.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Confetti::Config::Image do
|
4
|
+
before do
|
5
|
+
@image = Confetti::Config::Image.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should have a readable and writable src field" do
|
9
|
+
lambda { @image.src = "icon.png" }.should_not raise_error
|
10
|
+
@image.src.should == "icon.png"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have a readable and writable width field" do
|
14
|
+
lambda { @image.width = 50 }.should_not raise_error
|
15
|
+
@image.width.should == 50
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have a readable and writable height field" do
|
19
|
+
lambda { @image.height = 50 }.should_not raise_error
|
20
|
+
@image.height.should == 50
|
21
|
+
end
|
22
|
+
end
|
data/spec/config_spec.rb
CHANGED
@@ -84,8 +84,8 @@ describe Confetti::Config do
|
|
84
84
|
@config.icon_set.should be_a TypedSet
|
85
85
|
end
|
86
86
|
|
87
|
-
it "icon_set should be typed to
|
88
|
-
@config.icon_set.set_class.should be Confetti::Config::
|
87
|
+
it "icon_set should be typed to Image objects" do
|
88
|
+
@config.icon_set.set_class.should be Confetti::Config::Image
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should not allow icon_set to be clobbered" do
|
@@ -210,6 +210,40 @@ describe Confetti::Config do
|
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
213
|
+
describe "splash screens" do
|
214
|
+
it "should append splash screens to the splash_set" do
|
215
|
+
@config.splash_set.size.should be 1
|
216
|
+
end
|
217
|
+
|
218
|
+
it "should set the splash screen's src correctly" do
|
219
|
+
@config.splash_set.first.src.should == "mainsplash.png"
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should set the splash screen's height correctly" do
|
223
|
+
@config.splash_set.first.height.should == "480"
|
224
|
+
end
|
225
|
+
|
226
|
+
it "should set the splash screen's width correctly" do
|
227
|
+
@config.splash_set.first.width.should == "360"
|
228
|
+
end
|
229
|
+
|
230
|
+
describe "with custom splash screen attributes" do
|
231
|
+
before do
|
232
|
+
@config = Confetti::Config.new
|
233
|
+
@config.populate_from_xml(fixture_dir + "/config-icons-custom-attribs.xml")
|
234
|
+
end
|
235
|
+
|
236
|
+
it "should populate splash screen non-standards attributes to extras field" do
|
237
|
+
@config.splash_set.size.should be 1
|
238
|
+
@config.splash_set.first.extras.should_not == nil
|
239
|
+
@config.splash_set.first.extras.length.should be 1
|
240
|
+
@config.splash_set.first.extras["main"].should == "true"
|
241
|
+
end
|
242
|
+
|
243
|
+
end
|
244
|
+
|
245
|
+
end
|
246
|
+
|
213
247
|
describe "icons" do
|
214
248
|
it "should append icons to the icon_set" do
|
215
249
|
@config.icon_set.size.should be 1
|
@@ -250,6 +284,7 @@ describe Confetti::Config do
|
|
250
284
|
@config.icon_set.first.extras.length.should be 1
|
251
285
|
@config.icon_set.first.extras["hover"].should == "true"
|
252
286
|
end
|
287
|
+
|
253
288
|
end
|
254
289
|
end
|
255
290
|
|
@@ -299,12 +334,12 @@ describe Confetti::Config do
|
|
299
334
|
@config = Confetti::Config.new(fixture_dir + "/config.xml")
|
300
335
|
end
|
301
336
|
|
302
|
-
it "#icon should return an
|
303
|
-
@config.icon.should be_a Confetti::Config::
|
337
|
+
it "#icon should return an Image" do
|
338
|
+
@config.icon.should be_a Confetti::Config::Image
|
304
339
|
end
|
305
340
|
|
306
|
-
it "#biggest_icon should return an
|
307
|
-
@config.biggest_icon.should be_a Confetti::Config::
|
341
|
+
it "#biggest_icon should return an Image" do
|
342
|
+
@config.biggest_icon.should be_a Confetti::Config::Image
|
308
343
|
end
|
309
344
|
end
|
310
345
|
|
@@ -313,8 +348,8 @@ describe Confetti::Config do
|
|
313
348
|
@config.populate_from_xml(fixture_dir + "/config-icons.xml")
|
314
349
|
end
|
315
350
|
|
316
|
-
it "#icon should return a single
|
317
|
-
@config.icon.should be_a Confetti::Config::
|
351
|
+
it "#icon should return a single Image" do
|
352
|
+
@config.icon.should be_a Confetti::Config::Image
|
318
353
|
end
|
319
354
|
|
320
355
|
it "#biggest_icon should return the bigger of the two" do
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<widget xmlns = "http://www.w3.org/ns/widgets"
|
3
3
|
xmlns:rim="http://www.blackberry.com/ns/widgets"
|
4
|
+
xmlns:gap = "http://phonegap.com/ns/1.0"
|
4
5
|
id = "com.alunny.confetti"
|
5
6
|
version = "1.0.0">
|
6
7
|
|
@@ -16,6 +17,7 @@
|
|
16
17
|
</author>
|
17
18
|
|
18
19
|
<icon src="smallicon.png" height="100" width="100" rim:hover="true" />
|
20
|
+
<gap:splash src="mainsplash.png" height="480" width="360" rim:main="true" />
|
19
21
|
|
20
22
|
<feature name="http://api.phonegap.com/1.0/geolocation"/>
|
21
23
|
<feature name="http://api.phonegap.com/1.0/network"/>
|
data/spec/fixtures/config.xml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<widget xmlns = "http://www.w3.org/ns/widgets"
|
3
|
+
xmlns:gap = "http://phonegap.com/ns/1.0"
|
3
4
|
id = "com.alunny.confetti"
|
4
5
|
version = "1.0.0">
|
5
6
|
|
@@ -38,6 +39,8 @@ THE SOFTWARE.</license>
|
|
38
39
|
|
39
40
|
<icon src="icon.png" height="150" width="200" />
|
40
41
|
|
42
|
+
<gap:splash src="mainsplash.png" height="480" width="360" />
|
43
|
+
|
41
44
|
<feature name="http://api.phonegap.com/1.0/geolocation" required="true"/>
|
42
45
|
<feature name="http://api.phonegap.com/1.0/camera" required="true"/>
|
43
46
|
<feature name="http://api.phonegap.com/1.0/notification" required="true"/>
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confetti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andrew Lunny
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-29 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -147,7 +147,7 @@ files:
|
|
147
147
|
- spec/config/config_author_spec.rb
|
148
148
|
- spec/config/config_content_spec.rb
|
149
149
|
- spec/config/config_feature_spec.rb
|
150
|
-
- spec/config/
|
150
|
+
- spec/config/config_image_spec.rb
|
151
151
|
- spec/config/config_license_spec.rb
|
152
152
|
- spec/config/config_name_spec.rb
|
153
153
|
- spec/config/config_preference_spec.rb
|
@@ -212,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
212
|
requirements: []
|
213
213
|
|
214
214
|
rubyforge_project: confetti
|
215
|
-
rubygems_version: 1.
|
215
|
+
rubygems_version: 1.5.0
|
216
216
|
signing_key:
|
217
217
|
specification_version: 3
|
218
218
|
summary: Generate mobile app config files
|
@@ -228,7 +228,7 @@ test_files:
|
|
228
228
|
- spec/config/config_author_spec.rb
|
229
229
|
- spec/config/config_content_spec.rb
|
230
230
|
- spec/config/config_feature_spec.rb
|
231
|
-
- spec/config/
|
231
|
+
- spec/config/config_image_spec.rb
|
232
232
|
- spec/config/config_license_spec.rb
|
233
233
|
- spec/config/config_name_spec.rb
|
234
234
|
- spec/config/config_preference_spec.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Confetti::Config::Icon do
|
4
|
-
before do
|
5
|
-
@icon = Confetti::Config::Icon.new
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should have a readable and writable src field" do
|
9
|
-
lambda { @icon.src = "icon.png" }.should_not raise_error
|
10
|
-
@icon.src.should == "icon.png"
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should have a readable and writable width field" do
|
14
|
-
lambda { @icon.width = 50 }.should_not raise_error
|
15
|
-
@icon.width.should == 50
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should have a readable and writable height field" do
|
19
|
-
lambda { @icon.height = 50 }.should_not raise_error
|
20
|
-
@icon.height.should == 50
|
21
|
-
end
|
22
|
-
end
|