confetti 0.1.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/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +48 -0
- data/README.md +46 -0
- data/Rakefile +19 -0
- data/bin/confetti +4 -0
- data/confetti.gemspec +29 -0
- data/features/android.feature +14 -0
- data/features/blackberry.feature +9 -0
- data/features/command_line.feature +12 -0
- data/features/ios.feature +9 -0
- data/features/step_definitions/aruba_ext_steps.rb +7 -0
- data/features/support/setup.rb +1 -0
- data/features/symbian.wrt.feature +9 -0
- data/features/webos.feature +9 -0
- data/lib/confetti.rb +31 -0
- data/lib/confetti/cli.rb +19 -0
- data/lib/confetti/config.rb +57 -0
- data/lib/confetti/config/feature.rb +13 -0
- data/lib/confetti/helpers.rb +7 -0
- data/lib/confetti/template.rb +4 -0
- data/lib/confetti/template_helper.rb +28 -0
- data/lib/confetti/templates/android_manifest.mustache +33 -0
- data/lib/confetti/templates/android_manifest.rb +27 -0
- data/lib/confetti/templates/android_strings.mustache +5 -0
- data/lib/confetti/templates/android_strings.rb +13 -0
- data/lib/confetti/templates/base.mustache +0 -0
- data/lib/confetti/templates/base.rb +13 -0
- data/lib/confetti/templates/blackberry_widgets_config.mustache +20 -0
- data/lib/confetti/templates/blackberry_widgets_config.rb +37 -0
- data/lib/confetti/templates/ios_info.mustache +48 -0
- data/lib/confetti/templates/ios_info.rb +21 -0
- data/lib/confetti/templates/java_checks.rb +18 -0
- data/lib/confetti/templates/symbian_wrt_info.mustache +17 -0
- data/lib/confetti/templates/symbian_wrt_info.rb +21 -0
- data/lib/confetti/templates/webos_appinfo.mustache +9 -0
- data/lib/confetti/templates/webos_appinfo.rb +49 -0
- data/lib/confetti/version.rb +3 -0
- data/lib/typedset.rb +23 -0
- data/spec/config/config_author_spec.rb +22 -0
- data/spec/config/config_content_spec.rb +22 -0
- data/spec/config/config_feature_spec.rb +33 -0
- data/spec/config/config_icon_spec.rb +22 -0
- data/spec/config/config_license_spec.rb +17 -0
- data/spec/config/config_name_spec.rb +17 -0
- data/spec/config/config_preference_spec.rb +22 -0
- data/spec/config_spec.rb +217 -0
- data/spec/fixtures/AndroidManifest_expected.xml +33 -0
- data/spec/fixtures/android_manifest_spec.xml +33 -0
- data/spec/fixtures/android_strings_expected.xml +5 -0
- data/spec/fixtures/android_strings_spec.xml +5 -0
- data/spec/fixtures/appinfo_expected.json +9 -0
- data/spec/fixtures/blackberry_widget_config_expected.xml +20 -0
- data/spec/fixtures/blackberry_widget_config_spec.xml +20 -0
- data/spec/fixtures/config.xml +21 -0
- data/spec/fixtures/ios_info_expected.plist +48 -0
- data/spec/fixtures/ios_info_spec.plist +48 -0
- data/spec/fixtures/symbian_wrt_info_expected.plist +17 -0
- data/spec/fixtures/symbian_wrt_info_spec.plist +17 -0
- data/spec/fixtures/webos_appinfo_spec.json +9 -0
- data/spec/helpers_spec.rb +21 -0
- data/spec/integration_spec.rb +66 -0
- data/spec/spec_helper.rb +83 -0
- data/spec/template_spec.rb +4 -0
- data/spec/templates/android_manifest_spec.rb +66 -0
- data/spec/templates/android_strings_spec.rb +56 -0
- data/spec/templates/base_spec.rb +25 -0
- data/spec/templates/blackberry_widget_config_spec.rb +94 -0
- data/spec/templates/ios_info_spec.rb +68 -0
- data/spec/templates/java_checks_spec.rb +59 -0
- data/spec/templates/symbian_wrt_info_spec.rb +68 -0
- data/spec/templates/webos_appinfo_spec.rb +101 -0
- data/spec/typedset_spec.rb +72 -0
- metadata +256 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
module Confetti
|
2
|
+
module Template
|
3
|
+
class AndroidManifest < Base
|
4
|
+
include JavaChecks
|
5
|
+
|
6
|
+
def package_name
|
7
|
+
if @config
|
8
|
+
if is_java_package_id(@config.package)
|
9
|
+
@config.package
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def class_name
|
15
|
+
convert_to_java_identifier(@config.name.name) if @config
|
16
|
+
end
|
17
|
+
|
18
|
+
def output_filename
|
19
|
+
"AndroidManifest.xml"
|
20
|
+
end
|
21
|
+
|
22
|
+
def version
|
23
|
+
@config.version || '0.0.1'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
File without changes
|
@@ -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="{{ widget_version }}"
|
5
|
+
id="{{ widget_id }}">
|
6
|
+
<name>{{ widget_name }}</name>
|
7
|
+
<author href="{{ author_href }}" email="{{ author_email }}">{{ author_name }}</author>
|
8
|
+
<description>{{ widget_description }}</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,37 @@
|
|
1
|
+
module Confetti
|
2
|
+
module Template
|
3
|
+
class BlackberryWidgetsConfig < Base
|
4
|
+
def widget_version
|
5
|
+
@config.version
|
6
|
+
end
|
7
|
+
|
8
|
+
def widget_id
|
9
|
+
@config.package
|
10
|
+
end
|
11
|
+
|
12
|
+
def widget_name
|
13
|
+
@config.name.name
|
14
|
+
end
|
15
|
+
|
16
|
+
def author_href
|
17
|
+
@config.author.href
|
18
|
+
end
|
19
|
+
|
20
|
+
def author_email
|
21
|
+
@config.author.email
|
22
|
+
end
|
23
|
+
|
24
|
+
def author_name
|
25
|
+
@config.author.name
|
26
|
+
end
|
27
|
+
|
28
|
+
def widget_description
|
29
|
+
@config.description
|
30
|
+
end
|
31
|
+
|
32
|
+
def output_filename
|
33
|
+
"bb-config.xml"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -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>{{ product_name }}</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>{{ bundle_identifier }}</string>
|
31
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
32
|
+
<string>6.0</string>
|
33
|
+
<key>CFBundleName</key>
|
34
|
+
<string>{{ product_name }}</string>
|
35
|
+
<key>CFBundlePackageType</key>
|
36
|
+
<string>APPL</string>
|
37
|
+
<key>CFBundleSignature</key>
|
38
|
+
<string>????</string>
|
39
|
+
<key>CFBundleVersion</key>
|
40
|
+
<string>{{ bundle_version }}</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>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Confetti
|
2
|
+
module Template
|
3
|
+
class IosInfo < Base
|
4
|
+
def bundle_identifier
|
5
|
+
@config.package
|
6
|
+
end
|
7
|
+
|
8
|
+
def bundle_version
|
9
|
+
@config.version
|
10
|
+
end
|
11
|
+
|
12
|
+
def product_name
|
13
|
+
@config.name.name
|
14
|
+
end
|
15
|
+
|
16
|
+
def output_filename
|
17
|
+
"Info.plist"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Confetti
|
2
|
+
module Template
|
3
|
+
module JavaChecks
|
4
|
+
def is_java_identifier(str)
|
5
|
+
str.match(/^[a-zA-Z_][a-zA-Z0-9_]*$/)
|
6
|
+
end
|
7
|
+
|
8
|
+
def convert_to_java_identifier(str)
|
9
|
+
str.sub(/^\d/,"_").gsub(/\s/,"").gsub(/[^a-zA-Z0-9_]/,"_")
|
10
|
+
end
|
11
|
+
|
12
|
+
def is_java_package_id(str)
|
13
|
+
# second param to #split ensures can't be dot-terminated
|
14
|
+
str.split('.', -1).all? { |s| is_java_identifier(s) }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Nokia//DTD PLIST 1.0//EN" "http://www.nokia.com/DTDs/plist-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>DisplayName</key>
|
6
|
+
<string>{{ display_name }}</string>
|
7
|
+
<key>Identifier</key>
|
8
|
+
<string>{{ identifier }}</string>
|
9
|
+
<key>Version</key>
|
10
|
+
<string>{{ version }}</string>
|
11
|
+
<key>MainHTML</key>
|
12
|
+
<string>index.html</string>
|
13
|
+
<key>MiniViewEnabled</key>
|
14
|
+
<false/>
|
15
|
+
</dict>
|
16
|
+
</plist>
|
17
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Confetti
|
2
|
+
module Template
|
3
|
+
class SymbianWrtInfo < Base
|
4
|
+
def identifier
|
5
|
+
@config.package
|
6
|
+
end
|
7
|
+
|
8
|
+
def version
|
9
|
+
@config.version
|
10
|
+
end
|
11
|
+
|
12
|
+
def display_name
|
13
|
+
@config.name.name
|
14
|
+
end
|
15
|
+
|
16
|
+
def output_filename
|
17
|
+
"info.plist"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Confetti
|
2
|
+
module Template
|
3
|
+
class WebosAppinfo < Base
|
4
|
+
include JavaChecks
|
5
|
+
|
6
|
+
def app_id
|
7
|
+
if @config
|
8
|
+
if is_java_package_id(@config.package)
|
9
|
+
@config.package
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def app_name
|
15
|
+
@config.name.name
|
16
|
+
end
|
17
|
+
|
18
|
+
def output_filename
|
19
|
+
"appinfo.json"
|
20
|
+
end
|
21
|
+
|
22
|
+
def version
|
23
|
+
if @config.version.nil?
|
24
|
+
'0.0.1'
|
25
|
+
elsif @config.version.match /^(\d)+[.](\d)+[.](\d)+$/
|
26
|
+
@config.version
|
27
|
+
elsif @config.version.match /^((\d)+[.])*(\d)+$/
|
28
|
+
fix_version(@config.version)
|
29
|
+
else
|
30
|
+
fail "need a valid version number of the form 0.0.0"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def vendor
|
35
|
+
@config.author.name
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def fix_version(str)
|
40
|
+
segments = str.split('.')
|
41
|
+
|
42
|
+
segments << '0' if segments.length == 1
|
43
|
+
segments << '0' if segments.length == 2
|
44
|
+
|
45
|
+
segments[0,3].join '.'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/typedset.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "set"
|
2
|
+
|
3
|
+
# based on RestricedSet from Ruby's stdlib, cf
|
4
|
+
# http://github.com/ruby/ruby/blob/72ef219804e5524848170a197887a95718334e2a/lib/set.rb#L627-717
|
5
|
+
# not sure why it's been commented out
|
6
|
+
# I should follow these things
|
7
|
+
|
8
|
+
class TypedSet < Set
|
9
|
+
attr_reader :klass
|
10
|
+
alias set_class klass
|
11
|
+
|
12
|
+
def initialize (klass, *args)
|
13
|
+
raise ArgumentError, "require a Class object" unless klass.class == Class
|
14
|
+
@klass = klass
|
15
|
+
super args
|
16
|
+
end
|
17
|
+
|
18
|
+
def add o
|
19
|
+
raise ArgumentError, "members must be of class #{@klass}" unless o.class == @klass
|
20
|
+
super o
|
21
|
+
end
|
22
|
+
alias << add
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Confetti::Config::Author do
|
4
|
+
before do
|
5
|
+
@author = Confetti::Config::Author.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should have a readable and writable name field" do
|
9
|
+
lambda { @author.name = "Andrew Lunny" }.should_not raise_error
|
10
|
+
@author.name.should == "Andrew Lunny"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have a readable and writable href field" do
|
14
|
+
lambda { @author.href = "http://alunny.github.com" }.should_not raise_error
|
15
|
+
@author.href.should == "http://alunny.github.com"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have a readable and writable email field" do
|
19
|
+
lambda { @author.email = "alunny@gmail.com" }.should_not raise_error
|
20
|
+
@author.email.should == "alunny@gmail.com"
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Confetti::Config::Content do
|
4
|
+
before do
|
5
|
+
@content = Confetti::Config::Content.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should have a readable and writable src field" do
|
9
|
+
lambda { @content.src = "content.html" }.should_not raise_error
|
10
|
+
@content.src.should == "content.html"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have a readable and writable type field" do
|
14
|
+
lambda { @content.type = "text/html" }.should_not raise_error
|
15
|
+
@content.type.should == "text/html"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have a readable and writable encoding field" do
|
19
|
+
lambda { @content.encoding = "GB2313" }.should_not raise_error
|
20
|
+
@content.encoding.should == "GB2313"
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Confetti::Config::Feature do
|
4
|
+
before do
|
5
|
+
@feature = Confetti::Config::Feature.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should have a readable and writable name field" do
|
9
|
+
lambda { @feature.name = "Geolocation" }.should_not raise_error
|
10
|
+
@feature.name.should == "Geolocation"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have a readable and writable required field" do
|
14
|
+
lambda { @feature.required = true }.should_not raise_error
|
15
|
+
@feature.required.should be_true
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "parameter set" do
|
19
|
+
it "should have a param_set field, that is a TypedSet" do
|
20
|
+
@feature.param_set.should be_a TypedSet
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should make the param_set set typed to Confetti::Config::Feature::Param" do
|
24
|
+
@feature.param_set.set_class.should be Confetti::Config::Feature::Param
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should not allow the param_set to be clobbered" do
|
28
|
+
lambda {
|
29
|
+
@feature.param_set = { :accuracy => 2.0 }
|
30
|
+
}.should raise_error
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,22 @@
|
|
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
|