lore 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/LICENSE +19 -0
  2. data/README +74 -0
  3. data/aspect.rb +80 -0
  4. data/behaviours/lockable.rb +41 -0
  5. data/behaviours/movable.rb +54 -0
  6. data/behaviours/versioned.rb +24 -0
  7. data/benchmark.rb +193 -0
  8. data/bits.rb +52 -0
  9. data/cache/abstract_entity_cache.rb +82 -0
  10. data/cache/bits.rb +22 -0
  11. data/cache/cacheable.rb +202 -0
  12. data/cache/cached_entities.rb +116 -0
  13. data/cache/file_index.rb +35 -0
  14. data/cache/mmap_entity_cache.rb +67 -0
  15. data/clause.rb +528 -0
  16. data/connection.rb +155 -0
  17. data/custom_functions.sql +14 -0
  18. data/exception/ambiguous_attribute.rb +14 -0
  19. data/exception/cache_exception.rb +30 -0
  20. data/exception/invalid_klass_parameters.rb +63 -0
  21. data/exception/invalid_parameter.rb +42 -0
  22. data/exception/unknown_typecode.rb +19 -0
  23. data/file_index.sql +56 -0
  24. data/gui/erb_template.rb +79 -0
  25. data/gui/erb_template_helpers.rhtml +19 -0
  26. data/gui/form.rb +314 -0
  27. data/gui/form_element.rb +676 -0
  28. data/gui/form_generator.rb +151 -0
  29. data/gui/templates/button.rhtml +2 -0
  30. data/gui/templates/checkbox.rhtml +3 -0
  31. data/gui/templates/checkbox_row.rhtml +1 -0
  32. data/gui/templates/file.rhtml +2 -0
  33. data/gui/templates/file_readonly.rhtml +3 -0
  34. data/gui/templates/form_element.rhtml +5 -0
  35. data/gui/templates/form_element_horizontal.rhtml +3 -0
  36. data/gui/templates/form_element_listed.rhtml +8 -0
  37. data/gui/templates/form_table.rhtml +3 -0
  38. data/gui/templates/form_table_blank.rhtml +3 -0
  39. data/gui/templates/form_table_horizontal.rhtml +8 -0
  40. data/gui/templates/password.rhtml +2 -0
  41. data/gui/templates/password_readonly.rhtml +3 -0
  42. data/gui/templates/radio.rhtml +1 -0
  43. data/gui/templates/radio_row.rhtml +1 -0
  44. data/gui/templates/select.rhtml +23 -0
  45. data/gui/templates/text.rhtml +2 -0
  46. data/gui/templates/text_readonly.rhtml +3 -0
  47. data/gui/templates/textarea.rhtml +3 -0
  48. data/gui/templates/textarea_readonly.rhtml +4 -0
  49. data/lore.gemspec +40 -0
  50. data/lore.rb +94 -0
  51. data/migration.rb +48 -0
  52. data/model.rb +139 -0
  53. data/model_factory.rb +202 -0
  54. data/model_shortcuts.rb +16 -0
  55. data/query_shortcuts.rb +367 -0
  56. data/reserved_methods.txt +3 -0
  57. data/result.rb +100 -0
  58. data/symbol.rb +58 -0
  59. data/table_accessor.rb +1926 -0
  60. data/table_deleter.rb +115 -0
  61. data/table_inserter.rb +168 -0
  62. data/table_instance.rb +384 -0
  63. data/table_selector.rb +314 -0
  64. data/table_updater.rb +155 -0
  65. data/test/README +31 -0
  66. data/test/env.rb +5 -0
  67. data/test/lore_test.log +8218 -0
  68. data/test/model.rb +142 -0
  69. data/test/prepare.rb +37 -0
  70. data/test/tc_aspect.rb +58 -0
  71. data/test/tc_cache.rb +80 -0
  72. data/test/tc_clause.rb +104 -0
  73. data/test/tc_deep_inheritance.rb +49 -0
  74. data/test/tc_factory.rb +57 -0
  75. data/test/tc_filter.rb +37 -0
  76. data/test/tc_form.rb +32 -0
  77. data/test/tc_model.rb +86 -0
  78. data/test/tc_prepare.rb +45 -0
  79. data/test/tc_refined_query.rb +88 -0
  80. data/test/tc_table_accessor.rb +265 -0
  81. data/test/test.log +181 -0
  82. data/test/test_db.sql +400 -0
  83. data/test/ts_lore.rb +49 -0
  84. data/types.rb +55 -0
  85. data/validation/message.rb +60 -0
  86. data/validation/parameter_validator.rb +104 -0
  87. data/validation/reason.rb +54 -0
  88. data/validation/type_validator.rb +91 -0
  89. data/validation.rb +65 -0
  90. metadata +170 -0
@@ -0,0 +1,91 @@
1
+
2
+ require('lore/exception/invalid_parameter')
3
+ require('lore/exception/unknown_typecode')
4
+ require('lore/types')
5
+
6
+ module Lore
7
+ module Validation
8
+
9
+ class Type_Validator # :nodoc:
10
+
11
+ def typecheck(code, value, nil_allowed=true)
12
+
13
+ case code
14
+
15
+ # bool
16
+ when Lore::PG_BOOL
17
+ if value == 't' || value == 'f' ||
18
+ value == '' && nil_allowed || value.nil? && nil_allowed
19
+ then true else false end
20
+ # bytea
21
+ when Lore::PG_BYTEA
22
+ true
23
+ # int
24
+ when Lore::PG_INT
25
+ if value.kind_of?(Integer) or
26
+ value.to_i.to_s == value or
27
+ value.nil? && nil_allowed or
28
+ value == '' && nil_allowed
29
+ then true else false end
30
+ # smallint
31
+ when Lore::PG_SMALLINT
32
+ if ((value.kind_of?(Integer) or value.to_i.to_s == value or
33
+ value.nil? && nil_allowed || value == '' && nil_allowed)) and
34
+ value.to_i < 1024 and value.to_i > -1024
35
+ then true else false end
36
+ # decimal
37
+ when Lore::PG_DECIMAL
38
+ if ((value.kind_of?(Integer) or value.to_f.to_s == value or
39
+ value.nil? && nil_allowed || value == '' && nil_allowed))
40
+ then true else false end
41
+ # text
42
+ when Lore::PG_TEXT
43
+ if nil_allowed || !nil_allowed && !value.nil? && value != ''
44
+ then true else false end
45
+ # varchar
46
+ when Lore::PG_CHAR
47
+ if nil_allowed || !nil_allowed && !value.nil? && value != ''
48
+ then true else false end
49
+ # varchar
50
+ when Lore::PG_CHARACTER
51
+ if nil_allowed || !nil_allowed && !value.nil? && value != ''
52
+ then true else false end
53
+ # varchar
54
+ when Lore::PG_VARCHAR
55
+ if nil_allowed || !nil_allowed && !value.nil? && value != ''
56
+ then true else false end
57
+ # timestamp
58
+ when Lore::PG_TIME
59
+ # TODO
60
+ if nil_allowed || !nil_allowed && !value.nil? && value != ''
61
+ then true else false end
62
+ # timestamp with timezone
63
+ when Lore::PG_TIMESTAMP
64
+ # TODO
65
+ if nil_allowed || !nil_allowed && !value.nil? && value != ''
66
+ then true else false end
67
+ # timestamp with timezone
68
+ when Lore::PG_TIMESTAMP_TIMEZONE
69
+ # TODO
70
+ if nil_allowed || !nil_allowed && !value.nil? && value != ''
71
+ then true else false end
72
+ # date
73
+ when Lore::PG_DATE
74
+ # TODO
75
+ if nil_allowed || !nil_allowed && !value.nil? && value != ''
76
+ then true else false end
77
+
78
+ # character varying[]
79
+ when Lore::PG_VCHAR_LIST
80
+ true
81
+
82
+ else
83
+ raise ::Exception.new('Unknown type code (' << code.inspect + ') for value ' << value.inspect + '. See README on how to add new types. ')
84
+ end
85
+
86
+ end
87
+
88
+ end
89
+
90
+ end # module
91
+ end # module
data/validation.rb ADDED
@@ -0,0 +1,65 @@
1
+
2
+
3
+ module Lore
4
+ module Validation
5
+
6
+
7
+ def validates(attrib, constraints)
8
+ # {{{
9
+ if attrib.kind_of? Clause then
10
+ attrib_split = attrib.to_s.split('.')
11
+ table = attrib_split[0..-2]
12
+ attrib = attrib_split[-1]
13
+ else
14
+ table = get_table_name
15
+ end
16
+ attrib = attrib.intern unless attrib.instance_of? Symbol
17
+
18
+ @constraints = Hash.new if @constraints.nil?
19
+ @constraints[table] = Hash.new if @constraints[table].nil?
20
+ @constraints[table][attrib] = Hash.new
21
+
22
+ if constraints[:mandatory] then
23
+ add_explicit_attribute(table, attrib.to_s)
24
+ end
25
+ if constraints[:type] then
26
+ # @attribute_types[table][attrib] = constraints[:type]
27
+ @constraints[table][attrib][:type] = constraints[:type]
28
+ end
29
+ if constraints[:format] then
30
+ @constraints[table][attrib][:format] = constraints[:format]
31
+ end
32
+ if constraints[:length] then
33
+ if constraints[:length].kind_of? Range then
34
+ @constraints[table][attrib][:minlength] = constraints[:length].first
35
+ @constraints[table][attrib][:maxlength] = constraints[:length].last
36
+ else
37
+ @constraints[table][attrib][:minlength] = constraints[:length]
38
+ @constraints[table][attrib][:maxlength] = constraints[:length]
39
+ end
40
+ end
41
+ if constraints[:minlength] then
42
+ @constraints[table][attrib][:minlength] = constraints[:minlength]
43
+ end
44
+ if constraints[:maxlength] then
45
+ @constraints[table][attrib][:maxlength] = constraints[:maxlength]
46
+ end
47
+ end # }}}
48
+
49
+
50
+ def get_constraints
51
+ # {{{
52
+
53
+ @constraints = Hash.new if @constraints.nil?
54
+ if !@is_a_klasses.nil? then
55
+ @is_a_klasses.each_pair { |foreign_key, klass|
56
+ @constraints.update(klass.get_constraints)
57
+ }
58
+ end
59
+ @constraints
60
+
61
+ end # }}}
62
+
63
+
64
+ end
65
+ end
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lore
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.2
5
+ platform: ruby
6
+ authors:
7
+ - Tobias Fuchs
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-09 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mmap
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0.1"
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: postgres
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: "0.1"
32
+ version:
33
+ description: Lore is an object-relational mapping (ORM) implementation providing many features like prepared statements, (multiple) inheritance, a comfortable query syntax, highly customizable automated form generation, and result caching using memory mapping (MMap). Lore is currently using PostgreSQL as database backend.
34
+ email: fuchs@atomnode.net
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files: []
40
+
41
+ files:
42
+ - table_updater.rb
43
+ - exception
44
+ - table_deleter.rb
45
+ - model_factory.rb
46
+ - clause.rb
47
+ - connection.rb
48
+ - behaviours
49
+ - symbol.rb
50
+ - file_index.sql
51
+ - table_accessor.rb
52
+ - README
53
+ - table_inserter.rb
54
+ - custom_functions.sql
55
+ - model.rb
56
+ - lore.rb
57
+ - table_instance.rb
58
+ - types.rb
59
+ - benchmark.rb
60
+ - test
61
+ - result.rb
62
+ - validation.rb
63
+ - table_selector.rb
64
+ - reserved_methods.txt
65
+ - aspect.rb
66
+ - cache
67
+ - validation
68
+ - lore.gemspec
69
+ - migration.rb
70
+ - model_shortcuts.rb
71
+ - LICENSE
72
+ - bits.rb
73
+ - query_shortcuts.rb
74
+ - gui
75
+ - behaviours/movable.rb
76
+ - behaviours/versioned.rb
77
+ - behaviours/lockable.rb
78
+ - test/tc_cache.rb
79
+ - test/test_db.sql
80
+ - test/tc_refined_query.rb
81
+ - test/tc_deep_inheritance.rb
82
+ - test/prepare.rb
83
+ - test/tc_model.rb
84
+ - test/README
85
+ - test/test.log
86
+ - test/model.rb
87
+ - test/tc_clause.rb
88
+ - test/tc_table_accessor.rb
89
+ - test/tc_aspect.rb
90
+ - test/tc_filter.rb
91
+ - test/env.rb
92
+ - test/lore_test.log
93
+ - test/benchmark
94
+ - test/tc_factory.rb
95
+ - test/tc_prepare.rb
96
+ - test/ts_lore.rb
97
+ - test/tc_form.rb
98
+ - cache/file_index.rb
99
+ - cache/abstract_entity_cache.rb
100
+ - cache/mmap_entity_cache.rb
101
+ - cache/cacheable.rb
102
+ - cache/cached_entities.rb
103
+ - cache/bits.rb
104
+ - validation/message.rb
105
+ - validation/parameter_validator.rb
106
+ - validation/reason.rb
107
+ - validation/type_validator.rb
108
+ - gui/form.rb
109
+ - gui/erb_template.rb
110
+ - gui/form_generator.rb
111
+ - gui/templates
112
+ - gui/erb_template_helpers.rhtml
113
+ - gui/form_element.rb
114
+ - gui/templates/button.rhtml
115
+ - gui/templates/form_element.rhtml
116
+ - gui/templates/file_readonly.rhtml
117
+ - gui/templates/text_readonly.rhtml
118
+ - gui/templates/form_table_blank.rhtml
119
+ - gui/templates/checkbox_row.rhtml
120
+ - gui/templates/password_readonly.rhtml
121
+ - gui/templates/password.rhtml
122
+ - gui/templates/checkbox.rhtml
123
+ - gui/templates/form_table.rhtml
124
+ - gui/templates/form_table_horizontal.rhtml
125
+ - gui/templates/form_element_horizontal.rhtml
126
+ - gui/templates/file.rhtml
127
+ - gui/templates/textarea.rhtml
128
+ - gui/templates/text.rhtml
129
+ - gui/templates/form_element_listed.rhtml
130
+ - gui/templates/textarea_readonly.rhtml
131
+ - gui/templates/radio_row.rhtml
132
+ - gui/templates/radio.rhtml
133
+ - gui/templates/select.rhtml
134
+ - exception/invalid_klass_parameters.rb
135
+ - exception/invalid_parameter.rb
136
+ - exception/ambiguous_attribute.rb
137
+ - exception/cache_exception.rb
138
+ - exception/unknown_typecode.rb
139
+ has_rdoc: true
140
+ homepage: http://lore.rubyforge.org
141
+ post_install_message:
142
+ rdoc_options:
143
+ - --title
144
+ - Lore ORM
145
+ - --main
146
+ - README
147
+ - --line-numbers
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: "0"
155
+ version:
156
+ required_rubygems_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: "0"
161
+ version:
162
+ requirements: []
163
+
164
+ rubyforge_project: lore
165
+ rubygems_version: 1.1.1
166
+ signing_key:
167
+ specification_version: 2
168
+ summary: A flexible ORM based on PostgreSQL
169
+ test_files: []
170
+