confetti 0.1.8 → 0.2.0
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 +12 -6
- data/lib/confetti/config/feature.rb +2 -1
- data/lib/confetti/templates/android_manifest.mustache +4 -13
- data/lib/confetti/templates/android_manifest.rb +27 -0
- data/lib/confetti/version.rb +1 -1
- data/spec/config/config_feature_spec.rb +1 -1
- data/spec/config_spec.rb +28 -0
- data/spec/fixtures/AndroidManifest_expected.xml +3 -11
- data/spec/fixtures/android_manifest_spec.xml +0 -10
- data/spec/fixtures/config-icons-custom-attribs.xml +22 -0
- data/spec/fixtures/config.xml +3 -2
- data/spec/templates/android_manifest_spec.rb +27 -0
- metadata +7 -5
data/Gemfile.lock
CHANGED
data/lib/confetti/config.rb
CHANGED
@@ -15,7 +15,7 @@ module Confetti
|
|
15
15
|
Name = Class.new Struct.new(:name, :shortname)
|
16
16
|
License = Class.new Struct.new(:text, :href)
|
17
17
|
Content = Class.new Struct.new(:src, :type, :encoding)
|
18
|
-
Icon = Class.new Struct.new(:src, :height, :width)
|
18
|
+
Icon = Class.new Struct.new(:src, :height, :width, :extras)
|
19
19
|
Feature = Class.new Struct.new(:name, :required)
|
20
20
|
Preference = Class.new Struct.new(:name, :value, :readonly)
|
21
21
|
|
@@ -50,17 +50,23 @@ module Confetti
|
|
50
50
|
@version = config_doc.attributes["version"]
|
51
51
|
|
52
52
|
config_doc.elements.each do |ele|
|
53
|
+
attr = ele.attributes
|
54
|
+
|
53
55
|
case ele.name
|
54
56
|
when "name"
|
55
|
-
@name = Name.new(ele.text.strip,
|
57
|
+
@name = Name.new(ele.text.strip, attr["shortname"])
|
56
58
|
when "author"
|
57
|
-
@author = Author.new(ele.text.strip,
|
58
|
-
ele.attributes["email"])
|
59
|
+
@author = Author.new(ele.text.strip, attr["href"], attr["email"])
|
59
60
|
when "description"
|
60
61
|
@description = ele.text.strip
|
61
62
|
when "icon"
|
62
|
-
|
63
|
-
|
63
|
+
extras = attr.keys.inject({}) do |hash, key|
|
64
|
+
hash[key] = attr[key] unless Icon.public_instance_methods.include? key
|
65
|
+
hash
|
66
|
+
end
|
67
|
+
@icon_set << Icon.new(attr["src"], attr["height"], attr["width"], extras)
|
68
|
+
when "feature"
|
69
|
+
@feature_set << Feature.new(attr["name"], attr["required"])
|
64
70
|
end
|
65
71
|
end
|
66
72
|
end
|
@@ -3,21 +3,12 @@
|
|
3
3
|
package="{{ package_name }}"
|
4
4
|
android:versionName="{{ version }}"
|
5
5
|
android:versionCode="1">
|
6
|
-
<uses-permission android:name="android.permission.CAMERA" />
|
7
|
-
<uses-permission android:name="android.permission.VIBRATE" />
|
8
|
-
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
9
|
-
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
10
|
-
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
11
6
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
12
7
|
<uses-permission android:name="android.permission.INTERNET" />
|
13
|
-
|
14
|
-
<uses-permission android:name="android.permission.
|
15
|
-
|
16
|
-
|
17
|
-
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
|
18
|
-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
19
|
-
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
20
|
-
|
8
|
+
{{# permissions }}
|
9
|
+
<uses-permission android:name="android.permission.{{ name }}" />
|
10
|
+
{{/ permissions }}
|
11
|
+
|
21
12
|
<application android:icon="@drawable/icon" android:label="@string/app_name"
|
22
13
|
android:debuggable="true">
|
23
14
|
<activity android:name=".{{ class_name }}"
|
@@ -3,6 +3,17 @@ module Confetti
|
|
3
3
|
class AndroidManifest < Base
|
4
4
|
include JavaChecks
|
5
5
|
|
6
|
+
GAP_PERMISSIONS_MAP = {
|
7
|
+
"camera" => ["CAMERA"],
|
8
|
+
"notification" => ["VIBRATE"],
|
9
|
+
"geolocation" => ["ACCESS_COARSE_LOCATION", "ACCESS_FINE_LOCATION",
|
10
|
+
"ACCESS_LOCATION_EXTRA_COMMANDS"],
|
11
|
+
"media" => ["RECORD_AUDIO", "MODIFY_AUDIO_SETTINGS"],
|
12
|
+
"contacts" => ["READ_CONTACTS", "WRITE_CONTACTS"],
|
13
|
+
"file" => ["WRITE_EXTERNAL_STORAGE"],
|
14
|
+
"network" => ["ACCESS_NETWORK_STATE"]
|
15
|
+
}
|
16
|
+
|
6
17
|
def package_name
|
7
18
|
if @config
|
8
19
|
if is_java_package_id(@config.package)
|
@@ -22,6 +33,22 @@ module Confetti
|
|
22
33
|
def version
|
23
34
|
@config.version || '0.0.1'
|
24
35
|
end
|
36
|
+
|
37
|
+
def permissions
|
38
|
+
permissions = []
|
39
|
+
phonegap_api = /http\:\/\/api.phonegap.com\/1[.]0\/(\w+)/
|
40
|
+
feature_names = @config.feature_set.map { |f| f.name }
|
41
|
+
feature_names.sort
|
42
|
+
|
43
|
+
feature_names.each do |f|
|
44
|
+
feature_name = f.match(phonegap_api)[1] if f.match(phonegap_api)
|
45
|
+
associated_permissions = GAP_PERMISSIONS_MAP[feature_name]
|
46
|
+
|
47
|
+
permissions.concat(associated_permissions) if associated_permissions
|
48
|
+
end
|
49
|
+
|
50
|
+
permissions.map { |f| { :name => f } }
|
51
|
+
end
|
25
52
|
end
|
26
53
|
end
|
27
54
|
end
|
data/lib/confetti/version.rb
CHANGED
data/spec/config_spec.rb
CHANGED
@@ -237,6 +237,34 @@ describe Confetti::Config do
|
|
237
237
|
@config.icon_set.size.should be 2
|
238
238
|
end
|
239
239
|
end
|
240
|
+
|
241
|
+
describe "with custom icon attributes" do
|
242
|
+
before do
|
243
|
+
@config = Confetti::Config.new
|
244
|
+
@config.populate_from_xml(fixture_dir + "/config-icons-custom-attribs.xml")
|
245
|
+
end
|
246
|
+
|
247
|
+
it "should populate icon non-standards attributes to extras field" do
|
248
|
+
@config.icon_set.size.should be 1
|
249
|
+
@config.icon_set.first.extras.should_not == nil
|
250
|
+
@config.icon_set.first.extras.length.should be 1
|
251
|
+
@config.icon_set.first.extras["hover"].should == "true"
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
describe "features" do
|
257
|
+
it "should append features to the feature set" do
|
258
|
+
@config.feature_set.size.should be 3
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should include the right features" do
|
262
|
+
# first tends to be last listed in xml document
|
263
|
+
features_names = @config.feature_set.map { |f| f.name }
|
264
|
+
features_names.should include "http://api.phonegap.com/1.0/geolocation"
|
265
|
+
features_names.should include "http://api.phonegap.com/1.0/camera"
|
266
|
+
features_names.should include "http://api.phonegap.com/1.0/notification"
|
267
|
+
end
|
240
268
|
end
|
241
269
|
end
|
242
270
|
end
|
@@ -3,21 +3,13 @@
|
|
3
3
|
package="com.alunny.confetti"
|
4
4
|
android:versionName="1.0.0"
|
5
5
|
android:versionCode="1">
|
6
|
-
<uses-permission android:name="android.permission.
|
6
|
+
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
7
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
7
8
|
<uses-permission android:name="android.permission.VIBRATE" />
|
9
|
+
<uses-permission android:name="android.permission.CAMERA" />
|
8
10
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
9
11
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
10
12
|
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
11
|
-
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
12
|
-
<uses-permission android:name="android.permission.INTERNET" />
|
13
|
-
<uses-permission android:name="android.permission.RECEIVE_SMS" />
|
14
|
-
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
15
|
-
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
16
|
-
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
17
|
-
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
|
18
|
-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
19
|
-
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
20
|
-
|
21
13
|
<application android:icon="@drawable/icon" android:label="@string/app_name"
|
22
14
|
android:debuggable="true">
|
23
15
|
<activity android:name=".ConfettiSampleApp"
|
@@ -3,21 +3,11 @@
|
|
3
3
|
package="com.whoever.awesome.app"
|
4
4
|
android:versionName="0.0.1"
|
5
5
|
android:versionCode="1">
|
6
|
-
<uses-permission android:name="android.permission.CAMERA" />
|
7
|
-
<uses-permission android:name="android.permission.VIBRATE" />
|
8
|
-
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
9
|
-
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
10
|
-
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
11
6
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
12
7
|
<uses-permission android:name="android.permission.INTERNET" />
|
13
|
-
<uses-permission android:name="android.permission.RECEIVE_SMS" />
|
14
8
|
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
15
9
|
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
16
|
-
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
17
|
-
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
|
18
|
-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
19
10
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
20
|
-
|
21
11
|
<application android:icon="@drawable/icon" android:label="@string/app_name"
|
22
12
|
android:debuggable="true">
|
23
13
|
<activity android:name=".AwesomeApp"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<widget xmlns = "http://www.w3.org/ns/widgets"
|
3
|
+
xmlns:rim="http://www.blackberry.com/ns/widgets"
|
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
|
+
<author href="http://alunny.github.com"
|
14
|
+
email="alunny@gmail.com">
|
15
|
+
Andrew Lunny
|
16
|
+
</author>
|
17
|
+
|
18
|
+
<icon src="smallicon.png" height="100" width="100" rim:hover="true" />
|
19
|
+
|
20
|
+
<feature name="http://api.phonegap.com/1.0/geolocation"/>
|
21
|
+
<feature name="http://api.phonegap.com/1.0/network"/>
|
22
|
+
</widget>
|
data/spec/fixtures/config.xml
CHANGED
@@ -16,6 +16,7 @@
|
|
16
16
|
|
17
17
|
<icon src="icon.png" height="150" width="200" />
|
18
18
|
|
19
|
-
<feature name="http://api.phonegap.com/1.0/geolocation"/>
|
20
|
-
<feature name="http://api.phonegap.com/1.0/
|
19
|
+
<feature name="http://api.phonegap.com/1.0/geolocation" required="true"/>
|
20
|
+
<feature name="http://api.phonegap.com/1.0/camera" required="true"/>
|
21
|
+
<feature name="http://api.phonegap.com/1.0/notification" required="true"/>
|
21
22
|
</widget>
|
@@ -33,6 +33,12 @@ describe Confetti::Template::AndroidManifest do
|
|
33
33
|
@config = Confetti::Config.new
|
34
34
|
@config.name.name = "Awesome App"
|
35
35
|
@config.package = "com.whoever.awesome.app"
|
36
|
+
|
37
|
+
network_feature = Confetti::Config::Feature.new("http://api.phonegap.com/1.0/network", nil)
|
38
|
+
media_feature = Confetti::Config::Feature.new("http://api.phonegap.com/1.0/media", nil)
|
39
|
+
|
40
|
+
@config.feature_set << network_feature
|
41
|
+
@config.feature_set << media_feature
|
36
42
|
end
|
37
43
|
|
38
44
|
it "should accept the config object" do
|
@@ -63,4 +69,25 @@ describe Confetti::Template::AndroidManifest do
|
|
63
69
|
end
|
64
70
|
end
|
65
71
|
end
|
72
|
+
|
73
|
+
describe "permissions method" do
|
74
|
+
before do
|
75
|
+
@config = Confetti::Config.new
|
76
|
+
|
77
|
+
camera_feature = Confetti::Config::Feature.new("http://api.phonegap.com/1.0/camera", nil)
|
78
|
+
network_feature = Confetti::Config::Feature.new("http://api.phonegap.com/1.0/network", nil)
|
79
|
+
media_feature = Confetti::Config::Feature.new("http://api.phonegap.com/1.0/media", nil)
|
80
|
+
|
81
|
+
@config.feature_set << camera_feature
|
82
|
+
@config.feature_set << network_feature
|
83
|
+
@config.feature_set << media_feature
|
84
|
+
|
85
|
+
@template = @template_class.new(@config)
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should return all of the permissions" do
|
89
|
+
# 1 camera, 1 network, 2 media
|
90
|
+
@template.permissions.size.should be 4
|
91
|
+
end
|
92
|
+
end
|
66
93
|
end
|
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: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
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-18 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- spec/fixtures/bad_config.xml
|
160
160
|
- spec/fixtures/blackberry_widget_config_expected.xml
|
161
161
|
- spec/fixtures/blackberry_widget_config_spec.xml
|
162
|
+
- spec/fixtures/config-icons-custom-attribs.xml
|
162
163
|
- spec/fixtures/config-icons.xml
|
163
164
|
- spec/fixtures/config.xml
|
164
165
|
- spec/fixtures/ios_info_expected.plist
|
@@ -238,6 +239,7 @@ test_files:
|
|
238
239
|
- spec/fixtures/bad_config.xml
|
239
240
|
- spec/fixtures/blackberry_widget_config_expected.xml
|
240
241
|
- spec/fixtures/blackberry_widget_config_spec.xml
|
242
|
+
- spec/fixtures/config-icons-custom-attribs.xml
|
241
243
|
- spec/fixtures/config-icons.xml
|
242
244
|
- spec/fixtures/config.xml
|
243
245
|
- spec/fixtures/ios_info_expected.plist
|