motion-sqlite3 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68a69012e93f6fd92e18374f83847c6ec82d5c96
4
- data.tar.gz: e0f5320cd0095fb0edbef10652879e8cc5b964df
3
+ metadata.gz: adc0d629a1d4122918dc1a81e793175ca57e82c4
4
+ data.tar.gz: 1b4a29b64c16b1a731a5124ed12f5cfb8c33b608
5
5
  SHA512:
6
- metadata.gz: 753b4e55db75a21d6cc057b6057a3b7ba007092b767036fca6f8f159503ab88eea9128e05f6600b2dd014a3256156acb42cd270613d22f104e00bf7fc7400761
7
- data.tar.gz: 9fda7b8a475b47974ca79daf2aad0a2aae3186daac61e010eb61120efe2a002b073d2357a90bfc771d50b71a528a4fe8ccbd7590f1df9d7e87d9776ea59df1bf
6
+ metadata.gz: bcb1864a24499ac5a039990495890dd6c3ee6f144e67856a9d4317e64bd277a8e2756144dbe0a5637091e7b2d80a001a65ca2bd852539b03b8b777387ae10f09
7
+ data.tar.gz: 904f8427a74a04edc1b5ff88810179405d9bcf43f3ff7211296a7564126c4c9ee4e50eecf01c38b1db1783727344fccd73b912975ba0c7eece26dcd3200a187d
data/.travis.yml ADDED
@@ -0,0 +1,2 @@
1
+ install: bundle install
2
+ language: objective-c
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
- # A sample Gemfile
2
1
  source "https://rubygems.org"
3
2
 
4
3
  gemspec
data/README.md CHANGED
@@ -4,6 +4,12 @@ This is a tiny wrapper around the SQLite C API that's written in RubyMotion. It
4
4
 
5
5
  Whenever possible, it uses Ruby idioms like blocks and exceptions.
6
6
 
7
+ [![Code Climate](https://codeclimate.com/github/mattgreen/motion-sqlite3.png)](https://codeclimate.com/github/mattgreen/motion-sqlite3) [![Build Status](https://travis-ci.org/mattgreen/motion-sqlite3.png?branch=master)](https://travis-ci.org/mattgreen/motion-sqlite3) [![Gem Version](https://badge.fury.io/rb/motion-sqlite3.png)](http://badge.fury.io/rb/motion-sqlite3)
8
+
9
+ Is it any good?
10
+ ---------------
11
+ Yes.
12
+
7
13
  Sample code
8
14
  -----------
9
15
 
@@ -43,6 +43,21 @@ module SQLite3
43
43
  execute(*args).first.values.first
44
44
  end
45
45
 
46
+ def transaction(&block)
47
+ execute("BEGIN TRANSACTION")
48
+
49
+ begin
50
+ result = yield
51
+ rescue
52
+ execute("ROLLBACK TRANSACTION")
53
+ raise
54
+ end
55
+
56
+ execute("COMMIT TRANSACTION")
57
+
58
+ result
59
+ end
60
+
46
61
  private
47
62
 
48
63
  def prepare(sql, params, &block)
@@ -1,3 +1,3 @@
1
1
  module SQLite3
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -15,6 +15,6 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = SQLite3::VERSION
17
17
 
18
- gem.add_development_dependency 'rake', '~> 0.9.0'
18
+ gem.add_development_dependency 'rake'
19
19
  gem.add_dependency 'motion.h', '~> 0.0.3'
20
20
  end
@@ -63,4 +63,37 @@ describe SQLite3::Database do
63
63
  @db.execute_scalar("SELECT COUNT(*) FROM test WHERE age > ?", [20]).should == 2
64
64
  end
65
65
  end
66
+
67
+ describe "#transaction" do
68
+ it "commits the transaction if no error is raised" do
69
+ @db.transaction do
70
+ @db.execute("CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)")
71
+ end
72
+
73
+ @db.execute_scalar("SELECT COUNT(*) FROM sqlite_master WHERE name = 'test'").should == 1
74
+ end
75
+
76
+ it "returns the value of the block" do
77
+ @db.transaction do
78
+ @db.execute("CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)")
79
+
80
+ 42
81
+ end.should == 42
82
+ end
83
+
84
+ it "aborts the transaction if an error is raised" do
85
+ begin
86
+ @db.transaction do
87
+ @db.execute("CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)")
88
+ @db.execute("INSERT INTO test (name) VALUES (?)", ["brad"])
89
+
90
+ raise ArgumentError
91
+ end
92
+
93
+ rescue ArgumentError
94
+ end
95
+
96
+ @db.execute_scalar("SELECT COUNT(*) FROM sqlite_master WHERE name = 'test'").should == 0
97
+ end
98
+ end
66
99
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-sqlite3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Green
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-03 00:00:00.000000000 Z
11
+ date: 2014-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.9.0
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.9.0
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: motion.h
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -46,7 +46,7 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - ".gitignore"
49
- - ".rvmrc"
49
+ - ".travis.yml"
50
50
  - Gemfile
51
51
  - Guardfile
52
52
  - README.md
data/.rvmrc DELETED
@@ -1,4 +0,0 @@
1
- rvm ruby-1.9.3-p194@rubymotion --create
2
-
3
- [[ -s "config/rvm_env.sh" ]] && . "config/rvm_env.sh"
4
- [[ -s ".rvm_env" ]] && . ".rvm_env"