sqlite_magic 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/sqlite_magic.rb CHANGED
@@ -42,6 +42,14 @@ module SqliteMagic
42
42
  raw_response = data ? database.execute2(query, data) : database.execute2(query)
43
43
  keys = raw_response.shift # get the keys
44
44
  raw_response.map{|e| Hash[keys.zip(e)] }
45
+ rescue SQLite3::SQLException => e
46
+ puts "Exception (#{e.inspect}) raised" if verbose?
47
+ case e.message
48
+ when /no such table/
49
+ raise NoSuchTable.new(e.message)
50
+ else
51
+ raise e
52
+ end
45
53
  end
46
54
 
47
55
  # This is an (expensive) convenience method to insert a row (for given unique keys), or if the row already exists
@@ -1,3 +1,3 @@
1
1
  module SqliteMagic
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -87,6 +87,29 @@ describe SqliteMagic do
87
87
  @connection.execute('some query',nil)
88
88
  end
89
89
  end
90
+
91
+ context 'and table does not exist' do
92
+ before do
93
+ @dummy_db.stub(:execute2).
94
+ and_raise(SQLite3::SQLException.new("no such table: foo_table") )
95
+ end
96
+
97
+ it 'should raise NoSuchTable exception' do
98
+ lambda { @connection.execute('some query') }.should raise_error(SqliteMagic::NoSuchTable)
99
+ end
100
+ end
101
+
102
+ context 'and other SQLite3 error raised' do
103
+ before do
104
+ @other_ex = SQLite3::SQLException.new("something else went wrong")
105
+ @dummy_db.stub(:execute2).
106
+ and_raise(@other_ex)
107
+ end
108
+
109
+ it 'should raise exception' do
110
+ lambda { @connection.execute('some query') }.should raise_error(@other_ex)
111
+ end
112
+ end
90
113
  end
91
114
 
92
115
  describe '#save_data' do
data/sqlite_magic.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["info@opencorporates.com"]
11
11
  spec.description = %q{Sprinkles some magic onto Sqlite3 gem. Sort of extracted from Scraperwiki gem}
12
12
  spec.summary = %q{Sprinkles some magic onto Sqlite3 gem}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/openc/sqlite_magic"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Chris Taggart
@@ -89,7 +89,7 @@ files:
89
89
  - spec/spec_helper.rb
90
90
  - sqlite_magic.gemspec
91
91
  has_rdoc: true
92
- homepage: ""
92
+ homepage: https://github.com/openc/sqlite_magic
93
93
  licenses:
94
94
  - MIT
95
95
  post_install_message: