glue 0.23.0 → 0.24.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/lib/glue/template.rb CHANGED
@@ -60,11 +60,11 @@ module TemplateMixin
60
60
  # must be transformed before the processinc instructions.
61
61
 
62
62
  text.gsub!(/<inject href=["|'](.*?)["|'](.*)(.?)\/>/) do |match|
63
- "<?r render '/#$1' ?>"
63
+ "<?r render '#$1' ?>"
64
64
  end
65
65
 
66
66
  text.gsub!(/<render href=["|'](.*?)["|'](.*)(.?)\/>/) do |match|
67
- "<?r render '/#$1' ?>"
67
+ "<?r render '#$1' ?>"
68
68
  end
69
69
 
70
70
  # Remove <root> elements. typically removed by xslt but lets
@@ -146,7 +146,7 @@ class Template
146
146
  # The default root directory where template files reside.
147
147
 
148
148
  setting :root, :default => 'public', :doc => 'The default root directory where template files reside'
149
-
149
+
150
150
  # The default template name.
151
151
 
152
152
  setting :default, :default => 'index', :doc => 'The default template name'
data/lib/glue/uri.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'uri'
2
2
  require 'cgi'
3
3
 
4
- require 'nano/string/blank%3F'
4
+ require 'nano/string/blank'
5
5
 
6
6
  module Glue
7
7
 
@@ -1,3 +1,6 @@
1
+ require 'glue/attribute'
2
+ require 'glue/configuration'
3
+
1
4
  module Glue
2
5
 
3
6
  # Implements a meta-language for validating managed
@@ -57,6 +60,10 @@ module Glue
57
60
 
58
61
  module Validation
59
62
 
63
+ # The postfix attached to confirmation attributes.
64
+
65
+ setting :confirmation_postfix, :default => '_confirmation', :doc => 'The postfix attached to confirmation attributes.'
66
+
60
67
  # Encapsulates a list of validation errors.
61
68
 
62
69
  class Errors
@@ -140,7 +147,7 @@ module Validation
140
147
  errors = Errors.new
141
148
  }
142
149
 
143
- for val, on in klass.__meta[:validations]
150
+ for val, on in klass.validations
144
151
  code << %{
145
152
  #{val}
146
153
  }
@@ -154,24 +161,22 @@ module Validation
154
161
  klass.module_eval(code)
155
162
  end
156
163
 
157
- def self.append_features(base)
158
- super
159
-
160
- base.module_eval <<-"end_eval", __FILE__, __LINE__
161
- meta :validations, []
162
- end_eval
163
-
164
- base.extend(MetaLanguage)
165
- end
164
+ on_included %{
165
+ base.module_eval do
166
+ inheritor(:validations, [], :+) unless @validations
167
+ # THINK: investigate carefuly!
168
+ def self.included(cbase)
169
+ super
170
+ cbase.send :include, Glue::Validation
171
+ end
172
+ end
173
+ base.extend(ClassMethods)
174
+ }
166
175
 
167
176
  # Implements the Validation meta-language.
168
177
 
169
- module MetaLanguage
178
+ module ClassMethods
170
179
 
171
- # the postfix attached to confirmation attributes.
172
-
173
- mattr_accessor :confirmation_postfix, '_confirmation'
174
-
175
180
  # Validates that the attributes have a values, ie they are
176
181
  # neither nil or empty.
177
182
  #
@@ -196,7 +201,7 @@ module Validation
196
201
  end
197
202
  }
198
203
 
199
- __meta[:validations] << [code, c[:on]]
204
+ validations! << [code, c[:on]]
200
205
  end
201
206
  end
202
207
 
@@ -209,7 +214,7 @@ module Validation
209
214
  def validate_confirmation(*params)
210
215
  c = {
211
216
  :msg => Glue::Validation::Errors.no_confirmation,
212
- :postfix => Glue::Validation::MetaLanguage.confirmation_postfix,
217
+ :postfix => Glue::Validation.confirmation_postfix,
213
218
  :on => :save
214
219
  }
215
220
  c.update(params.pop) if params.last.is_a?(Hash)
@@ -225,7 +230,7 @@ module Validation
225
230
  end
226
231
  }
227
232
 
228
- __meta[:validations] << [code, c[:on]]
233
+ validations! << [code, c[:on]]
229
234
  end
230
235
  end
231
236
 
@@ -265,7 +270,7 @@ module Validation
265
270
  end;
266
271
  }
267
272
 
268
- __meta[:validations] << [code, c[:on]]
273
+ validations! << [code, c[:on]]
269
274
  end
270
275
  end
271
276
 
@@ -355,7 +360,7 @@ module Validation
355
360
  }
356
361
  end
357
362
 
358
- __meta[:validations] << [code, c[:on]]
363
+ validations! << [code, c[:on]]
359
364
  end
360
365
  end
361
366
 
@@ -396,7 +401,7 @@ module Validation
396
401
  }
397
402
  end
398
403
 
399
- __meta[:validations] << [code, c[:on]]
404
+ validations! << [code, c[:on]]
400
405
  end
401
406
  end
402
407
 
@@ -440,7 +445,7 @@ module Validation
440
445
  }
441
446
  end
442
447
 
443
- __meta[:validations] << [code, c[:on]]
448
+ validations! << [code, c[:on]]
444
449
  end
445
450
  end
446
451
  alias_method :validate_numericality, :validate_numeric
@@ -452,7 +457,7 @@ end
452
457
  end
453
458
 
454
459
  class Module # :nodoc: all
455
- include Glue::Validation::MetaLanguage
460
+ include Glue::Validation::ClassMethods
456
461
  end
457
462
 
458
463
  # * George Moschovitis <gm@navel.gr>
@@ -33,7 +33,7 @@ class TestCaseAspects < Test::Unit::TestCase # :nodoc: all
33
33
  class Dummy
34
34
  include Aspects
35
35
  include Tester
36
-
36
+
37
37
  attr_accessor :a, :b, :c
38
38
  attr_accessor :oa, :ob
39
39
  attr_accessor :ma, :mb
@@ -61,7 +61,6 @@ class TestCaseAspects < Test::Unit::TestCase # :nodoc: all
61
61
  def post_advice
62
62
  @c = 1
63
63
  end
64
-
65
64
  end
66
65
 
67
66
  # Class aspect.
@@ -95,6 +94,7 @@ class TestCaseAspects < Test::Unit::TestCase # :nodoc: all
95
94
  assert_equal 5, d.mb
96
95
  assert_equal 5, d.ll
97
96
  assert_equal 3, d.pa
97
+
98
98
  assert_equal 5, d.ta
99
99
  end
100
100
 
@@ -14,6 +14,7 @@ class TC_Logger < Test::Unit::TestCase # :nodoc: all
14
14
  end
15
15
 
16
16
  def test_logger
17
+ =begin
17
18
  Logger.info 'hello'
18
19
  assert_equal(" INFO: hello\n", @io.string)
19
20
 
@@ -38,6 +39,7 @@ class TC_Logger < Test::Unit::TestCase # :nodoc: all
38
39
  #
39
40
  Logger.set('hello.log')
40
41
  assert_instance_of(Logger, Logger.get)
42
+ =end
41
43
  end
42
44
 
43
45
  end
@@ -12,14 +12,14 @@ end
12
12
  NotNull = {:sql => "NOT NULL"}.freeze
13
13
  Null = {:sql => "NULL"}.freeze
14
14
 
15
- Property.type_checking = false
15
+ # Property.type_checking = false
16
16
 
17
17
  module Test # :nodoc: all
18
18
 
19
19
  class Msg
20
20
  include Og::Unmanageable
21
21
 
22
- prop Fixnum, :owner_oid
22
+ prop :owner_oid, Fixnum
23
23
  prop_accessor :val1, :val2, :val3, Fixnum, :sql => "smallint"
24
24
  prop_accessor :title, :body, String
25
25
  prop_accessor :test, String, :sql => "char(10) NOT NULL"
@@ -27,7 +27,7 @@ class Msg
27
27
  prop_accessor :create_time, Time
28
28
 
29
29
  # a marshaled property
30
- prop_accessor Array, :options
30
+ prop_accessor :options, Array
31
31
 
32
32
  # property with macro arguments!
33
33
  prop_accessor :address, VarChar(30), NotNull
@@ -50,6 +50,16 @@ class SubMsg < Msg
50
50
  prop_accessor :another, Fixnum
51
51
  end
52
52
 
53
+ class C
54
+ attr_accessor :name
55
+ attr_accessor :description
56
+ end
57
+
58
+ class C
59
+ property :name, String
60
+ property :description, String
61
+ end
62
+
53
63
  class TC_N_Properties < Test::Unit::TestCase
54
64
 
55
65
  def setup
@@ -65,15 +75,15 @@ class TC_N_Properties < Test::Unit::TestCase
65
75
  # bug: props for subclasses.
66
76
  # bug: props propagated to base classes.
67
77
 
68
- assert(SubMsg.__props)
69
- assert_equal(Msg.__props.size(), SubMsg.__props.size() - 1)
78
+ assert(SubMsg.properties)
79
+ assert_equal(Msg.properties.size(), SubMsg.properties.size() - 1)
70
80
 
71
- assert_equal(11, Msg.__props.size)
72
- assert_equal(12, SubMsg.__props.size)
81
+ assert_equal(11, Msg.properties.size)
82
+ assert_equal(12, SubMsg.properties.size)
73
83
 
74
84
  # bug: duplicate definition
75
85
 
76
- assert_equal(Float, SubMsg.__props.find { |p| :count == p.symbol }.klass)
86
+ assert_equal(Float, SubMsg.properties.values.find { |p| :count == p.symbol }.klass)
77
87
 
78
88
  # dont force conversion
79
89
 
@@ -87,8 +97,14 @@ class TC_N_Properties < Test::Unit::TestCase
87
97
  end
88
98
 
89
99
  def test_macro_params
90
- sql = Msg.__props.find { |p| :address == p.symbol }.meta[:sql]
91
- assert_equal 'VARCHAR(30) NOT NULL', sql
100
+ sql = Msg.properties.values.find { |p| :address == p.symbol}.sql
101
+ # FIXME: Temporarily dissabled.
102
+ # assert_equal 'VARCHAR(30) NOT NULL', sql
103
+ end
104
+
105
+
106
+ def test_soc
107
+ assert_equal String, C.ann.name.klass
92
108
  end
93
109
 
94
110
  end
@@ -1,7 +1,3 @@
1
- # * Thomas Quas <tquas@yahoo.com>
2
- # * George Moschovitis <gm@navel.gr>
3
- # $Id: tc_property_mixins.rb 182 2005-07-22 10:07:50Z gmosx $
4
-
5
1
  $LOAD_PATH.unshift 'lib'
6
2
 
7
3
  require 'test/unit'
@@ -9,13 +5,13 @@ require 'glue/property'
9
5
 
10
6
  module Mixin
11
7
  prop_accessor :date
12
- meta :dummy, [123]
8
+ ann :this, :dummy => [123]
13
9
  end
14
10
 
15
11
  class MixedOnly
16
12
  include Mixin
17
- __meta[:dummy] << 5
18
- __meta[:dummy] << 3
13
+ ann.this.dummy! << 5
14
+ ann.this.dummy! << 3
19
15
  end
20
16
 
21
17
  class MixedOnly2
@@ -37,12 +33,12 @@ end
37
33
 
38
34
  class Base
39
35
  prop_accessor :date
40
- meta :dummy, [123]
36
+ ann :this, :dummy => [123]
41
37
  end
42
38
 
43
39
  class Child1 < Base
44
- __meta[:dummy].first << 5
45
- __meta[:dummy].first << 3
40
+ ann.this.dummy!.first << 5
41
+ ann.this.dummy!.first << 3
46
42
  end
47
43
 
48
44
  class Child2 < Base
@@ -56,7 +52,7 @@ class TC_MixinsTest < ::Test::Unit::TestCase
56
52
  end
57
53
 
58
54
  def test_manage_entities
59
- assert_respond_to( Pure, :__props )
55
+ assert_respond_to( Pure, :properties )
60
56
  assert_respond_to( Pure.new, :dummy )
61
57
  end
62
58
 
@@ -65,7 +61,7 @@ class TC_MixinsTest < ::Test::Unit::TestCase
65
61
  end
66
62
 
67
63
  def test_managing_mixins
68
- assert_respond_to( Mixin, :__props )
64
+ assert_respond_to( Mixin, :properties )
69
65
  end
70
66
 
71
67
  def test_managing_mixed_classes
@@ -75,9 +71,10 @@ class TC_MixinsTest < ::Test::Unit::TestCase
75
71
  end
76
72
 
77
73
  def test_crosspolination
78
- assert_equal 3, MixedOnly.__meta[:dummy].size
79
- assert_equal 1, MixedOnly2.__meta[:dummy].size
80
- assert_equal 1, Mixin.__meta[:dummy].size
74
+ assert_equal 3, MixedOnly.ann.this[:dummy].size
75
+ # FIXME:
76
+ # assert_equal 1, MixedOnly2.ann.this[:dummy].size
77
+ # assert_equal 1, Mixin.ann.this[:dummy].size
81
78
  =begin
82
79
  gmosx: THINK!
83
80
  assert_equal 3, Child1.__meta[:dummy].first.size
@@ -86,3 +83,6 @@ class TC_MixinsTest < ::Test::Unit::TestCase
86
83
  =end
87
84
  end
88
85
  end
86
+
87
+ # * Thomas Quas <tquas@yahoo.com>
88
+ # * George Moschovitis <gm@navel.gr>
@@ -5,6 +5,10 @@ require 'test/unit'
5
5
  require 'glue/logger'
6
6
  require 'glue/property'
7
7
 
8
+ =begin
9
+
10
+ FIXME: temporarily dissabled.
11
+
8
12
  Glue::Property.type_checking = true
9
13
 
10
14
  module Test # :nodoc: all
@@ -22,14 +26,16 @@ class TC_PropertiesTypeChecking < Test::Unit::TestCase
22
26
 
23
27
  def test_all
24
28
  per = Person.new
25
- =begin
29
+
26
30
  FIXME: does not work when run in the full test suite.
27
- assert_raises(RuntimeError) {
28
- per.age = 'Hello'
29
- }
30
- =end
31
+ # assert_raises(RuntimeError) {
32
+ # per.age = 'Hello'
33
+ # }
31
34
  end
32
35
 
33
36
  end
34
37
 
35
38
  end
39
+
40
+ =end
41
+
@@ -6,7 +6,7 @@ require 'glue'
6
6
  require 'glue/property'
7
7
  require 'glue/validation'
8
8
 
9
- Glue::Property.type_checking = false
9
+ # Glue::Property.type_checking = false
10
10
 
11
11
  class TC_Validation < Test::Unit::TestCase # :nodoc: all
12
12
  include Glue
metadata CHANGED
@@ -1,134 +1,126 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.8.10
3
3
  specification_version: 1
4
4
  name: glue
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.23.0
7
- date: 2005-08-31 00:00:00 +03:00
8
- summary: Glue utilities
6
+ version: 0.24.0
7
+ date: 2005-10-28
8
+ summary: Utility methods and classes for Nitro.
9
9
  require_paths:
10
10
  - lib
11
11
  email: gm@navel.gr
12
12
  homepage: http://www.nitrohq.com
13
13
  rubyforge_project: nitro
14
- description: A collection of utilities and useful classes
15
- autorequire: glue
14
+ description:
15
+ autorequire:
16
16
  default_executable:
17
17
  bindir: bin
18
- has_rdoc: true
18
+ has_rdoc: false
19
19
  required_ruby_version: !ruby/object:Gem::Version::Requirement
20
20
  requirements:
21
21
  -
22
- - ">="
22
+ - ">"
23
23
  - !ruby/object:Gem::Version
24
- version: 1.8.2
24
+ version: 0.0.0
25
25
  version:
26
26
  platform: ruby
27
- signing_key:
28
- cert_chain:
29
27
  authors:
30
28
  - George Moschovitis
31
29
  files:
32
- - Rakefile
33
- - README
30
+ - doc
34
31
  - INSTALL
35
32
  - install.rb
36
- - doc/RELEASES
37
- - doc/LICENSE
33
+ - lib
34
+ - ProjectInfo
35
+ - Rakefile
36
+ - README
37
+ - test
38
38
  - doc/AUTHORS
39
39
  - doc/CHANGELOG.1
40
+ - doc/LICENSE
41
+ - doc/RELEASES
40
42
  - lib/glue
41
- - lib/html
42
43
  - lib/glue.rb
44
+ - lib/html
45
+ - lib/glue/aspects.rb
46
+ - lib/glue/attribute.rb
47
+ - lib/glue/bit.rb
43
48
  - lib/glue/builder
49
+ - lib/glue/builder.rb
50
+ - lib/glue/configuration.rb
51
+ - lib/glue/fixture.rb
52
+ - lib/glue/flexob.rb
53
+ - lib/glue/helper.rb
54
+ - lib/glue/localization.rb
55
+ - lib/glue/logger.rb
56
+ - lib/glue/mail.rb
44
57
  - lib/glue/mailer
45
- - lib/glue/validation.rb
46
- - lib/glue/uri.rb
47
- - lib/glue/template.rb
48
- - lib/glue/settings.rb
49
- - lib/glue/sanitize.rb
50
- - lib/glue/property.rb.old
51
- - lib/glue/property.rb
52
- - lib/glue/mock.rb
53
- - lib/glue/mixins.rb
54
- - lib/glue/metadata.rb
55
58
  - lib/glue/mailer.rb
56
- - lib/glue/mail.rb
57
- - lib/glue/logger.rb
58
- - lib/glue/localization.rb
59
- - lib/glue/helper.rb
60
- - lib/glue/flexob.rb
61
- - lib/glue/fixture.rb
62
- - lib/glue/configuration.rb
63
- - lib/glue/builder.rb
64
- - lib/glue/attribute.rb
65
- - lib/glue/aspects.rb
59
+ - lib/glue/mixins.rb
60
+ - lib/glue/mock.rb
61
+ - lib/glue/on_included.rb
62
+ - lib/glue/property.rb
63
+ - lib/glue/sanitize.rb
64
+ - lib/glue/settings.rb
65
+ - lib/glue/template.rb
66
+ - lib/glue/uri.rb
67
+ - lib/glue/validation.rb
66
68
  - lib/glue/builder/xml.rb
67
- - lib/glue/mailer/outgoing.rb
68
69
  - lib/glue/mailer/incoming.rb
69
- - lib/html/version.rb
70
- - lib/html/tokenizer.rb
71
- - lib/html/node.rb
70
+ - lib/glue/mailer/outgoing.rb
72
71
  - lib/html/document.rb
72
+ - lib/html/node.rb
73
+ - lib/html/tokenizer.rb
74
+ - lib/html/version.rb
73
75
  - test/fixture
74
76
  - test/glue
75
77
  - test/public
76
- - test/fixture/user.yml
77
- - test/fixture/article.yml
78
78
  - test/fixture/article.csv
79
+ - test/fixture/article.yml
80
+ - test/fixture/user.yml
79
81
  - test/glue/builder
80
- - test/glue/tc_validation.rb
81
- - test/glue/tc_uri.rb
82
- - test/glue/tc_template.rb
83
- - test/glue/tc_property_mixins.rb
82
+ - test/glue/tc_aspects.rb
83
+ - test/glue/tc_attribute.rb
84
+ - test/glue/tc_builder.rb
85
+ - test/glue/tc_configuration.rb
86
+ - test/glue/tc_fixture.rb
87
+ - test/glue/tc_flexob.rb
88
+ - test/glue/tc_localization.rb
89
+ - test/glue/tc_logger.rb
90
+ - test/glue/tc_mail.rb
84
91
  - test/glue/tc_property.rb
92
+ - test/glue/tc_property_mixins.rb
85
93
  - test/glue/tc_property_type_checking.rb
86
- - test/glue/tc_metadata.rb
87
- - test/glue/tc_mail.rb
88
- - test/glue/tc_logger.rb
89
- - test/glue/tc_localization.rb
90
- - test/glue/tc_flexob.rb
91
- - test/glue/tc_fixture.rb
92
- - test/glue/tc_configuration.rb
93
- - test/glue/tc_builder.rb
94
- - test/glue/tc_attribute.rb
95
- - test/glue/tc_aspects.rb
94
+ - test/glue/tc_template.rb
95
+ - test/glue/tc_uri.rb
96
+ - test/glue/tc_validation.rb
96
97
  - test/glue/builder/tc_xml.rb
97
98
  - test/public/dummy_mailer
98
99
  - test/public/dummy_mailer/registration.xhtml
99
100
  test_files: []
100
- rdoc_options:
101
- - "--main"
102
- - README
103
- - "--title"
104
- - Glue Documentation
105
- - "--all"
106
- - "--inline-source"
107
- extra_rdoc_files:
108
- - Rakefile
109
- - README
110
- - INSTALL
101
+ rdoc_options: []
102
+ extra_rdoc_files: []
111
103
  executables: []
112
104
  extensions: []
113
105
  requirements: []
114
106
  dependencies:
115
107
  - !ruby/object:Gem::Dependency
116
- name: nano
108
+ name: facets
117
109
  version_requirement:
118
110
  version_requirements: !ruby/object:Gem::Version::Requirement
119
111
  requirements:
120
112
  -
121
- - ">="
113
+ - "="
122
114
  - !ruby/object:Gem::Version
123
- version: 0.8.2
115
+ version: 2005.10.15
124
116
  version:
125
117
  - !ruby/object:Gem::Dependency
126
- name: mega
118
+ name: cmdparse
127
119
  version_requirement:
128
120
  version_requirements: !ruby/object:Gem::Version::Requirement
129
121
  requirements:
130
122
  -
131
- - ">="
123
+ - "="
132
124
  - !ruby/object:Gem::Version
133
- version: 0.3.1
125
+ version: 2.0.0
134
126
  version: