confetti 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/confetti/config.rb +13 -4
- data/lib/confetti/version.rb +1 -1
- data/spec/config_spec.rb +23 -0
- data/spec/fixtures/android/AndroidManifest_bare.xml +33 -0
- data/spec/fixtures/configs/config_bare.xml +21 -0
- data/spec/templates/android_manifest_spec.rb +13 -0
- metadata +7 -3
data/Gemfile.lock
CHANGED
data/lib/confetti/config.rb
CHANGED
@@ -102,13 +102,13 @@ module Confetti
|
|
102
102
|
# simple helper for grabbing chosen orientation, or the default
|
103
103
|
# returns one of :portrait, :landscape, or :default
|
104
104
|
def orientation
|
105
|
-
values =
|
106
|
-
|
105
|
+
values = [:portrait, :landscape, :default]
|
106
|
+
choice = preference :orientation
|
107
107
|
|
108
|
-
unless
|
108
|
+
unless choice and values.include?(choice)
|
109
109
|
:default
|
110
110
|
else
|
111
|
-
|
111
|
+
choice
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
@@ -119,5 +119,14 @@ module Confetti
|
|
119
119
|
end
|
120
120
|
extras
|
121
121
|
end
|
122
|
+
|
123
|
+
# helper to retrieve a preference's value
|
124
|
+
# returns nil if the preference doesn't exist
|
125
|
+
def preference name
|
126
|
+
name = name.to_s
|
127
|
+
pref = @preference_set.detect { |pref| pref.name == name }
|
128
|
+
|
129
|
+
pref && pref.value && pref.value.to_sym
|
130
|
+
end
|
122
131
|
end
|
123
132
|
end
|
data/lib/confetti/version.rb
CHANGED
data/spec/config_spec.rb
CHANGED
@@ -434,4 +434,27 @@ describe Confetti::Config do
|
|
434
434
|
end
|
435
435
|
end
|
436
436
|
end
|
437
|
+
|
438
|
+
describe "preference accessor" do
|
439
|
+
before do
|
440
|
+
@config = Confetti::Config.new
|
441
|
+
@pref = Confetti::Config::Preference.new "permissions", "none"
|
442
|
+
@config.preference_set << @pref
|
443
|
+
end
|
444
|
+
|
445
|
+
it "should return the value of the specified preference" do
|
446
|
+
@config.preference(:permissions).should == :none
|
447
|
+
end
|
448
|
+
|
449
|
+
it "should be nil when the preference is not set" do
|
450
|
+
@config.preference(:size).should be_nil
|
451
|
+
end
|
452
|
+
|
453
|
+
it "should be nil when the preference has no value" do
|
454
|
+
pref = Confetti::Config::Preference.new "privacy"
|
455
|
+
@config.preference_set << pref
|
456
|
+
|
457
|
+
@config.preference(:privacy).should be_nil
|
458
|
+
end
|
459
|
+
end
|
437
460
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
+
package="com.app.bare"
|
4
|
+
android:versionName="1.0.0"
|
5
|
+
android:versionCode="1">
|
6
|
+
|
7
|
+
<supports-screens
|
8
|
+
android:largeScreens="true"
|
9
|
+
android:normalScreens="true"
|
10
|
+
android:smallScreens="true"
|
11
|
+
android:resizeable="true"
|
12
|
+
android:anyDensity="true"
|
13
|
+
/>
|
14
|
+
|
15
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
16
|
+
<application android:icon="@drawable/icon" android:label="@string/app_name"
|
17
|
+
android:debuggable="true">
|
18
|
+
<activity android:name=".ConfettiBareApp"
|
19
|
+
android:screenOrientation="unspecified"
|
20
|
+
android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
|
21
|
+
<intent-filter>
|
22
|
+
<action android:name="android.intent.action.MAIN" />
|
23
|
+
<category android:name="android.intent.category.LAUNCHER" />
|
24
|
+
</intent-filter>
|
25
|
+
</activity>
|
26
|
+
<activity android:name="com.phonegap.DroidGap" android:label="@string/app_name">
|
27
|
+
<intent-filter>
|
28
|
+
</intent-filter>
|
29
|
+
</activity>
|
30
|
+
</application>
|
31
|
+
<uses-sdk android:minSdkVersion="2" />
|
32
|
+
|
33
|
+
</manifest>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<widget xmlns = "http://www.w3.org/ns/widgets"
|
3
|
+
id = "com.app.bare"
|
4
|
+
version = "1.0.0">
|
5
|
+
|
6
|
+
<name>Confetti Bare App</name>
|
7
|
+
|
8
|
+
<description>
|
9
|
+
This is a sample config.xml with all Android permissions disabled
|
10
|
+
</description>
|
11
|
+
|
12
|
+
<author href="http://alunny.github.com"
|
13
|
+
email="hardeep.shoker@nitobi.com">
|
14
|
+
Hardeep Shoker
|
15
|
+
</author>
|
16
|
+
|
17
|
+
<icon src="smallicon.png" height="100" width="100" />
|
18
|
+
<icon src="bigicon.png" height="200" width="200" />
|
19
|
+
|
20
|
+
<preference name="permissions" value="none"/>
|
21
|
+
</widget>
|
@@ -97,6 +97,19 @@ describe Confetti::Template::AndroidManifest do
|
|
97
97
|
|
98
98
|
permission_names.should == expected
|
99
99
|
end
|
100
|
+
|
101
|
+
describe "when preference specifies no permissions" do
|
102
|
+
before do
|
103
|
+
bare_config = "#{ fixture_dir }/configs/config_bare.xml"
|
104
|
+
@config = Confetti::Config.new bare_config
|
105
|
+
@template = @template_class.new(@config)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should only render the INTERNET permission" do
|
109
|
+
bare_manifest = File.read "#{ fixture_dir }/android/AndroidManifest_bare.xml"
|
110
|
+
@template.render.should == bare_manifest
|
111
|
+
end
|
112
|
+
end
|
100
113
|
end
|
101
114
|
|
102
115
|
describe "version code should be set" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 5
|
9
|
+
version: 0.3.5
|
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: 2011-08-
|
19
|
+
date: 2011-08-25 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- spec/config/config_name_spec.rb
|
145
145
|
- spec/config/config_preference_spec.rb
|
146
146
|
- spec/config_spec.rb
|
147
|
+
- spec/fixtures/android/AndroidManifest_bare.xml
|
147
148
|
- spec/fixtures/android/AndroidManifest_expected.xml
|
148
149
|
- spec/fixtures/android/android_manifest_spec.xml
|
149
150
|
- spec/fixtures/android/android_manifest_spec_with_expected_orientation.xml
|
@@ -159,6 +160,7 @@ files:
|
|
159
160
|
- spec/fixtures/config.xml
|
160
161
|
- spec/fixtures/config_with_orientation.xml
|
161
162
|
- spec/fixtures/config_with_version_code.xml
|
163
|
+
- spec/fixtures/configs/config_bare.xml
|
162
164
|
- spec/fixtures/empty_elements.xml
|
163
165
|
- spec/fixtures/ios/ios_info_expected.plist
|
164
166
|
- spec/fixtures/ios/ios_info_spec.plist
|
@@ -228,6 +230,7 @@ test_files:
|
|
228
230
|
- spec/config/config_name_spec.rb
|
229
231
|
- spec/config/config_preference_spec.rb
|
230
232
|
- spec/config_spec.rb
|
233
|
+
- spec/fixtures/android/AndroidManifest_bare.xml
|
231
234
|
- spec/fixtures/android/AndroidManifest_expected.xml
|
232
235
|
- spec/fixtures/android/android_manifest_spec.xml
|
233
236
|
- spec/fixtures/android/android_manifest_spec_with_expected_orientation.xml
|
@@ -243,6 +246,7 @@ test_files:
|
|
243
246
|
- spec/fixtures/config.xml
|
244
247
|
- spec/fixtures/config_with_orientation.xml
|
245
248
|
- spec/fixtures/config_with_version_code.xml
|
249
|
+
- spec/fixtures/configs/config_bare.xml
|
246
250
|
- spec/fixtures/empty_elements.xml
|
247
251
|
- spec/fixtures/ios/ios_info_expected.plist
|
248
252
|
- spec/fixtures/ios/ios_info_spec.plist
|