extlib 0.9.12 → 0.9.13

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

Potentially problematic release.


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

@@ -1,3 +1,11 @@
1
+ === 0.9.13 / 2009-10-15
2
+
3
+ * 3 minor enhancements:
4
+ * Updated LazyArray#head, #tail and #lazy_possible? to be public
5
+ * Refactored Time#to_datetime to not use DateTime.parse
6
+ * Updated Logger to use Array#join instead of Array#to_s to make
7
+ it compatible with Ruby 1.9
8
+
1
9
  === 0.9.12 / 2009-05-05
2
10
 
3
11
  * 4 bug fixes
data/Rakefile CHANGED
@@ -70,7 +70,7 @@ namespace :extlib do
70
70
  Spec::Rake::SpecTask.new(:spec) do |t|
71
71
  t.spec_opts << '--options' << ROOT + 'spec/spec.opts'
72
72
  t.spec_files = Pathname.glob(ENV['FILES'] || 'spec/**/*_spec.rb').map { |f| f.to_s }
73
-
73
+ t.libs << 'lib'
74
74
  begin
75
75
  gem 'rcov'
76
76
  t.rcov = JRUBY ? false : (ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true)
@@ -1,43 +1,35 @@
1
1
  require 'pathname'
2
- require 'rubygems'
3
-
4
- $LOAD_PATH.unshift(File.dirname(__FILE__))
5
2
 
6
3
  # for Pathname /
7
- require File.expand_path(File.join(File.dirname(__FILE__), 'extlib', 'pathname'))
8
-
9
- dir = Pathname(__FILE__).dirname.expand_path / 'extlib'
10
-
11
- require dir / 'class.rb'
12
- require dir / 'object'
13
- require dir / 'object_space'
14
-
15
- require dir / 'array'
16
- require dir / 'string'
17
- require dir / 'symbol'
18
- require dir / 'hash'
19
- require dir / 'mash'
20
- require dir / 'virtual_file'
21
- require dir / 'logger'
22
- require dir / 'time'
23
- require dir / 'datetime'
24
-
25
- require dir / 'assertions'
26
- require dir / 'blank'
27
- require dir / 'boolean'
28
- require dir / 'byte_array'
29
- require dir / 'inflection'
30
- require dir / 'lazy_array'
31
- require dir / 'module'
32
- require dir / 'nil'
33
- require dir / 'numeric'
34
- require dir / 'blank'
35
- require dir / 'simple_set'
36
- require dir / 'struct'
37
- require dir / 'symbol'
38
-
39
- Extlib.autoload('Hook', (dir / 'hook').to_s)
40
- Extlib.autoload('Pooling', (dir / 'pooling').to_s)
4
+ require 'extlib/pathname'
5
+ require 'extlib/class.rb'
6
+ require 'extlib/object'
7
+ require 'extlib/object_space'
8
+ require 'extlib/array'
9
+ require 'extlib/string'
10
+ require 'extlib/symbol'
11
+ require 'extlib/hash'
12
+ require 'extlib/mash'
13
+ require 'extlib/virtual_file'
14
+ require 'extlib/logger'
15
+ require 'extlib/time'
16
+ require 'extlib/datetime'
17
+ require 'extlib/assertions'
18
+ require 'extlib/blank'
19
+ require 'extlib/boolean'
20
+ require 'extlib/byte_array'
21
+ require 'extlib/inflection'
22
+ require 'extlib/lazy_array'
23
+ require 'extlib/module'
24
+ require 'extlib/nil'
25
+ require 'extlib/numeric'
26
+ require 'extlib/blank'
27
+ require 'extlib/simple_set'
28
+ require 'extlib/struct'
29
+ require 'extlib/symbol'
30
+
31
+ Extlib.autoload('Hook', 'extlib/hook')
32
+ Extlib.autoload('Pooling', 'extlib/pooling')
41
33
 
42
34
  module Extlib
43
35
 
@@ -1,6 +1,8 @@
1
1
  class LazyArray # borrowed partially from StrokeDB
2
2
  instance_methods.each { |m| undef_method m unless %w[ __id__ __send__ send class dup object_id kind_of? respond_to? equal? assert_kind_of should should_not instance_variable_set instance_variable_get extend ].include?(m.to_s) }
3
3
 
4
+ attr_reader :head, :tail
5
+
4
6
  def first(*args)
5
7
  if lazy_possible?(@head, *args)
6
8
  @head.first(*args)
@@ -126,7 +128,7 @@ class LazyArray # borrowed partially from StrokeDB
126
128
  def []=(*args)
127
129
  index, length = extract_slice_arguments(*args[0..-2])
128
130
 
129
- if index >= 0 && lazy_possible?(@head, index + length)
131
+ if index >= 0 && lazy_possible?(@head, index + length)
130
132
  @head.[]=(*args)
131
133
  elsif index < 0 && lazy_possible?(@tail, index.abs - 1 + length)
132
134
  @tail.[]=(*args)
@@ -170,8 +172,6 @@ class LazyArray # borrowed partially from StrokeDB
170
172
  self
171
173
  end
172
174
 
173
- alias add <<
174
-
175
175
  def concat(other)
176
176
  if loaded?
177
177
  lazy_load
@@ -335,10 +335,6 @@ class LazyArray # borrowed partially from StrokeDB
335
335
  cmp?(other, :eql?)
336
336
  end
337
337
 
338
- protected
339
-
340
- attr_reader :head, :tail
341
-
342
338
  def lazy_possible?(list, need_length = 1)
343
339
  !loaded? && need_length <= list.size
344
340
  end
@@ -356,15 +352,9 @@ class LazyArray # borrowed partially from StrokeDB
356
352
  end
357
353
 
358
354
  def initialize_copy(original)
359
- if original.loaded?
360
- mark_loaded
361
- @array = @array.dup
362
- @head = @tail = nil
363
- else
364
- @head = @head.dup
365
- @tail = @tail.dup
366
- @array = @array.dup
367
- end
355
+ @head = @head.try_dup
356
+ @tail = @tail.try_dup
357
+ @array = @array.try_dup
368
358
  end
369
359
 
370
360
  def lazy_load
@@ -123,7 +123,7 @@ module Extlib
123
123
  # Flush the entire buffer to the log object.
124
124
  def flush
125
125
  return unless @buffer.size > 0
126
- @log.write(@buffer.slice!(0..-1).to_s)
126
+ @log.write(@buffer.slice!(0..-1).join)
127
127
  end
128
128
 
129
129
  # Close and remove the current log object.
@@ -38,6 +38,6 @@ class Time
38
38
  # @api public
39
39
  remove_method :to_datetime if instance_methods(false).any? { |m| m.to_sym == :to_datetime }
40
40
  def to_datetime
41
- DateTime.parse self.to_s
41
+ DateTime.new(year, month, day, hour, min, sec, Rational(gmt_offset, 24 * 3600))
42
42
  end
43
43
  end
@@ -1,3 +1,3 @@
1
1
  module Extlib
2
- VERSION = '0.9.12'
2
+ VERSION = '0.9.13'
3
3
  end
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), "spec_helper")
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2
2
 
3
3
  class Grandparent
4
4
  end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2
2
  require 'json'
3
3
 
4
4
  describe DateTime, "#to_time" do
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2
2
  require "date"
3
3
  require 'bigdecimal'
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
2
 
3
3
  describe Extlib::Inflection, "#singular" do
4
4
  it "pluralizes equipment => equipment" do
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
2
 
3
3
  describe Extlib::Inflection, "#singular" do
4
4
  # ==== exceptional cases
@@ -158,18 +158,16 @@ end
158
158
  end
159
159
  end
160
160
 
161
- [ :add, :<< ].each do |method|
162
- should_respond_to(method)
161
+ should_respond_to(:<<)
163
162
 
164
- describe "##{method}" do
165
- action { subject.send(method, @steve) }
163
+ describe '#<<' do
164
+ action { subject << @steve }
166
165
 
167
- should_return_subject
168
- should_not_be_a_kicker
166
+ should_return_subject
167
+ should_not_be_a_kicker
169
168
 
170
- it 'should append an entry' do
171
- subject.send(method, @steve).should == [ @nancy, @bessie, @steve ]
172
- end
169
+ it 'should append an entry' do
170
+ (subject << @steve).should == [ @nancy, @bessie, @steve ]
173
171
  end
174
172
  end
175
173
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2
2
 
3
3
  describe Extlib::SimpleSet do
4
4
 
@@ -3,4 +3,8 @@ require "rubygems"
3
3
  require "spec"
4
4
  require "yaml"
5
5
 
6
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'extlib'))
6
+ dir = File.dirname(__FILE__)
7
+ lib_path = File.expand_path("#{dir}/../lib")
8
+ $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
9
+
10
+ require 'extlib'
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2
2
  require 'json'
3
3
 
4
4
  describe Time, "#to_json" do
@@ -20,3 +20,10 @@ describe Time, "#to_time" do
20
20
  time.to_time.should == time
21
21
  end
22
22
  end
23
+
24
+ describe Time, "#to_datetime" do
25
+ it "should return an equivalent DateTime" do
26
+ time = Time.now
27
+ time.to_datetime.should == DateTime.parse(time.to_s)
28
+ end
29
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.12
4
+ version: 0.9.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Kubb
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-05 00:00:00 +02:00
12
+ date: 2009-09-15 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  requirements: []
112
112
 
113
113
  rubyforge_project:
114
- rubygems_version: 1.3.2
114
+ rubygems_version: 1.3.5
115
115
  signing_key:
116
116
  specification_version: 3
117
117
  summary: Support library for DataMapper and Merb.