momomoto 0.1.18 → 0.1.19

Sign up to get free protection for your applications and to get access to all the features.
data/lib/momomoto/base.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  module Momomoto
4
4
 
5
5
  @debug = false
6
+ @verbose = false
6
7
 
7
8
  class << self
8
9
 
@@ -11,6 +12,11 @@ module Momomoto
11
12
  # are printed to STDOUT.
12
13
  attr_accessor :debug
13
14
 
15
+ # Getter and setter for verbose mode.
16
+ # If +verbose+ evaluates to +true+ the exception message of exceptions
17
+ # will include the SQL statement causing the exception.
18
+ attr_accessor :verbose
19
+
14
20
  # Returns an instance of Order::Lower where +args+ is either a single
15
21
  # or array of +Symbol+ representing columns.
16
22
  #
@@ -56,7 +62,16 @@ module Momomoto
56
62
  end
57
63
 
58
64
  # Base exception for all exceptions thrown by Momomoto
59
- class Error < StandardError; end
65
+ class Error < StandardError
66
+ # contains the sql statement causing the exception
67
+ attr_accessor :sql
68
+
69
+ def initialize( message = nil, sql = nil )
70
+ super( message )
71
+ self.sql = sql
72
+ end
73
+
74
+ end
60
75
 
61
76
  # Thrown when datatype conversion fails and if a +block+ given to
62
77
  # Table#select_or_new does not act on all primary keys.
@@ -81,7 +81,12 @@ module Momomoto
81
81
  rescue
82
82
  end
83
83
  end
84
- raise CriticalError, "#{e}: #{sql}"
84
+ if Momomoto.verbose
85
+ raise CriticalError.new( "#{e}: #{sql}", sql )
86
+ else
87
+ raise CriticalError.new( e.to_s, sql )
88
+ end
89
+
85
90
  end
86
91
 
87
92
  # fetch columns which are primary key columns
@@ -150,8 +155,8 @@ module Momomoto
150
155
 
151
156
  # begin a transaction
152
157
  def begin
153
- execute( "BEGIN;" )
154
158
  @transaction_active = true
159
+ execute( "BEGIN;" )
155
160
  end
156
161
 
157
162
  # executes the block and commits the transaction if a block is given
metadata CHANGED
@@ -1,131 +1,124 @@
1
1
  --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
2
4
  name: momomoto
3
5
  version: !ruby/object:Gem::Version
4
- version: 0.1.18
6
+ version: 0.1.19
7
+ date: 2009-03-02 00:00:00 +01:00
8
+ summary: Momomoto is an object relational mapper for PostgreSQL.
9
+ require_paths:
10
+ - lib
11
+ email: sven@c3d2.de
12
+ homepage: http://pentabarf.org/Momomoto
13
+ rubyforge_project:
14
+ description: Momomoto is an object relational mapper for PostgreSQL.
15
+ autorequire: momomoto
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.8.2
24
+ version:
5
25
  platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
6
29
  authors:
7
30
  - Sven Klemm
8
- autorequire: momomoto
9
- bindir: bin
10
- cert_chain: []
11
-
12
- date: 2009-02-19 00:00:00 +01:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: postgres
17
- version_requirement:
18
- version_requirements: !ruby/object:Gem::Requirement
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 0.7.9.2008.01.09
23
- version:
24
- description: Momomoto is an object relational mapper for PostgreSQL.
25
- email: sven@c3d2.de
26
- executables: []
27
-
28
- extensions: []
29
-
30
- extra_rdoc_files: []
31
-
32
31
  files:
32
+ - lib/timeinterval.rb
33
33
  - lib/momomoto.rb
34
+ - lib/momomoto/database.rb
34
35
  - lib/momomoto/momomoto.rb
35
- - lib/momomoto/datatype/character.rb
36
- - lib/momomoto/datatype/bytea.rb
37
- - lib/momomoto/datatype/array/text.rb
38
- - lib/momomoto/datatype/array/base.rb
39
- - lib/momomoto/datatype/array/integer.rb
40
- - lib/momomoto/datatype/interval.rb
36
+ - lib/momomoto/row.rb
37
+ - lib/momomoto/table.rb
38
+ - lib/momomoto/procedure.rb
39
+ - lib/momomoto/datatype.rb
40
+ - lib/momomoto/base.rb
41
+ - lib/momomoto/order.rb
42
+ - lib/momomoto/information_schema/table_constraints.rb
43
+ - lib/momomoto/information_schema/columns.rb
44
+ - lib/momomoto/information_schema/fetch_procedure_parameters.rb
45
+ - lib/momomoto/information_schema/fetch_procedure_columns.rb
46
+ - lib/momomoto/information_schema/routines.rb
47
+ - lib/momomoto/information_schema/key_column_usage.rb
48
+ - lib/momomoto/datatype/boolean.rb
49
+ - lib/momomoto/datatype/date.rb
41
50
  - lib/momomoto/datatype/array.rb
51
+ - lib/momomoto/datatype/smallint.rb
42
52
  - lib/momomoto/datatype/real.rb
43
53
  - lib/momomoto/datatype/text.rb
44
- - lib/momomoto/datatype/time_with_time_zone.rb
45
- - lib/momomoto/datatype/inet.rb
46
- - lib/momomoto/datatype/character_varying.rb
54
+ - lib/momomoto/datatype/interval.rb
55
+ - lib/momomoto/datatype/character.rb
56
+ - lib/momomoto/datatype/integer.rb
47
57
  - lib/momomoto/datatype/time_without_time_zone.rb
58
+ - lib/momomoto/datatype/character_varying.rb
59
+ - lib/momomoto/datatype/inet.rb
48
60
  - lib/momomoto/datatype/numeric.rb
49
- - lib/momomoto/datatype/smallint.rb
61
+ - lib/momomoto/datatype/bytea.rb
50
62
  - lib/momomoto/datatype/timestamp_without_time_zone.rb
51
- - lib/momomoto/datatype/base.rb
52
63
  - lib/momomoto/datatype/timestamp_with_time_zone.rb
53
- - lib/momomoto/datatype/date.rb
54
- - lib/momomoto/datatype/integer.rb
55
- - lib/momomoto/datatype/boolean.rb
64
+ - lib/momomoto/datatype/time_with_time_zone.rb
65
+ - lib/momomoto/datatype/base.rb
56
66
  - lib/momomoto/datatype/bigint.rb
57
- - lib/momomoto/information_schema/routines.rb
58
- - lib/momomoto/information_schema/key_column_usage.rb
59
- - lib/momomoto/information_schema/table_constraints.rb
60
- - lib/momomoto/information_schema/fetch_procedure_columns.rb
61
- - lib/momomoto/information_schema/fetch_procedure_parameters.rb
62
- - lib/momomoto/information_schema/columns.rb
63
- - lib/momomoto/database.rb
64
- - lib/momomoto/datatype.rb
65
- - lib/momomoto/row.rb
66
- - lib/momomoto/table.rb
67
- - lib/momomoto/base.rb
68
- - lib/momomoto/order.rb
69
- - lib/momomoto/procedure.rb
70
- - lib/timeinterval.rb
67
+ - lib/momomoto/datatype/array/integer.rb
68
+ - lib/momomoto/datatype/array/text.rb
69
+ - lib/momomoto/datatype/array/base.rb
71
70
  - sql/procedures.sql
72
- - sql/install.sql
73
71
  - sql/types.sql
72
+ - sql/install.sql
73
+ - test/test_procedure.rb
74
+ - test/test_array.rb
75
+ - test/test_boolean.rb
74
76
  - test/test_real.rb
75
- - test/test_time_with_time_zone.rb
76
- - test/test_inet.rb
77
+ - test/test_smallint.rb
78
+ - test/test_interval.rb
79
+ - test/test_text.rb
77
80
  - test/test_table.rb
81
+ - test/test_numeric.rb
82
+ - test/test_inet.rb
83
+ - test/test_time_without_time_zone.rb
84
+ - test/test_character_varying.rb
85
+ - test/test_character.rb
78
86
  - test/test_integer.rb
79
- - test/test_information_schema.rb
80
- - test/test_timeinterval.rb
81
- - test/test_text.rb
82
87
  - test/test_datatype.rb
83
- - test/test_character.rb
84
- - test/test_boolean.rb
85
88
  - test/test_row.rb
86
- - test/test_date.rb
87
- - test/test_array.rb
88
- - test/test_bigint.rb
89
- - test/test_base.rb
90
89
  - test/test_timestamp_without_time_zone.rb
91
- - test/test_interval.rb
90
+ - test/test_time_with_time_zone.rb
91
+ - test/test_timeinterval.rb
92
92
  - test/test_database.rb
93
- - test/test_smallint.rb
94
- - test/test_procedure.rb
95
93
  - test/test_bytea.rb
96
- - test/test_character_varying.rb
94
+ - test/test_information_schema.rb
95
+ - test/test_base.rb
96
+ - test/test_bigint.rb
97
97
  - test/test_timestamp_with_time_zone.rb
98
- - test/test_time_without_time_zone.rb
99
- - test/test_numeric.rb
98
+ - test/test_date.rb
100
99
  - test/test_functions.sql
101
100
  - test/test.sql
102
- - Rakefile
103
101
  - LICENSE
104
- has_rdoc: true
105
- homepage: http://pentabarf.org/Momomoto
106
- post_install_message:
102
+ - Rakefile
103
+ test_files: []
104
+
107
105
  rdoc_options: []
108
106
 
109
- require_paths:
110
- - lib
111
- required_ruby_version: !ruby/object:Gem::Requirement
112
- requirements:
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- version: 1.8.2
116
- version:
117
- required_rubygems_version: !ruby/object:Gem::Requirement
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- version: "0"
122
- version:
107
+ extra_rdoc_files: []
108
+
109
+ executables: []
110
+
111
+ extensions: []
112
+
123
113
  requirements:
124
114
  - PostgreSQL 8.1.x or greater
125
- rubyforge_project:
126
- rubygems_version: 1.1.1
127
- signing_key:
128
- specification_version: 2
129
- summary: Momomoto is an object relational mapper for PostgreSQL.
130
- test_files: []
131
-
115
+ dependencies:
116
+ - !ruby/object:Gem::Dependency
117
+ name: postgres
118
+ version_requirement:
119
+ version_requirements: !ruby/object:Gem::Version::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: 0.7.9.2008.01.09
124
+ version: