confetti 0.3.2 → 0.3.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.3.2)
4
+ confetti (0.3.3)
5
5
  mustache (~> 0.11.2)
6
6
  thor (~> 0.14.3)
7
7
 
data/lib/confetti.rb CHANGED
@@ -17,6 +17,7 @@ require "mustache"
17
17
  # internal dependencies
18
18
  require 'typedset'
19
19
  require 'confetti/version'
20
+ require 'confetti/error'
20
21
  require 'confetti/helpers'
21
22
  require 'confetti/phonegap'
22
23
 
@@ -4,6 +4,10 @@ module Confetti
4
4
  include PhoneGap
5
5
  self.extend TemplateHelper
6
6
 
7
+ class XMLError < Confetti::Error ; end
8
+
9
+ class FileError < Confetti::Error ; end
10
+
7
11
  attr_accessor :package, :version_string, :version_code, :description,
8
12
  :height, :width
9
13
  attr_reader :author, :viewmodes, :name, :license, :content,
@@ -40,9 +44,12 @@ module Confetti
40
44
 
41
45
  def populate_from_xml(xml_file)
42
46
  begin
43
- config_doc = REXML::Document.new(File.read(xml_file)).root
47
+ file = File.read(xml_file)
48
+ config_doc = REXML::Document.new(file).root
44
49
  rescue REXML::ParseException
45
- raise ArgumentError, "malformed config.xml"
50
+ raise XMLError, "malformed config.xml"
51
+ rescue Errno::ENOENT
52
+ raise FileError, "file #{ xml_file } doesn't exist"
46
53
  end
47
54
 
48
55
  fail "no doc parsed" unless config_doc
@@ -0,0 +1,3 @@
1
+ module Confetti
2
+ class Error < Exception ; end
3
+ end
@@ -1,3 +1,3 @@
1
1
  module Confetti
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
data/spec/config_spec.rb CHANGED
@@ -162,16 +162,16 @@ describe Confetti::Config do
162
162
  }.should raise_error
163
163
  end
164
164
 
165
- it "should raise an error if can't parse" do
165
+ it "should raise an error if the file doesn't exist" do
166
166
  lambda {
167
167
  @config.populate_from_xml("foo.goo")
168
- }.should raise_error
168
+ }.should raise_error Confetti::Config::FileError
169
169
  end
170
170
 
171
171
  it "should raise an error with malformed xml" do
172
172
  lambda {
173
173
  @config.populate_from_xml("#{ fixture_dir }/bad_config.xml")
174
- }.should raise_error ArgumentError
174
+ }.should raise_error Confetti::Config::XMLError
175
175
  end
176
176
 
177
177
  describe "when setting attributes from config.xml" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 2
9
- version: 0.3.2
8
+ - 3
9
+ version: 0.3.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: 2011-08-15 00:00:00 -07:00
19
+ date: 2011-08-22 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -114,6 +114,7 @@ files:
114
114
  - lib/confetti/cli.rb
115
115
  - lib/confetti/config.rb
116
116
  - lib/confetti/config/feature.rb
117
+ - lib/confetti/error.rb
117
118
  - lib/confetti/helpers.rb
118
119
  - lib/confetti/phonegap.rb
119
120
  - lib/confetti/template.rb