disposable_db 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,8 +2,8 @@ module DisposableDB
2
2
  class Database
3
3
  attr_accessor :connection
4
4
 
5
- def initialize(args = {})
6
- @connection = args[:connection] || Sequel.sqlite
5
+ def initialize(connection = nil, opts = {})
6
+ @connection = connection || Sequel.connect('sqlite:/')
7
7
  end
8
8
 
9
9
  def create_table!(table_template)
@@ -2,14 +2,14 @@ module DisposableDB
2
2
  module Databases
3
3
  class SQLite < Database
4
4
 
5
- def intialize(args = {})
6
- unless args.has_key? :connection
7
- if args[:connection_string]
8
- args[:connection] = Sequel.connect(args[:connection_string])
9
- end
5
+ def initialize(args = {})
6
+ if args[:connection]
7
+ connection = args[:connection]
8
+ elsif args[:db_path]
9
+ connection = Sequel.sqlite args[:db_path]
10
10
  end
11
11
 
12
- super(args)
12
+ super(connection)
13
13
  end
14
14
 
15
15
  end
@@ -1,3 +1,3 @@
1
1
  module DisposableDB
2
- VERSION = '0.0.4' unless defined? DisposableDB::VERSION
2
+ VERSION = '0.0.5' unless defined? DisposableDB::VERSION
3
3
  end
@@ -1,5 +1,20 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SQLite do
4
+ it "can be instantiated" do
5
+ db = Databases::SQLite.new
6
+ db.should be_a_kind_of(SQLite)
7
+ end
8
+
9
+ it "has a connection" do
10
+ db = Databases::SQLite.new
11
+ db.connection.should be_a_kind_of(Sequel::SQLite::Database)
12
+ end
13
+
14
+ it "can set correct connection path" do
15
+ tf = Tempfile.new ['displosable_db_sqlite_spec_', '.db']
16
+ db = Databases::SQLite.new :db_path => tf.path
17
+ db.connection.uri.should == "sqlite:/#{tf.path}"
18
+ end
4
19
 
5
20
  end
@@ -13,13 +13,13 @@ describe DisposableModel do
13
13
  end
14
14
 
15
15
  it "has a database with connection" do
16
- m = DisposableModel.factory(:database => Database.new(:connection => Sequel.sqlite))
16
+ m = DisposableModel.factory(:database => Database.new(Sequel.sqlite))
17
17
  m.database.connection.should be_a_kind_of(Sequel::SQLite::Database)
18
18
  end
19
19
 
20
20
  it "has a database with adjustable connection" do
21
- m1 = DisposableModel.factory(:database => Database.new(:connection => Sequel.sqlite))
22
- m2 = DisposableModel.factory(:database => Database.new(:connection => Sequel.sqlite('/tmp/test.db')))
21
+ m1 = DisposableModel.factory(:database => Database.new(Sequel.sqlite))
22
+ m2 = DisposableModel.factory(:database => Database.new(Sequel.sqlite('/tmp/test.db')))
23
23
  m1.database.connection.uri.should == 'sqlite:/'
24
24
  m2.database.connection.uri.should == 'sqlite://tmp/test.db'
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: disposable_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-28 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &21150400 !ruby/object:Gem::Requirement
16
+ requirement: &14220320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.9.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *21150400
24
+ version_requirements: *14220320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &21149240 !ruby/object:Gem::Requirement
27
+ requirement: &14219680 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *21149240
35
+ version_requirements: *14219680
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ffaker
38
- requirement: &21147000 !ruby/object:Gem::Requirement
38
+ requirement: &14218700 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.13.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *21147000
46
+ version_requirements: *14218700
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: ruby-prof
49
- requirement: &21146240 !ruby/object:Gem::Requirement
49
+ requirement: &14218080 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *21146240
57
+ version_requirements: *14218080
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: sequel
60
- requirement: &21144760 !ruby/object:Gem::Requirement
60
+ requirement: &14216840 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - =
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 3.33.0
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *21144760
68
+ version_requirements: *14216840
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sqlite3
71
- requirement: &21143400 !ruby/object:Gem::Requirement
71
+ requirement: &14216020 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *21143400
79
+ version_requirements: *14216020
80
80
  description: A utility that makes it easy to create "on-the-fly databases"
81
81
  email:
82
82
  - keithlarrimore@icehook.com