activesupport 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activesupport might be problematic. Click here for more details.

data/CHANGELOG CHANGED
@@ -1,3 +1,24 @@
1
+ *1.2.3* (November 7th, 2005)
2
+
3
+ * Define kernel.rb methods in "class Object" instead of "module Kernel" to work around a Windows peculiarity [Sam Stephenson]
4
+
5
+ * Fix broken tests caused by incomplete loading of active support. [Nicholas Seckar]
6
+
7
+ * Fix status pluralization bug so status_codes doesn't get pluralized as statuses_code. #2758 [keithm@infused.org]
8
+
9
+ * Added Kernel#silence_stderr to silence stderr for the duration of the given block [Sam Stephenson]
10
+
11
+ * Changed Kernel#` to print a message to stderr (like Unix) instead of raising Errno::ENOENT on Win32 [Sam Stephenson]
12
+
13
+ * Changed 0.blank? to false rather than true since it violates everyone's expectation of blankness. #2518, #2705 [rails@jeffcole.net]
14
+
15
+ * When loading classes using const_missing, raise a NameError if and only if the file we tried to load was not present. [Nicholas Seckar]
16
+
17
+ * Added petabytes and exebytes to numeric extensions #2397 [timct@mac.com]
18
+
19
+ * Added Time#end_of_month to accompany Time#beginning_of_month #2514 [Jens-Christian Fischer]
20
+
21
+
1
22
  *1.2.2* (October 26th, 2005)
2
23
 
3
24
  * Set Logger.silencer = false to disable Logger#silence. Useful for debugging fixtures.
@@ -32,5 +32,7 @@ class String #:nodoc:
32
32
  end
33
33
 
34
34
  class Numeric #:nodoc:
35
- alias_method :blank?, :zero?
36
- end
35
+ def blank?
36
+ false
37
+ end
38
+ end
@@ -1,4 +1,4 @@
1
- module Kernel
1
+ class Object
2
2
  # A Ruby-ized realization of the K combinator, courtesy of Mikael Brockman.
3
3
  #
4
4
  # def foo
@@ -29,6 +29,32 @@ module Kernel
29
29
  $VERBOSE = old_verbose
30
30
  end
31
31
 
32
+ # Silences stderr for the duration of the block.
33
+ #
34
+ # silence_stderr do
35
+ # $stderr.puts 'This will never be seen'
36
+ # end
37
+ #
38
+ # $stderr.puts 'But this will'
39
+ def silence_stderr
40
+ old_stderr = STDERR.dup
41
+ STDERR.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
42
+ STDERR.sync = true
43
+ yield
44
+ ensure
45
+ STDERR.reopen(old_stderr)
46
+ end
47
+
48
+ # Makes backticks behave (somewhat more) similarly on all platforms.
49
+ # On win32 `nonexistent_command` raises Errno::ENOENT; on Unix, the
50
+ # spawned shell prints a message to stderr and sets $?. We emulate
51
+ # Unix on the former but not the latter.
52
+ def `(command) #:nodoc:
53
+ super
54
+ rescue Errno::ENOENT => e
55
+ STDERR.puts "#$0: #{e}"
56
+ end
57
+
32
58
  # Method that requires a library, ensuring that rubygems is loaded
33
59
  def require_library_or_gem(library_name)
34
60
  begin
@@ -27,6 +27,17 @@ module ActiveSupport #:nodoc:
27
27
  self * 1024.gigabytes
28
28
  end
29
29
  alias :terabyte :terabytes
30
+
31
+ def petabytes
32
+ self * 1024.terabytes
33
+ end
34
+ alias :petabyte :petabytes
35
+
36
+ def exabytes
37
+ self * 1024.petabytes
38
+ end
39
+ alias :exabyte :exabytes
40
+
30
41
  end
31
42
  end
32
43
  end
@@ -14,19 +14,17 @@ class Object #:nodoc:
14
14
  subclasses
15
15
  end
16
16
 
17
- # "", " ", nil, and 0 are all blank
17
+ # "", " ", nil, [], and {} are blank
18
18
  def blank?
19
19
  if respond_to?(:empty?) && respond_to?(:strip)
20
- strip.empty?
21
- elsif respond_to? :empty?
20
+ empty? or strip.empty?
21
+ elsif respond_to?(:empty?)
22
22
  empty?
23
- elsif respond_to? :zero?
24
- zero?
25
23
  else
26
24
  !self
27
25
  end
28
26
  end
29
-
27
+
30
28
  def suppress(*exception_classes)
31
29
  begin yield
32
30
  rescue Exception => e
@@ -145,6 +145,14 @@ module ActiveSupport #:nodoc:
145
145
  end
146
146
  alias :at_beginning_of_month :beginning_of_month
147
147
 
148
+ # Returns a new Time representing the end of the month (last day of the month, 0:00)
149
+ def end_of_month
150
+ #self - ((self.mday-1).days + self.seconds_since_midnight)
151
+ last_day = ::Time.days_in_month( self.month, self.year )
152
+ change(:mday => last_day,:hour => 0, :min => 0, :sec => 0, :usec => 0)
153
+ end
154
+ alias :at_end_of_month :end_of_month
155
+
148
156
  # Returns a new Time representing the start of the year (1st of january, 0:00)
149
157
  def beginning_of_year
150
158
  change(:month => 1,:mday => 1,:hour => 0, :min => 0, :sec => 0, :usec => 0)
@@ -1,4 +1,5 @@
1
1
  require File.dirname(__FILE__) + '/module_attribute_accessors'
2
+ require File.dirname(__FILE__) + '/core_ext/load_error'
2
3
 
3
4
  module Dependencies #:nodoc:
4
5
  extend self
@@ -188,15 +189,15 @@ class Module #:nodoc:
188
189
  return Object::Controllers.const_get(class_id)
189
190
  end
190
191
 
192
+ file_name = class_id.to_s.demodulize.underscore
191
193
  begin
192
- require_dependency(class_id.to_s.demodulize.underscore)
193
- if Object.const_defined?(class_id) then return Object.const_get(class_id) else raise LoadError end
194
- rescue LoadError => e
195
- begin
196
- rails_original_const_missing(class_id)
197
- rescue Exception
198
- raise NameError.new("uninitialized constant #{class_id}").copy_blame!(e)
199
- end
194
+ require_dependency(file_name)
195
+ raise NameError.new("uninitialized constant #{class_id}") unless Object.const_defined?(class_id)
196
+ return Object.const_get(class_id)
197
+ rescue MissingSourceFile => e
198
+ # Convert the exception to a NameError only if the file we are looking for is the missing one.
199
+ raise unless e.path == "#{file_name}.rb"
200
+ raise NameError.new("uninitialized constant #{class_id}").copy_blame!(e)
200
201
  end
201
202
  end
202
203
  end
@@ -3,7 +3,7 @@ Inflector.inflections do |inflect|
3
3
  inflect.plural /s$/i, 's'
4
4
  inflect.plural /(ax|test)is$/i, '\1es'
5
5
  inflect.plural /(octop|vir)us$/i, '\1i'
6
- inflect.plural /(alias|status)/i, '\1es'
6
+ inflect.plural /(alias|status)$/i, '\1es'
7
7
  inflect.plural /(bu)s$/i, '\1ses'
8
8
  inflect.plural /(buffal|tomat)o$/i, '\1oes'
9
9
  inflect.plural /([ti])um$/i, '\1a'
@@ -50,4 +50,4 @@ Inflector.inflections do |inflect|
50
50
  inflect.irregular 'move', 'moves'
51
51
 
52
52
  inflect.uncountable %w( equipment information rice money species series fish sheep )
53
- end
53
+ end
@@ -2,7 +2,7 @@ module ActiveSupport
2
2
  module Version #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 2
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: activesupport
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.2.2
7
- date: 2005-10-26 00:00:00 +02:00
6
+ version: 1.2.3
7
+ date: 2005-11-07 00:00:00 +01:00
8
8
  summary: Support and utility classes used by the Rails framework.
9
9
  require_paths:
10
10
  - lib