lore 0.4.7 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +6 -0
- data/custom_models.rb +0 -153
- data/lib/lore/behaviours/lockable.rb +27 -13
- data/lib/lore/behaviours/movable.rb +31 -13
- data/lib/lore/behaviours/paginated.rb +31 -0
- data/lib/lore/behaviours/versioned.rb +15 -3
- data/lib/lore/gui/form_generator.rb +72 -104
- data/lib/lore/gui/lore_model_select_field.rb +59 -0
- data/lore.gemspec +4 -3
- metadata +13 -27
- data/lib/lore/gui/erb_template.rb +0 -79
- data/lib/lore/gui/erb_template_helpers.rhtml +0 -19
- data/lib/lore/gui/form.rb +0 -314
- data/lib/lore/gui/form_element.rb +0 -676
- data/lib/lore/gui/templates/button.rhtml +0 -2
- data/lib/lore/gui/templates/checkbox.rhtml +0 -3
- data/lib/lore/gui/templates/checkbox_row.rhtml +0 -1
- data/lib/lore/gui/templates/file.rhtml +0 -2
- data/lib/lore/gui/templates/file_readonly.rhtml +0 -3
- data/lib/lore/gui/templates/form_element.rhtml +0 -5
- data/lib/lore/gui/templates/form_element_horizontal.rhtml +0 -3
- data/lib/lore/gui/templates/form_element_listed.rhtml +0 -8
- data/lib/lore/gui/templates/form_table.rhtml +0 -3
- data/lib/lore/gui/templates/form_table_blank.rhtml +0 -3
- data/lib/lore/gui/templates/form_table_horizontal.rhtml +0 -8
- data/lib/lore/gui/templates/password.rhtml +0 -2
- data/lib/lore/gui/templates/password_readonly.rhtml +0 -3
- data/lib/lore/gui/templates/radio.rhtml +0 -1
- data/lib/lore/gui/templates/radio_row.rhtml +0 -1
- data/lib/lore/gui/templates/select.rhtml +0 -23
- data/lib/lore/gui/templates/text.rhtml +0 -2
- data/lib/lore/gui/templates/text_readonly.rhtml +0 -3
- data/lib/lore/gui/templates/textarea.rhtml +0 -3
- data/lib/lore/gui/templates/textarea_readonly.rhtml +0 -4
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Fuchs
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-01-08 00:00:00 +01: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.1"
|
23
23
|
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: aurita-gui
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: "0.1"
|
32
|
+
version:
|
24
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). It aims at performance, usability and - unlike most ORMs - high coverage of native SQL functions and features. Lore is currently using PostgreSQL as database backend.
|
25
34
|
email: fuchs@atomnode.net
|
26
35
|
executables: []
|
@@ -67,6 +76,7 @@ files:
|
|
67
76
|
- lib/lore/bits.rb
|
68
77
|
- lib/lore/query_shortcuts.rb
|
69
78
|
- lib/lore/gui
|
79
|
+
- lib/lore/behaviours/paginated.rb
|
70
80
|
- lib/lore/behaviours/movable.rb
|
71
81
|
- lib/lore/behaviours/versioned.rb
|
72
82
|
- lib/lore/behaviours/lockable.rb
|
@@ -80,32 +90,8 @@ files:
|
|
80
90
|
- lib/lore/validation/parameter_validator.rb
|
81
91
|
- lib/lore/validation/reason.rb
|
82
92
|
- lib/lore/validation/type_validator.rb
|
83
|
-
- lib/lore/gui/
|
84
|
-
- lib/lore/gui/erb_template.rb
|
93
|
+
- lib/lore/gui/lore_model_select_field.rb
|
85
94
|
- lib/lore/gui/form_generator.rb
|
86
|
-
- lib/lore/gui/templates
|
87
|
-
- lib/lore/gui/erb_template_helpers.rhtml
|
88
|
-
- lib/lore/gui/form_element.rb
|
89
|
-
- lib/lore/gui/templates/button.rhtml
|
90
|
-
- lib/lore/gui/templates/form_element.rhtml
|
91
|
-
- lib/lore/gui/templates/file_readonly.rhtml
|
92
|
-
- lib/lore/gui/templates/text_readonly.rhtml
|
93
|
-
- lib/lore/gui/templates/form_table_blank.rhtml
|
94
|
-
- lib/lore/gui/templates/checkbox_row.rhtml
|
95
|
-
- lib/lore/gui/templates/password_readonly.rhtml
|
96
|
-
- lib/lore/gui/templates/password.rhtml
|
97
|
-
- lib/lore/gui/templates/checkbox.rhtml
|
98
|
-
- lib/lore/gui/templates/form_table.rhtml
|
99
|
-
- lib/lore/gui/templates/form_table_horizontal.rhtml
|
100
|
-
- lib/lore/gui/templates/form_element_horizontal.rhtml
|
101
|
-
- lib/lore/gui/templates/file.rhtml
|
102
|
-
- lib/lore/gui/templates/textarea.rhtml
|
103
|
-
- lib/lore/gui/templates/text.rhtml
|
104
|
-
- lib/lore/gui/templates/form_element_listed.rhtml
|
105
|
-
- lib/lore/gui/templates/textarea_readonly.rhtml
|
106
|
-
- lib/lore/gui/templates/radio_row.rhtml
|
107
|
-
- lib/lore/gui/templates/radio.rhtml
|
108
|
-
- lib/lore/gui/templates/select.rhtml
|
109
95
|
- lib/lore/exception/invalid_klass_parameters.rb
|
110
96
|
- lib/lore/exception/invalid_parameter.rb
|
111
97
|
- lib/lore/exception/ambiguous_attribute.rb
|
@@ -1,79 +0,0 @@
|
|
1
|
-
|
2
|
-
require('lore')
|
3
|
-
require('logger')
|
4
|
-
require('erb')
|
5
|
-
|
6
|
-
module Lore
|
7
|
-
module GUI
|
8
|
-
|
9
|
-
class ERB_Binding_Params
|
10
|
-
|
11
|
-
def initialize(param_hash)
|
12
|
-
@params = Hash.new
|
13
|
-
param_hash.each_pair { |key,value|
|
14
|
-
@params[key.to_s.intern] = value
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
def get(param)
|
19
|
-
@params[param]
|
20
|
-
end
|
21
|
-
|
22
|
-
def param(param)
|
23
|
-
@params[param]
|
24
|
-
end
|
25
|
-
|
26
|
-
def method_missing(method)
|
27
|
-
@params[method]
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
class ERB_Template
|
33
|
-
|
34
|
-
public
|
35
|
-
|
36
|
-
def initialize(template_path, param_hash={}, from=:backend)
|
37
|
-
|
38
|
-
@logger = Lore.logger
|
39
|
-
|
40
|
-
@template = ''
|
41
|
-
IO.foreach(Lore.path + 'lore/gui/erb_template_helpers.rhtml') { |line|
|
42
|
-
@template << line
|
43
|
-
}
|
44
|
-
template_path = template_path.to_s << '.rhtml' if template_path.instance_of? Symbol
|
45
|
-
IO.foreach(Lore.path + 'lore/gui/templates/' << template_path) { |line|
|
46
|
-
@template << line
|
47
|
-
}
|
48
|
-
|
49
|
-
@logger.debug('Template: ' << template_path)
|
50
|
-
|
51
|
-
@erb = ERB.new(@template)
|
52
|
-
|
53
|
-
@binding = binding_for(ERB_Binding_Params.new(param_hash))
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
def set_data(param_hash)
|
58
|
-
@binding = binding_for(ERB_Binding_Params.new(param_hash))
|
59
|
-
end
|
60
|
-
|
61
|
-
def string
|
62
|
-
@erb.result(@binding)
|
63
|
-
end
|
64
|
-
|
65
|
-
def print
|
66
|
-
puts @erb.result(@binding)
|
67
|
-
end
|
68
|
-
|
69
|
-
protected
|
70
|
-
|
71
|
-
def binding_for(params)
|
72
|
-
binding
|
73
|
-
end
|
74
|
-
|
75
|
-
|
76
|
-
end # class
|
77
|
-
|
78
|
-
end # module
|
79
|
-
end # module
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<%
|
2
|
-
|
3
|
-
def tag_attributes(attrib_hash)
|
4
|
-
return '' if attrib_hash.nil?
|
5
|
-
string = ''
|
6
|
-
attrib_hash.each_pair { |name, value|
|
7
|
-
string << name.to_s
|
8
|
-
string << '="' << value.to_s
|
9
|
-
string << '" '
|
10
|
-
}
|
11
|
-
string
|
12
|
-
end
|
13
|
-
|
14
|
-
@params = params
|
15
|
-
def method_missing(method)
|
16
|
-
@params.get(method)
|
17
|
-
end
|
18
|
-
|
19
|
-
%>
|
data/lib/lore/gui/form.rb
DELETED
@@ -1,314 +0,0 @@
|
|
1
|
-
|
2
|
-
require('lore/clause')
|
3
|
-
require 'lore/gui/form_element'
|
4
|
-
|
5
|
-
module Lore
|
6
|
-
module GUI
|
7
|
-
|
8
|
-
# Form class returned by Cuba::GUI::Form_Generator.
|
9
|
-
# Usage:
|
10
|
-
#
|
11
|
-
# generator = Form_Generator.new(Table_Accessor, Lang, :readonly | :mutable)
|
12
|
-
# form = generator.generate
|
13
|
-
#
|
14
|
-
# Setting templates is optional (uses System_Templates 'form/element.amr.html'
|
15
|
-
# and 'form/table.arm.html' by default):
|
16
|
-
#
|
17
|
-
# form.element_template Some_Template.new('template/element.amr.html')
|
18
|
-
# form.form_template Some_Template.new('template/table.amr.html')
|
19
|
-
#
|
20
|
-
# Set a form title (optional):
|
21
|
-
#
|
22
|
-
# form.set_title('An example form')
|
23
|
-
#
|
24
|
-
# Fill form values if present:
|
25
|
-
#
|
26
|
-
# values = [Some Cuba::Attributes hash like $cb__libparams]
|
27
|
-
# form.set_values(values)
|
28
|
-
#
|
29
|
-
# Add additional hidden fields Form_Generator can't resolve itself:
|
30
|
-
#
|
31
|
-
# form.add_hidden(Table_Accessor.table_name, :attribute_name, value)
|
32
|
-
#
|
33
|
-
# Add buttons:
|
34
|
-
#
|
35
|
-
# form.add_button(:submit, 'click here to submit data')
|
36
|
-
# form.add_button(:clear, 'click here to clear form')
|
37
|
-
#
|
38
|
-
# Configure attribute order and grouping (optional). See method
|
39
|
-
# documentation for #set_groups for details:
|
40
|
-
#
|
41
|
-
# form.set_groups(attribute_array)
|
42
|
-
#
|
43
|
-
# form.print # alias for puts form.string
|
44
|
-
#
|
45
|
-
class Form
|
46
|
-
|
47
|
-
attr_accessor :element_template, :form_template, :form_values
|
48
|
-
|
49
|
-
@@logger = Lore.logger
|
50
|
-
|
51
|
-
def initialize # {{{
|
52
|
-
|
53
|
-
@elements = Array.new
|
54
|
-
@buttons = Array.new
|
55
|
-
@indexed_elements = Hash.new
|
56
|
-
@element_template = ERB_Template.new('form_element.rhtml')
|
57
|
-
@form_template = ERB_Template.new('form_table.rhtml')
|
58
|
-
@form_values = Hash.new
|
59
|
-
@element_groups = nil
|
60
|
-
@hidden_fields = Array.new
|
61
|
-
@title = nil
|
62
|
-
|
63
|
-
end # }}}
|
64
|
-
|
65
|
-
# adders and setters # {{{
|
66
|
-
def add(form_element)
|
67
|
-
if form_element.instance_of? Hidden then
|
68
|
-
@hidden_fields.push(form_element)
|
69
|
-
else
|
70
|
-
if form_element.attribute_table then
|
71
|
-
index = form_element.attribute_table+'.'+form_element.attribute_name
|
72
|
-
else
|
73
|
-
index = form_element.attribute_name
|
74
|
-
end
|
75
|
-
# If there is an element for this attribute present already, delete
|
76
|
-
# it and use the new one only:
|
77
|
-
if !@indexed_elements[index].nil? then
|
78
|
-
@elements.delete_if { |e| e.attribute_table == form_element.attribute_table &&
|
79
|
-
e.attribute_name == form_element.attribute_name }
|
80
|
-
end
|
81
|
-
@indexed_elements[index] = form_element
|
82
|
-
@elements.push(form_element)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def add_duplicate(form_element)
|
87
|
-
if form_element.instance_of? Hidden then
|
88
|
-
@hidden_fields.push(form_element)
|
89
|
-
else
|
90
|
-
index = form_element.attribute_table+'.'+form_element.attribute_name
|
91
|
-
# If there is an element for this attribute present already, delete
|
92
|
-
# it and use the new one only:
|
93
|
-
@indexed_elements[index] = form_element
|
94
|
-
@elements.push(form_element)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def set_readonly(*attributes)
|
99
|
-
attributes.each { |a|
|
100
|
-
@indexed_elements[a.to_s].set_mode(:readonly)
|
101
|
-
}
|
102
|
-
end
|
103
|
-
|
104
|
-
# Add additional hidden fields Form_Generator can't resolve itself:
|
105
|
-
#
|
106
|
-
# form.add_hidden(Table_Accessor.table_name, :attribute_name, value)
|
107
|
-
#
|
108
|
-
def add_hidden(name, value=nil)
|
109
|
-
if name.instance_of? Lore::Clause then
|
110
|
-
value = value.to_s
|
111
|
-
name_parts = name.to_s.split('.')
|
112
|
-
table = name_parts[0..1].join('.')
|
113
|
-
name = name_parts[2]
|
114
|
-
else
|
115
|
-
table = nil
|
116
|
-
name = name.to_s
|
117
|
-
end
|
118
|
-
hidden = Hidden.new(table, name.to_s)
|
119
|
-
if !value.nil? then
|
120
|
-
hidden.set_attribute_value(value.to_s)
|
121
|
-
end
|
122
|
-
@hidden_fields.push(hidden)
|
123
|
-
end
|
124
|
-
|
125
|
-
def add_hidden_fields(params={})
|
126
|
-
params.each_pair { |k,v|
|
127
|
-
add_hidden(k, v)
|
128
|
-
}
|
129
|
-
end
|
130
|
-
|
131
|
-
def drop_hidden_fields
|
132
|
-
@hidden_fields = []
|
133
|
-
end
|
134
|
-
|
135
|
-
# Add buttons:
|
136
|
-
#
|
137
|
-
# form.add_button(:submit, 'click here to submit data')
|
138
|
-
# form.add_button(:clear, 'click here to clear form')
|
139
|
-
#
|
140
|
-
def add_button(type, label)
|
141
|
-
button = Button.new(type, label)
|
142
|
-
@buttons.push(button)
|
143
|
-
end
|
144
|
-
|
145
|
-
# Fill form values if present:
|
146
|
-
#
|
147
|
-
# values = [Some Cuba::Attributes hash like $cb__libparams]
|
148
|
-
# form.set_values(values)
|
149
|
-
#
|
150
|
-
def set_values(values)
|
151
|
-
@form_values = values
|
152
|
-
end
|
153
|
-
|
154
|
-
def [](key)
|
155
|
-
@form_values[key.to_s]
|
156
|
-
end
|
157
|
-
|
158
|
-
def []=(key, value)
|
159
|
-
@form_values[key.to_s] = value
|
160
|
-
end
|
161
|
-
|
162
|
-
def values
|
163
|
-
@form_values
|
164
|
-
end
|
165
|
-
|
166
|
-
def keys
|
167
|
-
@form_values.keys
|
168
|
-
end
|
169
|
-
|
170
|
-
# Configure attribute order and grouping (optional).
|
171
|
-
# Array argument is a one- or two-dimensional array of
|
172
|
-
# full attribute names this form should print. This way,
|
173
|
-
# order of input fields can be specified, and attributes
|
174
|
-
# can be filtered. Two-dimensional arrays provide grouping
|
175
|
-
# of form elements. Example:
|
176
|
-
#
|
177
|
-
# qttribute_array =
|
178
|
-
# [
|
179
|
-
# [ Klass_A.foo, Klass_A.bar ],
|
180
|
-
# [ Klass_B.wombat, Klass_C.bla ]
|
181
|
-
# ]
|
182
|
-
#
|
183
|
-
# form.set_groups(attribute_array)
|
184
|
-
#
|
185
|
-
# Add filtered attribute as hidden field:
|
186
|
-
#
|
187
|
-
# form.add_hidden(Klass_A.table_name, :wombat)
|
188
|
-
#
|
189
|
-
def set_groups(groups)
|
190
|
-
if(groups.nil? || groups.at(0).nil?) then
|
191
|
-
@@logger.warn('Form groups are nil or empty')
|
192
|
-
return
|
193
|
-
end
|
194
|
-
groups.map! { |entry|
|
195
|
-
if entry.instance_of? Array then
|
196
|
-
entry.map! { |field| field.to_s }
|
197
|
-
else
|
198
|
-
entry.to_s
|
199
|
-
end
|
200
|
-
}
|
201
|
-
@@logger.debug('Form groups set: '+groups.inspect)
|
202
|
-
@element_groups = groups
|
203
|
-
end
|
204
|
-
|
205
|
-
# Set a form title (optional):
|
206
|
-
#
|
207
|
-
# form.set_title('An example form')
|
208
|
-
#
|
209
|
-
def set_title(title)
|
210
|
-
@title = title
|
211
|
-
end
|
212
|
-
|
213
|
-
# end adders / setters }}}
|
214
|
-
|
215
|
-
# Return form as XHTML string based on current configuration
|
216
|
-
#
|
217
|
-
def string # {{{
|
218
|
-
|
219
|
-
elements = ''
|
220
|
-
|
221
|
-
if !@title.nil? then
|
222
|
-
title_string = '<div class="form_header">'+@title.to_s+'</div>'
|
223
|
-
else
|
224
|
-
title_string = ''
|
225
|
-
end
|
226
|
-
|
227
|
-
if @element_groups.nil? then
|
228
|
-
@elements.each { |element|
|
229
|
-
elements += process_element(element)
|
230
|
-
}
|
231
|
-
else
|
232
|
-
@element_groups.each { |attribs|
|
233
|
-
group = ''
|
234
|
-
attribs.each { |attrib|
|
235
|
-
attrib = attrib.to_s
|
236
|
-
if !@indexed_elements[attrib].nil? then
|
237
|
-
element = @indexed_elements[attrib]
|
238
|
-
group += process_element(element)
|
239
|
-
end
|
240
|
-
}
|
241
|
-
if attribs.instance_of? Array then
|
242
|
-
elements += '<div class="form_delimiter"></div>'+group
|
243
|
-
else
|
244
|
-
elements += group
|
245
|
-
end
|
246
|
-
}
|
247
|
-
# Check for explicit (expected/required) attributes
|
248
|
-
# group configuration doesn't contain. Add those as
|
249
|
-
# hidden field:
|
250
|
-
# TODO: Cannot be realized in current solution!
|
251
|
-
|
252
|
-
end
|
253
|
-
@form_template.set_data({
|
254
|
-
:form => elements
|
255
|
-
})
|
256
|
-
|
257
|
-
buttons = ''
|
258
|
-
@buttons.each { |button|
|
259
|
-
data = {
|
260
|
-
:label => '',
|
261
|
-
:element => button.string
|
262
|
-
}
|
263
|
-
@element_template.set_data(data)
|
264
|
-
buttons += @element_template.string
|
265
|
-
}
|
266
|
-
|
267
|
-
hidden_fields_string = ''
|
268
|
-
@hidden_fields.each { |element|
|
269
|
-
set_element_value(element)
|
270
|
-
hidden_fields_string += element.string
|
271
|
-
}
|
272
|
-
|
273
|
-
result = title_string + hidden_fields_string + @form_template.string + buttons
|
274
|
-
|
275
|
-
return result
|
276
|
-
|
277
|
-
end # }}}
|
278
|
-
|
279
|
-
# Alias for puts form.string
|
280
|
-
def print
|
281
|
-
puts string()
|
282
|
-
end
|
283
|
-
|
284
|
-
private
|
285
|
-
|
286
|
-
def set_element_value(element) # {{{
|
287
|
-
if !@form_values[element.attribute_name].nil? then
|
288
|
-
value = @form_values[element.attribute_name]
|
289
|
-
element.set_attribute_value(value)
|
290
|
-
elsif !@form_values[element.attribute_table.to_s+'.'+element.attribute_name].nil? then
|
291
|
-
value = @form_values[element.attribute_table+'.'+element.attribute_name]
|
292
|
-
element.set_attribute_value(value)
|
293
|
-
end
|
294
|
-
end # }}}
|
295
|
-
|
296
|
-
def process_element(element) # {{{
|
297
|
-
|
298
|
-
set_element_value(element)
|
299
|
-
|
300
|
-
data = {
|
301
|
-
:label => "<label id=\"#{element.attribute_id}_label\" for=\"#{element.attribute_id}\">#{element.label}</label>",
|
302
|
-
:element => element.string,
|
303
|
-
:element_obj => element
|
304
|
-
}
|
305
|
-
@element_template.set_data(data)
|
306
|
-
|
307
|
-
return @element_template.string
|
308
|
-
|
309
|
-
end # }}}
|
310
|
-
|
311
|
-
end # class
|
312
|
-
|
313
|
-
end # module
|
314
|
-
end # module
|