glue 0.30.0 → 0.31.0

Sign up to get free protection for your applications and to get access to all the features.
data/ProjectInfo CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  TITLE : &title Glue
4
4
  NAME : &pkg glue
5
- VERSION : '0.30.0'
5
+ VERSION : '0.31.0'
6
6
  STATUS : beta
7
7
 
8
8
  AUTHOR : George Moschovitis
@@ -19,7 +19,7 @@ RUBYFORGE:
19
19
  USERNAME: 'gmosx'
20
20
 
21
21
  DEPENDENCIES:
22
- - [ facets, '= 1.3.3' ]
22
+ - [ facets, '= 1.4.5' ]
23
23
 
24
24
  PACKAGE: !!package
25
25
  distribute: [ gem, tgz, zip ]
data/doc/RELEASES CHANGED
@@ -1,3 +1,7 @@
1
+ == Version 0.31.0
2
+
3
+ Bugfixes. Refactored taggable.rb and removed attribute in favor of Facets's cattr which was then replaced with settings.
4
+
1
5
  == Version 0.30.0
2
6
 
3
7
  Cleaned up the codebase. Removed files duplicating functionality
data/lib/glue.rb CHANGED
@@ -13,10 +13,10 @@ require 'pp'
13
13
 
14
14
  require 'facet/nullclass'
15
15
  require 'facets/more/paramix' # keep this before module/is
16
- require 'facet/module/is'
16
+ require 'facets/core/module/is'
17
+ require 'facets/core/class/cattr'
17
18
 
18
19
  require 'glue/property'
19
- require 'glue/attribute'
20
20
 
21
21
  # Glue is a collection of reusable utilities and methods to
22
22
  # especially suited to Nitro and Og coding. We try to extract
@@ -36,7 +36,7 @@ module Glue
36
36
 
37
37
  # The version.
38
38
 
39
- Version = '0.30.0'
39
+ Version = '0.31.0'
40
40
 
41
41
  # Library path.
42
42
 
@@ -5,9 +5,6 @@ require 'facet/synchash'
5
5
  require 'facet/dictionary'
6
6
  require 'facet/string/capitalized'
7
7
 
8
- require 'glue/attribute'
9
- require 'glue/flexob'
10
-
11
8
  module Glue
12
9
 
13
10
  # A Configuration holds a group of Settings organized by
@@ -17,7 +14,6 @@ module Glue
17
14
  # You can pass strings, constants or symbols as keys for the
18
15
  # classes to be configured. Passing symbols you can configure
19
16
  # classes even before they are defined.
20
- #
21
17
  #--
22
18
  # TODO: implement with annotations.
23
19
  #++
@@ -185,7 +181,6 @@ class Configuration
185
181
 
186
182
  def method_missing(sym)
187
183
  if sym.to_s.capitalized?
188
- # Flexob.new(self[sym])
189
184
  bdl = SettingCollection.new
190
185
  bdl.owner = sym
191
186
  if hash = self[sym]
data/lib/glue/logger.rb CHANGED
@@ -1,10 +1,16 @@
1
1
  require 'logger'
2
2
 
3
- # A simple wrapper arround the Ruby logger. Mainly for
3
+ # A simple extension of the Ruby logger. Mainly for
4
4
  # compatibility purposes.
5
5
  #
6
+ # === Convention
7
+ #
8
+ # When using debug level logger messages always append 'if $DBG'
9
+ # at the end. This hack is needed because Ruby does not support
10
+ # lazy evaluation (lisp macros).
6
11
  #--
7
- # TODO: implement as mixin that can be added to Log4R.
12
+ # THINK: some people think, this extension is dangerous,
13
+ # investigate.
8
14
  #++
9
15
 
10
16
  class Logger
@@ -76,24 +82,24 @@ class Logger
76
82
  # block should return formatted strings given severity,
77
83
  # timestamp, msg, progname.
78
84
  #
79
- # Useless example:
85
+ # === Example
80
86
  #
81
87
  # logger = Logger.new
82
- # logger.format do |severity, timestamp, msg, progname|
88
+ # logger.setup_format do |severity, timestamp, msg, progname|
83
89
  # "#{progname}@#{timestamp} - #{severity}::#{msg}"
84
90
  # end
85
91
 
86
92
  def setup_format(&format_proc)
87
- # raise 'Formating block needed' unless format_proc
88
- # @format_proc = format_proc
93
+ raise 'Formating block needed' unless format_proc
94
+ @format_proc = format_proc
89
95
  end
90
96
 
91
97
  private
92
98
 
93
99
  # hackish use of *args, give me some love.
94
100
 
95
- alias_method :old_format_message, :format_message
96
- def format_message(*args)
101
+ alias_method :old_format_message, :format_message # :nodoc:
102
+ def format_message(*args) # :nodoc:
97
103
  @format_proc ? @format_proc.call(*args) : old_format_message(*args)
98
104
  end
99
105
  end
@@ -179,18 +185,25 @@ end
179
185
 
180
186
  module Glue
181
187
 
188
+ # UNDER CONSTRUCTION.
189
+ #
182
190
  # Add logging capabilities to the including class.
183
- # When using the log/logger variables always check
184
- # for nil:
185
191
  #
186
- # log.info "your #{expensive_calculation} comes here" if @log
192
+ # === Examples
187
193
  #
188
- # This way the expensive calculation is avoided if the
189
- # logger is dissabled (@log == nil).
194
+ # Og.log_info 'Hello' => '[Og] Hello'
195
+ # Render.log_info ...
196
+ # In Render:
197
+ # log_info '...'
190
198
 
191
199
  module Logging
192
- attr_accessor :logger
193
- alias_method :log, :logger
200
+ =begin
201
+ def self.included base
202
+ [ :info, :debug ].each do |l|
203
+
204
+ end
205
+ end
206
+ =end
194
207
  end
195
208
 
196
209
  end
data/lib/glue/markup.rb CHANGED
@@ -2,7 +2,7 @@ require 'singleton'
2
2
  require 'redcloth'
3
3
  require 'cgi'
4
4
 
5
- require 'facet/classinherit'
5
+ require 'facets/core/module/class_extension'
6
6
 
7
7
  require 'glue/sanitize'
8
8
 
@@ -94,7 +94,7 @@ module Markup
94
94
  CGI.unescape(str.gsub(/_/, ' '))
95
95
  end
96
96
 
97
- class_inherit do
97
+ class_extension do
98
98
  # Helper method for manipulating the sanitize transformation.
99
99
 
100
100
  def setup_sanitize_transform(&block)
data/lib/glue/template.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'glue/flexob'
1
+ require 'facets/more/openobject'
2
2
  require 'glue/configuration'
3
3
 
4
4
  module Glue
@@ -164,14 +164,14 @@ class Template
164
164
  setting :strip_xml_comments, :default => false, :doc => 'Strip xml comments from templates?'
165
165
 
166
166
  class << self
167
- include Glue::TemplateMixin
167
+ include TemplateMixin
168
168
  alias_method :compile, :compile_template
169
169
  alias_method :transform, :compile_template
170
170
  alias_method :evaluate, :evaluate_template
171
171
  alias_method :process, :process_template
172
172
  end
173
173
 
174
- include Glue::TemplateMixin
174
+ include TemplateMixin
175
175
 
176
176
  # Helper.
177
177
 
@@ -187,8 +187,8 @@ end
187
187
  # An intuitive binding mechanism provides the
188
188
  # expansion environment.
189
189
 
190
- class FileTemplate < Flexob
191
- include Glue::TemplateMixin
190
+ class FileTemplate < OpenObject
191
+ include TemplateMixin
192
192
 
193
193
  @@compiled_template_cache = {}
194
194
 
@@ -1,4 +1,5 @@
1
- require 'glue/attribute'
1
+ require 'facets/core/class/cattr'
2
+
2
3
  require 'glue/configuration'
3
4
 
4
5
  module Glue
@@ -70,16 +71,16 @@ module Validation
70
71
  class Errors
71
72
  attr_accessor :errors
72
73
 
73
- cattr_accessor :no_value, 'No value provided'
74
- cattr_accessor :no_confirmation, 'Invalid confirmation'
75
- cattr_accessor :invalid_format, 'Invalid format'
76
- cattr_accessor :too_short, 'Too short, must be more than %d characters long'
77
- cattr_accessor :too_long, 'Too long, must be less than %d characters long'
78
- cattr_accessor :invalid_length, 'Must be %d characters long'
79
- cattr_accessor :no_inclusion, 'The value is invalid'
80
- cattr_accessor :no_numeric, 'The value must be numeric'
81
- cattr_accessor :not_unique, 'The value is already used'
82
-
74
+ setting :no_value, :default => 'No value provided'
75
+ setting :no_confirmation, :default => 'Invalid confirmation'
76
+ setting :invalid_format, :default => 'Invalid format'
77
+ setting :too_short, :default => 'Too short, must be more than %d characters long'
78
+ setting :too_long, :default => 'Too long, must be less than %d characters long'
79
+ setting :invalid_length, :default => 'Must be %d characters long'
80
+ setting :no_inclusion, :default => 'The value is invalid'
81
+ setting :no_numeric, :default => 'The value must be numeric'
82
+ setting :not_unique, :default => 'The value is already used'
83
+
83
84
  def initialize
84
85
  @errors = {}
85
86
  end
@@ -199,7 +200,7 @@ module Validation
199
200
  params.each do |field|
200
201
  define_validation(:value, field, c[:on]) do |obj|
201
202
  value = obj.send(field)
202
- obj.errors.add(field, c[:msg]) if value.nil? || (value.respond_to?(:empty) && value.empty?)
203
+ obj.errors.add(field, c[:msg]) if value.nil? || (value.respond_to?(:empty?) && value.empty?)
203
204
  end
204
205
  end
205
206
  end
@@ -14,7 +14,6 @@ class TC_Logger < Test::Unit::TestCase # :nodoc: all
14
14
  end
15
15
 
16
16
  def test_logger
17
- =begin
18
17
  Logger.info 'hello'
19
18
  assert_equal(" INFO: hello\n", @io.string)
20
19
 
@@ -39,7 +38,6 @@ class TC_Logger < Test::Unit::TestCase # :nodoc: all
39
38
  #
40
39
  Logger.set('hello.log')
41
40
  assert_instance_of(Logger, Logger.get)
42
- =end
43
41
  end
44
42
 
45
43
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: glue
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.30.0
7
- date: 2006-05-05 00:00:00 +03:00
6
+ version: 0.31.0
7
+ date: 2006-07-20 00:00:00 -07:00
8
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.nitroproject.org
13
- rubyforge_project: nitro
13
+ rubyforge_project:
14
14
  description:
15
15
  autorequire:
16
16
  default_executable:
@@ -22,88 +22,84 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
22
22
  - !ruby/object:Gem::Version
23
23
  version: 0.0.0
24
24
  version:
25
- platform:
25
+ platform: ruby
26
26
  signing_key:
27
27
  cert_chain:
28
+ post_install_message:
28
29
  authors:
29
30
  - George Moschovitis
30
31
  files:
31
- - ProjectInfo
32
- - INSTALL
33
- - README
34
32
  - doc
35
33
  - lib
36
34
  - test
37
- - setup.rb
38
- - doc/CHANGELOG.1
39
- - doc/AUTHORS
40
- - doc/LICENSE
41
- - doc/RELEASES
35
+ - .
42
36
  - lib/glue
43
37
  - lib/html
44
- - lib/glue.rb
45
- - lib/glue/attribute.rb
46
- - lib/glue/builder
47
- - lib/glue/html.rb
48
- - lib/glue/mailer
49
- - lib/glue/builder.rb
50
- - lib/glue/fixture.rb
51
- - lib/glue/configuration.rb
52
- - lib/glue/flexob.rb
53
38
  - lib/glue/cache
54
- - lib/glue/logger.rb
55
- - lib/glue/localization.rb
56
- - lib/glue/mail.rb
57
- - lib/glue/property.rb
58
- - lib/glue/mailer.rb
59
- - lib/glue/cache.rb
60
- - lib/glue/sanitize.rb
61
- - lib/glue/settings.rb
62
- - lib/glue/template.rb
63
- - lib/glue/uri.rb
64
- - lib/glue/validation.rb
65
- - lib/glue/markup.rb
66
- - lib/glue/accumulate.rb
67
- - lib/glue/autoreload.rb
68
- - lib/glue/builder/xml.rb
69
- - lib/glue/mailer/incoming.rb
70
- - lib/glue/mailer/outgoing.rb
71
- - lib/glue/cache/file.rb
72
- - lib/glue/cache/drb.rb
73
- - lib/glue/cache/memcached.rb
74
- - lib/glue/cache/memory.rb
75
- - lib/glue/cache/og.rb
76
- - lib/html/document.rb
77
- - lib/html/node.rb
78
- - lib/html/tokenizer.rb
79
- - lib/html/version.rb
80
- - test/fixture
39
+ - lib/glue/mailer
40
+ - lib/glue/builder
81
41
  - test/glue
42
+ - test/fixture
82
43
  - test/public
83
- - test/fixture/article.csv
84
- - test/fixture/article.yml
85
- - test/fixture/user.yml
86
44
  - test/glue/builder
87
- - test/glue/tc_attribute.rb
88
- - test/glue/tc_aspects.rb
89
- - test/glue/tc_validation.rb
45
+ - test/public/dummy_mailer
46
+ - test/fixture/article.csv
90
47
  - test/glue/tc_builder.rb
48
+ - test/glue/tc_validation.rb
49
+ - lib/glue/builder/xml.rb
50
+ - lib/glue/mailer/incoming.rb
51
+ - lib/glue/cache/memory.rb
52
+ - lib/glue/cache/drb.rb
91
53
  - test/glue/tc_fixture.rb
92
- - test/glue/tc_configuration.rb
93
- - test/glue/tc_flexob.rb
94
- - test/glue/tc_logger.rb
95
- - test/glue/tc_localization.rb
96
- - test/glue/tc_mail.rb
97
- - test/glue/tc_property.rb
98
- - test/glue/tc_template.rb
54
+ - lib/html/tokenizer.rb
55
+ - lib/glue/mail.rb
56
+ - setup.rb
57
+ - lib/html/node.rb
58
+ - lib/glue/configuration.rb
59
+ - lib/glue.rb
60
+ - test/public/dummy_mailer/registration.xhtml
99
61
  - test/glue/tc_property_mixins.rb
100
- - test/glue/tc_uri.rb
101
62
  - test/glue/tc_stores.rb
63
+ - lib/glue/localization.rb
64
+ - doc/LICENSE
65
+ - README
66
+ - test/glue/tc_aspects.rb
67
+ - test/glue/tc_property.rb
102
68
  - test/glue/tc_property_type_checking.rb
103
- - test/glue/tc_accumulate.rb
69
+ - lib/html/version.rb
70
+ - lib/glue/cache/memcached.rb
71
+ - lib/glue/settings.rb
72
+ - doc/CHANGELOG.1
73
+ - test/glue/tc_uri.rb
74
+ - lib/glue/mailer/outgoing.rb
75
+ - lib/glue/cache.rb
76
+ - lib/glue/sanitize.rb
77
+ - INSTALL
78
+ - test/fixture/user.yml
104
79
  - test/glue/builder/tc_xml.rb
105
- - test/public/dummy_mailer
106
- - test/public/dummy_mailer/registration.xhtml
80
+ - test/glue/tc_template.rb
81
+ - lib/glue/uri.rb
82
+ - lib/glue/autoreload.rb
83
+ - lib/glue/markup.rb
84
+ - test/fixture/article.yml
85
+ - test/glue/tc_localization.rb
86
+ - lib/glue/html.rb
87
+ - lib/glue/property.rb
88
+ - doc/RELEASES
89
+ - ProjectInfo
90
+ - lib/glue/builder.rb
91
+ - lib/glue/logger.rb
92
+ - test/glue/tc_logger.rb
93
+ - test/glue/tc_mail.rb
94
+ - test/glue/tc_configuration.rb
95
+ - lib/html/document.rb
96
+ - lib/glue/cache/file.rb
97
+ - lib/glue/cache/og.rb
98
+ - lib/glue/template.rb
99
+ - lib/glue/fixture.rb
100
+ - lib/glue/mailer.rb
101
+ - lib/glue/validation.rb
102
+ - doc/AUTHORS
107
103
  test_files: []
108
104
 
109
105
  rdoc_options: []
@@ -124,5 +120,5 @@ dependencies:
124
120
  requirements:
125
121
  - - "="
126
122
  - !ruby/object:Gem::Version
127
- version: 1.3.3
123
+ version: 1.4.5
128
124
  version:
@@ -1,21 +0,0 @@
1
- require 'facet/functor'
2
-
3
- module Enumerable
4
-
5
- # Project has_many Group
6
- # Group has_many User
7
- # projects.groups.accumulate.users
8
- #--
9
- # gmosx: any idea for a better name?
10
- #++
11
-
12
- def accumulate
13
- Functor.new do |op, *args|
14
- self.inject([]) { |a, x| a << x.send(op, *args) }.flatten
15
- end
16
- end
17
- alias_method :acc, :accumulate
18
-
19
- end
20
-
21
- # * George Moschovitis <gm@navel.gr>
@@ -1,79 +0,0 @@
1
- # Original code from Rails distribution.
2
- # http://www.rubyonrails.com
3
-
4
- #--
5
- # Extends the module object with module and instance accessors
6
- # for class attributes, just like the native attr* accessors for
7
- # instance attributes. Aliases for classes are also provided.
8
- #
9
- # Example:
10
- #
11
- # mattr_accessor :my_attr, 'Default value'
12
- #
13
- # FIXME: I think those methods do *not* work as expected.
14
- # FIXME: I should probably use @-attributes instead of
15
- # @@-attributes.
16
- #++
17
-
18
- class Module # :nodoc:
19
-
20
- # A macro that creates a reader method for class/module
21
- # attributes.
22
-
23
- def mattr_reader(*params)
24
- default = if params.last.is_a?(Symbol) then nil else params.pop end
25
-
26
- for sym in params
27
- module_eval <<-"end_eval", __FILE__, __LINE__
28
-
29
- if not defined?(@@#{sym.id2name})
30
- @@#{sym.id2name} = #{default.inspect}
31
- end
32
-
33
- def self.#{sym.id2name}
34
- @@#{sym}
35
- end
36
-
37
- end_eval
38
- end
39
- end
40
- alias_method :cattr_reader, :mattr_reader
41
-
42
- # A macro that creates a writer method for class/module
43
- # attributes.
44
-
45
- def mattr_writer(*params)
46
- default = if params.last.is_a?(Symbol) then nil else params.pop end
47
-
48
- for sym in params
49
- module_eval <<-"end_eval", __FILE__, __LINE__
50
-
51
- if not defined?(@@#{sym.id2name})
52
- @@#{sym.id2name} = #{default.inspect.inspect}
53
- end
54
-
55
- def self.#{sym.id2name}=(obj)
56
- @@#{sym.id2name} = obj
57
- end
58
-
59
- def self.set_#{sym.id2name}(obj)
60
- @@#{sym.id2name} = obj
61
- end
62
-
63
- end_eval
64
- end
65
- end
66
- alias_method :cattr_writer, :cattr_writer
67
-
68
- # A macro that creates a reader and a writer method for
69
- # class/module attributes.
70
-
71
- def mattr_accessor(*syms)
72
- mattr_reader(*syms)
73
- mattr_writer(*syms)
74
- end
75
- alias_method :cattr_accessor, :mattr_accessor
76
-
77
- end
78
-
79
- # * George Moschovitis <gm@navel.gr>
data/lib/glue/flexob.rb DELETED
@@ -1,46 +0,0 @@
1
- require 'ostruct'
2
-
3
- module Glue
4
-
5
- # A flexible Object.
6
- # Temporarily implemented as a simple OpenStruct.
7
-
8
- class Flexob < OpenStruct
9
-
10
- def update(hash)
11
- hash.each do |k, v|
12
- send("#{k}=", v)
13
- end
14
- end
15
- alias_method :set, :update
16
- alias_method :merge, :update
17
-
18
- def fetch(key, default = nil)
19
- if @table.has_key?(key)
20
- @table[key.to_sym]
21
- else
22
- default
23
- end
24
- end
25
-
26
- def []=(key, val)
27
- @table[key.to_sym] = val
28
- end
29
-
30
- def [](key)
31
- @table[key.to_sym]
32
- end
33
-
34
- def each(&block)
35
- @table.each(&block)
36
- end
37
-
38
- def has_key?(key)
39
- @table.has_key?(key)
40
- end
41
-
42
- end
43
-
44
- end
45
-
46
- # * George Moschovitis <gm@navel.gr>
@@ -1,37 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
2
-
3
- require 'test/unit'
4
- require 'glue/accumulate'
5
-
6
- class TC_Accumulate < Test::Unit::TestCase # :nodoc: all
7
-
8
- class Project
9
- attr_accessor :groups
10
- end
11
-
12
- class Group
13
- attr_accessor :users
14
- end
15
-
16
- class User
17
- end
18
-
19
- def test_all
20
- pr = Project.new
21
- gr1 = Group.new
22
- gr2 = Group.new
23
- us1 = User.new
24
- us2 = User.new
25
- gr1.users = [ us1 ]
26
- gr2.users = [ us2 ]
27
- pr.groups = [ gr1, gr2 ]
28
-
29
- users = pr.groups.accumulate.users
30
- assert_equal 2, users.size
31
- assert_equal us1, users[0]
32
- assert_equal us2, users[1]
33
- end
34
-
35
- end
36
-
37
- # * George Moschovitis <gm@navel.gr>
@@ -1,22 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
2
-
3
- require 'test/unit'
4
- require 'glue/attribute'
5
-
6
- class TC_Attribute < Test::Unit::TestCase # :nodoc: all
7
-
8
- class Dummy
9
- cattr_accessor :value, 'Default'
10
- cattr_reader :reader, 3
11
- end
12
-
13
- def test_attr
14
- assert_equal 'Default', Dummy.value
15
- assert_nothing_raised { Dummy.value = 2 }
16
- assert_equal 2, Dummy.value
17
-
18
- assert_equal 3, Dummy.reader
19
- assert_raise(NoMethodError) { Dummy.reader = 19 }
20
- end
21
-
22
- end
@@ -1,20 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
2
-
3
- require 'test/unit'
4
- require 'glue/flexob'
5
-
6
- class TC_Flexob < Test::Unit::TestCase # :nodoc: all
7
- include Glue
8
-
9
- def test_all
10
- f = Flexob.new
11
- f.title = 'Test'
12
- f[:another] = 'Another'
13
-
14
- assert_equal 'Test', f.title
15
- assert_equal 'Another', f.another
16
- assert_equal 'Another', f[:another]
17
- assert_equal 'Another', f['another']
18
- end
19
-
20
- end