From 9ebb625d8a987bd54526006441ff97bc14c30e53 Mon Sep 17 00:00:00 2001 From: Florian Frank Date: Mon, 9 Nov 2015 16:27:21 +0100 Subject: [PATCH] Use new syntax for ruby 2.0 --- README.md | 3 +++ Rakefile | 1 + VERSION | 2 +- lib/tins/file_binary.rb | 8 ++++---- lib/tins/proc_prelude.rb | 12 ++++++------ lib/tins/version.rb | 2 +- tests/blank_full_test.rb | 6 +++--- tests/extract_last_argument_options_test.rb | 4 ++-- tests/file_binary_test.rb | 16 ++++++++-------- tests/find_test.rb | 18 +++++++++--------- tests/from_module_test.rb | 4 ++-- tests/null_test.rb | 10 +++++----- tests/token_test.rb | 16 ++++++++-------- tins.gemspec | 13 +++++++------ 14 files changed, 60 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 7247263..51ed402 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,9 @@ Non yet. ## Changes +* 2015-11-09 Release 1.7.0 + - Officially require ruby >= 2.0 and use new hash syntax. + * 2015-08-13 Release 1.6.0 - Add complete method for readline completion * 2015-06-21 Release 1.5.4 diff --git a/Rakefile b/Rakefile index b83c32c..1bf3951 100644 --- a/Rakefile +++ b/Rakefile @@ -17,5 +17,6 @@ GemHadar do readme 'README.md' licenses << 'MIT' + required_ruby_version '>= 2.0' development_dependency 'test-unit', '~>2.5' end diff --git a/VERSION b/VERSION index dc1e644..bd8bf88 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.6.0 +1.7.0 diff --git a/lib/tins/file_binary.rb b/lib/tins/file_binary.rb index e98d216..255f3c1 100644 --- a/lib/tins/file_binary.rb +++ b/lib/tins/file_binary.rb @@ -17,10 +17,10 @@ class << self attr_accessor :default_options end self.default_options = { - :offset => 0, - :buffer_size => 2 ** 13, - :percentage_binary => 30.0, - :percentage_zeros => 0.0, + offset: 0, + buffer_size: 2 ** 13, + percentage_binary: 30.0, + percentage_zeros: 0.0, } # Returns true if this file is considered to be binary, false if it is not diff --git a/lib/tins/proc_prelude.rb b/lib/tins/proc_prelude.rb index f2487c2..8bb6cbe 100644 --- a/lib/tins/proc_prelude.rb +++ b/lib/tins/proc_prelude.rb @@ -20,29 +20,29 @@ def call(obj, &my_proc) def array lambda { |*list| list } end - memoize_function :array, :freeze => true + memoize_function :array, freeze: true def first lambda { |*list| list.first } end - memoize_function :first, :freeze => true + memoize_function :first, freeze: true alias head first def second lambda { |*list| list[1] } end - memoize_function :second, :freeze => true + memoize_function :second, freeze: true def tail lambda { |*list| list[1..-1] } end - memoize_function :tail, :freeze => true + memoize_function :tail, freeze: true def last lambda { |*list| list.last } end - memoize_function :last, :freeze => true + memoize_function :last, freeze: true def rotate(n = 1) lambda { |*list| list.rotate(n) } @@ -53,7 +53,7 @@ def rotate(n = 1) def id1 lambda { |obj| obj } end - memoize_function :id1, :freeze => true + memoize_function :id1, freeze: true def const(konst = nil, &my_proc) konst ||= my_proc.call diff --git a/lib/tins/version.rb b/lib/tins/version.rb index 335796f..e3519bb 100644 --- a/lib/tins/version.rb +++ b/lib/tins/version.rb @@ -1,6 +1,6 @@ module Tins # Tins version - VERSION = '1.6.0' + VERSION = '1.7.0' VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc: VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc: VERSION_MINOR = VERSION_ARRAY[1] # :nodoc: diff --git a/tests/blank_full_test.rb b/tests/blank_full_test.rb index 03d25c4..bfc7080 100644 --- a/tests/blank_full_test.rb +++ b/tests/blank_full_test.rb @@ -14,7 +14,7 @@ def test_blank assert Set[].blank? assert !Set[23].blank? assert({}.blank?) - assert !{ :foo => 23 }.blank? + assert !{ foo: 23 }.blank? assert "".blank? assert " ".blank? assert !"foo".blank? @@ -29,7 +29,7 @@ def test_present assert !Set[].present? assert Set[23].present? assert !{}.present? - assert({ :foo => 23 }.present?) + assert({ foo: 23 }.present?) assert !"".present? assert !" ".present? assert "foo".present? @@ -44,7 +44,7 @@ def test_full assert_nil Set[].full? assert_equal Set[23], Set[23].full? assert_nil({}.full?) - assert_equal({ :foo => 23 }, { :foo => 23 }.full?) + assert_equal({ foo: 23 }, { foo: 23 }.full?) assert_nil "".full? assert_nil " ".full? assert_equal "foo", "foo".full? diff --git a/tests/extract_last_argument_options_test.rb b/tests/extract_last_argument_options_test.rb index 8bff642..496f2c6 100644 --- a/tests/extract_last_argument_options_test.rb +++ b/tests/extract_last_argument_options_test.rb @@ -20,9 +20,9 @@ def test_argument_array_without_options end def test_argument_array_witt_options - arguments = [ 1, 2, 3, { :foo => :bar } ] + arguments = [ 1, 2, 3, { foo: :bar } ] result = arguments.extract_last_argument_options - assert_equal [ [ 1, 2, 3 ], { :foo => :bar } ], result + assert_equal [ [ 1, 2, 3 ], { foo: :bar } ], result assert_not_same arguments, result.first assert_not_same arguments.last, result.last end diff --git a/tests/file_binary_test.rb b/tests/file_binary_test.rb index ef1bae3..fadce85 100644 --- a/tests/file_binary_test.rb +++ b/tests/file_binary_test.rb @@ -7,10 +7,10 @@ class TinsFileBinaryTest < Test::Unit::TestCase def test_ascii_buffer_size write_file do |file| file.write "A" * 10 + "\x00" - assert_equal true, file.ascii?(:buffer_size => 10) - assert_equal true, File.ascii?(file.path, :buffer_size => 10) - assert_equal false, file.binary?(:buffer_size => 10) - assert_equal false, File.binary?(file.path, :buffer_size => 10) + assert_equal true, file.ascii?(buffer_size: 10) + assert_equal true, File.ascii?(file.path, buffer_size: 10) + assert_equal false, file.binary?(buffer_size: 10) + assert_equal false, File.binary?(file.path, buffer_size: 10) end end @@ -27,10 +27,10 @@ def test_binary def test_ascii_offset write_file do |file| file.write "\x01" * 31 + "A" * 70 - assert_equal false, file.binary?(:offset => 1) - assert_equal false, File.binary?(file.path, :offset => 1) - assert_equal true, file.ascii?(:offset => 1) - assert_equal true, File.ascii?(file.path, :offset => 1) + assert_equal false, file.binary?(offset: 1) + assert_equal false, File.binary?(file.path, offset: 1) + assert_equal true, file.ascii?(offset: 1) + assert_equal true, File.ascii?(file.path, offset: 1) end end diff --git a/tests/find_test.rb b/tests/find_test.rb index 7fc9b30..627b55d 100644 --- a/tests/find_test.rb +++ b/tests/find_test.rb @@ -17,18 +17,18 @@ def teardown end def test_raising_errors - assert_equal [], find(File.join(@work_dir, 'nix'), :raise_errors => false).to_a + assert_equal [], find(File.join(@work_dir, 'nix'), raise_errors: false).to_a assert_equal [], find(File.join(@work_dir, 'nix')).to_a assert_raise(Errno::ENOENT) do - find(File.join(@work_dir, 'nix'), :raise_errors => true).to_a + find(File.join(@work_dir, 'nix'), raise_errors: true).to_a end end def test_showing_hidden touch file = File.join(@work_dir, '.foo') - assert_equal [ @work_dir ], find(@work_dir, :show_hidden => false).to_a + assert_equal [ @work_dir ], find(@work_dir, show_hidden: false).to_a assert_equal [ @work_dir, file ], find(@work_dir).to_a - assert_equal [ @work_dir, file ], find(@work_dir, :show_hidden => true).to_a + assert_equal [ @work_dir, file ], find(@work_dir, show_hidden: true).to_a end def test_check_directory_without_access @@ -42,10 +42,10 @@ def test_check_directory_without_access mkdir_p directory2 = File.join(directory1, 'bar') touch file = File.join(directory2, 'file') chmod 0, directory2 - assert_equal [ @work_dir, directory1, directory2 ], find(@work_dir, :raise_errors => false).to_a + assert_equal [ @work_dir, directory1, directory2 ], find(@work_dir, raise_errors: false).to_a assert_equal [ @work_dir, directory1, directory2 ], find(@work_dir).to_a assert_raise(Errno::EACCES) do - find(@work_dir, :raise_errors => true).to_a + find(@work_dir, raise_errors: true).to_a end ensure File.exist?(directory2) and chmod 0777, directory2 @@ -58,9 +58,9 @@ def test_follow_symlinks mkdir_p directory3 = File.join(directory1, 'bar') touch file = File.join(directory3, 'foo') ln_s directory3, link = File.join(directory2, 'baz') - assert_equal [ directory2, link ], find(directory2, :follow_symlinks => false).to_a + assert_equal [ directory2, link ], find(directory2, follow_symlinks: false).to_a assert_equal [ directory2, link, linked = File.join(link, 'foo') ], find(directory2).to_a - assert_equal [ directory2, link, linked ], find(directory2, :follow_symlinks => true).to_a + assert_equal [ directory2, link, linked ], find(directory2, follow_symlinks: true).to_a end def test_path_file @@ -89,7 +89,7 @@ def test_path_extension end def test_suffix - finder = Tins::Find::Finder.new(:suffix => 'bar') + finder = Tins::Find::Finder.new(suffix: 'bar') f = File.open(fpath = File.join(@work_dir, 'foo.bar'), 'w') g = File.open(gpath = File.join(@work_dir, 'foo.baz'), 'w') fpath = finder.prepare_path fpath diff --git a/tests/from_module_test.rb b/tests/from_module_test.rb index 03532b5..14f3da9 100644 --- a/tests/from_module_test.rb +++ b/tests/from_module_test.rb @@ -25,7 +25,7 @@ def bar class DerivedKlass < MyKlass extend Tins::FromModule - include from :module => MyIncludedModule, :methods => [ :foo ] + include from module: MyIncludedModule, methods: [ :foo ] end module MyModule @@ -44,7 +44,7 @@ class AnotherDerivedKlass extend Tins::FromModule - include from :module => MyIncludedModule, :methods => :foo + include from module: MyIncludedModule, methods: :foo end def test_derived_klass diff --git a/tests/null_test.rb b/tests/null_test.rb index f380a1d..fd26f11 100644 --- a/tests/null_test.rb +++ b/tests/null_test.rb @@ -25,10 +25,10 @@ def test_null end def test_null_plus - assert_equal 1, null_plus(:value => 1) - assert_equal 1, NullPlus(:value => 1) - assert_kind_of Tins::NullPlus, null_plus(:value => nil) - assert_kind_of Tins::NullPlus, NullPlus(:value => nil) + assert_equal 1, null_plus(value: 1) + assert_equal 1, NullPlus(value: 1) + assert_kind_of Tins::NullPlus, null_plus(value: nil) + assert_kind_of Tins::NullPlus, NullPlus(value: nil) assert_kind_of Tins::NullPlus, null_plus assert_kind_of Tins::NullPlus, NullPlus() assert_kind_of Tins::NullPlus, null_plus.foo @@ -48,7 +48,7 @@ def test_null_plus def foo 1 / 0 rescue => e - null_plus(:error => e) + null_plus(error: e) end def test_null_plus_caller_and_misc diff --git a/tests/token_test.rb b/tests/token_test.rb index f8edfcc..d1fddb1 100644 --- a/tests/token_test.rb +++ b/tests/token_test.rb @@ -4,32 +4,32 @@ module Tins class TokenTest < Test::Unit::TestCase def test_token_failures - assert_raises(ArgumentError) { Tins::Token.new(:bits => 0) } - assert_raises(ArgumentError) { Tins::Token.new(:length => 0) } - assert_raises(ArgumentError) { Tins::Token.new(:alphabet => %w[0]) } + assert_raises(ArgumentError) { Tins::Token.new(bits: 0) } + assert_raises(ArgumentError) { Tins::Token.new(length: 0) } + assert_raises(ArgumentError) { Tins::Token.new(alphabet: %w[0]) } end def test_token_for_length - token = Tins::Token.new(:length => 22) + token = Tins::Token.new(length: 22) assert_equal 22, token.length assert_equal 130, token.bits end def test_token_for_bits - token = Tins::Token.new(:bits => 128) + token = Tins::Token.new(bits: 128) assert_equal 22, token.length # can differ from bits argument depending on alphabet: assert_equal 130, token.bits end def test_alphabet - token = Tins::Token.new(:alphabet => %w[0 1]) + token = Tins::Token.new(alphabet: %w[0 1]) assert_equal 128, token.length assert_equal 128, token.bits - token = Tins::Token.new(:alphabet => %w[0 1 2 3]) + token = Tins::Token.new(alphabet: %w[0 1 2 3]) assert_equal 64, token.length assert_equal 128, token.bits - token = Tins::Token.new(:length => 128, :alphabet => %w[0 1 2 3]) + token = Tins::Token.new(length: 128, alphabet: %w[0 1 2 3]) assert_equal 128, token.length assert_equal 256, token.bits end diff --git a/tins.gemspec b/tins.gemspec index 187ba8e..5cec86c 100644 --- a/tins.gemspec +++ b/tins.gemspec @@ -1,14 +1,14 @@ # -*- encoding: utf-8 -*- -# stub: tins 1.6.0 ruby lib +# stub: tins 1.7.0 ruby lib Gem::Specification.new do |s| s.name = "tins" - s.version = "1.6.0" + s.version = "1.7.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.require_paths = ["lib"] s.authors = ["Florian Frank"] - s.date = "2015-08-13" + s.date = "2015-11-09" s.description = "All the stuff that isn't good/big enough for a real library." s.email = "flori@ping.de" s.extra_rdoc_files = ["README.md", "lib/dslkit.rb", "lib/dslkit/polite.rb", "lib/dslkit/rude.rb", "lib/spruz.rb", "lib/tins.rb", "lib/tins/alias.rb", "lib/tins/annotate.rb", "lib/tins/ask_and_send.rb", "lib/tins/attempt.rb", "lib/tins/bijection.rb", "lib/tins/case_predicate.rb", "lib/tins/complete.rb", "lib/tins/concern.rb", "lib/tins/count_by.rb", "lib/tins/date_dummy.rb", "lib/tins/date_time_dummy.rb", "lib/tins/deep_const_get.rb", "lib/tins/deep_dup.rb", "lib/tins/dslkit.rb", "lib/tins/extract_last_argument_options.rb", "lib/tins/file_binary.rb", "lib/tins/find.rb", "lib/tins/generator.rb", "lib/tins/go.rb", "lib/tins/hash_symbolize_keys_recursive.rb", "lib/tins/hash_union.rb", "lib/tins/if_predicate.rb", "lib/tins/implement.rb", "lib/tins/limited.rb", "lib/tins/lines_file.rb", "lib/tins/memoize.rb", "lib/tins/method_description.rb", "lib/tins/minimize.rb", "lib/tins/module_group.rb", "lib/tins/named_set.rb", "lib/tins/null.rb", "lib/tins/once.rb", "lib/tins/p.rb", "lib/tins/partial_application.rb", "lib/tins/proc_compose.rb", "lib/tins/proc_prelude.rb", "lib/tins/range_plus.rb", "lib/tins/require_maybe.rb", "lib/tins/responding.rb", "lib/tins/rotate.rb", "lib/tins/secure_write.rb", "lib/tins/sexy_singleton.rb", "lib/tins/shuffle.rb", "lib/tins/string_byte_order_mark.rb", "lib/tins/string_camelize.rb", "lib/tins/string_underscore.rb", "lib/tins/string_version.rb", "lib/tins/subhash.rb", "lib/tins/terminal.rb", "lib/tins/thread_local.rb", "lib/tins/time_dummy.rb", "lib/tins/to.rb", "lib/tins/to_proc.rb", "lib/tins/token.rb", "lib/tins/uniq_by.rb", "lib/tins/version.rb", "lib/tins/write.rb", "lib/tins/xt.rb", "lib/tins/xt/annotate.rb", "lib/tins/xt/ask_and_send.rb", "lib/tins/xt/attempt.rb", "lib/tins/xt/blank.rb", "lib/tins/xt/case_predicate.rb", "lib/tins/xt/complete.rb", "lib/tins/xt/concern.rb", "lib/tins/xt/count_by.rb", "lib/tins/xt/date_dummy.rb", "lib/tins/xt/date_time_dummy.rb", "lib/tins/xt/deep_const_get.rb", "lib/tins/xt/deep_dup.rb", "lib/tins/xt/dslkit.rb", "lib/tins/xt/extract_last_argument_options.rb", "lib/tins/xt/file_binary.rb", "lib/tins/xt/full.rb", "lib/tins/xt/hash_symbolize_keys_recursive.rb", "lib/tins/xt/hash_union.rb", "lib/tins/xt/if_predicate.rb", "lib/tins/xt/implement.rb", "lib/tins/xt/irb.rb", "lib/tins/xt/method_description.rb", "lib/tins/xt/named.rb", "lib/tins/xt/null.rb", "lib/tins/xt/p.rb", "lib/tins/xt/partial_application.rb", "lib/tins/xt/proc_compose.rb", "lib/tins/xt/proc_prelude.rb", "lib/tins/xt/range_plus.rb", "lib/tins/xt/require_maybe.rb", "lib/tins/xt/responding.rb", "lib/tins/xt/rotate.rb", "lib/tins/xt/secure_write.rb", "lib/tins/xt/sexy_singleton.rb", "lib/tins/xt/shuffle.rb", "lib/tins/xt/string.rb", "lib/tins/xt/string_byte_order_mark.rb", "lib/tins/xt/string_camelize.rb", "lib/tins/xt/string_underscore.rb", "lib/tins/xt/string_version.rb", "lib/tins/xt/subhash.rb", "lib/tins/xt/symbol_to_proc.rb", "lib/tins/xt/time_dummy.rb", "lib/tins/xt/time_freezer.rb", "lib/tins/xt/to.rb", "lib/tins/xt/uniq_by.rb", "lib/tins/xt/write.rb"] @@ -16,6 +16,7 @@ Gem::Specification.new do |s| s.homepage = "https://github.com/flori/tins" s.licenses = ["MIT"] s.rdoc_options = ["--title", "Tins - Useful stuff.", "--main", "README.md"] + s.required_ruby_version = Gem::Requirement.new(">= 2.0") s.rubygems_version = "2.4.6" s.summary = "Useful stuff." s.test_files = ["tests/annotate_test.rb", "tests/ask_and_send_test.rb", "tests/attempt_test.rb", "tests/bijection_test.rb", "tests/blank_full_test.rb", "tests/case_predicate_test.rb", "tests/concern_test.rb", "tests/count_by_test.rb", "tests/date_dummy_test.rb", "tests/date_time_dummy_test.rb", "tests/deep_const_get_test.rb", "tests/deep_dup_test.rb", "tests/delegate_test.rb", "tests/dslkit_test.rb", "tests/dynamic_scope_test.rb", "tests/extract_last_argument_options_test.rb", "tests/file_binary_test.rb", "tests/find_test.rb", "tests/from_module_test.rb", "tests/generator_test.rb", "tests/go_test.rb", "tests/hash_symbolize_keys_recursive_test.rb", "tests/hash_union_test.rb", "tests/if_predicate_test.rb", "tests/implement_test.rb", "tests/limited_test.rb", "tests/lines_file_test.rb", "tests/memoize_test.rb", "tests/method_description_test.rb", "tests/minimize_test.rb", "tests/module_group_test.rb", "tests/named_set_test.rb", "tests/named_test.rb", "tests/null_test.rb", "tests/p_test.rb", "tests/partial_application_test.rb", "tests/proc_compose_test.rb", "tests/proc_prelude_test.rb", "tests/range_plus_test.rb", "tests/require_maybe_test.rb", "tests/responding_test.rb", "tests/rotate_test.rb", "tests/scope_test.rb", "tests/secure_write_test.rb", "tests/sexy_singleton_test.rb", "tests/shuffle_test.rb", "tests/string_byte_order_mark_test.rb", "tests/string_camelize_test.rb", "tests/string_underscore_test.rb", "tests/string_version_test.rb", "tests/subhash_test.rb", "tests/test_helper.rb", "tests/time_dummy_test.rb", "tests/time_freezer_test.rb", "tests/to_test.rb", "tests/token_test.rb", "tests/uniq_by_test.rb", "tests/annotate_test.rb", "tests/ask_and_send_test.rb", "tests/attempt_test.rb", "tests/bijection_test.rb", "tests/blank_full_test.rb", "tests/case_predicate_test.rb", "tests/concern_test.rb", "tests/count_by_test.rb", "tests/date_dummy_test.rb", "tests/date_time_dummy_test.rb", "tests/deep_const_get_test.rb", "tests/deep_dup_test.rb", "tests/delegate_test.rb", "tests/dslkit_test.rb", "tests/dynamic_scope_test.rb", "tests/extract_last_argument_options_test.rb", "tests/file_binary_test.rb", "tests/find_test.rb", "tests/from_module_test.rb", "tests/generator_test.rb", "tests/go_test.rb", "tests/hash_symbolize_keys_recursive_test.rb", "tests/hash_union_test.rb", "tests/if_predicate_test.rb", "tests/implement_test.rb", "tests/limited_test.rb", "tests/lines_file_test.rb", "tests/memoize_test.rb", "tests/method_description_test.rb", "tests/minimize_test.rb", "tests/module_group_test.rb", "tests/named_set_test.rb", "tests/named_test.rb", "tests/null_test.rb", "tests/p_test.rb", "tests/partial_application_test.rb", "tests/proc_compose_test.rb", "tests/proc_prelude_test.rb", "tests/range_plus_test.rb", "tests/require_maybe_test.rb", "tests/responding_test.rb", "tests/rotate_test.rb", "tests/scope_test.rb", "tests/secure_write_test.rb", "tests/sexy_singleton_test.rb", "tests/shuffle_test.rb", "tests/string_byte_order_mark_test.rb", "tests/string_camelize_test.rb", "tests/string_underscore_test.rb", "tests/string_version_test.rb", "tests/subhash_test.rb", "tests/time_dummy_test.rb", "tests/time_freezer_test.rb", "tests/to_test.rb", "tests/token_test.rb", "tests/uniq_by_test.rb"] @@ -24,14 +25,14 @@ Gem::Specification.new do |s| s.specification_version = 4 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_development_dependency(%q, ["~> 1.2.0"]) + s.add_development_dependency(%q, ["~> 1.3.1"]) s.add_development_dependency(%q, ["~> 2.5"]) else - s.add_dependency(%q, ["~> 1.2.0"]) + s.add_dependency(%q, ["~> 1.3.1"]) s.add_dependency(%q, ["~> 2.5"]) end else - s.add_dependency(%q, ["~> 1.2.0"]) + s.add_dependency(%q, ["~> 1.3.1"]) s.add_dependency(%q, ["~> 2.5"]) end end