glue 0.41.0 → 1.0.0
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/Manifest.txt +6 -0
- data/README.txt +130 -0
- data/Rakefile +16 -0
- data/lib/glue.rb +49 -72
- data/test/test_glue.rb +218 -0
- metadata +84 -100
- data/doc/AUTHORS +0 -13
- data/doc/CHANGELOG.1 +0 -354
- data/doc/LICENSE +0 -32
- data/doc/RELEASES +0 -207
- data/lib/glue/attribute.rb +0 -113
- data/lib/glue/attributeutils.rb +0 -117
- data/lib/glue/autoreload.rb +0 -60
- data/lib/glue/builder.rb +0 -57
- data/lib/glue/builder/xml.rb +0 -103
- data/lib/glue/cache.rb +0 -22
- data/lib/glue/cache/drb.rb +0 -51
- data/lib/glue/cache/file.rb +0 -78
- data/lib/glue/cache/memcached.rb +0 -68
- data/lib/glue/cache/memory.rb +0 -79
- data/lib/glue/cache/og.rb +0 -61
- data/lib/glue/configuration.rb +0 -305
- data/lib/glue/fixture.rb +0 -154
- data/lib/glue/html.rb +0 -12
- data/lib/glue/localization.rb +0 -129
- data/lib/glue/logger.rb +0 -208
- data/lib/glue/mail.rb +0 -160
- data/lib/glue/mailer.rb +0 -55
- data/lib/glue/mailer/incoming.rb +0 -41
- data/lib/glue/mailer/outgoing.rb +0 -119
- data/lib/glue/settings.rb +0 -3
- data/lib/glue/uri.rb +0 -190
- data/lib/glue/validation.rb +0 -447
- data/lib/html/document.rb +0 -63
- data/lib/html/node.rb +0 -480
- data/lib/html/tokenizer.rb +0 -103
- data/lib/html/version.rb +0 -11
- data/test/fixture/article.csv +0 -3
- data/test/fixture/article.yml +0 -13
- data/test/fixture/user.yml +0 -12
- data/test/glue/builder/tc_xml.rb +0 -57
- data/test/glue/tc_aspects.rb +0 -99
- data/test/glue/tc_attribute.rb +0 -112
- data/test/glue/tc_attribute_mixins.rb +0 -86
- data/test/glue/tc_builder.rb +0 -30
- data/test/glue/tc_configuration.rb +0 -135
- data/test/glue/tc_fixture.rb +0 -98
- data/test/glue/tc_localization.rb +0 -49
- data/test/glue/tc_logger.rb +0 -43
- data/test/glue/tc_mail.rb +0 -99
- data/test/glue/tc_stores.rb +0 -16
- data/test/glue/tc_uri.rb +0 -97
- data/test/glue/tc_validation.rb +0 -217
- data/test/public/dummy_mailer/registration.xhtml +0 -5
data/doc/LICENSE
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
The BSD License
|
2
|
-
|
3
|
-
Copyright (c) 2004-2006, George K. Moschovitis. (http://www.gmosx.com)
|
4
|
-
All rights reserved.
|
5
|
-
|
6
|
-
Redistribution and use in source and binary forms, with or without
|
7
|
-
modification, are permitted provided that the following conditions are
|
8
|
-
met:
|
9
|
-
|
10
|
-
* Redistributions of source code must retain the above copyright
|
11
|
-
notice, this list of conditions and the following disclaimer.
|
12
|
-
|
13
|
-
* Redistributions in binary form must reproduce the above copyright
|
14
|
-
notice, this list of conditions and the following disclaimer in the
|
15
|
-
documentation and/or other materials provided with the distribution.
|
16
|
-
|
17
|
-
* Neither the name of Glue nor the names of its contributors may be
|
18
|
-
used to endorse or promote products derived from this software
|
19
|
-
without specific prior written permission.
|
20
|
-
|
21
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
22
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
23
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
24
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
25
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
26
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
27
|
-
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
28
|
-
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
29
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
30
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
31
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
-
|
data/doc/RELEASES
DELETED
@@ -1,207 +0,0 @@
|
|
1
|
-
== Version 0.30.0
|
2
|
-
|
3
|
-
Cleaned up the codebase. Removed files duplicating functionality
|
4
|
-
already present in Facets. Moreover, we moved several generally
|
5
|
-
useful files into Facets. Expect the cleanup process to be
|
6
|
-
continued in next versions.
|
7
|
-
|
8
|
-
|
9
|
-
== Version 0.29.0
|
10
|
-
|
11
|
-
* MemCache store for the generalized caching system.
|
12
|
-
|
13
|
-
* Many, many bugfixes and small improvements.
|
14
|
-
|
15
|
-
* Updated for facets 1.0.3
|
16
|
-
|
17
|
-
== Version 0.28.0
|
18
|
-
|
19
|
-
* New generalized caching system. The caching code is refactored
|
20
|
-
in a new Glue system. At the moment, caches in memory, DRb,
|
21
|
-
filesystem and Og are provided. A memcache version will be available
|
22
|
-
in the near future. The new caching system is used to implement
|
23
|
-
Session stores, Og caching, Fragment caching, and Application scoped
|
24
|
-
parameters. A useful DRb cache management script is provided to
|
25
|
-
manage multiple DRb caches.
|
26
|
-
|
27
|
-
* Integration of Facets 1.0.1. The new library features a better
|
28
|
-
API and better implementation of various features.
|
29
|
-
|
30
|
-
|
31
|
-
== Version 0.27.0
|
32
|
-
|
33
|
-
Various fixes and smaller improvements.
|
34
|
-
|
35
|
-
|
36
|
-
== Version 0.26.0
|
37
|
-
|
38
|
-
This is the release with the most community contributions. Many
|
39
|
-
fixes and minor improvements. Download now!
|
40
|
-
|
41
|
-
|
42
|
-
== Version 0.25.0
|
43
|
-
|
44
|
-
This is the first in a series of releases focused on stability
|
45
|
-
and refinement. Many bugs where fixed, the high level api was
|
46
|
-
improved where needed, and we still got some small but incredibly
|
47
|
-
useful new features. Enjoy!
|
48
|
-
|
49
|
-
|
50
|
-
== Version 0.24.0
|
51
|
-
|
52
|
-
* Totaly recoded annotation / property system. The property
|
53
|
-
system is now based on Facet annotations and inheritors.
|
54
|
-
You can now annotate every object, attribute or method
|
55
|
-
in Nitro. For example you can annotate your actions with
|
56
|
-
routing rules or sitemap strings etc, etc. One unified
|
57
|
-
system for annotations and metadata is used throughout
|
58
|
-
the whole Framework.
|
59
|
-
|
60
|
-
* Fixed minor Ruby 1.8.3 compatibility issues.
|
61
|
-
|
62
|
-
* Even better integration with Ruby Facets.
|
63
|
-
|
64
|
-
* Tons of bug fixes and small but useful features.
|
65
|
-
|
66
|
-
|
67
|
-
== Version 0.23.0
|
68
|
-
|
69
|
-
Major cleanup, this release marks a bold step towards Nano/Nitro
|
70
|
-
integration.
|
71
|
-
|
72
|
-
* Moved some files to the Nano/Mega project.
|
73
|
-
|
74
|
-
* Dreprecated functionality already available in Nano/Mega.
|
75
|
-
|
76
|
-
|
77
|
-
== Version 0.22.0
|
78
|
-
|
79
|
-
* New mailer implementation.
|
80
|
-
|
81
|
-
* Moved template here.
|
82
|
-
|
83
|
-
* Generalized fixture support.
|
84
|
-
|
85
|
-
|
86
|
-
== Version 0.21.2
|
87
|
-
|
88
|
-
This is a bug fix release.
|
89
|
-
|
90
|
-
|
91
|
-
== Version 0.21.0 was released on 25-07-2005.
|
92
|
-
|
93
|
-
* New builder system.
|
94
|
-
|
95
|
-
* Added utility methods from Wee.
|
96
|
-
|
97
|
-
* Added utility methods from Nitro.
|
98
|
-
|
99
|
-
|
100
|
-
== Version 0.20.0 was released on 12-07-2005.
|
101
|
-
|
102
|
-
* Brand new, self-documenting configuration system. There is a new
|
103
|
-
keyword for defining configuration settings:
|
104
|
-
|
105
|
-
Here is an example:
|
106
|
-
|
107
|
-
class Render
|
108
|
-
setting :template_extension, :default => 'xhtml', :doc => 'The default template extension'
|
109
|
-
end
|
110
|
-
|
111
|
-
class Session
|
112
|
-
setting :store, :default => 'memory', :doc => 'The session store'
|
113
|
-
end
|
114
|
-
|
115
|
-
You can configure the Application using ruby code or yaml files:
|
116
|
-
|
117
|
-
Render.template_extension = 'xhtml'
|
118
|
-
Session.store = 'drb'
|
119
|
-
|
120
|
-
or
|
121
|
-
|
122
|
-
Render:
|
123
|
-
template_extension: xhtml
|
124
|
-
Session:
|
125
|
-
store: drb
|
126
|
-
|
127
|
-
You can access all defined settings:
|
128
|
-
|
129
|
-
Configuration.settings.each { |s| ... }
|
130
|
-
|
131
|
-
You can view the settings of the application along with documentation
|
132
|
-
on the following url:
|
133
|
-
|
134
|
-
www.myapp.com/settings
|
135
|
-
|
136
|
-
* Flexob, many improvements.
|
137
|
-
|
138
|
-
* Many bug fixes.
|
139
|
-
|
140
|
-
|
141
|
-
== Version 0.19.0 was released on 31/05/2005.
|
142
|
-
|
143
|
-
* Improved Logger.
|
144
|
-
|
145
|
-
* Improved mattr_accessor.
|
146
|
-
|
147
|
-
* Added autoreload support.
|
148
|
-
|
149
|
-
* Improved metadata.
|
150
|
-
|
151
|
-
|
152
|
-
== Version 0.18.0 was released on 01/06/2005.
|
153
|
-
|
154
|
-
Deprecated many methods. Facet methods are used instead.
|
155
|
-
|
156
|
-
|
157
|
-
== Version 0.17.0 was released on 16/05/2005.
|
158
|
-
|
159
|
-
A lot of fucntionality is deprecated. The great Facets library
|
160
|
-
will gradually replace the general utility methods found in
|
161
|
-
Glue.
|
162
|
-
|
163
|
-
|
164
|
-
== Version 0.16.0 was released on 16/04/2005.
|
165
|
-
|
166
|
-
A snapshot of the latest developments. Many, many subtle improvements,
|
167
|
-
new features and a major cleanup of the source code.
|
168
|
-
|
169
|
-
Most notable attitions:
|
170
|
-
|
171
|
-
* Aspect Oriented Programming support. This new system
|
172
|
-
is used to reimplement features such as Controller filters,
|
173
|
-
Og callbacks and Og observers. By using this unified
|
174
|
-
system you can now add Observers to controllers and use
|
175
|
-
a metalanguage for wraping Og object callbacks:
|
176
|
-
|
177
|
-
class Controller
|
178
|
-
pre :force_login, :where => :prepend
|
179
|
-
wrap Benchmark, :on => :index
|
180
|
-
post :taraa, :on => login
|
181
|
-
end
|
182
|
-
|
183
|
-
module Timestamped
|
184
|
-
pre :on => :og_insert { |this| this.create_time = Time.now }
|
185
|
-
pre :on => :og_update { |this| this.update_time = Time.now }
|
186
|
-
pre :on => [:og_insert, :og_update] { |this| this.create_time = Time.now }
|
187
|
-
end
|
188
|
-
|
189
|
-
This feature will be used extensivelly in future versions
|
190
|
-
to improve logging, the shaders and more.
|
191
|
-
|
192
|
-
|
193
|
-
== Version 0.15.0 was released on 04/04/2005.
|
194
|
-
|
195
|
-
* Dynamic include.
|
196
|
-
|
197
|
-
|
198
|
-
== Version 0.14.0 was released on 28/03/2005.
|
199
|
-
|
200
|
-
* Fixes nasty property inheritance bug.
|
201
|
-
|
202
|
-
|
203
|
-
== Version 0.13.0 was released on 17/03/2005.
|
204
|
-
|
205
|
-
The first release as a standalone gem.
|
206
|
-
|
207
|
-
* Additional validations.
|
data/lib/glue/attribute.rb
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
# This file extends the functionality in facets/more/annotation.
|
2
|
-
|
3
|
-
require 'facets/more/annotation'
|
4
|
-
require 'facets/more/annattr'
|
5
|
-
require 'facets/more/aspects'
|
6
|
-
|
7
|
-
require 'glue/validation'
|
8
|
-
require 'og/entity'
|
9
|
-
|
10
|
-
class Module
|
11
|
-
|
12
|
-
# If the class has serializable attributes, automatically
|
13
|
-
# add some useful mixins.
|
14
|
-
#
|
15
|
-
# Extends the default facets implementation.
|
16
|
-
|
17
|
-
[:attr_reader, :attr_writer, :attr_accessor].each do |m|
|
18
|
-
module_eval %{
|
19
|
-
alias_method :#{m}_previous, :#{m}
|
20
|
-
|
21
|
-
def #{m} *args
|
22
|
-
# gmosx: this is a hack, rethink!
|
23
|
-
# Jo: still hackish, alot faster
|
24
|
-
|
25
|
-
if args.last.is_a?(Hash)
|
26
|
-
klass = args.last[:class] ? args.last[:class] : args[-2]
|
27
|
-
klass = nil unless klass.is_a? Class
|
28
|
-
else
|
29
|
-
klass = args.last if args.last.is_a? Class
|
30
|
-
end
|
31
|
-
|
32
|
-
# If the class defines the included_as_property callback
|
33
|
-
# call to modify the base with custom code.
|
34
|
-
|
35
|
-
if klass.respond_to? :included_as_property
|
36
|
-
klass.included_as_property(self, args)
|
37
|
-
else
|
38
|
-
#{m}_previous *args
|
39
|
-
end
|
40
|
-
|
41
|
-
if klass && !serializable_attributes.empty?
|
42
|
-
include Og::EntityMixin unless ancestors.include?(Og::EntityMixin)
|
43
|
-
include Glue::Validation unless ancestors.include?(Glue::Validation)
|
44
|
-
include Aspects unless ancestors.include?(Aspects)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
}
|
48
|
-
end
|
49
|
-
|
50
|
-
alias_method :property, :attr_accessor
|
51
|
-
|
52
|
-
# Return the serializable attributes of this class.
|
53
|
-
# Serializable are attributes with the class annotation that
|
54
|
-
# are not marked as :serializable => false.
|
55
|
-
#
|
56
|
-
# === Examples
|
57
|
-
#
|
58
|
-
# class MyClass
|
59
|
-
# attr_accessor :test
|
60
|
-
# attr_accessor :name, String, :doc => 'Hello'
|
61
|
-
# attr_accessor :age, Fixnum
|
62
|
-
# attr_accessor :body, String, :serialize => false
|
63
|
-
# end
|
64
|
-
#
|
65
|
-
# MyClass.attributes # => [:test, :name, :age, :body]
|
66
|
-
# MyClass.serializable_attributes # => [:name, :age]
|
67
|
-
|
68
|
-
def serializable_attributes
|
69
|
-
attributes.find_all do |a|
|
70
|
-
anno = self.ann(a)
|
71
|
-
anno.class? and (anno.serialize != false)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
#--
|
76
|
-
# Define force methods for the given attribute.
|
77
|
-
#++
|
78
|
-
|
79
|
-
def define_force_method_for(sym)
|
80
|
-
if klass = self.ann(sym).class
|
81
|
-
code = %{
|
82
|
-
def __force_#{sym}(val)
|
83
|
-
if respond_to?(:force_#{sym})
|
84
|
-
self.#{sym} = force_#{sym}(val)
|
85
|
-
else
|
86
|
-
self.#{sym}=(} << case klass.name
|
87
|
-
when Fixnum.name: 'val.to_s.empty? ? nil : val.to_i'
|
88
|
-
when String.name: 'val.to_s'
|
89
|
-
when Float.name: 'val.to_f'
|
90
|
-
when Time.name: 'val.is_a?(Hash) ? Time.local(val["year"],val["month"],val["day"],val["hour"],val["min"]) : Time.parse(val.to_s)'
|
91
|
-
when Date.name: 'val.is_a?(Hash) ? Time.local(val["year"],val["month"],val["day"]).to_date : Time.parse(val.to_s).to_date'
|
92
|
-
when TrueClass.name, FalseClass.name: 'val == "on" or val == "true" ? true: val.to_i > 0'
|
93
|
-
else 'val'
|
94
|
-
end + %{)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
}
|
98
|
-
|
99
|
-
module_eval code
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
#--
|
104
|
-
# Define all force methods.
|
105
|
-
#++
|
106
|
-
|
107
|
-
def define_force_methods
|
108
|
-
for a in serializable_attributes
|
109
|
-
define_force_method_for(a)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
data/lib/glue/attributeutils.rb
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
require 'cgi'
|
2
|
-
require 'og/relation/all'
|
3
|
-
|
4
|
-
#--
|
5
|
-
# TODO: find a better name!
|
6
|
-
# TODO: this is nitro request specific, should probably get moved
|
7
|
-
# into the Nitro directory.
|
8
|
-
#++
|
9
|
-
|
10
|
-
class AttributeUtils
|
11
|
-
class << self
|
12
|
-
|
13
|
-
#--
|
14
|
-
# TODO: Add preprocessing.
|
15
|
-
#++
|
16
|
-
|
17
|
-
def set_attr(obj, name, value)
|
18
|
-
obj.send("__force_#{name}", value)
|
19
|
-
rescue Object => ex
|
20
|
-
obj.instance_variable_set("@#{name}", value)
|
21
|
-
end
|
22
|
-
|
23
|
-
# Populate an object from a hash of values.
|
24
|
-
# This is a truly dangerous method.
|
25
|
-
#
|
26
|
-
# === Options
|
27
|
-
#
|
28
|
-
# * name
|
29
|
-
# * force_boolean
|
30
|
-
|
31
|
-
def populate_object(obj, values, options = {})
|
32
|
-
# If a class is passed create an instance.
|
33
|
-
|
34
|
-
obj = obj.new if obj.is_a?(Class)
|
35
|
-
|
36
|
-
for sym in obj.class.serializable_attributes
|
37
|
-
anno = obj.class.ann(sym)
|
38
|
-
|
39
|
-
unless options[:all]
|
40
|
-
# THINK: should skip control none attributes?
|
41
|
-
next if sym == obj.class.primary_key or anno.control == :none or anno.disable_control?
|
42
|
-
end
|
43
|
-
|
44
|
-
prop_name = sym.to_s
|
45
|
-
|
46
|
-
# See if there is an incoming request param for this prop.
|
47
|
-
|
48
|
-
if values.has_key? prop_name
|
49
|
-
|
50
|
-
prop_value = values[prop_name]
|
51
|
-
|
52
|
-
# to_s must be called on the prop_value incase the
|
53
|
-
# request is IOString.
|
54
|
-
|
55
|
-
prop_value = prop_value.to_s unless prop_value.is_a?(Hash) or prop_value.is_a?(Array)
|
56
|
-
|
57
|
-
# If property is a Blob dont overwrite current
|
58
|
-
# property's data if "".
|
59
|
-
|
60
|
-
break if anno.class == Og::Blob and prop_value.empty?
|
61
|
-
|
62
|
-
set_attr(obj, prop_name, CGI.unescape(prop_value))
|
63
|
-
|
64
|
-
elsif options[:force_boolean] and (anno.class == TrueClass or anno.class == FalseClass)
|
65
|
-
# Set a boolean property to false if it is not in the
|
66
|
-
# request. Requires force_boolean == true.
|
67
|
-
|
68
|
-
set_attr(obj, prop_name, 0)
|
69
|
-
obj.send("__force_#{prop_name}", 0)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
if options[:assign_relations]
|
74
|
-
for rel in obj.class.relations
|
75
|
-
unless options[:all]
|
76
|
-
next if rel.options[:control] == :none or rel.options[:disable_control]
|
77
|
-
end
|
78
|
-
|
79
|
-
rel_name = rel.name.to_s
|
80
|
-
|
81
|
-
# Renew the relations from values
|
82
|
-
|
83
|
-
if rel.kind_of?(Og::RefersTo)
|
84
|
-
if foreign_oid = values[rel_name]
|
85
|
-
foreign_oid = foreign_oid.to_s unless foreign_oid.is_a?(Hash) or foreign_oid.is_a?(Array)
|
86
|
-
foreign_oid = nil if foreign_oid == 'nil' or foreign_oid == 'none'
|
87
|
-
end
|
88
|
-
set_attr(obj, rel.foreign_key, foreign_oid)
|
89
|
-
elsif rel.kind_of?(Og::JoinsMany) || rel.kind_of?(Og::HasMany)
|
90
|
-
collection = obj.send(rel_name)
|
91
|
-
collection.remove_all
|
92
|
-
if values.has_key?(rel_name)
|
93
|
-
primary_keys = values[rel_name]
|
94
|
-
primary_keys.each do |v|
|
95
|
-
v = v.to_s
|
96
|
-
next if v == "nil" or v == "none"
|
97
|
-
collection << rel.target_class[v.to_i]
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
#--
|
105
|
-
# gmosx, FIXME: this is a hack, will be replaced with proper
|
106
|
-
# code soon.
|
107
|
-
#++
|
108
|
-
|
109
|
-
for callback in obj.class.assign_callbacks
|
110
|
-
callback.call(obj, values, options)
|
111
|
-
end if obj.class.respond_to?(:assign_callbacks)
|
112
|
-
|
113
|
-
return obj
|
114
|
-
end
|
115
|
-
|
116
|
-
end
|
117
|
-
end
|