glue 0.20.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/CHANGELOG +161 -110
  2. data/INSTALL +12 -12
  3. data/README +1 -1
  4. data/Rakefile +43 -45
  5. data/doc/AUTHORS +5 -5
  6. data/doc/LICENSE +3 -3
  7. data/doc/RELEASES +32 -24
  8. data/install.rb +7 -17
  9. data/lib/facet/object/alias_class.rb +12 -0
  10. data/lib/glue.rb +35 -35
  11. data/lib/glue/array.rb +46 -46
  12. data/lib/glue/aspects.rb +199 -209
  13. data/lib/glue/attribute.rb +15 -15
  14. data/lib/glue/autoreload.rb +1 -1
  15. data/lib/glue/builder.rb +48 -0
  16. data/lib/glue/builder/xml.rb +114 -0
  17. data/lib/glue/cache.rb +189 -0
  18. data/lib/glue/configuration.rb +108 -90
  19. data/lib/glue/flexob.rb +17 -17
  20. data/lib/glue/hash.rb +71 -71
  21. data/lib/glue/helper.rb +12 -12
  22. data/lib/glue/idgen.rb +9 -0
  23. data/lib/glue/idgen/md5.rb +24 -0
  24. data/lib/glue/idgen/sequential.rb +15 -0
  25. data/lib/glue/literal_method.rb +44 -0
  26. data/lib/glue/localization.rb +130 -0
  27. data/lib/glue/logger.rb +98 -98
  28. data/lib/glue/misc.rb +7 -7
  29. data/lib/glue/mixins.rb +19 -19
  30. data/lib/glue/number.rb +8 -8
  31. data/lib/glue/object.rb +2 -2
  32. data/lib/glue/pool.rb +43 -43
  33. data/lib/glue/property.rb +392 -392
  34. data/lib/glue/sanitize.rb +34 -34
  35. data/lib/glue/settings.rb +1 -1
  36. data/lib/glue/snapshot.rb +104 -0
  37. data/lib/glue/string.rb +129 -129
  38. data/lib/glue/time.rb +53 -53
  39. data/lib/glue/uri.rb +162 -162
  40. data/lib/glue/validation.rb +421 -421
  41. data/lib/vendor/blankslate.rb +53 -0
  42. data/test/glue/builder/tc_xml.rb +56 -0
  43. data/test/glue/tc_aspects.rb +90 -90
  44. data/test/glue/tc_attribute.rb +11 -11
  45. data/test/glue/tc_builder.rb +30 -0
  46. data/test/glue/tc_configuration.rb +97 -97
  47. data/test/glue/tc_flexob.rb +10 -10
  48. data/test/glue/tc_hash.rb +23 -23
  49. data/test/glue/tc_localization.rb +49 -0
  50. data/test/glue/tc_logger.rb +31 -31
  51. data/test/glue/tc_numbers.rb +9 -9
  52. data/test/glue/tc_property.rb +67 -67
  53. data/test/glue/tc_property_mixins.rb +17 -17
  54. data/test/glue/tc_property_type_checking.rb +13 -13
  55. data/test/glue/tc_strings.rb +94 -94
  56. data/test/glue/tc_uri.rb +65 -65
  57. data/test/glue/tc_validation.rb +196 -196
  58. metadata +26 -4
data/Rakefile CHANGED
@@ -1,7 +1,3 @@
1
- # * George Moschovitis <gm@navel.gr>
2
- # (c) 2004-2005 Navel, all rights reserved.
3
- # $Id$
4
-
5
1
  require 'rake/rdoctask'
6
2
  require 'rake/testtask'
7
3
  require 'rake/gempackagetask'
@@ -27,63 +23,63 @@ VersionFile = MainFile = File.join("lib", Name + '.rb')
27
23
 
28
24
  RubyForgeProject = 'nitro'
29
25
  RubyForgeUser = 'gmosx'
30
- Homepage = "http://#{RubyForgeProject}.rubyforge.org/"
26
+ Homepage = "http://www.nitrohq.com/"
31
27
 
32
28
  task :default => :package
33
29
 
34
30
  # Run all tests.
35
31
 
36
32
  Rake::TestTask.new do |t|
37
- t.libs << 'test'
38
- t.test_files = FileList['test/**/*.rb']
39
- t.verbose = true
33
+ t.libs << 'test'
34
+ t.test_files = FileList['test/**/*.rb']
35
+ t.verbose = true
40
36
  end
41
37
 
42
38
  # Generate RDoc documentation.
43
39
 
44
40
  Rake::RDocTask.new do |rd|
45
- rd.main = 'README'
46
- rd.rdoc_dir = 'rdoc'
47
- rd.rdoc_files.include('README', 'INSTALL', 'lib/**/*.rb')
48
- rd.options << '--all --inline-source'
41
+ rd.main = 'README'
42
+ rd.rdoc_dir = 'rdoc'
43
+ rd.rdoc_files.include('README', 'INSTALL', 'lib/**/*.rb')
44
+ rd.options << '--all --inline-source'
49
45
  end
50
46
 
51
47
  # Build gem.
52
48
 
53
49
  spec = Gem::Specification.new do |s|
54
- s.name = 'glue'
55
- if File.read('lib/glue.rb') =~ /Version\s+=\s+'(\d+\.\d+\.\d+)'/
56
- s.version = $1
57
- else
58
- raise 'No version found'
59
- end
60
- s.summary = 'Glue utilities'
61
- s.description = 'A collection of utilities and useful classes'
62
- s.add_dependency 'facets', '>= 0.7.2'
63
- #s.add_dependency 'flexmock', '>= 0.0.3'
64
-
65
- s.required_ruby_version = '>= 1.8.2'
66
-
67
- s.files = FileList[
68
- '[A-Z]*', 'install.rb', '{doc,lib,test,vendor}/**/*'
69
- ].exclude('.svn/**/*').exclude('**/*.log').to_a
70
-
71
- s.require_path = 'lib'
72
- s.autorequire = 'glue'
73
-
74
- s.has_rdoc = true
75
- s.extra_rdoc_files = FileList['[A-Z]*'].exclude('*.og').to_a
76
- s.rdoc_options << '--main' << 'README' << '--title' << 'Glue Documentation'
77
- s.rdoc_options << '--all' << '--inline-source'
78
-
79
- s.test_files = []
80
-
81
- s.bindir = 'bin'
82
-
83
- s.author = 'George Moschovitis'
84
- s.email = 'gm@navel.gr'
85
- s.homepage = 'http://nitro.rubyforge.org'
86
- s.rubyforge_project = 'nitro'
50
+ s.name = 'glue'
51
+ if File.read('lib/glue.rb') =~ /Version\s+=\s+'(\d+\.\d+\.\d+)'/
52
+ s.version = $1
53
+ else
54
+ raise 'No version found'
55
+ end
56
+ s.summary = 'Glue utilities'
57
+ s.description = 'A collection of utilities and useful classes'
58
+ s.add_dependency 'facets', '>= 0.7.2'
59
+ #s.add_dependency 'flexmock', '>= 0.0.3'
60
+
61
+ s.required_ruby_version = '>= 1.8.2'
62
+
63
+ s.files = FileList[
64
+ '[A-Z]*', 'install.rb', '{doc,lib,test,vendor}/**/*'
65
+ ].exclude('.svn/**/*').exclude('**/*.log').to_a
66
+
67
+ s.require_path = 'lib'
68
+ s.autorequire = 'glue'
69
+
70
+ s.has_rdoc = true
71
+ s.extra_rdoc_files = FileList['[A-Z]*'].to_a
72
+ s.rdoc_options << '--main' << 'README' << '--title' << 'Glue Documentation'
73
+ s.rdoc_options << '--all' << '--inline-source'
74
+
75
+ s.test_files = []
76
+
77
+ s.bindir = 'bin'
78
+
79
+ s.author = 'George Moschovitis'
80
+ s.email = 'gm@navel.gr'
81
+ s.homepage = 'http://www.nitrohq.com'
82
+ s.rubyforge_project = 'nitro'
87
83
  end
88
84
 
89
85
  Rake::GemPackageTask.new(spec) do |pkg|
@@ -218,3 +214,5 @@ task :publish => [:package] do
218
214
  end
219
215
  end
220
216
  end
217
+
218
+ # * George Moschovitis <gm@navel.gr>
data/doc/AUTHORS CHANGED
@@ -1,13 +1,13 @@
1
1
  MAIN DEVELOPER:
2
2
 
3
3
  * George Moschovitis <gm@navel.gr>
4
- Project leader, architecture and design, code,
5
- documentation, maintainer.
6
-
4
+ Project leader, architecture and design, code,
5
+ documentation, maintainer.
6
+
7
7
  IDEAS, ADDITIONAL CODING, SUPPORT:
8
8
 
9
9
  * Michael Neumann <mneumann@ntecs.de>
10
- Design, additional coding and bug reports.
10
+ Design, additional coding and bug reports.
11
11
 
12
12
  * Gavin Sinclair <gsinclair@soyabean.com.au>
13
- Logger#trace method.
13
+ Logger#trace method.
data/doc/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The BSD License
2
2
 
3
- Copyright (c) 2004-2005, George 'tml' Moschovitis.
3
+ Copyright (c) 2004-2005, George 'gmosx' Moschovitis. (http://www.gmosx.com)
4
4
  Copyright (c) 2004-2005, Navel Ltd. (http://www.navel.gr)
5
5
  All rights reserved.
6
6
 
@@ -10,11 +10,11 @@ met:
10
10
 
11
11
  * Redistributions of source code must retain the above copyright
12
12
  notice, this list of conditions and the following disclaimer.
13
-
13
+
14
14
  * Redistributions in binary form must reproduce the above copyright
15
15
  notice, this list of conditions and the following disclaimer in the
16
16
  documentation and/or other materials provided with the distribution.
17
-
17
+
18
18
  * Neither the name of Navel nor the names of its contributors may be
19
19
  used to endorse or promote products derived from this software
20
20
  without specific prior written permission.
data/doc/RELEASES CHANGED
@@ -1,4 +1,12 @@
1
- == Version 0.20.0
1
+ == Version 0.21.0
2
+
3
+ * New builder system.
4
+
5
+ * Added utility methods from Wee.
6
+
7
+ * Added utility methods from Nitro.
8
+
9
+ == Version 0.20.0 was released on 12-07-2005.
2
10
 
3
11
  * Brand new, self-documenting configuration system. There is a new
4
12
  keyword for defining configuration settings:
@@ -6,11 +14,11 @@
6
14
  Here is an example:
7
15
 
8
16
  class Render
9
- setting :template_extension, :default => 'xhtml', :doc => 'The default template extension'
17
+ setting :template_extension, :default => 'xhtml', :doc => 'The default template extension'
10
18
  end
11
19
 
12
20
  class Session
13
- setting :store, :default => 'memory', :doc => 'The session store'
21
+ setting :store, :default => 'memory', :doc => 'The session store'
14
22
  end
15
23
 
16
24
  You can configure the Application using ruby code or yaml files:
@@ -21,10 +29,10 @@
21
29
  or
22
30
 
23
31
  Render:
24
- template_extension: xhtml
32
+ template_extension: xhtml
25
33
  Session:
26
- store: drb
27
-
34
+ store: drb
35
+
28
36
  You can access all defined settings:
29
37
 
30
38
  Configuration.settings.each { |s| ... }
@@ -70,25 +78,25 @@ new features and a major cleanup of the source code.
70
78
  Most notable attitions:
71
79
 
72
80
  * Aspect Oriented Programming support. This new system
73
- is used to reimplement features such as Controller filters,
74
- Og callbacks and Og observers. By using this unified
75
- system you can now add Observers to controllers and use
76
- a metalanguage for wraping Og object callbacks:
77
-
78
- class Controller
79
- pre :force_login, :where => :prepend
80
- wrap Benchmark, :on => :index
81
- post :taraa, :on => login
82
- end
81
+ is used to reimplement features such as Controller filters,
82
+ Og callbacks and Og observers. By using this unified
83
+ system you can now add Observers to controllers and use
84
+ a metalanguage for wraping Og object callbacks:
85
+
86
+ class Controller
87
+ pre :force_login, :where => :prepend
88
+ wrap Benchmark, :on => :index
89
+ post :taraa, :on => login
90
+ end
83
91
 
84
- module Timestamped
85
- pre :on => :og_insert { |this| this.create_time = Time.now }
86
- pre :on => :og_update { |this| this.update_time = Time.now }
87
- pre :on => [:og_insert, :og_update] { |this| this.create_time = Time.now }
88
- end
89
-
90
- This feature will be used extensivelly in future versions
91
- to improve logging, the shaders and more.
92
+ module Timestamped
93
+ pre :on => :og_insert { |this| this.create_time = Time.now }
94
+ pre :on => :og_update { |this| this.update_time = Time.now }
95
+ pre :on => [:og_insert, :og_update] { |this| this.create_time = Time.now }
96
+ end
97
+
98
+ This feature will be used extensivelly in future versions
99
+ to improve logging, the shaders and more.
92
100
 
93
101
 
94
102
  == Version 0.15.0 was released on 04/04/2005.
data/install.rb CHANGED
@@ -1,28 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # * George Moschovitis <gm@navel.gr>
4
- # (c) 2004-2005 Navel, all rights reserved.
5
- # $Id: install.rb 1 2005-04-11 11:04:30Z gmosx $
6
-
7
3
  require 'rbconfig'
8
4
  require 'ftools'
9
5
 
10
6
  dst_dir = Config::CONFIG['sitelibdir']
11
7
 
12
8
  Dir.chdir('lib') do
13
- Dir['**/*.rb'].each do |file|
14
- File.mkpath File.join(dst_dir, File.dirname(file)), true
15
- File.install file, File.join(dst_dir, file), 0644, true
16
- end
17
- end
18
-
19
- # gmosx: this is potentially dangerous, rethink.
20
-
21
- Dir.chdir('vendor') do
22
- Dir['**/*.rb'].each do |file|
23
- File.mkpath File.join(dst_dir, File.dirname(file)), true
24
- File.install file, File.join(dst_dir, file), 0644, true
25
- end
9
+ Dir['**/*.rb'].each do |file|
10
+ File.mkpath File.join(dst_dir, File.dirname(file)), true
11
+ File.install file, File.join(dst_dir, file), 0644, true
12
+ end
26
13
  end
27
14
 
28
15
  puts %{
@@ -45,3 +32,6 @@ at the command line.
45
32
 
46
33
  Enjoy the magic of Og!
47
34
  }
35
+
36
+ # * George Moschovitis <gm@navel.gr>
37
+
@@ -0,0 +1,12 @@
1
+
2
+ # Alias a class.
3
+ #
4
+ # alias_class App, Server
5
+ #--
6
+ # by George Moschovitis
7
+ #++
8
+
9
+ def alias_class(new_class, old_class)
10
+ raise "Cannot alias a non class, '#{old_class}'" unless old_class.is_a?(Class)
11
+ const_set new_class, old_class
12
+ end
data/lib/glue.rb CHANGED
@@ -17,55 +17,55 @@ require 'glue/attribute'
17
17
 
18
18
  class NilClass
19
19
 
20
- # quite usefull for error tolerant apps.
21
- # a bit dangerous? Will have to rethink this.
22
-
23
- def empty?
24
- true
25
- end
26
-
27
- def blank?
28
- true
29
- end
30
-
20
+ # quite usefull for error tolerant apps.
21
+ # a bit dangerous? Will have to rethink this.
22
+
23
+ def empty?
24
+ true
25
+ end
26
+
27
+ def blank?
28
+ true
29
+ end
30
+
31
31
  end
32
32
 
33
33
  class Class
34
- #--
35
- # gmosx: is this really needed?
36
- #++
37
-
38
- def to_i
39
- return self.hash
40
- end
34
+ #--
35
+ # gmosx: is this really needed?
36
+ #++
37
+
38
+ def to_i
39
+ return self.hash
40
+ end
41
41
  end
42
42
 
43
43
  module Kernel
44
44
 
45
- # Pretty prints an exception/error object
46
- # usefull for helpfull debug messages
47
- #
48
- # Input:
49
- # The Exception/StandardError object
50
- #
51
- # Output:
52
- # the pretty printed string
53
-
54
- def pp_exception(ex)
55
- return %{#{ex.message}\n #{ex.backtrace.join("\n ")}\n LOGGED FROM: #{caller[0]}}
56
- end
45
+ # Pretty prints an exception/error object
46
+ # usefull for helpfull debug messages
47
+ #
48
+ # Input:
49
+ # The Exception/StandardError object
50
+ #
51
+ # Output:
52
+ # the pretty printed string
53
+
54
+ def pp_exception(ex)
55
+ return %{#{ex.message}\n #{ex.backtrace.join("\n ")}\n LOGGED FROM: #{caller[0]}}
56
+ end
57
57
 
58
58
  end
59
59
 
60
60
  module Glue
61
61
 
62
- # The version.
62
+ # The version.
63
63
 
64
- Version = '0.20.0'
65
-
66
- # Library path.
64
+ Version = '0.21.0'
65
+
66
+ # Library path.
67
67
 
68
- LibPath = File.dirname(__FILE__)
68
+ LibPath = File.dirname(__FILE__)
69
69
 
70
70
  end
71
71
 
data/lib/glue/array.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # * George Moschovitis <gm@navel.gr>
2
2
  # (c) 2002-2005 Navel, all rights reserved.
3
- # $Id: array.rb 1 2005-04-11 11:04:30Z gmosx $
3
+ # $Id: array.rb 182 2005-07-22 10:07:50Z gmosx $
4
4
 
5
5
  require 'sync'
6
6
 
@@ -11,51 +11,51 @@ module Glue
11
11
  # needed when writing, a shared lock IS NEEDED when reading.
12
12
 
13
13
  class SafeArray < Array
14
-
15
- attr :sync
16
-
17
- # gmosx: delegator is not used.
18
-
19
- def initialize(delegator = nil)
20
- @sync = Sync.new()
21
- end
22
-
23
- def << (value)
24
- return @sync.synchronize(Sync::SH) { super }
25
- end
26
-
27
- def delete_if(&block)
28
- return @sync.synchronize(Sync::SH) { super }
29
- end
30
-
31
- def [](key)
32
- return @sync.synchronize(Sync::SH) { super }
33
- end
34
-
35
- def []=(key, value)
36
- return @sync.synchronize(Sync::EX) { super }
37
- end
38
-
39
- def delete(key)
40
- return @sync.synchronize(Sync::EX) { super }
41
- end
42
-
43
- def clear
44
- @sync.synchronize(Sync::EX) { super }
45
- end
46
-
47
- def size
48
- return @sync.synchronize(Sync::SH) { super }
49
- end
50
-
51
- def shift
52
- return @sync.synchronize(::Sync::EX) { super }
53
- end
54
-
55
- def unshift(el)
56
- return @sync.synchronize(::Sync::EX) { super }
57
- end
58
-
14
+
15
+ attr :sync
16
+
17
+ # gmosx: delegator is not used.
18
+
19
+ def initialize(delegator = nil)
20
+ @sync = Sync.new()
21
+ end
22
+
23
+ def << (value)
24
+ return @sync.synchronize(Sync::SH) { super }
25
+ end
26
+
27
+ def delete_if(&block)
28
+ return @sync.synchronize(Sync::SH) { super }
29
+ end
30
+
31
+ def [](key)
32
+ return @sync.synchronize(Sync::SH) { super }
33
+ end
34
+
35
+ def []=(key, value)
36
+ return @sync.synchronize(Sync::EX) { super }
37
+ end
38
+
39
+ def delete(key)
40
+ return @sync.synchronize(Sync::EX) { super }
41
+ end
42
+
43
+ def clear
44
+ @sync.synchronize(Sync::EX) { super }
45
+ end
46
+
47
+ def size
48
+ return @sync.synchronize(Sync::SH) { super }
49
+ end
50
+
51
+ def shift
52
+ return @sync.synchronize(::Sync::EX) { super }
53
+ end
54
+
55
+ def unshift(el)
56
+ return @sync.synchronize(::Sync::EX) { super }
57
+ end
58
+
59
59
  end
60
60
 
61
61
  end