confetti 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- confetti (0.2.3)
4
+ confetti (0.2.4)
5
5
  mustache (= 0.11.2)
6
6
  thor (= 0.14.3)
7
7
 
@@ -4,7 +4,7 @@ module Confetti
4
4
  include PhoneGap
5
5
  self.extend TemplateHelper
6
6
 
7
- attr_accessor :package, :version, :description, :height, :width
7
+ attr_accessor :package, :version_string, :version_code, :description, :height, :width
8
8
  attr_reader :author, :viewmodes, :name, :license, :content,
9
9
  :icon_set, :feature_set, :preference_set, :xml_doc,
10
10
  :splash_set
@@ -50,18 +50,18 @@ module Confetti
50
50
  @xml_doc = config_doc
51
51
 
52
52
  @package = config_doc.attributes["id"]
53
- @version = config_doc.attributes["version"]
53
+ @version_string = config_doc.attributes["version"]
54
54
 
55
55
  config_doc.elements.each do |ele|
56
56
  attr = ele.attributes
57
57
 
58
58
  case ele.name
59
59
  when "name"
60
- @name = Name.new(ele.text.strip, attr["shortname"])
60
+ @name = Name.new(ele.text.nil? ? "" : ele.text.strip, attr["shortname"])
61
61
  when "author"
62
- @author = Author.new(ele.text.strip, attr["href"], attr["email"])
62
+ @author = Author.new(ele.text.nil? ? "" : ele.text.strip, attr["href"], attr["email"])
63
63
  when "description"
64
- @description = ele.text.strip
64
+ @description = ele.text.nil? ? "" : ele.text.strip
65
65
  when "icon"
66
66
  extras = grab_extras attr
67
67
  @icon_set << Image.new(attr["src"], attr["height"], attr["width"], extras)
@@ -71,7 +71,7 @@ module Confetti
71
71
  when "feature"
72
72
  @feature_set << Feature.new(attr["name"], attr["required"])
73
73
  when "license"
74
- @license = License.new(ele.text.strip, attr["href"])
74
+ @license = License.new(ele.text.nil? ? "" : ele.text.strip, attr["href"])
75
75
  end
76
76
  end
77
77
  end
@@ -2,7 +2,7 @@
2
2
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
3
  package="{{ package_name }}"
4
4
  android:versionName="{{ version }}"
5
- android:versionCode="1">
5
+ android:versionCode="{{ version_code }}">
6
6
  <uses-permission android:name="android.permission.READ_PHONE_STATE" />
7
7
  <uses-permission android:name="android.permission.INTERNET" />
8
8
  {{# permissions }}
@@ -31,7 +31,11 @@ module Confetti
31
31
  end
32
32
 
33
33
  def version
34
- @config.version || '0.0.1'
34
+ @config.version_string || '0.0.1'
35
+ end
36
+
37
+ def version_code
38
+ @config.version_code || '1'
35
39
  end
36
40
 
37
41
  def permissions
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <!-- Widget Configuration Reference: http://docs.blackberry.com/en/developers/deliverables/15274/ -->
3
3
  <widget xmlns="http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets"
4
- version="2.0"
4
+ version="{{ version }}"
5
5
  id="{{ widget_id }}">
6
6
  <name>{{ widget_name }}</name>
7
7
  <author href="{{ author_href }}" email="{{ author_email }}">{{ author_name }}</author>
@@ -5,6 +5,10 @@ module Confetti
5
5
  @config.package
6
6
  end
7
7
 
8
+ def version
9
+ @config.version_string || "0.0.1"
10
+ end
11
+
8
12
  def widget_name
9
13
  @config.name.name
10
14
  end
@@ -6,7 +6,7 @@ module Confetti
6
6
  end
7
7
 
8
8
  def bundle_version
9
- @config.version
9
+ @config.version_string
10
10
  end
11
11
 
12
12
  def product_name
@@ -6,7 +6,7 @@ module Confetti
6
6
  end
7
7
 
8
8
  def version
9
- @config.version
9
+ @config.version_string
10
10
  end
11
11
 
12
12
  def display_name
@@ -20,12 +20,12 @@ module Confetti
20
20
  end
21
21
 
22
22
  def version
23
- if @config.version.nil?
23
+ if @config.version_string.nil?
24
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)
25
+ elsif @config.version_string.match /^(\d)+[.](\d)+[.](\d)+$/
26
+ @config.version_string
27
+ elsif @config.version_string.match /^((\d)+[.])*(\d)+$/
28
+ fix_version(@config.version_string)
29
29
  else
30
30
  fail "need a valid version number of the form 0.0.0"
31
31
  end
@@ -1,3 +1,3 @@
1
1
  module Confetti
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
data/spec/config_spec.rb CHANGED
@@ -14,9 +14,14 @@ describe Confetti::Config do
14
14
  @config.package.should == "com.alunny.greatapp"
15
15
  end
16
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"
17
+ it "has a writable and readable version_string field" do
18
+ lambda { @config.version_string = "0.1.0" }.should_not raise_error
19
+ @config.version_string.should == "0.1.0"
20
+ end
21
+
22
+ it "has a writable and readable version_code field" do
23
+ lambda { @config.version_code = 12 }.should_not raise_error
24
+ @config.version_code.should == 12
20
25
  end
21
26
 
22
27
  it "has a writable and readable height field" do
@@ -174,9 +179,32 @@ describe Confetti::Config do
174
179
  @config.populate_from_xml(fixture_dir + "/config.xml")
175
180
  end
176
181
 
182
+ describe "that has empty tags" do
183
+ before do
184
+ @config.populate_from_xml(fixture_dir + "/empty_elements.xml")
185
+ end
186
+
187
+ it "should set the author to the empty string" do
188
+ @config.author.name.should == ""
189
+ end
190
+
191
+ it "should set the name to the empty string" do
192
+ @config.name.name.should == ""
193
+ end
194
+
195
+ it "should set the description to the empty string" do
196
+ @config.description.should == ""
197
+ end
198
+
199
+ it "should set the license to the empty string" do
200
+ @config.license.text.should == ""
201
+ end
202
+
203
+ end
204
+
177
205
  it "should keep a reference to the xml doc" do
178
206
  @config.xml_doc.should_not == nil
179
- @config.xml_doc.class.should == REXML::Element
207
+ @config.xml_doc.class.should == REXML::Element
180
208
  end
181
209
 
182
210
  it "should populate the app's package when present" do
@@ -187,8 +215,8 @@ describe Confetti::Config do
187
215
  @config.name.name.should == "Confetti Sample App"
188
216
  end
189
217
 
190
- it "should populate the app's version when present" do
191
- @config.version.should == "1.0.0"
218
+ it "should populate the app's version_string when present" do
219
+ @config.version_string.should == "1.0.0"
192
220
  end
193
221
 
194
222
  it "should populate the app's description when present" do
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <!-- Widget Configuration Reference: http://docs.blackberry.com/en/developers/deliverables/15274/ -->
3
3
  <widget xmlns="http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets"
4
- version="2.0"
4
+ version="1.0.0"
5
5
  id="com.alunny.confetti">
6
6
  <name>Confetti Sample App</name>
7
7
  <author href="http://alunny.github.com" email="alunny@gmail.com">Andrew Lunny</author>
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <!-- Widget Configuration Reference: http://docs.blackberry.com/en/developers/deliverables/15274/ -->
3
3
  <widget xmlns="http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets"
4
- version="2.0"
4
+ version="1.0.0"
5
5
  id="com.whoever.awesome.app">
6
6
  <name>Awesome App</name>
7
7
  <author href="http://brucelee.cn" email="blee@hotmail.com">Bruce Lee</author>
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <widget xmlns = "http://www.w3.org/ns/widgets"
3
+ xmlns:gap = "http://phonegap.com/ns/1.0"
4
+ id = "com.alunny.confetti"
5
+ version = "1.0.0">
6
+
7
+ <name />
8
+
9
+ <description />
10
+
11
+ <license href="http://www.opensource.org/licenses/mit-license.php" />
12
+
13
+ <author href="http://alunny.github.com"
14
+ email="alunny@gmail.com" />
15
+ <icon src="icon.png" height="150" width="200" />
16
+
17
+ <gap:splash src="mainsplash.png" height="480" width="360" />
18
+
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"/>
22
+ </widget>
@@ -39,7 +39,7 @@ describe Confetti::Template::BlackberryWidgetsConfig do
39
39
  @config = Confetti::Config.new
40
40
  @config.name.name = "Awesome App"
41
41
  @config.package = "com.whoever.awesome.app"
42
- @config.version = "1.0.0"
42
+ @config.version_string = "1.0.0"
43
43
  @config.author.name = "Bruce Lee"
44
44
  @config.author.email = "blee@hotmail.com"
45
45
  @config.author.href = "http://brucelee.cn"
@@ -34,7 +34,7 @@ describe Confetti::Template::IosInfo do
34
34
  @config = Confetti::Config.new
35
35
  @config.name.name = "Awesome App"
36
36
  @config.package = "com.whoever.awesome.app"
37
- @config.version = "1.0.0"
37
+ @config.version_string = "1.0.0"
38
38
  end
39
39
 
40
40
  it "should accept the config object" do
@@ -34,7 +34,7 @@ describe Confetti::Template::SymbianWrtInfo do
34
34
  @config = Confetti::Config.new
35
35
  @config.name.name = "Awesome App"
36
36
  @config.package = "com.whoever.awesome.app"
37
- @config.version = "1.0.0"
37
+ @config.version_string = "1.0.0"
38
38
  end
39
39
 
40
40
  it "should accept the config object" do
@@ -35,7 +35,7 @@ describe Confetti::Template::WebosAppinfo do
35
35
  @config.name.name = "Awesome App"
36
36
  @config.package = "com.whoever.awesome.app"
37
37
  @config.author.name = "Bruce Lee"
38
- @config.version = "1.0.0"
38
+ @config.version_string = "1.0.0"
39
39
  end
40
40
 
41
41
  it "should accept the config object" do
@@ -66,33 +66,33 @@ describe Confetti::Template::WebosAppinfo do
66
66
  end
67
67
 
68
68
  describe "#version method" do
69
- it "should return the default (0.0.1) when version is not set" do
70
- @config.version = nil
69
+ it "should return the default (0.0.1) when version_string is not set" do
70
+ @config.version_string = nil
71
71
  @template.version.should == "0.0.1"
72
72
  end
73
73
 
74
- it "should raise an error if version isn't even close" do
75
- @config.version = 'breakfast'
74
+ it "should raise an error if version_string isn't even close" do
75
+ @config.version_string = 'breakfast'
76
76
  lambda { @template.version }.should raise_error
77
77
  end
78
78
 
79
79
  it "should add empty digits if string has one segment" do
80
- @config.version = '1'
80
+ @config.version_string = '1'
81
81
  @template.version.should == "1.0.0"
82
82
  end
83
83
 
84
84
  it "should add empty digits if string has two segments" do
85
- @config.version = '1.1'
85
+ @config.version_string = '1.1'
86
86
  @template.version.should == "1.1.0"
87
87
  end
88
88
 
89
89
  it "should truncate extra digits if string has too many segments" do
90
- @config.version = '1.2.3.4.5'
90
+ @config.version_string = '1.2.3.4.5'
91
91
  @template.version.should == "1.2.3"
92
92
  end
93
93
 
94
94
  it "should return config.version when it is valid" do
95
- @config.version = '0.1.0'
95
+ @config.version_string = '0.1.0'
96
96
  @template.version.should == "0.1.0"
97
97
  end
98
98
  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: 17
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
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-29 00:00:00 -07:00
18
+ date: 2011-04-12 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -163,6 +163,7 @@ files:
163
163
  - spec/fixtures/config-icons-custom-attribs.xml
164
164
  - spec/fixtures/config-icons.xml
165
165
  - spec/fixtures/config.xml
166
+ - spec/fixtures/empty_elements.xml
166
167
  - spec/fixtures/ios_info_expected.plist
167
168
  - spec/fixtures/ios_info_spec.plist
168
169
  - spec/fixtures/symbian_wrt_info_expected.plist
@@ -244,6 +245,7 @@ test_files:
244
245
  - spec/fixtures/config-icons-custom-attribs.xml
245
246
  - spec/fixtures/config-icons.xml
246
247
  - spec/fixtures/config.xml
248
+ - spec/fixtures/empty_elements.xml
247
249
  - spec/fixtures/ios_info_expected.plist
248
250
  - spec/fixtures/ios_info_spec.plist
249
251
  - spec/fixtures/symbian_wrt_info_expected.plist