From e472b99b630df95b51c24bd9d46bb6e5fbffa7a0 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 8 Aug 2022 01:18:47 +0900 Subject: [PATCH] Drop deprecated ULID.valid? since #205 --- CONTRIBUTING.md | 8 ++++---- lib/ulid.rb | 13 ------------- sig/ulid.rbs | 13 ------------- test/core/test_ulid_class.rb | 25 ------------------------- 4 files changed, 4 insertions(+), 55 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d8602f95..f92db9d5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,7 +31,7 @@ The name of this source file (`Rakefile'`) should use snake_case. $ ./bin/console # Starting up IRB with loading developing ULID library irb(main):001:0> ULID::VERSION -=> "0.7.0.pre" +=> "0.8.0.pre" ``` ```ruby @@ -47,9 +47,9 @@ ls ULID # Module#methods: ... # Class#methods: ... # ULID.methods: -# at decode_time encode floor from_integer generate max min -# normalize normalized? parse parse_variant_format range sample scan try_convert -# valid? valid_as_variant_format? +# at decode_time encode floor from_integer generate max min +# normalize normalized? parse parse_variant_format range sample scan try_convert +# valid_as_variant_format? # => nil ``` diff --git a/lib/ulid.rb b/lib/ulid.rb index 59c395e6..d75bfdbd 100644 --- a/lib/ulid.rb +++ b/lib/ulid.rb @@ -321,19 +321,6 @@ def self.valid_as_variant_format?(string) true end - # @deprecated Use [.valid_as_variant_format?] or [.normalized?] instead - # - # Returns `true` if it is normalized string. - # Basically the difference of normalized? is to accept downcase or not. This returns true for downcased ULIDs. - # - # @return [Boolean] - def self.valid?(string) - warn_kwargs = (RUBY_VERSION >= '3.0') ? { category: :deprecated } : {} - Warning.warn('ULID.valid? is deprecated. Use ULID.valid_as_variant_format? or ULID.normalized? instead.', **warn_kwargs) - string = String.try_convert(string) - string ? STRICT_PATTERN_WITH_CROCKFORD_BASE32_SUBSET.match?(string) : false - end - # @param [ULID, #to_ulid] object # @return [ULID, nil] # @raise [TypeError] if `object.to_ulid` did not return ULID instance diff --git a/sig/ulid.rbs b/sig/ulid.rbs index eeb82fbe..1de83520 100644 --- a/sig/ulid.rbs +++ b/sig/ulid.rbs @@ -394,19 +394,6 @@ class ULID < Object def self.valid_as_variant_format?: (_ToStr string) -> bool | (untyped) -> false - # DEPRECATED Use valid_as_variant_format? instead - # - # Returns `true` if it is normalized string. - # Basically the difference of normalized? is to accept downcase or not. This returns true for downcased ULIDs. - # - # ```ruby - # ULID.valid?(ULID.generate.to_s.downcase) #=> true - # ``` - # - # See also [ulid/spec#57](https://github.com/ulid/spec/pull/57) and [ulid/spec#3](https://github.com/ulid/spec/issues/3) - def self.valid?: (_ToStr string) -> bool - | (untyped) -> false - # Returns parsed ULIDs from given String for rough operations. # # ```ruby diff --git a/test/core/test_ulid_class.rb b/test/core/test_ulid_class.rb index ebe7af7c..178f3771 100644 --- a/test/core/test_ulid_class.rb +++ b/test/core/test_ulid_class.rb @@ -46,7 +46,6 @@ def test_exposed_methods :scan, :sample, :try_convert, - :valid?, # deprecated :max, :min, :generate, @@ -228,30 +227,6 @@ def test_new assert_match(/private method `new' called/, err.message) end - def test_valid? - assert_warning('ULID.valid? is deprecated. Use ULID.valid_as_variant_format? or ULID.normalized? instead.') do - assert_false(ULID.valid?(nil)) - assert_false(ULID.valid?('')) - assert_false(ULID.valid?(BasicObject.new)) - assert_false(ULID.valid?(Object.new)) - assert_false(ULID.valid?(42)) - assert_false(ULID.valid?(:'01ARZ3NDEKTSV4RRFFQ69G5FAV')) - assert_false(ULID.valid?(ULID.sample)) - assert_false(ULID.valid?("01ARZ3NDEKTSV4RRFFQ69G5FAV\n")) - assert_false(ULID.valid?('01ARZ3NDEKTSV4RRFFQ69G5FAU')) - assert_true(ULID.valid?('01ARZ3NDEKTSV4RRFFQ69G5FAV')) - assert_true(ULID.valid?('01ARZ3NDEKTSV4RRFFQ69G5FAV'.downcase)) - assert_true(ULID.valid?('7ZZZZZZZZZZZZZZZZZZZZZZZZZ')) - assert_false(ULID.valid?('80000000000000000000000000')) - - assert_false(ULID.valid?('01G70Y0Y7G-Z1XWDAREXERGSDDD')) - end - - assert_raises(ArgumentError) do - ULID.valid? - end - end - def test_normalize # This is the core of this feature assert_equal(ULID.parse('01ARZ3N0EK1SV4RRFFQ61G5FAV'), ULID.parse(ULID.normalize('-OlARZ3-NoEKISV4rRFF-Q6iG5FAV--')))