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,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>Awesome 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.whoever.awesome.app</string>
31
+ <key>CFBundleInfoDictionaryVersion</key>
32
+ <string>6.0</string>
33
+ <key>CFBundleName</key>
34
+ <string>Awesome 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>
@@ -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>Confetti Sample App</string>
7
+ <key>Identifier</key>
8
+ <string>com.alunny.confetti</string>
9
+ <key>Version</key>
10
+ <string>1.0.0</string>
11
+ <key>MainHTML</key>
12
+ <string>index.html</string>
13
+ <key>MiniViewEnabled</key>
14
+ <false/>
15
+ </dict>
16
+ </plist>
17
+
@@ -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>Awesome App</string>
7
+ <key>Identifier</key>
8
+ <string>com.whoever.awesome.app</string>
9
+ <key>Version</key>
10
+ <string>1.0.0</string>
11
+ <key>MainHTML</key>
12
+ <string>index.html</string>
13
+ <key>MiniViewEnabled</key>
14
+ <false/>
15
+ </dict>
16
+ </plist>
17
+
@@ -0,0 +1,9 @@
1
+ {
2
+ "id": "com.whoever.awesome.app",
3
+ "version": "1.0.0",
4
+ "vendor": "Bruce Lee",
5
+ "type": "web",
6
+ "main": "index.html",
7
+ "title": "Awesome App",
8
+ "icon": "icon.png"
9
+ }
@@ -0,0 +1,21 @@
1
+ require "spec_helper"
2
+
3
+ describe Confetti::Helpers do
4
+ include Confetti::Helpers
5
+
6
+ describe "#is_file?" do
7
+ it "should call File.exist? for the passed argument" do
8
+ File.should_receive(:exist?).with("foo.txt")
9
+
10
+ is_file? "foo.txt"
11
+ end
12
+
13
+ it "should return the same result as File.exist? does" do
14
+ File.should_receive(:exist?).with("foo.txt").and_return(true)
15
+ is_file?("foo.txt").should be_true
16
+
17
+ File.should_receive(:exist?).with("foo.txt").and_return(false)
18
+ is_file?("foo.txt").should be_false
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Writing Output' do
4
+ include HelpfulPaths
5
+ include FileHelpers
6
+
7
+ before do
8
+ @config = Confetti::Config.new "#{ fixture_dir }/config.xml"
9
+ end
10
+
11
+ context "Android" do
12
+ it "should read config.xml and spit out AndroidManifest.xml" do
13
+ @output_file = "#{ fixture_dir }/AndroidManifest_output.xml"
14
+ @config.write_android_manifest @output_file
15
+
16
+ files_should_match @output_file, "#{ fixture_dir }/AndroidManifest_expected.xml"
17
+ end
18
+
19
+ it "should read config.xml and spit out strings.xml" do
20
+ @output_file = "#{ fixture_dir }/android_strings_output.xml"
21
+ @config.write_android_strings @output_file
22
+
23
+ files_should_match @output_file, "#{ fixture_dir }/android_strings_expected.xml"
24
+ end
25
+ end
26
+
27
+ context "webOS" do
28
+ it "should read config.xml and spit out appinfo.json" do
29
+ @output_file = "#{ fixture_dir }/appinfo_output.json"
30
+ @config.write_webos_appinfo @output_file
31
+
32
+ files_should_match @output_file, "#{ fixture_dir }/appinfo_expected.json"
33
+ end
34
+ end
35
+
36
+ context "iOS" do
37
+ it "should read config.xml and spit out Info.plist" do
38
+ @output_file = "#{ fixture_dir }/ios_info_output.plist"
39
+ @config.write_ios_info @output_file
40
+
41
+ files_should_match @output_file, "#{ fixture_dir }/ios_info_expected.plist"
42
+ end
43
+ end
44
+
45
+ context "Symbian.wrt" do
46
+ it "should read config.xml and spit out info.plist" do
47
+ @output_file = "#{ fixture_dir }/symbian_wrt_info_output.plist"
48
+ @config.write_symbian_wrt_info @output_file
49
+
50
+ files_should_match @output_file, "#{ fixture_dir }/symbian_wrt_info_expected.plist"
51
+ end
52
+ end
53
+
54
+ context "Blackberry Widgets" do
55
+ it "should read config.xml and spit out bb-config.xml" do
56
+ @output_file = "#{ fixture_dir }/blackberry_widget_config_output.xml"
57
+ @config.write_blackberry_widgets_config @output_file
58
+
59
+ files_should_match @output_file, "#{ fixture_dir }/blackberry_widget_config_expected.xml"
60
+ end
61
+ end
62
+
63
+ after do
64
+ FileUtils.rm @output_file if File.exist? @output_file
65
+ end
66
+ end
@@ -0,0 +1,83 @@
1
+ require "confetti"
2
+
3
+ module HelpfulPaths
4
+ SPEC_DIR = File.dirname(__FILE__)
5
+ FIXTURE_DIR = SPEC_DIR + "/fixtures"
6
+ TEMPLATES_DIR = File.expand_path "../lib/confetti/templates", SPEC_DIR
7
+
8
+ def fixture_dir
9
+ FIXTURE_DIR
10
+ end
11
+
12
+ def templates_dir
13
+ TEMPLATES_DIR
14
+ end
15
+ end
16
+
17
+ module FileHelpers
18
+ def files_should_match(file_one, file_two = nil)
19
+ File.read(file_one).should == File.read(file_two)
20
+ end
21
+ end
22
+
23
+ module ConfigHelpers
24
+ def self.included(base)
25
+ base.extend(WriteAndGenerateMacros)
26
+ end
27
+
28
+ module WriteAndGenerateMacros
29
+ generate_write_spec = "it_should_have_generate_and_write_methods_for"
30
+
31
+ send :define_method, generate_write_spec do |config_type|
32
+ class_name = config_type.to_s.split("_").collect do |s|
33
+ s.capitalize
34
+ end.join
35
+ template_class = Confetti::Template.const_get(class_name)
36
+ default_filename = template_class.new.output_filename
37
+
38
+ generate_method = "generate_#{ config_type }".to_sym
39
+ write_method = "write_#{ config_type }".to_sym
40
+
41
+ describe config_type do
42
+ before do
43
+ @config.package = "com.whoever.awesome.app"
44
+ @config.name.name = "Awesome App"
45
+ end
46
+
47
+ describe "#generate_#{ config_type }" do
48
+ it "should create a new #{ class_name } template" do
49
+ @config.send(generate_method).should be_a template_class
50
+ end
51
+ end
52
+
53
+ describe "#write_#{ config_type }" do
54
+ before do
55
+ @contents = "foo"
56
+ @template = template_class.new
57
+ @output = mock(IO)
58
+
59
+ @config.should_receive(generate_method).and_return(@template)
60
+ @template.should_receive(:render).and_return(@contents)
61
+ @output.should_receive(:puts).with(@contents)
62
+ end
63
+
64
+ it "should write the rendered #{ default_filename } to the fs" do
65
+ filepath = "my_directory/#{ default_filename }"
66
+ @config.should_receive(:open).with(filepath, 'w').and_yield(@output)
67
+
68
+ @config.send(write_method, filepath)
69
+ end
70
+
71
+ describe "when no filepath is passed" do
72
+ it "should write the rendered #{ default_filename } to the default location" do
73
+ default_path = File.join(Dir.pwd, default_filename)
74
+ @config.should_receive(:open).with(default_path, 'w').and_yield(@output)
75
+
76
+ @config.send(write_method)
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,4 @@
1
+ require "spec_helper"
2
+
3
+ describe Confetti::Template do
4
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe Confetti::Template::AndroidManifest do
4
+ include HelpfulPaths
5
+
6
+ before :all do
7
+ @template_class = Confetti::Template::AndroidManifest
8
+ end
9
+
10
+ it "should inherit from the base template" do
11
+ @template_class.superclass.should be Confetti::Template::Base
12
+ end
13
+
14
+ it "should have the template_file \"android.mustache\" in the confetti/templates dir" do
15
+ @template_class.template_file.should == "#{ templates_dir }/android_manifest.mustache"
16
+ end
17
+
18
+ describe "templated attributes" do
19
+ subject { @template = @template_class.new }
20
+
21
+ it { should respond_to :package_name }
22
+ it { should respond_to :class_name }
23
+ end
24
+
25
+ describe "default values" do
26
+ it "should define output filename as \"AndroidManifest.xml\"" do
27
+ @template_class.new.output_filename.should == "AndroidManifest.xml"
28
+ end
29
+ end
30
+
31
+ describe "when passed a config object" do
32
+ before do
33
+ @config = Confetti::Config.new
34
+ @config.name.name = "Awesome App"
35
+ @config.package = "com.whoever.awesome.app"
36
+ end
37
+
38
+ it "should accept the config object" do
39
+ lambda {
40
+ @template_class.new(@config)
41
+ }.should_not raise_error
42
+ end
43
+
44
+ describe "templated attributes" do
45
+ before do
46
+ @template = @template_class.new(@config)
47
+ end
48
+
49
+ it "should set package_name correctly" do
50
+ @template.package_name.should == "com.whoever.awesome.app"
51
+ end
52
+
53
+ it "should set class_name correctly" do
54
+ @template.class_name.should == "AwesomeApp"
55
+ end
56
+
57
+ it "should use the default version" do
58
+ @template.version.should == "0.0.1"
59
+ end
60
+
61
+ it "should render the correct AndroidManifest" do
62
+ @template.render.should == File.read("#{ fixture_dir }/android_manifest_spec.xml")
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe Confetti::Template::AndroidStrings do
4
+ include HelpfulPaths
5
+
6
+ before :all do
7
+ @template_class = Confetti::Template::AndroidStrings
8
+ end
9
+
10
+ it "should inherit from the base template" do
11
+ @template_class.superclass.should be Confetti::Template::Base
12
+ end
13
+
14
+ it "should have the template_file \"android_strings.mustache\" in the confetti/templates dir" do
15
+ @template_class.template_file.should == "#{ templates_dir }/android_strings.mustache"
16
+ end
17
+
18
+ describe "templated attributes" do
19
+ subject { @template = @template_class.new }
20
+
21
+ it { should respond_to :app_name }
22
+ end
23
+
24
+ describe "default values" do
25
+ it "should define output filename as \"strings.xml\"" do
26
+ @template_class.new.output_filename.should == "strings.xml"
27
+ end
28
+ end
29
+
30
+ describe "when passed a config object" do
31
+ before do
32
+ @config = Confetti::Config.new
33
+ @config.name.name = "Awesome App"
34
+ end
35
+
36
+ it "should accept the config object" do
37
+ lambda {
38
+ @template_class.new(@config)
39
+ }.should_not raise_error
40
+ end
41
+
42
+ describe "templated attributes" do
43
+ before do
44
+ @template = @template_class.new(@config)
45
+ end
46
+
47
+ it "should set app_name correctly" do
48
+ @template.app_name.should == "Awesome App"
49
+ end
50
+
51
+ it "should render the correct AndroidManifest" do
52
+ @template.render.should == File.read("#{ fixture_dir }/android_strings_spec.xml")
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Confetti::Template::Base do
4
+ include HelpfulPaths
5
+
6
+ before :all do
7
+ BaseTemplate = Confetti::Template::Base
8
+ end
9
+
10
+ it "should inherit from Mustache" do
11
+ BaseTemplate.superclass.should be Mustache
12
+ end
13
+
14
+ it "should have the template_file \"base.mustache\" in the confetti/templates dir" do
15
+ BaseTemplate.template_file.should == "#{ templates_dir }/base.mustache"
16
+ end
17
+
18
+ it "should find the template and render without error" do
19
+ lambda { BaseTemplate.new.render }.should_not raise_error
20
+ end
21
+
22
+ it "should accept a config object passed in" do
23
+ lambda { BaseTemplate.new }.should_not raise_error
24
+ end
25
+ end
@@ -0,0 +1,94 @@
1
+ require 'spec_helper'
2
+
3
+ describe Confetti::Template::BlackberryWidgetsConfig do
4
+ include HelpfulPaths
5
+
6
+ before :all do
7
+ @template_class = Confetti::Template::BlackberryWidgetsConfig
8
+ end
9
+
10
+ it "should inherit from the base template" do
11
+ @template_class.superclass.should be Confetti::Template::Base
12
+ end
13
+
14
+ it "should have the template_file \"blackberry_widgets_config.mustache\" in the confetti/templates dir" do
15
+ @template_class.template_file.should == "#{ templates_dir }/blackberry_widgets_config.mustache"
16
+ end
17
+
18
+ describe "templated attributes" do
19
+ subject { @template = @template_class.new }
20
+
21
+ it { should respond_to :widget_version }
22
+ it { should respond_to :widget_id }
23
+ it { should respond_to :widget_name }
24
+ it { should respond_to :author_name }
25
+ it { should respond_to :author_email }
26
+ it { should respond_to :author_href }
27
+ it { should respond_to :widget_description }
28
+ end
29
+
30
+ describe "default values" do
31
+ it "should define output filename as \"bb-config.xml\"" do
32
+ @template_class.new.output_filename.should == "bb-config.xml"
33
+ end
34
+ end
35
+
36
+ describe "when passed a config object" do
37
+ before do
38
+ @config = Confetti::Config.new
39
+ @config.name.name = "Awesome App"
40
+ @config.package = "com.whoever.awesome.app"
41
+ @config.version = "1.0.0"
42
+ @config.author.name = "Bruce Lee"
43
+ @config.author.email = "blee@hotmail.com"
44
+ @config.author.href = "http://brucelee.cn"
45
+ @config.description = "My New App, by Bruce Lee"
46
+ end
47
+
48
+ it "should accept the config object" do
49
+ lambda {
50
+ @template_class.new(@config)
51
+ }.should_not raise_error
52
+ end
53
+
54
+ describe "templated attributes" do
55
+ before do
56
+ @template = @template_class.new(@config)
57
+ end
58
+
59
+ it "should set identifier correctly" do
60
+ @template.widget_id.should == "com.whoever.awesome.app"
61
+ end
62
+
63
+ it "should set display_name correctly" do
64
+ @template.widget_name.should == "Awesome App"
65
+ end
66
+
67
+ it "should set version correctly" do
68
+ @template.widget_version.should == "1.0.0"
69
+ end
70
+
71
+ it "should set description correctly" do
72
+ @template.widget_description.should == "My New App, by Bruce Lee"
73
+ end
74
+
75
+ describe "author" do
76
+ it "should set name correctly" do
77
+ @template.author_name.should == "Bruce Lee"
78
+ end
79
+
80
+ it "should set href correctly" do
81
+ @template.author_href.should == "http://brucelee.cn"
82
+ end
83
+
84
+ it "should set email correctly" do
85
+ @template.author_email.should == "blee@hotmail.com"
86
+ end
87
+ end
88
+
89
+ it "should render the correct config.xml" do
90
+ @template.render.should == File.read("#{ fixture_dir }/blackberry_widget_config_spec.xml")
91
+ end
92
+ end
93
+ end
94
+ end