confetti 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +48 -0
  4. data/README.md +46 -0
  5. data/Rakefile +19 -0
  6. data/bin/confetti +4 -0
  7. data/confetti.gemspec +29 -0
  8. data/features/android.feature +14 -0
  9. data/features/blackberry.feature +9 -0
  10. data/features/command_line.feature +12 -0
  11. data/features/ios.feature +9 -0
  12. data/features/step_definitions/aruba_ext_steps.rb +7 -0
  13. data/features/support/setup.rb +1 -0
  14. data/features/symbian.wrt.feature +9 -0
  15. data/features/webos.feature +9 -0
  16. data/lib/confetti.rb +31 -0
  17. data/lib/confetti/cli.rb +19 -0
  18. data/lib/confetti/config.rb +57 -0
  19. data/lib/confetti/config/feature.rb +13 -0
  20. data/lib/confetti/helpers.rb +7 -0
  21. data/lib/confetti/template.rb +4 -0
  22. data/lib/confetti/template_helper.rb +28 -0
  23. data/lib/confetti/templates/android_manifest.mustache +33 -0
  24. data/lib/confetti/templates/android_manifest.rb +27 -0
  25. data/lib/confetti/templates/android_strings.mustache +5 -0
  26. data/lib/confetti/templates/android_strings.rb +13 -0
  27. data/lib/confetti/templates/base.mustache +0 -0
  28. data/lib/confetti/templates/base.rb +13 -0
  29. data/lib/confetti/templates/blackberry_widgets_config.mustache +20 -0
  30. data/lib/confetti/templates/blackberry_widgets_config.rb +37 -0
  31. data/lib/confetti/templates/ios_info.mustache +48 -0
  32. data/lib/confetti/templates/ios_info.rb +21 -0
  33. data/lib/confetti/templates/java_checks.rb +18 -0
  34. data/lib/confetti/templates/symbian_wrt_info.mustache +17 -0
  35. data/lib/confetti/templates/symbian_wrt_info.rb +21 -0
  36. data/lib/confetti/templates/webos_appinfo.mustache +9 -0
  37. data/lib/confetti/templates/webos_appinfo.rb +49 -0
  38. data/lib/confetti/version.rb +3 -0
  39. data/lib/typedset.rb +23 -0
  40. data/spec/config/config_author_spec.rb +22 -0
  41. data/spec/config/config_content_spec.rb +22 -0
  42. data/spec/config/config_feature_spec.rb +33 -0
  43. data/spec/config/config_icon_spec.rb +22 -0
  44. data/spec/config/config_license_spec.rb +17 -0
  45. data/spec/config/config_name_spec.rb +17 -0
  46. data/spec/config/config_preference_spec.rb +22 -0
  47. data/spec/config_spec.rb +217 -0
  48. data/spec/fixtures/AndroidManifest_expected.xml +33 -0
  49. data/spec/fixtures/android_manifest_spec.xml +33 -0
  50. data/spec/fixtures/android_strings_expected.xml +5 -0
  51. data/spec/fixtures/android_strings_spec.xml +5 -0
  52. data/spec/fixtures/appinfo_expected.json +9 -0
  53. data/spec/fixtures/blackberry_widget_config_expected.xml +20 -0
  54. data/spec/fixtures/blackberry_widget_config_spec.xml +20 -0
  55. data/spec/fixtures/config.xml +21 -0
  56. data/spec/fixtures/ios_info_expected.plist +48 -0
  57. data/spec/fixtures/ios_info_spec.plist +48 -0
  58. data/spec/fixtures/symbian_wrt_info_expected.plist +17 -0
  59. data/spec/fixtures/symbian_wrt_info_spec.plist +17 -0
  60. data/spec/fixtures/webos_appinfo_spec.json +9 -0
  61. data/spec/helpers_spec.rb +21 -0
  62. data/spec/integration_spec.rb +66 -0
  63. data/spec/spec_helper.rb +83 -0
  64. data/spec/template_spec.rb +4 -0
  65. data/spec/templates/android_manifest_spec.rb +66 -0
  66. data/spec/templates/android_strings_spec.rb +56 -0
  67. data/spec/templates/base_spec.rb +25 -0
  68. data/spec/templates/blackberry_widget_config_spec.rb +94 -0
  69. data/spec/templates/ios_info_spec.rb +68 -0
  70. data/spec/templates/java_checks_spec.rb +59 -0
  71. data/spec/templates/symbian_wrt_info_spec.rb +68 -0
  72. data/spec/templates/webos_appinfo_spec.rb +101 -0
  73. data/spec/typedset_spec.rb +72 -0
  74. metadata +256 -0
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Confetti::Config::License do
4
+ before do
5
+ @license = Confetti::Config::License.new
6
+ end
7
+
8
+ it "should have a readable and writable text field" do
9
+ lambda { @license.text = "You can do WTF you want" }.should_not raise_error
10
+ @license.text.should == "You can do WTF you want"
11
+ end
12
+
13
+ it "should have a readable and writable href field" do
14
+ lambda { @license.href = "http://apache.org/license" }.should_not raise_error
15
+ @license.href.should == "http://apache.org/license"
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Confetti::Config::Name do
4
+ before do
5
+ @name = Confetti::Config::Name.new
6
+ end
7
+
8
+ it "should have a readable and writable name field" do
9
+ lambda { @name.name = "Microsoft Windows 7 Ultimate Edition" }.should_not raise_error
10
+ @name.name.should == "Microsoft Windows 7 Ultimate Edition"
11
+ end
12
+
13
+ it "should have a readable and writable shortname field" do
14
+ lambda { @name.shortname = "Windows7" }.should_not raise_error
15
+ @name.shortname.should == "Windows7"
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Confetti::Config::Preference do
4
+ before do
5
+ @pref = Confetti::Config::Preference.new
6
+ end
7
+
8
+ it "should have a readable and writable name field" do
9
+ lambda { @pref.name = "Auto-Rotation" }.should_not raise_error
10
+ @pref.name.should == "Auto-Rotation"
11
+ end
12
+
13
+ it "should have a readable and writable value field" do
14
+ lambda { @pref.value = "disabled" }.should_not raise_error
15
+ @pref.value.should == "disabled"
16
+ end
17
+
18
+ it "should have a readable and writable readonly field" do
19
+ lambda { @pref.readonly = true }.should_not raise_error
20
+ @pref.readonly.should be_true
21
+ end
22
+ end
@@ -0,0 +1,217 @@
1
+ require 'spec_helper'
2
+
3
+ describe Confetti::Config do
4
+ include ConfigHelpers
5
+ include HelpfulPaths
6
+
7
+ before do
8
+ @config = Confetti::Config.new
9
+ end
10
+
11
+ describe "fields on the widget element" do
12
+ it "has a writable and readable package field" do
13
+ lambda { @config.package = "com.alunny.greatapp" }.should_not raise_error
14
+ @config.package.should == "com.alunny.greatapp"
15
+ end
16
+
17
+ it "has a writable and readable version field" do
18
+ lambda { @config.version = "0.1.0" }.should_not raise_error
19
+ @config.version.should == "0.1.0"
20
+ end
21
+
22
+ it "has a writable and readable height field" do
23
+ lambda { @config.height = 500 }.should_not raise_error
24
+ @config.height.should == 500
25
+ end
26
+
27
+ it "has a writable and readable width field" do
28
+ lambda { @config.width = 500 }.should_not raise_error
29
+ @config.width.should == 500
30
+ end
31
+
32
+ it "has a list of viewmodes" do
33
+ @config.viewmodes.should be_an Array
34
+ end
35
+
36
+ it "should let viewmodes be appended" do
37
+ @config.viewmodes << "windowed"
38
+ @config.viewmodes << "floating"
39
+ @config.viewmodes.should == ["windowed","floating"]
40
+ end
41
+
42
+ it "has a writable and readable description field" do
43
+ lambda { @config.description = "A Great App That Lets You Do Things" }.should_not raise_error
44
+ @config.description.should == "A Great App That Lets You Do Things"
45
+ end
46
+ end
47
+
48
+ describe "widget child elements (zero or one, per locale)" do
49
+ it "has a name field, that is a name object" do
50
+ @config.name.should be_a Confetti::Config::Name
51
+ end
52
+
53
+ it "doesn't allow name to be clobbered" do
54
+ lambda { @config.name = "Stellar Game" }.should raise_error
55
+ end
56
+
57
+ it "has an author field, that is an author object" do
58
+ @config.author.should be_a Confetti::Config::Author
59
+ end
60
+
61
+ it "doesn't allow author to be clobbered" do
62
+ lambda { @config.author = "Andrew Lunny" }.should raise_error
63
+ end
64
+
65
+ it "has a license field, that is a license object" do
66
+ @config.license.should be_a Confetti::Config::License
67
+ end
68
+
69
+ it "doesn't allow license to be clobbered" do
70
+ lambda { @config.license = "MIT" }.should raise_error
71
+ end
72
+
73
+ it "has a content field, that is a content object" do
74
+ @config.content.should be_a Confetti::Config::Content
75
+ end
76
+
77
+ it "doesn't allow content to be clobbered" do
78
+ lambda { @config.content = "foo.html" }.should raise_error
79
+ end
80
+ end
81
+
82
+ describe "widget child elements (zero or more)" do
83
+ it "has an icon_set field, that is a TypedSet" do
84
+ @config.icon_set.should be_a TypedSet
85
+ end
86
+
87
+ it "icon_set should be typed to icon objects" do
88
+ @config.icon_set.set_class.should be Confetti::Config::Icon
89
+ end
90
+
91
+ it "should not allow icon_set to be clobbered" do
92
+ lambda {
93
+ @config.icon_set = ['icon.png', 'icon-hires.png']
94
+ }.should raise_error
95
+ end
96
+
97
+ it "has an feature_set field, that is a TypedSet" do
98
+ @config.feature_set.should be_a TypedSet
99
+ end
100
+
101
+ it "feature_set should be typed to feature objects" do
102
+ @config.feature_set.set_class.should be Confetti::Config::Feature
103
+ end
104
+
105
+ it "should not allow feature_set to be clobbered" do
106
+ lambda {
107
+ @config.feature_set = ['Geolocation', 'Acceleration']
108
+ }.should raise_error
109
+ end
110
+
111
+ it "has an preference_set field, that is a TypedSet" do
112
+ @config.preference_set.should be_a TypedSet
113
+ end
114
+
115
+ it "preference_set should be typed to preference objects" do
116
+ @config.preference_set.set_class.should be Confetti::Config::Preference
117
+ end
118
+
119
+ it "should not allow preference_set to be clobbered" do
120
+ lambda {
121
+ @config.preference_set = {
122
+ 'Autorotate' => false,
123
+ 'Notification' => 'silent'
124
+ }
125
+ }.should raise_error
126
+ end
127
+ end
128
+
129
+ describe "#initialize with file" do
130
+ before do
131
+ # pretty gross rspec
132
+ @blank_config = Confetti::Config.new
133
+ end
134
+
135
+ it "should not call #is_file? if no arguments are passed" do
136
+ @blank_config.should_not_receive(:is_file?)
137
+ @blank_config.send :initialize
138
+ end
139
+
140
+ it "should call #is_file? with an argument passed" do
141
+ @blank_config.should_receive(:is_file?)
142
+ @blank_config.send :initialize, "config.xml"
143
+ end
144
+
145
+ it "should call #populate_from_xml with a file passed" do
146
+ @blank_config.stub(:is_file?).and_return(true)
147
+ @blank_config.should_receive(:populate_from_xml).with("config.xml")
148
+ @blank_config.send :initialize, "config.xml"
149
+ end
150
+ end
151
+
152
+ describe "#populate_from_xml" do
153
+ it "should try to read the passed filename" do
154
+ File.should_receive(:read).with("config.xml")
155
+ lambda {
156
+ @config.populate_from_xml "config.xml"
157
+ }.should raise_error
158
+ end
159
+
160
+ it "should raise an error if can't parse" do
161
+ lambda {
162
+ @config.populate_from_xml("foo.goo")
163
+ }.should raise_error
164
+ end
165
+
166
+ describe "when setting attributes from config.xml" do
167
+ before do
168
+ @config.populate_from_xml(fixture_dir + "/config.xml")
169
+ end
170
+
171
+ it "should populate the app's package when present" do
172
+ @config.package.should == "com.alunny.confetti"
173
+ end
174
+
175
+ it "should populate the app's name when present" do
176
+ @config.name.name.should == "Confetti Sample App"
177
+ end
178
+
179
+ it "should populate the app's version when present" do
180
+ @config.version.should == "1.0.0"
181
+ end
182
+
183
+ it "should populate the app's description when present" do
184
+ desc = "This is a sample config.xml for integration testing with Confetti"
185
+ @config.description.should == desc
186
+ end
187
+
188
+ describe "widget Author" do
189
+ it "should populate the author's name" do
190
+ @config.author.name.should == "Andrew Lunny"
191
+ end
192
+
193
+ it "should populate the author's href (url)" do
194
+ @config.author.href.should == "http://alunny.github.com"
195
+ end
196
+
197
+ it "should populate the author's email" do
198
+ @config.author.email.should == "alunny@gmail.com"
199
+ end
200
+ end
201
+ end
202
+ end
203
+
204
+ describe "config generation" do
205
+ it_should_have_generate_and_write_methods_for :android_manifest
206
+
207
+ it_should_have_generate_and_write_methods_for :android_strings
208
+
209
+ it_should_have_generate_and_write_methods_for :webos_appinfo
210
+
211
+ it_should_have_generate_and_write_methods_for :ios_info
212
+
213
+ it_should_have_generate_and_write_methods_for :symbian_wrt_info
214
+
215
+ it_should_have_generate_and_write_methods_for :blackberry_widgets_config
216
+ end
217
+ 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.alunny.confetti"
4
+ android:versionName="1.0.0"
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
+ <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
+ <application android:icon="@drawable/icon" android:label="@string/app_name"
22
+ android:debuggable="true">
23
+ <activity android:name=".ConfettiSampleApp"
24
+ android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
25
+ <intent-filter>
26
+ <action android:name="android.intent.action.MAIN" />
27
+ <category android:name="android.intent.category.LAUNCHER" />
28
+ </intent-filter>
29
+ </activity>
30
+ </application>
31
+ <uses-sdk android:minSdkVersion="2" />
32
+
33
+ </manifest>
@@ -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.whoever.awesome.app"
4
+ android:versionName="0.0.1"
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
+ <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
+ <application android:icon="@drawable/icon" android:label="@string/app_name"
22
+ android:debuggable="true">
23
+ <activity android:name=".AwesomeApp"
24
+ android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
25
+ <intent-filter>
26
+ <action android:name="android.intent.action.MAIN" />
27
+ <category android:name="android.intent.category.LAUNCHER" />
28
+ </intent-filter>
29
+ </activity>
30
+ </application>
31
+ <uses-sdk android:minSdkVersion="2" />
32
+
33
+ </manifest>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <resources>
3
+ <string name="app_name">Confetti Sample App</string>
4
+ <string name="go">Snap</string>
5
+ </resources>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <resources>
3
+ <string name="app_name">Awesome App</string>
4
+ <string name="go">Snap</string>
5
+ </resources>
@@ -0,0 +1,9 @@
1
+ {
2
+ "id": "com.alunny.confetti",
3
+ "version": "1.0.0",
4
+ "vendor": "Andrew Lunny",
5
+ "type": "web",
6
+ "main": "index.html",
7
+ "title": "Confetti Sample App",
8
+ "icon": "icon.png"
9
+ }
@@ -0,0 +1,20 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- Widget Configuration Reference: http://docs.blackberry.com/en/developers/deliverables/15274/ -->
3
+ <widget xmlns="http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets"
4
+ version="1.0.0"
5
+ id="com.alunny.confetti">
6
+ <name>Confetti Sample App</name>
7
+ <author href="http://alunny.github.com" email="alunny@gmail.com">Andrew Lunny</author>
8
+ <description>This is a sample config.xml for integration testing with Confetti</description>
9
+ <license></license>
10
+ <feature id="blackberry.system" required="true" version="1.0.0.0"/>
11
+ <feature id="phonegap" required="false" version="1.0.0"/>
12
+ <access subdomains="true" uri="file:///store/home"/>
13
+ <access subdomains="true" uri="file:///SDCard"/>
14
+ <icon rim:hover="false" src="resources/icon.png"/>
15
+ <icon rim:hover="true" src="resources/icon_hover.png"/>
16
+ <content src="index.html"/>
17
+ <rim:loadingScreen backgroundColor="#000000" foregroundImage="resources/loading_foreground.png" onFirstLaunch="true">
18
+ <rim:transitionEffect type="fadeOut"/>
19
+ </rim:loadingScreen>
20
+ </widget>
@@ -0,0 +1,20 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- Widget Configuration Reference: http://docs.blackberry.com/en/developers/deliverables/15274/ -->
3
+ <widget xmlns="http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets"
4
+ version="1.0.0"
5
+ id="com.whoever.awesome.app">
6
+ <name>Awesome App</name>
7
+ <author href="http://brucelee.cn" email="blee@hotmail.com">Bruce Lee</author>
8
+ <description>My New App, by Bruce Lee</description>
9
+ <license></license>
10
+ <feature id="blackberry.system" required="true" version="1.0.0.0"/>
11
+ <feature id="phonegap" required="false" version="1.0.0"/>
12
+ <access subdomains="true" uri="file:///store/home"/>
13
+ <access subdomains="true" uri="file:///SDCard"/>
14
+ <icon rim:hover="false" src="resources/icon.png"/>
15
+ <icon rim:hover="true" src="resources/icon_hover.png"/>
16
+ <content src="index.html"/>
17
+ <rim:loadingScreen backgroundColor="#000000" foregroundImage="resources/loading_foreground.png" onFirstLaunch="true">
18
+ <rim:transitionEffect type="fadeOut"/>
19
+ </rim:loadingScreen>
20
+ </widget>
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <widget xmlns = "http://www.w3.org/ns/widgets"
3
+ id = "com.alunny.confetti"
4
+ version = "1.0.0">
5
+
6
+ <name>Confetti Sample App</name>
7
+
8
+ <description>
9
+ This is a sample config.xml for integration testing with Confetti
10
+ </description>
11
+
12
+ <author href="http://alunny.github.com"
13
+ email="alunny@gmail.com">
14
+ Andrew Lunny
15
+ </author>
16
+
17
+ <icon src="icon.png" />
18
+
19
+ <feature name="http://api.phonegap.com/1.0/geolocation"/>
20
+ <feature name="http://api.phonegap.com/1.0/network"/>
21
+ </widget>
@@ -0,0 +1,48 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleIconFiles</key>
6
+ <array>
7
+ <string>icon.png</string>
8
+ <string>icon-72.png</string>
9
+ </array>
10
+ <key>UISupportedInterfaceOrientations~ipad</key>
11
+ <array>
12
+ <string>UIInterfaceOrientationPortrait</string>
13
+ <string>UIInterfaceOrientationLandscapeLeft</string>
14
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
15
+ <string>UIInterfaceOrientationLandscapeRight</string>
16
+ </array>
17
+ <key>UISupportedInterfaceOrientations</key>
18
+ <array>
19
+ <string>UIInterfaceOrientationPortrait</string>
20
+ </array>
21
+ <key>CFBundleDevelopmentRegion</key>
22
+ <string>English</string>
23
+ <key>CFBundleDisplayName</key>
24
+ <string>Confetti Sample App</string>
25
+ <key>CFBundleExecutable</key>
26
+ <string>${EXECUTABLE_NAME}</string>
27
+ <key>CFBundleIconFile</key>
28
+ <string>icon.png</string>
29
+ <key>CFBundleIdentifier</key>
30
+ <string>com.alunny.confetti</string>
31
+ <key>CFBundleInfoDictionaryVersion</key>
32
+ <string>6.0</string>
33
+ <key>CFBundleName</key>
34
+ <string>Confetti Sample App</string>
35
+ <key>CFBundlePackageType</key>
36
+ <string>APPL</string>
37
+ <key>CFBundleSignature</key>
38
+ <string>????</string>
39
+ <key>CFBundleVersion</key>
40
+ <string>1.0.0</string>
41
+ <key>LSRequiresIPhoneOS</key>
42
+ <true/>
43
+ <key>NSMainNibFile</key>
44
+ <string></string>
45
+ <key>NSMainNibFile~ipad</key>
46
+ <string>-iPad</string>
47
+ </dict>
48
+ </plist>