extlib 0.9.12 → 0.9.13
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.
Potentially problematic release.
This version of extlib might be problematic. Click here for more details.
- data/History.txt +8 -0
- data/Rakefile +1 -1
- data/lib/extlib.rb +29 -37
- data/lib/extlib/lazy_array.rb +6 -16
- data/lib/extlib/logger.rb +1 -1
- data/lib/extlib/time.rb +1 -1
- data/lib/extlib/version.rb +1 -1
- data/spec/class_spec.rb +1 -1
- data/spec/datetime_spec.rb +1 -1
- data/spec/hash_spec.rb +1 -1
- data/spec/inflection/plural_spec.rb +1 -1
- data/spec/inflection/singular_spec.rb +1 -1
- data/spec/lazy_array_spec.rb +7 -9
- data/spec/simple_set_spec.rb +1 -1
- data/spec/spec_helper.rb +5 -1
- data/spec/time_spec.rb +8 -1
- metadata +3 -3
    
        data/History.txt
    CHANGED
    
    | @@ -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)
         | 
    
        data/lib/extlib.rb
    CHANGED
    
    | @@ -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  | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
            require  | 
| 12 | 
            -
            require  | 
| 13 | 
            -
            require  | 
| 14 | 
            -
             | 
| 15 | 
            -
            require  | 
| 16 | 
            -
            require  | 
| 17 | 
            -
            require  | 
| 18 | 
            -
            require  | 
| 19 | 
            -
            require  | 
| 20 | 
            -
            require  | 
| 21 | 
            -
            require  | 
| 22 | 
            -
            require  | 
| 23 | 
            -
            require  | 
| 24 | 
            -
             | 
| 25 | 
            -
            require  | 
| 26 | 
            -
            require  | 
| 27 | 
            -
            require  | 
| 28 | 
            -
            require  | 
| 29 | 
            -
            require  | 
| 30 | 
            -
            require  | 
| 31 | 
            -
            require  | 
| 32 | 
            -
            require  | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 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 |  | 
    
        data/lib/extlib/lazy_array.rb
    CHANGED
    
    | @@ -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 && | 
| 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 | 
            -
                 | 
| 360 | 
            -
             | 
| 361 | 
            -
             | 
| 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
         | 
    
        data/lib/extlib/logger.rb
    CHANGED
    
    | @@ -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). | 
| 126 | 
            +
                  @log.write(@buffer.slice!(0..-1).join)
         | 
| 127 127 | 
             
                end
         | 
| 128 128 |  | 
| 129 129 | 
             
                # Close and remove the current log object.
         | 
    
        data/lib/extlib/time.rb
    CHANGED
    
    | @@ -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. | 
| 41 | 
            +
                DateTime.new(year, month, day, hour, min, sec, Rational(gmt_offset, 24 * 3600))
         | 
| 42 42 | 
             
              end
         | 
| 43 43 | 
             
            end
         | 
    
        data/lib/extlib/version.rb
    CHANGED
    
    
    
        data/spec/class_spec.rb
    CHANGED
    
    
    
        data/spec/datetime_spec.rb
    CHANGED
    
    
    
        data/spec/hash_spec.rb
    CHANGED
    
    
    
        data/spec/lazy_array_spec.rb
    CHANGED
    
    | @@ -158,18 +158,16 @@ end | |
| 158 158 | 
             
                  end
         | 
| 159 159 | 
             
                end
         | 
| 160 160 |  | 
| 161 | 
            -
                 | 
| 162 | 
            -
                  should_respond_to(method)
         | 
| 161 | 
            +
                should_respond_to(:<<)
         | 
| 163 162 |  | 
| 164 | 
            -
             | 
| 165 | 
            -
             | 
| 163 | 
            +
                describe '#<<' do
         | 
| 164 | 
            +
                  action { subject << @steve }
         | 
| 166 165 |  | 
| 167 | 
            -
             | 
| 168 | 
            -
             | 
| 166 | 
            +
                  should_return_subject
         | 
| 167 | 
            +
                  should_not_be_a_kicker
         | 
| 169 168 |  | 
| 170 | 
            -
             | 
| 171 | 
            -
             | 
| 172 | 
            -
                    end
         | 
| 169 | 
            +
                  it 'should append an entry' do
         | 
| 170 | 
            +
                    (subject << @steve).should == [ @nancy, @bessie, @steve ]
         | 
| 173 171 | 
             
                  end
         | 
| 174 172 | 
             
                end
         | 
| 175 173 |  | 
    
        data/spec/simple_set_spec.rb
    CHANGED
    
    
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -3,4 +3,8 @@ require "rubygems" | |
| 3 3 | 
             
            require "spec"
         | 
| 4 4 | 
             
            require "yaml"
         | 
| 5 5 |  | 
| 6 | 
            -
             | 
| 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'
         | 
    
        data/spec/time_spec.rb
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            require File.dirname(__FILE__)  | 
| 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. | 
| 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- | 
| 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. | 
| 114 | 
            +
            rubygems_version: 1.3.5
         | 
| 115 115 | 
             
            signing_key: 
         | 
| 116 116 | 
             
            specification_version: 3
         | 
| 117 117 | 
             
            summary: Support library for DataMapper and Merb.
         |