diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml new file mode 100644 index 00000000..a1cbaa9c --- /dev/null +++ b/.github/workflows/development.yml @@ -0,0 +1,45 @@ +name: Development + +on: [push, pull_request] + +jobs: + test: + name: ${{matrix.ruby}} on ${{matrix.os}} + runs-on: ${{matrix.os}}-latest + continue-on-error: ${{matrix.experimental}} + + strategy: + matrix: + os: + - ubuntu + - macos + + ruby: + - "2.7" + - "3.0" + - "3.1" + + experimental: [false] + env: [""] + + include: + - os: ubuntu + ruby: truffleruby + experimental: true + - os: ubuntu + ruby: jruby + experimental: true + - os: ubuntu + ruby: head + experimental: true + + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{matrix.ruby}} + bundler-cache: true + + - name: Run tests + timeout-minutes: 5 + run: ${{matrix.env}} bundle exec rake diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a2c4714b..00000000 --- a/.travis.yml +++ /dev/null @@ -1,35 +0,0 @@ -language: ruby - -sudo: false - -before_install: - - gem update --system - # bundler installation needed for jruby-head - # https://github.com/travis-ci/travis-ci/issues/5861 - - gem install bundler - -script: "bundle exec rubytest -Ilib test/ --verbose" -bundler_args: --without guard - -rvm: - - 2.0.0 - - 2.1.10 - - 2.2.4 - - 2.3.2 - - 2.4.0 - - rbx - - jruby-9.0.5.0 - - jruby-9.1.5.0 - - jruby-head - -matrix: - allow_failures: - - rvm: rbx - -cache: bundler - -# Use Java 8 for jruby to fix some Java 7 bugs. -addons: - apt: - packages: - - oracle-java8-set-default diff --git a/MANIFEST b/MANIFEST index d609eaa7..28c880a6 100644 --- a/MANIFEST +++ b/MANIFEST @@ -187,7 +187,6 @@ lib/core/facets/hash/count.rb lib/core/facets/hash/data.rb lib/core/facets/hash/dearray_values.rb lib/core/facets/hash/deep_merge.rb -lib/core/facets/hash/deep_rekey.rb lib/core/facets/hash/delete.rb lib/core/facets/hash/delete_at.rb lib/core/facets/hash/delete_unless.rb @@ -213,7 +212,6 @@ lib/core/facets/hash/op_push.rb lib/core/facets/hash/op_sub.rb lib/core/facets/hash/recurse.rb lib/core/facets/hash/recursively.rb -lib/core/facets/hash/rekey.rb lib/core/facets/hash/replace_each.rb lib/core/facets/hash/revalue.rb lib/core/facets/hash/reverse_merge.rb @@ -978,7 +976,6 @@ test/core/hash/test_op_push.rb test/core/hash/test_op_sub.rb test/core/hash/test_recurse.rb test/core/hash/test_recursively.rb -test/core/hash/test_rekey.rb test/core/hash/test_replace_each.rb test/core/hash/test_revalue.rb test/core/hash/test_reverse_merge.rb diff --git a/demo/standard/02_cloneable.rdoc b/demo/standard/02_cloneable.rdoc index b2c3b4d4..6a860477 100644 --- a/demo/standard/02_cloneable.rdoc +++ b/demo/standard/02_cloneable.rdoc @@ -22,10 +22,6 @@ Try #dup. b = a.dup b.bar_id.refute == a.bar_id - a.taint - b = a.dup - b.assert.tainted? - a.freeze b = a.dup b.refute.frozen? @@ -36,10 +32,6 @@ Note try #clone. b = a.clone b.bar_id.refute == a.bar_id - a.taint - b = a.dup - b.assert.tainted? - a.freeze b = a.clone b.assert.frozen? diff --git a/lib/core/facets.rb b/lib/core/facets.rb index 79f88c57..f40c758c 100644 --- a/lib/core/facets.rb +++ b/lib/core/facets.rb @@ -8,7 +8,6 @@ require 'facets/denumerable.rb' require 'facets/dir.rb' require 'facets/enumerable.rb' -require 'facets/enumerator.rb' require 'facets/exception.rb' require 'facets/file.rb' require 'facets/filetest.rb' diff --git a/lib/core/facets.yml b/lib/core/facets.yml index b935324c..cfeaf4e9 100644 --- a/lib/core/facets.yml +++ b/lib/core/facets.yml @@ -67,7 +67,7 @@ paths: - lib/standard name: facets title: Ruby Facets -version: 3.1.0 +version: 4.0.0 summary: The orginal well curated collection of extension methods for Ruby. slogan: ALL YOUR BASE ARE BELONG TO RUBY! description: Facets is the premier collection of extension methods for the Ruby programming diff --git a/lib/core/facets/binding/caller.rb b/lib/core/facets/binding/caller.rb index 76f7093d..91f8f2fd 100644 --- a/lib/core/facets/binding/caller.rb +++ b/lib/core/facets/binding/caller.rb @@ -8,16 +8,22 @@ def caller( skip=0 ) eval("caller(#{skip})") end + # Returns the call stack, same format as Kernel#caller_locations() + # + def caller_locations( skip=0 ) + eval("caller_locations(#{skip})") + end + # Return the line number on which the binding was created. # def __LINE__ - Kernel.eval("__LINE__", self) + self.source_location[1] end # Returns file name in which the binding was created. # def __FILE__ - Kernel.eval("__FILE__", self) + self.source_location[0] end # Return the directory of the file in which the binding was created. diff --git a/lib/core/facets/denumerable.rb b/lib/core/facets/denumerable.rb index c7ad4e53..76905810 100644 --- a/lib/core/facets/denumerable.rb +++ b/lib/core/facets/denumerable.rb @@ -1,6 +1,3 @@ -require 'facets/enumerator' -#require 'facets/enumerable/take' - # Classes which include Denumerable will get versions of map, # select, and so on, which return a Denumerator, so that they # work horizontally without creating intermediate arrays. diff --git a/lib/core/facets/enumerable/each_by.rb b/lib/core/facets/enumerable/each_by.rb index 2d01bbc4..17b663e3 100644 --- a/lib/core/facets/enumerable/each_by.rb +++ b/lib/core/facets/enumerable/each_by.rb @@ -1,5 +1,3 @@ -require 'facets/enumerator' - module Enumerable # Iterate through slices. If slice +steps+ is not diff --git a/lib/core/facets/enumerable/filter.rb b/lib/core/facets/enumerable/filter.rb deleted file mode 100644 index c484e563..00000000 --- a/lib/core/facets/enumerable/filter.rb +++ /dev/null @@ -1,33 +0,0 @@ -module Enumerable - - # The block acts as an arbitrary filter on the data. Unlike map, - # it can choose to drop elements from the result and/or add - # additional elements. The first object passed to the block is - # the receiver of the output. - # - # x = (1..10000) - # x = x.filter{ |out,i| out << i if i % 2 == 0 } # like select - # x = x.filter{ |out,i| out << i + 100 } # like map - # x = x.take(3) - # - # x #=> [102, 104, 106] - # - # This is very similar to #each_with_object, but #filter handles - # argument better by reversing their order and using the splat - # operator. (This was also once known as #injecting.) - # - # CREDIT: David Black, Louis J Scoras - - def filter(output=[]) #:yeild: - if block_given? - each do |*input| - yield(output, *input) - end - output - else - to_enum(:filter) - end - end - -end - diff --git a/lib/core/facets/enumerable/hashify.rb b/lib/core/facets/enumerable/hashify.rb index 9533fe06..ae4b198a 100644 --- a/lib/core/facets/enumerable/hashify.rb +++ b/lib/core/facets/enumerable/hashify.rb @@ -1,4 +1,3 @@ -#require 'facets/enumerator' require 'facets/hash/dearray_values' require 'facets/enumerable/value_by' diff --git a/lib/core/facets/enumerator.rb b/lib/core/facets/enumerator.rb index 65238c0c..6d6e4a3e 100644 --- a/lib/core/facets/enumerator.rb +++ b/lib/core/facets/enumerator.rb @@ -1,75 +1,2 @@ -if RUBY_VERSION < '1.9' - - require 'enumerator' - - # for Ruby 1.8 -> 1.9 transition - Enumerator = Enumerable::Enumerator unless defined?(::Enumerator) - - class Enumerator - - private - - alias :old_initialize :initialize - - # Provides the ruby-1.9 block form of Enumerator, where you can write: - # - # obj = Enumerator.new do |yielder| - # # ... - # yielder.yield(data) # or: yielder << data - # # ... - # end - # - # When obj.each is called, the block is run once. It should call - # yielder.yield with each item it wishes to generate. - # - # Example: - # - # fib = Enumerator.new { |y| - # a = b = 1 - # loop { - # y << a - # a, b = b, a + b - # } - # } - # - # fib.take(10) #=> [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] - # - def initialize(*args, &block) - if block - @body = block - old_initialize(self, :_start) - else - old_initialize(*args) - end - end - - def _start(*args,&receiver) #:nodoc: - @body.call(Yielder.new(&receiver), *args) - end - - # Wrapper to allow yielder.yield(output) or yielder << output - # in the same way as ruby-1.9 - # - # TODO: Why can't Yielder take a block instead of a proc argument? - - class Yielder #:nodoc: - def initialize(&proc) - @proc = proc - end - def yield(*args) - @proc[*args] - end - alias :<< :yield - end - - end - -end - -path = __FILE__.chomp('.rb') -base = File.basename(path) -Dir[File.join(path, '*.rb')].each do |lib| - #require lib # why is this so much slower? - require "facets/#{base}/#{File.basename(lib)}" -end - +require_relative 'enumerator/fx' +require_relative 'enumerator/lazy/squeeze' diff --git a/lib/core/facets/enumerator/fx.rb b/lib/core/facets/enumerator/fx.rb index 5feb0443..7150e294 100644 --- a/lib/core/facets/enumerator/fx.rb +++ b/lib/core/facets/enumerator/fx.rb @@ -11,17 +11,4 @@ def fx end end -# Old 1.8 version (left temporarily for reference) -# -# def fx -# Functor.new(&method(:fx_send).to_proc) -# end -# -# private -# -# def fx_send(op, *a, &b) -# map{ |e| e.send(op, *a, &b) } -# end - end - diff --git a/lib/core/facets/essentials.rb b/lib/core/facets/essentials.rb index b2fdb649..a58155ec 100644 --- a/lib/core/facets/essentials.rb +++ b/lib/core/facets/essentials.rb @@ -45,8 +45,6 @@ #require_relative 'hash/data' require_relative 'hash/delete_values' require_relative 'hash/except' -require_relative 'hash/rekey' -require_relative 'hash/revalue' require_relative 'hash/slice' ### Proc diff --git a/lib/core/facets/hash/deep_rekey.rb b/lib/core/facets/hash/deep_rekey.rb deleted file mode 100644 index 65e67a17..00000000 --- a/lib/core/facets/hash/deep_rekey.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'facets/hash/recurse' -require 'facets/hash/rekey' - -class Hash - - # Rekey a hash and all sub-hashes: - # - # deep_rekey() - # deep_rekey(from_key => to_key, ...) - # deep_rekey{|from_key| to_key} - # deep_rekey{|from_key, value| to_key} - # - # If a key map is given, then the first key is changed to the second key. - # - # foo = { :c=>{ :a=>1, :b=>2 } } - # foo.deep_rekey(:a=>'a') #=> { :c=>{ 'a'=>1, :b=>2 } } - # foo.deep_rekey(:b=>:x) #=> { :c=>{ :a =>1, :x=>2 } } - # foo.deep_rekey('foo'=>'bar') #=> { :c=>{ :a =>1, :b=>2 } } - # - # If a block is given, converts all keys in the Hash accroding to the - # given block procedure. - # - # foo = { :person=>{ :name=>'Gavin', :wife=>:Lisa } } - # foo.deep_rekey{ |k| k.to_s } #=> { "person"=>{ "name"=>"Gavin", "wife"=>:Lisa } } - # foo #=> { "person"=>{ "name"=>"Gavin", "wife"=>:Lisa } } - # - # If no key map or block is given, then all keys are converted - # to Symbols. - # - # Raises an ArgumentError if both a +key_map+ and a block are given. - # If both are needed just call #deep_rekey twice. - # - # TODO: If `nil` is returned by block should the key be set to `nil` or the orignal key? - # - # CREDIT: Trans, Gavin Kistner, Ryan Duryea - - def deep_rekey(key_map=nil, &block) - recurse do |h| - h.rekey(key_map, &block) - end - end - - # Synonym for Hash#deep_rekey, but modifies the receiver in place (and returns it). - # - # foo = { :person=>{ :name=>'Gavin', :wife=>:Lisa } } - # foo.deep_rekey!{ |k| k.to_s } #=> { "person"=>{ "name"=>"Gavin", "wife"=>:Lisa } } - # foo #=> { "person"=>{ "name"=>"Gavin", "wife"=>:Lisa } } - # - # CREDIT: Trans, Gavin Kistner, Ryan Duryea - - def deep_rekey!(key_map=nil, &block) - replace(deep_rekey(key_map, &block)) - end -end diff --git a/lib/core/facets/hash/rekey.rb b/lib/core/facets/hash/rekey.rb deleted file mode 100644 index bee0a33e..00000000 --- a/lib/core/facets/hash/rekey.rb +++ /dev/null @@ -1,81 +0,0 @@ -class Hash - - # Rekey a hash: - # - # rekey() - # rekey(from_key => to_key, ...) - # rekey{|from_key| to_key} - # rekey{|from_key, value| to_key} - # - # If a key map is given, then the first key is changed to the second key. - # - # foo = { :a=>1, :b=>2 } - # foo.rekey(:a=>'a') #=> { 'a'=>1, :b=>2 } - # foo.rekey(:b=>:x) #=> { :a =>1, :x=>2 } - # foo.rekey('foo'=>'bar') #=> { :a =>1, :b=>2 } - # - # If a block is given, converts all keys in the Hash accroding to the - # given block procedure. - # - # foo = { :name=>'Gavin', :wife=>:Lisa } - # foo.rekey{ |k| k.to_s } #=> { "name"=>"Gavin", "wife"=>:Lisa } - # foo #=> { :name =>"Gavin", :wife=>:Lisa } - # - # If no key map or block is given, then all keys are converted - # to Symbols. - # - # Raises an ArgumentError if both a +key_map+ and a block are given. - # If both are needed just call #rekey twice. - # - # TODO: If `nil` is returned by block should the key be set to `nil` or the orignal key? - # - # CREDIT: Trans, Gavin Kistner - - def rekey(key_map=nil, &block) - raise ArgumentError, "argument or block" if key_map && block - - if !(key_map or block) - block = lambda{|k| k.to_sym} - end - - if block - hash = dup.clear - if block.arity.abs == 1 - each_pair do |k, v| - hash[block[k]] = v #hash[block[k] || k] = v - end - else - each_pair do |k, v| - hash[block[k,v]] = v #hash[block[k,v] || k] = v - end - end - else - #hash = dup.clear # to keep default_proc - #(keys - key_map.keys).each do |key| - # hash[key] = self[key] - #end - #key_map.each do |from, to| - # hash[to] = self[from] if key?(from) - #end - hash = dup # to keep default_proc - key_map.each_pair do |from, to| - hash[to] = hash.delete(from) if hash.key?(from) - end - end - - hash - end - - # Synonym for Hash#rekey, but modifies the receiver in place (and returns it). - # - # foo = { :name=>'Gavin', :wife=>:Lisa } - # foo.rekey!{ |k| k.to_s } #=> { "name"=>"Gavin", "wife"=>:Lisa } - # foo #=> { "name"=>"Gavin", "wife"=>:Lisa } - # - # CREDIT: Trans, Gavin Kistner - - def rekey!(key_map=nil, &block) - replace(rekey(key_map, &block)) - end - -end diff --git a/lib/core/facets/hash/revalue.rb b/lib/core/facets/hash/revalue.rb deleted file mode 100644 index 71f1a928..00000000 --- a/lib/core/facets/hash/revalue.rb +++ /dev/null @@ -1,61 +0,0 @@ -class Hash - - # Generates a new hash where the values are the result of the passed in - # block. The block takes both the key and value of the current entry as - # arguments. - # - # hash = { a: 1, b: 2 } - # hash.revalue { |v| v + 1 } # => { a: 2, b: 3 } - # - # Returns [Hash]. - # - # Credit: Sean Mackesey - - def revalue(val_map=nil, &block) - raise ArgumentError, "argument or block, not both" if val_map && block - - if !(val_map or block) - raise ArgumentError, "must provide Hash arguments or a block" - #block = lambda{|v| v.to_s} - end - - if block - hash = dup.clear # to keep default_proc - if block.arity.abs == 1 - each_pair do |k, v| - hash[k] = block[v] #hash[k] = block[v] || v - end - else - each_pair do |k, v| - hash[k] = block[k,v] #hash[k] = block[k,v] || v - end - end - else - hash = dup.clear # to keep default_proc - each do |k,v| - if val_map.key?(v) - hash[k] = val_map[v] - else - hash[k] = v - end - end - end - - hash - end - - # The in-place version of Hash#revalue. - # - # hash = { a: 1, b: 2 } - # hash.revalue! { |v| v + 1 } - # hash # => { a: 2, b: 3 } - # - # Returns [Hash]. - # - # Credit: Sean Mackesey - - def revalue!(val_map=nil, &block) - replace(revalue(val_map, &block)) - end - -end diff --git a/lib/core/facets/range/nudge.rb b/lib/core/facets/range/nudge.rb index b2d3dfa9..f085a57c 100644 --- a/lib/core/facets/range/nudge.rb +++ b/lib/core/facets/range/nudge.rb @@ -25,3 +25,5 @@ def nudge(value = 1, min: nil, max: nil) end end end + +pp "LOADING NUDGE" diff --git a/lib/core/facets/string/ascii_only.rb b/lib/core/facets/string/ascii_only.rb index 1edce207..e8022031 100644 --- a/lib/core/facets/string/ascii_only.rb +++ b/lib/core/facets/string/ascii_only.rb @@ -21,7 +21,7 @@ def ascii_only(alt='') :replace => alt, # Use a blank for those replacements :UNIVERSAL_NEWLINE_DECORATOR => true # Always break lines with \n } - self.encode(Encoding.find('ASCII'), encoding_options) + self.encode(Encoding::ASCII_8BIT, **encoding_options) end # Modify string keeping only ASCII characters. @@ -46,7 +46,7 @@ def ascii_only!(alt='') :replace => alt, # Use a blank for those replacements :UNIVERSAL_NEWLINE_DECORATOR => true # Always break lines with \n } - self.encode!(Encoding.find('ASCII'), encoding_options) + self.encode!(Encoding::ASCII_8BIT, **encoding_options) end end diff --git a/lib/core/facets/string/cleanlines.rb b/lib/core/facets/string/cleanlines.rb index 27002bf2..e4b57183 100644 --- a/lib/core/facets/string/cleanlines.rb +++ b/lib/core/facets/string/cleanlines.rb @@ -1,5 +1,3 @@ -require "facets/enumerator" - class String # Returns an Enumerator for iterating over each diff --git a/lib/core/facets/string/newlines.rb b/lib/core/facets/string/newlines.rb index 2949f543..e9be95a9 100644 --- a/lib/core/facets/string/newlines.rb +++ b/lib/core/facets/string/newlines.rb @@ -1,5 +1,3 @@ -require "facets/enumerator" - class String # Returns an Enumerator for iterating over each diff --git a/lib/core/facets/version.rb b/lib/core/facets/version.rb index ac31cce4..1f1db514 100644 --- a/lib/core/facets/version.rb +++ b/lib/core/facets/version.rb @@ -14,6 +14,6 @@ def self.const_missing(name) end # deprecate - VERSION = '3.0.0' + VERSION = '4.0.0' end diff --git a/lib/standard/facets/find/select.rb b/lib/standard/facets/find/select.rb index b313ad7e..c9a9c7f5 100644 --- a/lib/standard/facets/find/select.rb +++ b/lib/standard/facets/find/select.rb @@ -1,5 +1,3 @@ -require 'facets/enumerator' - module Find # Identical to find except select returns the matching files as an array. # (find returns nil, which is not very useful if you actually wanted an array.) diff --git a/lib/standard/facets/ostruct.rb b/lib/standard/facets/ostruct.rb deleted file mode 100644 index 12ba6e44..00000000 --- a/lib/standard/facets/ostruct.rb +++ /dev/null @@ -1,89 +0,0 @@ -require 'ostruct' -require 'facets/ostruct/initialize' -require 'facets/ostruct/to_h' -require 'facets/ostruct/merge' -require 'facets/ostruct/each' -require 'facets/ostruct/to_ostruct' -require 'facets/ostruct/op_fetch' -require 'facets/ostruct/op_store' - -class OpenStruct - - #-- - # TO BE DEPRECATED - # Must consider that accessing instance_delegate instead can be dangerous. - # Might we us a Functor to ensure the table keys are always symbols? - #++ - - # Provides access to an OpenStruct's inner table. - # - # o = OpenStruct.new - # o.a = 1 - # o.b = 2 - # o.instance_delegate.map { |k, v| "#{k} #{v}" } - # #=> ["a 1", "b 2"] - # - # @deprecated Use `#marshal_dump` instead. - # - def instance_delegate - warn "OpenStruct#instance_delegate is deprecated, use #marshal_dump instead." - @table - end - - # @deprecated Use `#marshal_dump` instead. - alias ostruct_delegate instance_delegate - - # Insert/update hash data on the fly. - # - # o = OpenStruct.new - # o.ostruct_update(:a => 2) - # o.a #=> 2 - # - # @deprecated Use #merge! instead. - # - def ostruct_update(other) - warn "OpenSrtuct#ostruct_update has been deprecated. Use #merge! instead." - merge!(other) - end - - # Insert/update hash data on the fly. - # - # o = OpenStruct.new - # o.ostruct_update(:a => 2) - # o.a #=> 2 - # - # @deprecated Use #merge! instead. - # - def __update__(other) - raise NameError, "OpenSrtuct#__update__ has been deprecated. Use #merge! instead." - #merge!(other) - end - - # TODO: How to handle regular merge, since it lacks punctuation to make it safe. - # Maybe `#update!`? Kind of odd but could work. - - # Merge hash data creating a new OpenStruct object. - # - # o = OpenStruct.new - # x = o.ostruct_merge(:a => 2) - # x.a #=> 2 - # - def ostruct_merge(other) - o = dup - o.merge!(other) - o - end - - # Merge hash data creating a new OpenStruct object. - # - # o = OpenStruct.new - # x = o.__merge__(:a => 2) - # x.a #=> 2 - # - def __merge__(other) - o = dup - o.merge!(other) - o - end - -end diff --git a/lib/standard/facets/ostruct/each.rb b/lib/standard/facets/ostruct/each.rb deleted file mode 100644 index fddaf56a..00000000 --- a/lib/standard/facets/ostruct/each.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'ostruct' - -class OpenStruct - - # Iterate over key-value pairs. - # - def each(&blk) - @table.each(&blk) - end - -end diff --git a/lib/standard/facets/ostruct/initialize.rb b/lib/standard/facets/ostruct/initialize.rb deleted file mode 100644 index e602dc62..00000000 --- a/lib/standard/facets/ostruct/initialize.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'ostruct' - -class OpenStruct - - # Allows the initialization of an OpenStruct with a setter block: - # - # person = OpenStruct.new do |o| - # o.name = 'John Smith' - # o.gender = :M - # o.age = 71 - # end - # - # You can still provide a hash for initialization purposes, and even combine - # the two approaches if you wish. - # - # person = OpenStruct.new(:name => 'John Smith', :age => 31) do |p| - # p.gender = :M - # end - # - # Alternatively you can provide a default block: - # - # stuff = OpenStruct.new{ |o,k| o[k] = [] } - # stuff.place << :a - # stuff.place << :b - # stuff.place #=> [:a, :b] - # - # A setter block versus a defualt block is determined by the arity of - # the block. You cannot provide both at the same time. - # - # CREDIT: Noah Gibbs, Gavin Sinclair - def initialize(hash=nil, &block) - if block && block.arity==2 - @table = Hash.new(&block) - else - @table = {} - end - if hash - for k,v in hash - @table[k.to_sym] = v - new_ostruct_member(k) - end - end - if block && block.arity==1 - yield self - end - end - -end diff --git a/lib/standard/facets/ostruct/merge.rb b/lib/standard/facets/ostruct/merge.rb deleted file mode 100644 index 68458ad6..00000000 --- a/lib/standard/facets/ostruct/merge.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'ostruct' - -class OpenStruct - - # Insert/update hash data on the fly. - # - # o = OpenStruct.new - # o.merge!(:a => 2) - # o.a #=> 2 - # - def merge!(other) - raise TypeError, "can't modify frozen #{self.class}", caller(1) if self.frozen? - ##other = other.to_hash #to_h? - for k,v in other - @table[k.to_sym] = v - end - self - end - -end - diff --git a/lib/standard/facets/ostruct/op_fetch.rb b/lib/standard/facets/ostruct/op_fetch.rb deleted file mode 100644 index e6527c83..00000000 --- a/lib/standard/facets/ostruct/op_fetch.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'ostruct' - -class OpenStruct - - # Access a value in the OpenStruct by key, like a Hash. - # This increases OpenStruct's "duckiness". - # - # o = OpenStruct.new - # o.t = 4 - # o['t'] #=> 4 - # - def [](key) - key = key.to_sym unless key.is_a?(Symbol) - @table[key] - end - - # Set a value in the OpenStruct by key, like a Hash. - # - # o = OpenStruct.new - # o['t'] = 4 - # o.t #=> 4 - # - def []=(key,val) - raise TypeError, "can't modify frozen #{self.class}", caller(1) if self.frozen? - key = key.to_sym unless key.is_a?(Symbol) - @table[key]=val - end - -end diff --git a/lib/standard/facets/ostruct/op_store.rb b/lib/standard/facets/ostruct/op_store.rb deleted file mode 100644 index 7981e08f..00000000 --- a/lib/standard/facets/ostruct/op_store.rb +++ /dev/null @@ -1 +0,0 @@ -require 'facets/ostruct/op_fetch' diff --git a/lib/standard/facets/ostruct/to_h.rb b/lib/standard/facets/ostruct/to_h.rb deleted file mode 100644 index bafa6e15..00000000 --- a/lib/standard/facets/ostruct/to_h.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'ostruct' - -class OpenStruct - - # - def to_h - @table.dup - end - -end diff --git a/lib/standard/facets/ostruct/to_ostruct.rb b/lib/standard/facets/ostruct/to_ostruct.rb deleted file mode 100644 index 6996046d..00000000 --- a/lib/standard/facets/ostruct/to_ostruct.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'ostruct' - -class OpenStruct - # - def to_ostruct - self - end -end - -class Hash - # Turns a hash into a generic object using an OpenStruct. - # - # o = {'a' => 1}.to_ostruct - # o.a #=> 1 - # - def to_ostruct - OpenStruct.new(self) - end - - ## Recursively converts a Hash object to an OpenStruct object. - ## - ## Returns a copy of the hash as an OpenStruct. - #def to_ostruct() - # struct = OpenStruct.new(self.clone()) - # each do |k, v| - # struct.__send__("#{k}=", v.to_ostruct()) if v.is_a?(Hash) - # struct.__send__(k).map! {|x| x.is_a?(Hash) ? x.to_ostruct() : x} if v.is_a?(Array) - # end - # return struct - #end - - # Like `#to_ostruct` but recusively objectifies all hash elements as well. - # - # o = {'a' => { 'b' => 1 }}.to_ostruct_recurse - # o.a.b #=> 1 - # - # The `exclude` parameter is used internally to prevent infinite - # recursion and is not intended to be utilized by the end-user. - # But for more advance use, if there is a particular subhash you - # would like to prevent from being converted to an OpoenStruct - # then include it in the `exclude` hash referencing itself. e.g. - # - # h = { 'a' => { 'b' => 1 } } - # o = h.to_ostruct_recurse( { h['a'] => h['a'] } ) - # o.a['b'] #=> 1 - # - # CREDIT: Alison Rowland, Jamie Macey, Mat Schaffer - def to_ostruct_recurse(exclude={}) - return exclude[self] if exclude.key?( self ) - o = exclude[self] = OpenStruct.new - h = self.dup - each_pair do |k,v| - h[k] = v.to_ostruct_recurse( exclude ) if v.respond_to?(:to_ostruct_recurse) - end - o.merge!(h) - end -end - -class NilClass - # Create an empty OpenStruct object. - def to_ostruct - OpenStruct.new - end -end - diff --git a/lib/standard/facets/uri.rb b/lib/standard/facets/uri.rb index 0b877e3c..02f804b8 100644 --- a/lib/standard/facets/uri.rb +++ b/lib/standard/facets/uri.rb @@ -1,4 +1,5 @@ require 'uri' +require 'cgi' require 'facets/uri/cgi_escape.rb' require 'facets/uri/cgi_unescape.rb' @@ -12,19 +13,19 @@ module URI module Kernel # def uri(s, w=%r{[^a-zA-Z_0-9./-]}) - URI.escape(s, w) + CGI.escape(s, w) end # def unuri(s) - URI.unescape(s) + CGI.unescape(s) end end module Hash # def to_uri - URI.hash_to_query(self) + URI.hash_to_query_string(self) end end diff --git a/lib/standard/facets/uri/query.rb b/lib/standard/facets/uri/query.rb index 84bf0286..180dd6c1 100644 --- a/lib/standard/facets/uri/query.rb +++ b/lib/standard/facets/uri/query.rb @@ -17,7 +17,7 @@ module URI # Given a hash with parameter/value pairs construct a # standard query string. # - # URI.hash_to_query(:a => 1, :b => 2) + # URI.hash_to_query_string(:a => 1, :b => 2) # #=> "a=1;b=2" # def query(parameters) diff --git a/test/core/enumerable/test_filter.rb b/test/core/enumerable/test_filter.rb deleted file mode 100644 index 85140a60..00000000 --- a/test/core/enumerable/test_filter.rb +++ /dev/null @@ -1,19 +0,0 @@ -covers 'facets/enumerable/filter' - -test_case Enumerable do - - method :filter do - - test do - x = (1..10000) - x = x.filter{ |out,i| out << i if i % 2 == 0 } # like select - x = x.filter{ |out,i| out << i + 100 } # like map - x = x.take(3) - - x.assert == [102, 104, 106] - end - - end - -end - diff --git a/test/core/enumerator/test_new.rb b/test/core/enumerator/test_new.rb index f4b7fbf9..be6d3574 100644 --- a/test/core/enumerator/test_new.rb +++ b/test/core/enumerator/test_new.rb @@ -1,5 +1,3 @@ -covers 'facets/enumerator' - test_case Enumerator do class_method :new do diff --git a/test/core/enumerator_tc.rb b/test/core/enumerator_tc.rb deleted file mode 100644 index adacf2c5..00000000 --- a/test/core/enumerator_tc.rb +++ /dev/null @@ -1,40 +0,0 @@ -covers 'facets/enumerator' - -test_case Enumerator::Yielder do - - class_method :new do - - test do - y = Enumerator::Yielder.new{ |x| x + 1 } - end - - end - - method :yield do - - test do - y = Enumerator::Yielder.new{ |x| x + 1 } - y.yield(1).assert == 2 - end - - end - - method :<< do - - test do - a = [] - y = Enumerator::Yielder.new{ |x| a << x + 1 } - y << 1 - a.assert == [2] - end - - test do - a = [] - y = Enumerator::Yielder.new{ |x,y| a << x + y } - y.<<(1,2) - a.assert == [3] - end - - end - -end diff --git a/test/core/hash/test_deep_rekey.rb b/test/core/hash/test_deep_rekey.rb deleted file mode 100644 index be4d2474..00000000 --- a/test/core/hash/test_deep_rekey.rb +++ /dev/null @@ -1,131 +0,0 @@ -covers 'facets/hash/deep_rekey' - -test_case Hash do - - method :deep_rekey do - - test "default converts all keys to symbols" do - foo = { "c"=>{ "a"=>1, "b"=>2 } } - foo.deep_rekey.assert == { :c=>{ :a=>1, :b=>2 } } - foo.assert == { "c"=>{ "a"=>1, "b"=>2 } } - end - - test "specific key" do - bar = { :d=>{ :a=>1, :b=>2 } } - foo = bar.deep_rekey(:a=>:c) - foo[:d][:c].assert == 1 - foo[:d][:b].assert == 2 - foo[:d][:a].assert == nil - end - - test "multiple keys" do - bar = { :z=>{ :a=>1, :b=>2, :c=>3 } } - foo = bar.deep_rekey(:a=>:d,:b=>:e) - foo[:z][:d].assert == 1 - foo[:z][:e].assert == 2 - foo[:z][:c].assert == 3 - foo[:z][:a].assert == nil - foo[:z][:b].assert == nil - end - - test "multiple keys, some on same level as other hash" do - bar = { :z=>{ :a=>1, :b=>2, :c=>3 }, :y=>4 } - foo = bar.deep_rekey(:a=>:d,:b=>:e) - foo[:z][:d].assert == 1 - foo[:z][:e].assert == 2 - foo[:z][:c].assert == 3 - foo[:y].assert == 4 - foo[:z][:a].assert == nil - foo[:z][:b].assert == nil - end - - # TODO: Is using Hash#deep_rekey to exhange keys possible? - - #test "exchange keys via dummy key" do - # bar = { :a=>1, :b=>2, :c=>3 } - # foo = bar.deep_rekey(:a=>:d,:c=>:a,:d=>:c) - # foo[:a].assert == 3 - # foo[:b].assert == 2 - # foo[:c].assert == 1 - # foo[:d].assert == nil - #end - - test "with block" do - bar = { :c=>{ :a=>1, :b=>2 } } - foo = bar.deep_rekey{ |k| k.to_s } - foo['c']['a'].assert == 1 - foo['c']['b'].assert == 2 - foo['c'][:a].assert == nil - foo['c'][:b].assert == nil - foo.assert == { 'c'=>{ 'a'=>1, 'b'=>2 } } - end - - test "with block of key, value" do - bar = { :c=>{ :a=>1, :b=>2 } } - foo = bar.deep_rekey{ |k, v| v.to_s } - k = foo.keys.first - foo[k]['1'].assert == 1 - foo[k]['2'].assert == 2 - foo[k][:a].assert == nil - foo[k][:b].assert == nil - foo[k]['a'].assert == nil - foo[k]['b'].assert == nil - foo.assert == { k=>{ '1'=>1, '2'=>2 } } - end - - test "with keys and block" do - expect ArgumentError do - bar = { :c=>{ :a=>1, :b=>2 } } - bar.deep_rekey(:a=>:c){ |k| k.to_s } - end - end - - test "symbol proc" do - foo = { :c=>{ :a=>1, :b=>2 } } - foo.deep_rekey(&:to_s).assert == { "c"=>{ "a"=>1, "b"=>2 } } - foo.assert == { :c=>{ :a =>1, :b=>2 } } - end - - end - - method :deep_rekey! do - - test "default" do - foo = { "c"=>{ "a"=>1, "b"=>2 } } - foo.deep_rekey!.assert == { :c=>{ :a=>1, :b=>2 } } - foo.assert == { :c=>{ :a=>1, :b=>2 } } - end - - test "specific key" do - foo = { :d=>{ :a=>1, :b=>2 } } - foo.deep_rekey!(:a=>:c) - foo[:d][:c].assert == 1 - foo[:d][:b].assert == 2 - foo[:d][:a].assert == nil - end - - test "with block" do - foo = { :c=>{ :a=>1, :b=>2 } } - foo.deep_rekey!{ |k| k.to_s } - foo['c']['a'].assert == 1 - foo['c']['b'].assert == 2 - foo['c'][:a].assert == nil - foo['c'][:b].assert == nil - foo.assert == { 'c'=>{ 'a'=>1, 'b'=>2 } } - end - - test "symbol proc" do - foo = { :c=>{ :a=>1, :b=>2 } } - foo.deep_rekey!(&:to_s).assert == { "c"=>{ "a"=>1, "b"=>2 } } - foo.assert == { "c"=>{ "a"=>1, "b"=>2 } } - end - - test "no conflict between keys" do - r = { 0 => {1 => :a, 2 => :b} }.deep_rekey!{ |k| k + 1 } - r[1].refute = {3 => :a} - r[1].assert = {2 => :a, 3 => :b} - end - - end - -end diff --git a/test/core/hash/test_rekey.rb b/test/core/hash/test_rekey.rb deleted file mode 100644 index c993c7d4..00000000 --- a/test/core/hash/test_rekey.rb +++ /dev/null @@ -1,119 +0,0 @@ -covers 'facets/hash/rekey' - -test_case Hash do - - method :rekey do - - test "default converts all keys to symbols" do - foo = { "a"=>1, "b"=>2 } - foo.rekey.assert == { :a=>1, :b=>2 } - foo.assert == { "a"=>1, "b"=>2 } - end - - test "specific key" do - bar = { :a=>1, :b=>2 } - foo = bar.rekey(:a=>:c) - foo[:c].assert == 1 - foo[:b].assert == 2 - foo[:a].assert == nil - end - - test "multiple keys" do - bar = { :a=>1, :b=>2, :c=>3 } - foo = bar.rekey(:a=>:d,:b=>:e) - foo[:d].assert == 1 - foo[:e].assert == 2 - foo[:c].assert == 3 - foo[:a].assert == nil - foo[:b].assert == nil - end - - # TODO: Is using Hash#rekey to exhange keys possible? - - #test "exchange keys via dummy key" do - # bar = { :a=>1, :b=>2, :c=>3 } - # foo = bar.rekey(:a=>:d,:c=>:a,:d=>:c) - # foo[:a].assert == 3 - # foo[:b].assert == 2 - # foo[:c].assert == 1 - # foo[:d].assert == nil - #end - - test "with block" do - bar = { :a=>1, :b=>2 } - foo = bar.rekey{ |k| k.to_s } - foo['a'].assert == 1 - foo['b'].assert == 2 - foo[:a].assert == nil - foo[:b].assert == nil - foo.assert == { 'a'=>1, 'b'=>2 } - end - - test "with block of key, value" do - bar = { :a=>1, :b=>2 } - foo = bar.rekey{ |k, v| v.to_s } - foo['1'].assert == 1 - foo['2'].assert == 2 - foo[:a].assert == nil - foo[:b].assert == nil - foo['a'].assert == nil - foo['b'].assert == nil - foo.assert == { '1'=>1, '2'=>2 } - end - - test "with keys and block" do - expect ArgumentError do - bar = { :a=>1, :b=>2 } - bar.rekey(:a=>:c){ |k| k.to_s } - end - end - - test "symbol proc" do - foo = { :a=>1, :b=>2 } - foo.rekey(&:to_s).assert == { "a"=>1, "b"=>2 } - foo.assert == { :a =>1, :b=>2 } - end - - end - - method :rekey! do - - test "default" do - foo = { "a"=>1, "b"=>2 } - foo.rekey!.assert == { :a=>1, :b=>2 } - foo.assert == { :a=>1, :b=>2 } - end - - test "specific key" do - foo = { :a=>1, :b=>2 } - foo.rekey!(:a=>:c) - foo[:c].assert == 1 - foo[:b].assert == 2 - foo[:a].assert == nil - end - - test "with block" do - foo = { :a=>1, :b=>2 } - foo.rekey!{ |k| k.to_s } - foo['a'].assert == 1 - foo['b'].assert == 2 - foo[:a].assert == nil - foo[:b].assert == nil - foo.assert == { 'a'=>1, 'b'=>2 } - end - - test "symbol proc" do - foo = { :a=>1, :b=>2 } - foo.rekey!(&:to_s).assert == { "a"=>1, "b"=>2 } - foo.assert == { "a"=>1, "b"=>2 } - end - - test "no conflict between keys" do - r = {1 => :a, 2 => :b}.rekey!{ |k| k + 1 } - r.refute = {3 => :a} - r.assert = {2 => :a, 3 => :b} - end - - end - -end diff --git a/test/core/hash/test_revalue.rb b/test/core/hash/test_revalue.rb deleted file mode 100644 index 49611a0e..00000000 --- a/test/core/hash/test_revalue.rb +++ /dev/null @@ -1,98 +0,0 @@ -covers 'facets/hash/revalue' - -test_case Hash do - - method :revalue do - - #test "default converts all keys to symbols" do - # foo = { "a"=>1, "b"=>2 } - # foo.rekey.assert == { :a=>1, :b=>2 } - # foo.assert == { "a"=>1, "b"=>2 } - #end - - test "specific value" do - bar = { :a=>1, :b=>2 } - foo = bar.revalue(2=>3) - foo[:a].assert == 1 - foo[:b].assert == 3 - foo.size.assert == 2 - end - - test "multiple values" do - bar = { :a=>1, :b=>2, :c=>3 } - foo = bar.revalue(1=>4,3=>5) - foo[:a].assert == 4 - foo[:b].assert == 2 - foo[:c].assert == 5 - foo.size.assert == 3 - end - - test "with block" do - bar = { :a=>1, :b=>2 } - foo = bar.revalue{ |v| v.to_s } - foo[:a].assert == "1" - foo[:b].assert == "2" - foo.assert == { :a=>"1", :b=>"2" } - end - - test "with block of key, value" do - bar = { :a=>1, :b=>2 } - foo = bar.revalue{ |k, v| [k,v] } - foo[:a].assert == [:a,1] - foo[:b].assert == [:b,2] - foo.assert == { :a=>[:a,1], :b=>[:b,2] } - end - - test "with values and block" do - expect ArgumentError do - bar = { :a=>1, :b=>2 } - bar.revalue(1=>3){ |v| v.to_s } - end - end - - test "symbol proc" do - foo = { :a=>1, :b=>2 } - foo.revalue(&:to_s).assert == { :a=>"1", :b=>"2" } - foo.assert == { :a =>1, :b=>2 } - end - - end - - method :revalue! do - - #test "default" do - # foo = { "a"=>1, "b"=>2 } - # foo.revalue!.assert == { :a=>1, :b=>2 } - # foo.assert == { :a=>1, :b=>2 } - #end - - test "specific value" do - foo = { :a=>1, :b=>2 } - foo.revalue!(1=>3) - foo[:a].assert == 3 - foo[:b].assert == 2 - end - - test "with block" do - foo = { :a=>1, :b=>2 } - foo.revalue!{ |v| v.to_s } - foo[:a].assert == "1" - foo[:b].assert == "2" - foo.assert == { :a=>"1", :b=>"2" } - end - - test "symbol proc" do - foo = { :a=>1, :b=>2 } - foo.revalue!(&:to_s).assert == { :a=>"1", :b=>"2" } - foo.assert == { :a=>"1", :b=>"2" } - end - - test "no conflict between keys" do - r = {:a => 1, :b => 2}.revalue!{ |v| v + 1 } - r.refute = {:a => 3} - r.assert = {:a => 2, :b => 3} - end - - end - -end diff --git a/test/core/range/test_nudge.rb b/test/core/range/test_nudge.rb index 84c0407b..852c5de8 100644 --- a/test/core/range/test_nudge.rb +++ b/test/core/range/test_nudge.rb @@ -19,13 +19,14 @@ end test 'min nudge' do - (5..9).nudge(:min => 2).assert == (7..9) - (5...9).nudge(:min => 2).assert == (7...9) + binding.irb + (5..9).nudge(min: 2).assert == (7..9) + (5...9).nudge(min: 2).assert == (7...9) end test 'max nudge' do - (8..16).nudge(:max => 10).assert == (8..26) - (8...16).nudge(:max => 10).assert == (8...26) + (8..16).nudge(max: 10).assert == (8..26) + (8...16).nudge(max: 10).assert == (8...26) end end end diff --git a/test/standard/test_cloneable.rb b/test/standard/test_cloneable.rb index 7a50218f..e61cdaf6 100644 --- a/test/standard/test_cloneable.rb +++ b/test/standard/test_cloneable.rb @@ -19,13 +19,6 @@ def bar_id a.bar_id.refute == b.bar_id end - test "tainted" do - a = foo.new - a.taint - b = a.dup - b.assert.tainted? - end - test "frozen" do a = foo.new a.freeze @@ -41,13 +34,6 @@ def bar_id assert(a.bar_id != b.bar_id, "should not be equal") end - test "tainted" do - a = foo.new - a.taint - b = a.clone - assert b.tainted?, "b should be tainted" - end - test "frozen" do a = foo.new a.freeze diff --git a/test/standard/test_ostruct.rb b/test/standard/test_ostruct.rb deleted file mode 100644 index 5682522f..00000000 --- a/test/standard/test_ostruct.rb +++ /dev/null @@ -1,191 +0,0 @@ -covers 'facets/ostruct' - -test_case OpenStruct do - - method :merge! do - test do - o = OpenStruct.new(:a => 1) - h = { :b => 2 } - o.merge!(h) - o.b.assert == 2 - end - - test do - o = OpenStruct.new( { :a => 1 } ) - h = { :b => 2 } - o.merge!(h) - o.b.assert == 2 - end - end - - method :__merge__ do - test do - o = OpenStruct.new( { :a => 1 } ) - h = { :b => 2 } - q = o.__merge__( h ) - q.a.assert == 1 - q.b.assert == 2 - end - - test do - o1 = OpenStruct.new( { :a => 1 } ) - o2 = OpenStruct.new( { :b => 2 } ) - q = o1.__merge__( o2 ) - q.a.assert == 1 - q.b.assert == 2 - end - - test "with_hash" do - o = OpenStruct.new( { :a => 1 } ) - h = { :b => 2 } - q = o.__merge__(h) - q.a.assert == 1 - q.b.assert == 2 - end - - test "two open structs" do - o1 = OpenStruct.new( { :a => 1 } ) - o2 = OpenStruct.new( { :b => 2 } ) - q = o1.__merge__(o2) - q.a.assert == 1 - q.b.assert == 2 - end - end - - # @deprecated - #method :instance_delegate do - # test "store" do - # o = OpenStruct.new(:a => 1) - # o.instance_delegate.store(:a,1) - # o.a.assert == 1 - # end - # - # test "update" do - # o = OpenStruct.new - # o.instance_delegate.update(:a=>1) - # o.a.assert == 1 - # end - #end - - method :[] do - test do - o = OpenStruct.new( { :a => 1 } ) - o[:a].assert == 1 - end - end - - method :[]= do - test do - o = OpenStruct.new( { :a => 1 } ) - o[:b] = 2 - o.b.assert == 2 - end - end - - class_method :new do - test "old functionality" do - o = OpenStruct.new - o.foo.assert.nil? - o.foo = :bar - o.foo.assert ==:bar - o.delete_field(:foo) - o.foo.assert.nil? - - o1 = OpenStruct.new(:x => 1, :z => 2) - o1.x.assert == 1 - o1.z.assert == 2 - - o2 = OpenStruct.new(:x => 1, :z => 2) - o1.assert == o2 - end - - test "via block" do - person = OpenStruct.new do |p| - p.name = 'John Smith' - p.gender = :M - p.age = 71 - end - person.name.assert == 'John Smith' - person.gender.assert ==:M - person.age.assert == 71 - person.address.assert ==nil - end - - test "via hash and block" do - person = OpenStruct.new(:gender => :M, :age => 71) do |p| - p.name = 'John Smith' - end - person.name.assert == 'John Smith' - person.gender.assert == :M - person.age.assert == 71 - person.address.assert == nil - end - - test "subclass via block" do - person_class = Class.new(OpenStruct) - person = person_class.new do |p| - p.name = 'John Smith' - p.gender = :M - p.age = 71 - end - person.name.assert == 'John Smith' - person.gender.assert == :M - person.age.assert == 71 - person.address.assert == nil - end - - test "subclass via hash and block" do - person_class = Class.new(OpenStruct) - person = person_class.new(:gender => :M, :age => 71) do |p| - p.name = 'John Smith' - end - person.name.assert == 'John Smith' - person.gender.assert == :M - person.age.assert == 71 - person.address.assert ==nil - end - end - -end - -test_case Hash do - - method :to_ostruct do - - test do - a = { :a => 1, :b => 2, :c => 3 } - ao = a.to_ostruct - ao.a.assert == a[:a] - ao.b.assert == a[:b] - ao.c.assert == a[:c] - end - - end - - method :to_ostruct_recurse do - - test do - a = { :a => 1, :b => 2, :c => { :x => 4 } } - ao = a.to_ostruct_recurse - ao.a.assert == a[:a] - ao.b.assert == a[:b] - ao.c.x.assert == a[:c][:x] - end - - test "with recursion" do - a = {} - a[:a] = a - ao = a.to_ostruct_recurse - ao.a.assert == ao - end - - test "advanced usage" do - h = { 'a' => { 'b' => 1 } } - o = h.to_ostruct_recurse( { h['a'] => h['a'] } ) - o.a['b'].assert == 1 - Hash.assert === o.a - end - - end - -end diff --git a/test/standard/test_uri.rb b/test/standard/test_uri.rb index 8584d3b6..57bdc9b2 100644 --- a/test/standard/test_uri.rb +++ b/test/standard/test_uri.rb @@ -14,7 +14,7 @@ class_method :hash_to_query do test do h = { :a=>1, :b=>2 } - r = URI.hash_to_query(h) + r = URI.hash_to_query_string(h) assert(r == "a=1;b=2" || r == "b=2;a=1") end end diff --git a/work/reference/to_hash.rb b/work/reference/to_hash.rb index ea3c8eb1..2ef7e03c 100644 --- a/work/reference/to_hash.rb +++ b/work/reference/to_hash.rb @@ -1,6 +1,5 @@ warn 'facets: to_hash.rb is deprecated in favor of hashifier.rb.' -require 'facets/enumerator' require 'facets/hash/dearray_values' class Array