confetti 0.8.2 → 0.8.3

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.8.2)
4
+ confetti (0.8.3)
5
5
  mustache (~> 0.11.2)
6
6
 
7
7
  GEM
@@ -10,9 +10,10 @@ module Confetti
10
10
  :icon_set, :feature_set, :preference_set, :xml_doc,
11
11
  :splash_set, :plist_icon_set, :access_set, :plugin_set
12
12
 
13
- generate_and_write :android_manifest, :android_strings, :webos_appinfo,
14
- :ios_info, :symbian_wrt_info, :blackberry_widgets_config,
15
- :ios_remote_plist, :windows_phone7_manifest
13
+ generate_and_write :android_manifest, :android_strings,
14
+ :webos_appinfo, :ios_info, :symbian_wrt_info,
15
+ :blackberry_widgets_config, :ios_remote_plist,
16
+ :windows_phone7_manifest
16
17
 
17
18
  # handle bad generate/write calls
18
19
  def method_missing(method_name, *args)
@@ -37,7 +38,9 @@ module Confetti
37
38
  @splash_set = TypedSet.new Image
38
39
  @preference_set = TypedSet.new Preference
39
40
  @access_set = TypedSet.new Access
40
- @plugin_set = TypedSet.new Plugin # defined in PhoneGap module
41
+
42
+ # defined in PhoneGap module
43
+ @plugin_set = TypedSet.new Plugin
41
44
  @viewmodes = []
42
45
 
43
46
  if args.length > 0 && is_file?(args.first)
@@ -75,25 +78,58 @@ module Confetti
75
78
  when "http://www.w3.org/ns/widgets"
76
79
  case ele.name
77
80
  when "name"
78
- @name = Name.new(ele.text.nil? ? "" : ele.text.strip, attr["shortname"])
81
+ @name = Name.new(
82
+ ele.text.nil? ? "" : ele.text.strip,
83
+ attr["shortname"]
84
+ )
85
+
79
86
  when "author"
80
- @author = Author.new(ele.text.nil? ? "" : ele.text.strip, attr["href"], attr["email"])
87
+ @author = Author.new(
88
+ ele.text.nil? ? "" : ele.text.strip,
89
+ attr["href"],
90
+ attr["email"]
91
+ )
92
+
81
93
  when "description"
82
94
  @description = ele.text.nil? ? "" : ele.text.strip
95
+
83
96
  when "icon"
84
- @icon_set << Image.new(attr["src"], attr["height"], attr["width"], attr)
97
+ @icon_set << Image.new(
98
+ attr["src"],
99
+ attr["height"],
100
+ attr["width"],
101
+ attr
102
+ )
85
103
  # used for the info.plist file
86
104
  @plist_icon_set << attr["src"]
105
+
87
106
  when "feature"
88
- @feature_set << Feature.new(attr["name"], attr["required"])
107
+ @feature_set << Feature.new(
108
+ attr["name"],
109
+ attr["required"]
110
+ )
111
+
89
112
  when "preference"
90
- @preference_set << Preference.new(attr["name"], attr["value"], attr["readonly"])
113
+ @preference_set << Preference.new(
114
+ attr["name"],
115
+ attr["value"],
116
+ attr["readonly"]
117
+ )
118
+
91
119
  when "license"
92
- @license = License.new(ele.text.nil? ? "" : ele.text.strip, attr["href"])
120
+ @license = License.new(
121
+ ele.text.nil? ? "" : ele.text.strip,
122
+ attr["href"]
123
+ )
124
+
93
125
  when "access"
94
126
  sub = boolean_value(attr["subdomains"], true)
95
127
  browserOnly = boolean_value(attr["browserOnly"])
96
- @access_set << Access.new(attr["origin"], sub, browserOnly)
128
+ @access_set << Access.new(
129
+ attr["origin"],
130
+ sub,
131
+ browserOnly
132
+ )
97
133
  end
98
134
 
99
135
  # PhoneGap extensions (gap:)
@@ -101,13 +137,22 @@ module Confetti
101
137
  case ele.name
102
138
  when "splash"
103
139
  next if attr["src"].nil? or attr["src"].empty?
104
- @splash_set << Image.new(attr["src"], attr["height"], attr["width"], attr)
140
+ @splash_set << Image.new(
141
+ attr["src"],
142
+ attr["height"],
143
+ attr["width"],
144
+ attr
145
+ )
146
+
105
147
  when "plugin"
106
148
  next if attr["name"].nil? or attr["name"].empty?
107
149
  plugin = Plugin.new(attr["name"], attr["version"])
108
150
  ele.each_element('param') do |param|
109
151
  p_attr = param.attributes
110
- plugin.param_set << Param.new(p_attr["name"], p_attr["value"])
152
+ plugin.param_set << Param.new(
153
+ p_attr["name"],
154
+ p_attr["value"]
155
+ )
111
156
  end
112
157
  @plugin_set << plugin
113
158
  end
@@ -228,5 +273,21 @@ module Confetti
228
273
  value == "true"
229
274
  end
230
275
  end
276
+
277
+ def filtered_to_s( xpaths = [] )
278
+ xpaths = [ xpaths ] unless xpaths.kind_of?(Array)
279
+
280
+ @xml = @xml_doc.dup
281
+
282
+ xpaths.each do |path|
283
+ @xml.root.elements.delete_all path
284
+ end
285
+
286
+ @xml.root.to_s
287
+ end
288
+
289
+ def to_s
290
+ @xml_doc.root.to_s
291
+ end
231
292
  end
232
293
  end
@@ -1,3 +1,3 @@
1
1
  module Confetti
2
- VERSION = "0.8.2"
2
+ VERSION = "0.8.3"
3
3
  end
data/spec/config_spec.rb CHANGED
@@ -731,4 +731,23 @@ describe Confetti::Config do
731
731
  end
732
732
  end
733
733
  end
734
+
735
+ describe "serialization" do
736
+
737
+ before :each do
738
+ @config = Confetti::Config.new(File.join(
739
+ fixture_dir,
740
+ "config.xml"
741
+ ))
742
+ end
743
+
744
+ it "should define a to_s method" do
745
+ @config.to_s.kind_of?(String).should == true
746
+ end
747
+
748
+ it "should serialize when no filters provided" do
749
+ @config.to_s.should match /icon/
750
+ @config.filtered_to_s("//icon").should_not match /icon/
751
+ end
752
+ end
734
753
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 8
8
- - 2
9
- version: 0.8.2
8
+ - 3
9
+ version: 0.8.3
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: 2012-06-20 00:00:00 -07:00
19
+ date: 2012-06-26 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency