sequel 0.5 → 0.5.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ === 0.5.0.1 (2007-12-31)
2
+
3
+ * Added a stub for Sequel::Model that auto-loads sequel_model.
4
+
5
+ * Changed Sequel.method_missing and Database.adapter_class to raise AdapterNotFound if an adapter could not be loaded.
6
+
7
+ * Fixed behavior of error trap in sequel command line tool.
8
+
1
9
  === 0.5 (2007-12-30)
2
10
 
3
11
  * Removed model code into separate sub-project. Rearranged trunk into core, model and model_plugins.
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ include FileUtils
9
9
  # Configuration
10
10
  ##############################################################################
11
11
  NAME = "sequel"
12
- VERS = "0.5"
12
+ VERS = "0.5.0.1"
13
13
  CLEAN.include ["**/.*.sw?", "pkg/*", ".config", "doc/*", "coverage/*"]
14
14
  RDOC_OPTS = [
15
15
  "--quiet",
@@ -57,15 +57,21 @@ spec = Gem::Specification.new do |s|
57
57
  s.executables = ["sequel"]
58
58
  s.required_ruby_version = ">= 1.8.4"
59
59
 
60
+ s.add_dependency("metaid")
61
+
60
62
  case RUBY_PLATFORM
61
63
  when /mswin/
62
64
  s.platform = Gem::Platform::CURRENT
65
+ s.add_dependency("RubyInline", ">= 3.6.6")
66
+ s.add_dependency("ParseTree", ">= 2.1.1")
67
+ s.add_dependency("ruby2ruby")
63
68
  when /java/
64
69
  s.platform = "jruby"
65
70
  else
66
71
  s.platform = Gem::Platform::RUBY
67
- s.add_dependency("metaid")
68
- s.add_dependency("ParseTree", ">= 2.0.0")
72
+ # ParseTree on win32 requires PT2.1.1 and RI3.6.6
73
+ s.add_dependency("RubyInline", ">= 3.6.6")
74
+ s.add_dependency("ParseTree", ">= 2.1.1")
69
75
  s.add_dependency("ruby2ruby")
70
76
  end
71
77
 
data/bin/sequel CHANGED
@@ -23,9 +23,6 @@ end
23
23
 
24
24
  begin
25
25
  DB = Sequel.connect db
26
- rescue LoadError => e
27
- puts "Failed to load #{scheme} adapter: #{e.message}"
28
- exit
29
26
  rescue => e
30
27
  puts e.message
31
28
  exit
@@ -45,10 +45,22 @@ module Sequel #:nodoc:
45
45
  opts = args[1].merge(:database => args[0])
46
46
  end
47
47
  rescue
48
- raise Error, "Unknown adapter (#{m})"
48
+ raise Error::AdapterNotFound, "Unknown adapter (#{m})"
49
49
  end
50
50
  c.new(opts)
51
51
  end
52
+
53
+ # stub for Sequel::Model()
54
+ def Model(*args)
55
+ require 'sequel_model'
56
+ if respond_to?(:Model)
57
+ send(:Model, *args)
58
+ else
59
+ raise LoadError
60
+ end
61
+ rescue LoadError
62
+ raise SequelError, "The sequel_model library could not be found. In order to use Sequel models please install sequel_model."
63
+ end
52
64
  end
53
65
  end
54
66
 
@@ -371,13 +371,23 @@ module Sequel
371
371
  end
372
372
 
373
373
  def self.adapter_class(scheme)
374
- scheme = scheme.to_s =~ /\-/ ? scheme.to_s.gsub('-', '_').to_sym : scheme.to_sym
375
- unless c = @@adapters[scheme.to_sym]
376
- require File.join(File.dirname(__FILE__), "adapters/#{scheme}")
377
- c = @@adapters[scheme.to_sym]
374
+ adapter_name = scheme.to_s =~ /\-/ ? scheme.to_s.gsub('-', '_').to_sym : scheme.to_sym
375
+ scheme = scheme.to_sym
376
+
377
+ if (klass = @@adapters[scheme]).nil?
378
+ # attempt to load the adapter file
379
+ begin
380
+ require File.join(File.dirname(__FILE__), "adapters/#{scheme}")
381
+ rescue LoadError => e
382
+ raise Error::AdapterNotFound, "Could not load #{scheme} adapter:\n #{e.message}"
383
+ end
384
+
385
+ # make sure we actually loaded the adapter
386
+ if (klass = @@adapters[scheme]).nil?
387
+ raise Error::AdapterNotFound, "Could not load #{scheme} adapter"
388
+ end
378
389
  end
379
- raise Error::InvalidDatabaseScheme, "Invalid database scheme" unless c
380
- c
390
+ return klass
381
391
  end
382
392
 
383
393
  # call-seq:
@@ -5,8 +5,6 @@ module Sequel
5
5
  # Rollback is a special error used to rollback a transactions.
6
6
  # A transaction block will catch this error and wont pass further up the stack.
7
7
  class Rollback < Error ; end
8
-
9
- class InvalidDatabaseScheme < Error; end
10
8
 
11
9
  # Represents an invalid value stored in the database.
12
10
  class InvalidValue < Error ; end
@@ -26,7 +24,9 @@ module Sequel
26
24
  class InvalidJoinType < Error ; end
27
25
 
28
26
  class WorkerStop < RuntimeError ; end
29
-
27
+
28
+ # Raised when Sequel is unable to load a specified adapter.
29
+ class AdapterNotFound < Error ; end
30
30
  end
31
31
  end
32
32
 
@@ -545,15 +545,15 @@ end
545
545
 
546
546
  context "An unknown database scheme" do
547
547
  specify "should raise an error in Sequel::Database.connect" do
548
- proc {Sequel::Database.connect('ddd://localhost/db')}.should raise_error(LoadError)
548
+ proc {Sequel::Database.connect('ddd://localhost/db')}.should raise_error(Sequel::Error::AdapterNotFound)
549
549
  end
550
550
 
551
551
  specify "should raise an error in Sequel.connect" do
552
- proc {Sequel.connect('ddd://localhost/db')}.should raise_error(LoadError)
552
+ proc {Sequel.connect('ddd://localhost/db')}.should raise_error(Sequel::Error::AdapterNotFound)
553
553
  end
554
554
 
555
555
  specify "should raise an error in Sequel.open" do
556
- proc {Sequel.open('ddd://localhost/db')}.should raise_error(LoadError)
556
+ proc {Sequel.open('ddd://localhost/db')}.should raise_error(Sequel::Error::AdapterNotFound)
557
557
  end
558
558
  end
559
559
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.5"
4
+ version: 0.5.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2007-12-30 00:00:00 +02:00
12
+ date: 2007-12-31 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -21,6 +21,15 @@ dependencies:
21
21
  - !ruby/object:Gem::Version
22
22
  version: "0"
23
23
  version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: RubyInline
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 3.6.6
32
+ version:
24
33
  - !ruby/object:Gem::Dependency
25
34
  name: ParseTree
26
35
  version_requirement:
@@ -28,7 +37,7 @@ dependencies:
28
37
  requirements:
29
38
  - - ">="
30
39
  - !ruby/object:Gem::Version
31
- version: 2.0.0
40
+ version: 2.1.1
32
41
  version:
33
42
  - !ruby/object:Gem::Dependency
34
43
  name: ruby2ruby