glue 0.40.0 → 0.41.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.
@@ -20,26 +20,25 @@ class Module
20
20
 
21
21
  def #{m} *args
22
22
  # gmosx: this is a hack, rethink!
23
+ # Jo: still hackish, alot faster
23
24
 
24
- unless klass = args.last.is_a?(Hash) ? args.last[:class] : nil
25
- for a in args
26
- if a.is_a? Class
27
- klass = a
28
- break
29
- end
30
- end
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
31
30
  end
32
-
31
+
33
32
  # If the class defines the included_as_property callback
34
33
  # call to modify the base with custom code.
35
34
 
36
- if klass.respond_to? :included_as_property
35
+ if klass.respond_to? :included_as_property
37
36
  klass.included_as_property(self, args)
38
37
  else
39
38
  #{m}_previous *args
40
39
  end
41
40
 
42
- unless serializable_attributes.empty?
41
+ if klass && !serializable_attributes.empty?
43
42
  include Og::EntityMixin unless ancestors.include?(Og::EntityMixin)
44
43
  include Glue::Validation unless ancestors.include?(Glue::Validation)
45
44
  include Aspects unless ancestors.include?(Aspects)
@@ -117,13 +117,45 @@ class Configuration
117
117
  # use the parameters for the live (production)
118
118
  # server. Optimized for speed.
119
119
  #
120
- # Tries to set the default value from the CONFIGURATION_MODE
120
+ # Tries to set the default value from the NITRO_MODE
121
121
  # environment variable.
122
122
 
123
123
  attr_accessor :mode
124
124
 
125
125
  def mode
126
- @mode || ENV.fetch('CONFIGURATION_MODE', :debug).to_sym
126
+ mode = nil
127
+ if mode = ENV['CONFIGURATION_MODE']
128
+ $stderr.puts "CONFIGURATION_MODE is deprecated, use NITRO_MODE"
129
+ end
130
+ @mode || mode || ENV.fetch('NITRO_MODE', :debug).to_sym
131
+ end
132
+
133
+ # The log output destination.
134
+ #
135
+ # ['STDOUT' 'STDERR']
136
+ # Sets the log to stdout or stderr.
137
+ #
138
+ # [str]
139
+ # Any other string is regarded as path
140
+
141
+ attr_accessor :log
142
+
143
+ def log
144
+ return @log if @log
145
+
146
+ log = ENV.fetch('NITRO_LOG', Logger.new('log/app.log'))
147
+
148
+ if log.kind_of?(String)
149
+ if log =~ /(STD(?:OUT|ERR))/i
150
+ log = Object.const_get($1.upcase)
151
+ elsif File.directory?(File.dirname(log))
152
+ log = Logger.new(log)
153
+ else
154
+ log = 'log/app.log'
155
+ end
156
+ end
157
+
158
+ @log = log
127
159
  end
128
160
 
129
161
  alias kernel_load load
@@ -118,18 +118,16 @@ class Logger
118
118
  # Set the global Logger.
119
119
 
120
120
  def self.set(logger)
121
- if logger.is_a?(String)
121
+ if logger.is_a?(String) || logger.is_a?(IO)
122
122
  @@global_logger = Logger.new(logger)
123
- @@global_logger.setup_format do |severity, timestamp, progname, msg|
124
- SIMPLE_FORMAT % [severity, msg]
125
- end
126
123
  elsif logger.is_a?(Logger)
127
124
  @@global_logger = logger
128
- @@global_logger.setup_format do |severity, timestamp, progname, msg|
129
- SIMPLE_FORMAT % [severity, msg]
130
- end
131
125
  else
132
- raise ArgumentError.new
126
+ raise ArgumentError
127
+ end
128
+
129
+ @@global_logger.setup_format do |severity, timestamp, progname, msg|
130
+ SIMPLE_FORMAT % [severity, msg]
133
131
  end
134
132
  end
135
133
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: glue
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.40.0
7
- date: 2006-11-13 10:56:17 +02:00
6
+ version: 0.41.0
7
+ date: 2006-12-12 12:36:45 +02:00
8
8
  summary: Utility methods and classes for Nitro + Og
9
9
  require_paths:
10
10
  - lib