confetti 0.3.7 → 0.3.8
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 +9 -9
- data/confetti.gemspec +1 -1
- data/lib/confetti.rb +2 -0
- data/lib/confetti/cli.rb +4 -2
- data/lib/confetti/config.rb +62 -25
- data/lib/confetti/version.rb +1 -1
- data/spec/cli_spec.rb +28 -0
- data/spec/config_spec.rb +26 -0
- data/spec/fixtures/config.xml +5 -0
- metadata +8 -21
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
confetti (0.3.
|
4
|
+
confetti (0.3.8)
|
5
5
|
mustache (~> 0.11.2)
|
6
6
|
thor (~> 0.14.3)
|
7
7
|
|
@@ -25,14 +25,14 @@ GEM
|
|
25
25
|
term-ansicolor (~> 1.0.5)
|
26
26
|
json (1.4.6)
|
27
27
|
mustache (0.11.2)
|
28
|
-
rspec (2.
|
29
|
-
rspec-core (~> 2.
|
30
|
-
rspec-expectations (~> 2.
|
31
|
-
rspec-mocks (~> 2.
|
32
|
-
rspec-core (2.
|
33
|
-
rspec-expectations (2.
|
28
|
+
rspec (2.6.0)
|
29
|
+
rspec-core (~> 2.6.0)
|
30
|
+
rspec-expectations (~> 2.6.0)
|
31
|
+
rspec-mocks (~> 2.6.0)
|
32
|
+
rspec-core (2.6.4)
|
33
|
+
rspec-expectations (2.6.0)
|
34
34
|
diff-lcs (~> 1.1.2)
|
35
|
-
rspec-mocks (2.
|
35
|
+
rspec-mocks (2.6.0)
|
36
36
|
term-ansicolor (1.0.5)
|
37
37
|
thor (0.14.6)
|
38
38
|
|
@@ -43,4 +43,4 @@ DEPENDENCIES
|
|
43
43
|
aruba
|
44
44
|
confetti!
|
45
45
|
cucumber
|
46
|
-
rspec (~> 2.
|
46
|
+
rspec (~> 2.6.0)
|
data/confetti.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_dependency "mustache", "~> 0.11.2"
|
24
24
|
s.add_dependency "thor", "~> 0.14.3"
|
25
25
|
|
26
|
-
s.add_development_dependency "rspec", "~> 2.
|
26
|
+
s.add_development_dependency "rspec", "~> 2.6.0"
|
27
27
|
s.add_development_dependency "cucumber"
|
28
28
|
s.add_development_dependency "aruba"
|
29
29
|
end
|
data/lib/confetti.rb
CHANGED
data/lib/confetti/cli.rb
CHANGED
@@ -11,8 +11,10 @@ module Confetti
|
|
11
11
|
|
12
12
|
begin
|
13
13
|
config.send msg
|
14
|
-
rescue
|
15
|
-
fail "Confetti
|
14
|
+
rescue Confetti::Config::FiletypeError
|
15
|
+
fail "Confetti failed: #{ output_file } unsupported"
|
16
|
+
rescue Confetti::Error => e
|
17
|
+
fail "Confetti Failed: #{ e.message }"
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
data/lib/confetti/config.rb
CHANGED
@@ -8,15 +8,29 @@ module Confetti
|
|
8
8
|
|
9
9
|
class FileError < Confetti::Error ; end
|
10
10
|
|
11
|
+
class FiletypeError < Confetti::Error ; end
|
12
|
+
|
11
13
|
attr_accessor :package, :version_string, :version_code, :description,
|
12
14
|
:height, :width, :plist_icon_set
|
13
15
|
attr_reader :author, :viewmodes, :name, :license, :content,
|
14
16
|
:icon_set, :feature_set, :preference_set, :xml_doc,
|
15
|
-
:splash_set, :plist_icon_set
|
17
|
+
:splash_set, :plist_icon_set, :plugin_set
|
16
18
|
|
17
19
|
generate_and_write :android_manifest, :android_strings, :webos_appinfo,
|
18
20
|
:ios_info, :symbian_wrt_info, :blackberry_widgets_config
|
19
21
|
|
22
|
+
# handle bad generate/write calls
|
23
|
+
def method_missing(method_name, *args)
|
24
|
+
bad_call = /^(generate)|(write)_(.*)$/
|
25
|
+
matches = method_name.to_s.match(bad_call)
|
26
|
+
|
27
|
+
if matches
|
28
|
+
raise FiletypeError, "#{ matches[3] } not supported"
|
29
|
+
else
|
30
|
+
super method_name, *args
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
20
34
|
# classes that represent child elements
|
21
35
|
Author = Class.new Struct.new(:name, :href, :email)
|
22
36
|
Name = Class.new Struct.new(:name, :shortname)
|
@@ -25,6 +39,7 @@ module Confetti
|
|
25
39
|
Image = Class.new Struct.new(:src, :height, :width, :extras)
|
26
40
|
Feature = Class.new Struct.new(:name, :required)
|
27
41
|
Preference = Class.new Struct.new(:name, :value, :readonly)
|
42
|
+
Plugin = Class.new Struct.new(:name, :value, :platforms)
|
28
43
|
|
29
44
|
def initialize(*args)
|
30
45
|
@author = Author.new
|
@@ -36,6 +51,7 @@ module Confetti
|
|
36
51
|
@feature_set = TypedSet.new Feature
|
37
52
|
@splash_set = TypedSet.new Image
|
38
53
|
@preference_set = TypedSet.new Preference
|
54
|
+
@plugin_set = TypedSet.new Plugin
|
39
55
|
@viewmodes = []
|
40
56
|
|
41
57
|
if args.length > 0 && is_file?(args.first)
|
@@ -65,33 +81,46 @@ module Confetti
|
|
65
81
|
config_doc.elements.each do |ele|
|
66
82
|
attr = ele.attributes
|
67
83
|
|
68
|
-
case ele.
|
69
|
-
|
70
|
-
|
71
|
-
when "
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
84
|
+
case ele.namespace
|
85
|
+
|
86
|
+
# W3C widget elements
|
87
|
+
when "http://www.w3.org/ns/widgets"
|
88
|
+
case ele.name
|
89
|
+
when "name"
|
90
|
+
@name = Name.new(ele.text.nil? ? "" : ele.text.strip, attr["shortname"])
|
91
|
+
when "author"
|
92
|
+
@author = Author.new(ele.text.nil? ? "" : ele.text.strip, attr["href"], attr["email"])
|
93
|
+
when "description"
|
94
|
+
@description = ele.text.nil? ? "" : ele.text.strip
|
95
|
+
when "icon"
|
96
|
+
extras = grab_extras attr
|
97
|
+
@icon_set << Image.new(attr["src"], attr["height"], attr["width"], extras)
|
98
|
+
# used for the info.plist file
|
99
|
+
@plist_icon_set << attr["src"]
|
100
|
+
when "feature"
|
101
|
+
@feature_set << Feature.new(attr["name"], attr["required"])
|
102
|
+
when "preference"
|
103
|
+
@preference_set << Preference.new(attr["name"], attr["value"], attr["readonly"])
|
104
|
+
when "license"
|
105
|
+
@license = License.new(ele.text.nil? ? "" : ele.text.strip, attr["href"])
|
106
|
+
end
|
107
|
+
|
108
|
+
# PhoneGap extensions (gap:)
|
109
|
+
when "http://phonegap.com/ns/1.0"
|
110
|
+
case ele.name
|
111
|
+
when "splash"
|
112
|
+
extras = grab_extras attr
|
113
|
+
@splash_set << Image.new(attr["src"], attr["height"], attr["width"], extras)
|
114
|
+
when "plugin"
|
115
|
+
plugin = Plugin.new(attr["name"], attr["value"])
|
116
|
+
plugin.platforms = plugin_platforms(ele)
|
117
|
+
@plugin_set << plugin
|
118
|
+
end
|
89
119
|
end
|
90
120
|
end
|
121
|
+
end
|
91
122
|
|
92
|
-
|
93
|
-
|
94
|
-
def icon
|
123
|
+
def icon
|
95
124
|
@icon_set.first
|
96
125
|
end
|
97
126
|
|
@@ -132,5 +161,13 @@ module Confetti
|
|
132
161
|
|
133
162
|
pref && pref.value && pref.value.to_sym
|
134
163
|
end
|
164
|
+
|
165
|
+
# retrieve the specified platforms as a list of lowercase symbols
|
166
|
+
# extracted from children of ele
|
167
|
+
def plugin_platforms ele
|
168
|
+
ele.children.
|
169
|
+
select { |e| e.respond_to?(:name) and e.name == "platform" }.
|
170
|
+
map { |e| e.attributes["name"].downcase.to_sym }
|
171
|
+
end
|
135
172
|
end
|
136
173
|
end
|
data/lib/confetti/version.rb
CHANGED
data/spec/cli_spec.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Confetti::CLI do
|
4
|
+
include HelpfulPaths
|
5
|
+
|
6
|
+
describe "generate method" do
|
7
|
+
before do
|
8
|
+
Dir.stub(:pwd).and_return(fixture_dir)
|
9
|
+
@cli = Confetti::CLI.new
|
10
|
+
Confetti::Config.any_instance.stub(:open)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "with a correct ouput file" do
|
14
|
+
it "should not raise an error" do
|
15
|
+
lambda { @cli.generate "android_manifest" }.should_not raise_error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "with an unsupported output file" do
|
20
|
+
it "should raise the correct error" do
|
21
|
+
lambda {
|
22
|
+
@cli.generate "mgm_dvd"
|
23
|
+
}.should raise_error RuntimeError,
|
24
|
+
"Confetti failed: mgm_dvd unsupported"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/spec/config_spec.rb
CHANGED
@@ -329,6 +329,32 @@ describe Confetti::Config do
|
|
329
329
|
features_names.should include "http://api.phonegap.com/1.0/notification"
|
330
330
|
end
|
331
331
|
end
|
332
|
+
|
333
|
+
describe "plugins" do
|
334
|
+
it "should append plugins to the plugin set" do
|
335
|
+
@config.plugin_set.size.should be 1
|
336
|
+
end
|
337
|
+
|
338
|
+
describe "created object" do
|
339
|
+
before do
|
340
|
+
@plugin = @config.plugin_set.first
|
341
|
+
end
|
342
|
+
|
343
|
+
it "should have the right name" do
|
344
|
+
@plugin.name.should == "ChildBrowser"
|
345
|
+
end
|
346
|
+
|
347
|
+
it "should have the right value" do
|
348
|
+
package = "com.phonegap.plugins.childBrowser.ChildBrowser"
|
349
|
+
@plugin.value.should == package
|
350
|
+
end
|
351
|
+
|
352
|
+
it "should have the right platforms" do
|
353
|
+
@plugin.platforms.size.should be 1
|
354
|
+
@plugin.platforms.first.should be :android
|
355
|
+
end
|
356
|
+
end
|
357
|
+
end
|
332
358
|
end
|
333
359
|
end
|
334
360
|
|
data/spec/fixtures/config.xml
CHANGED
@@ -46,4 +46,9 @@ THE SOFTWARE.</license>
|
|
46
46
|
<feature name="http://api.phonegap.com/1.0/geolocation" required="true"/>
|
47
47
|
<feature name="http://api.phonegap.com/1.0/camera" required="true"/>
|
48
48
|
<feature name="http://api.phonegap.com/1.0/notification" required="true"/>
|
49
|
+
|
50
|
+
<gap:plugin name="ChildBrowser"
|
51
|
+
value="com.phonegap.plugins.childBrowser.ChildBrowser">
|
52
|
+
<platform name="android" />
|
53
|
+
</gap:plugin>
|
49
54
|
</widget>
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confetti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 29
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
8
|
+
- 8
|
9
|
+
version: 0.3.8
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Andrew Lunny
|
@@ -17,18 +16,16 @@ autorequire:
|
|
17
16
|
bindir: bin
|
18
17
|
cert_chain: []
|
19
18
|
|
20
|
-
date: 2011-08-
|
19
|
+
date: 2011-08-31 00:00:00 -07:00
|
21
20
|
default_executable:
|
22
21
|
dependencies:
|
23
22
|
- !ruby/object:Gem::Dependency
|
24
23
|
name: mustache
|
25
24
|
prerelease: false
|
26
25
|
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
26
|
requirements:
|
29
27
|
- - ~>
|
30
28
|
- !ruby/object:Gem::Version
|
31
|
-
hash: 55
|
32
29
|
segments:
|
33
30
|
- 0
|
34
31
|
- 11
|
@@ -40,11 +37,9 @@ dependencies:
|
|
40
37
|
name: thor
|
41
38
|
prerelease: false
|
42
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
40
|
requirements:
|
45
41
|
- - ~>
|
46
42
|
- !ruby/object:Gem::Version
|
47
|
-
hash: 33
|
48
43
|
segments:
|
49
44
|
- 0
|
50
45
|
- 14
|
@@ -56,27 +51,23 @@ dependencies:
|
|
56
51
|
name: rspec
|
57
52
|
prerelease: false
|
58
53
|
requirement: &id003 !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
54
|
requirements:
|
61
55
|
- - ~>
|
62
56
|
- !ruby/object:Gem::Version
|
63
|
-
hash: 11
|
64
57
|
segments:
|
65
58
|
- 2
|
66
|
-
-
|
59
|
+
- 6
|
67
60
|
- 0
|
68
|
-
version: 2.
|
61
|
+
version: 2.6.0
|
69
62
|
type: :development
|
70
63
|
version_requirements: *id003
|
71
64
|
- !ruby/object:Gem::Dependency
|
72
65
|
name: cucumber
|
73
66
|
prerelease: false
|
74
67
|
requirement: &id004 !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
68
|
requirements:
|
77
69
|
- - ">="
|
78
70
|
- !ruby/object:Gem::Version
|
79
|
-
hash: 3
|
80
71
|
segments:
|
81
72
|
- 0
|
82
73
|
version: "0"
|
@@ -86,11 +77,9 @@ dependencies:
|
|
86
77
|
name: aruba
|
87
78
|
prerelease: false
|
88
79
|
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
80
|
requirements:
|
91
81
|
- - ">="
|
92
82
|
- !ruby/object:Gem::Version
|
93
|
-
hash: 3
|
94
83
|
segments:
|
95
84
|
- 0
|
96
85
|
version: "0"
|
@@ -147,6 +136,7 @@ files:
|
|
147
136
|
- lib/confetti/templates/webos_appinfo.rb
|
148
137
|
- lib/confetti/version.rb
|
149
138
|
- lib/typedset.rb
|
139
|
+
- spec/cli_spec.rb
|
150
140
|
- spec/config/config_author_spec.rb
|
151
141
|
- spec/config/config_content_spec.rb
|
152
142
|
- spec/config/config_feature_spec.rb
|
@@ -204,27 +194,23 @@ rdoc_options: []
|
|
204
194
|
require_paths:
|
205
195
|
- lib
|
206
196
|
required_ruby_version: !ruby/object:Gem::Requirement
|
207
|
-
none: false
|
208
197
|
requirements:
|
209
198
|
- - ">="
|
210
199
|
- !ruby/object:Gem::Version
|
211
|
-
hash: 3
|
212
200
|
segments:
|
213
201
|
- 0
|
214
202
|
version: "0"
|
215
203
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
216
|
-
none: false
|
217
204
|
requirements:
|
218
205
|
- - ">="
|
219
206
|
- !ruby/object:Gem::Version
|
220
|
-
hash: 3
|
221
207
|
segments:
|
222
208
|
- 0
|
223
209
|
version: "0"
|
224
210
|
requirements: []
|
225
211
|
|
226
212
|
rubyforge_project: confetti
|
227
|
-
rubygems_version: 1.3.
|
213
|
+
rubygems_version: 1.3.6
|
228
214
|
signing_key:
|
229
215
|
specification_version: 3
|
230
216
|
summary: Generate mobile app config files
|
@@ -237,6 +223,7 @@ test_files:
|
|
237
223
|
- features/support/setup.rb
|
238
224
|
- features/symbian.wrt.feature
|
239
225
|
- features/webos.feature
|
226
|
+
- spec/cli_spec.rb
|
240
227
|
- spec/config/config_author_spec.rb
|
241
228
|
- spec/config/config_content_spec.rb
|
242
229
|
- spec/config/config_feature_spec.rb
|