memoist 0.16.1 → 0.16.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af4a5344777f88d07223d20fae69de50867916ed579032325013f4c5160b37c7
4
- data.tar.gz: 5997e635a721a2bfcf779592e61ea1bda7361208c9182cdbd8f6a288bf32e78c
3
+ metadata.gz: '058dae917e46d13306497f0bcd18df607cb1d5dca2d85ee6f9cbc18739172e27'
4
+ data.tar.gz: c0874b135f70db573a863e4b54bb141905c003d9e451d7c3637d8f67c96a0696
5
5
  SHA512:
6
- metadata.gz: ff876e4b317f71b26b6c3505977fb707d839e97820852fc97d117cc58d0f00c3d1f2a952a000062ef63af2c1289ad6852c02a68e11f8342d73c95dc42976fe6c
7
- data.tar.gz: 15f0e432b722826bff600c642be765dcc4f6e2a7ae8b32b2f907a945cbbcbf97b87f9589262141430646d8880570223ef592e0f2cde92b21cc0dbb8263a3b3b0
6
+ metadata.gz: 409f37c0861015cc81704bf4fbbb1002d7a011a5f3dccb0e1430baf8b5eac601f5caae99cf4e1634fe044ea01123c1a0319692fad6d64c848026329f9a4dfa7a
7
+ data.tar.gz: 7f3134101c02c37ce88fd6a814c6bce19f5ffc4085fcfbb08e22ce720f125b7f8c2c2644c6a694cf4bb5dc4feb40974785f1209d598c18ba098bc055bca33146
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [Unreleased](https://github.com/matthewrudy/memoist/tree/HEAD)
4
+
5
+ [Full Changelog](https://github.com/matthewrudy/memoist/compare/v0.16.1...HEAD)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Fix regression introduced by frozen symbol fix [\#86](https://github.com/matthewrudy/memoist/pull/86) ([sebjacobs](https://github.com/sebjacobs))
10
+
3
11
  ## [v0.16.1](https://github.com/matthewrudy/memoist/tree/v0.16.1) (2019-11-08)
4
12
 
5
13
  [Full Changelog](https://github.com/matthewrudy/memoist/compare/v0.16.0...v0.16.1)
@@ -38,12 +38,10 @@ module Memoist
38
38
  end
39
39
 
40
40
  def self.escape_punctuation(string)
41
- string = string.to_s
41
+ string = string.is_a?(String) ? string.dup : string.to_s.dup
42
42
 
43
43
  return string unless string.end_with?('?'.freeze, '!'.freeze)
44
44
 
45
- string = string.dup if string.frozen?
46
-
47
45
  # A String can't end in both ? and !
48
46
  if string.sub!(/\?\Z/, '_query'.freeze)
49
47
  else
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Memoist
4
- VERSION = '0.16.1'.freeze
4
+ VERSION = '0.16.2'.freeze
5
5
  end
@@ -67,6 +67,12 @@ class MemoistTest < Minitest::Test
67
67
 
68
68
  memoize :name, :age
69
69
 
70
+ def age?
71
+ @counter.call(:age?)
72
+ true
73
+ end
74
+ memoize 'age?'
75
+
70
76
  def sleep(hours = 8)
71
77
  @counter.call(:sleep)
72
78
  hours
@@ -272,6 +278,13 @@ class MemoistTest < Minitest::Test
272
278
  @person.unmemoize_all
273
279
  end
274
280
 
281
+ def test_memoization_when_memoize_is_called_with_punctuated_string
282
+ assert_equal true, @person.age?
283
+
284
+ @person.memoize_all
285
+ @person.unmemoize_all
286
+ end
287
+
275
288
  def test_memoization_flush_with_punctuation
276
289
  assert_equal true, @person.name?
277
290
  @person.flush_cache(:name?)
@@ -344,11 +357,11 @@ class MemoistTest < Minitest::Test
344
357
  end
345
358
 
346
359
  def test_all_memoized_structs
347
- # Person memoize :age, :is_developer?, :memoize_protected_test, :name, :name?, :sleep, :update, :update_attributes
360
+ # Person memoize :age, :age?, :is_developer?, :memoize_protected_test, :name, :name?, :sleep, :update, :update_attributes
348
361
  # Student < Person memoize :name, :identifier => :student
349
362
  # Teacher < Person memoize :seniority
350
363
 
351
- expected = %w[age is_developer? memoize_protected_test name name? sleep update update_attributes]
364
+ expected = %w[age age? is_developer? memoize_protected_test name name? sleep update update_attributes]
352
365
  structs = Person.all_memoized_structs
353
366
  assert_equal expected, structs.collect(&:memoized_method).collect(&:to_s).sort
354
367
  assert_equal '@_memoized_name', structs.detect { |s| s.memoized_method == :name }.ivar
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memoist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.1
4
+ version: 0.16.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Peek
@@ -19,7 +19,7 @@ authors:
19
19
  autorequire:
20
20
  bindir: bin
21
21
  cert_chain: []
22
- date: 2019-11-08 00:00:00.000000000 Z
22
+ date: 2019-12-04 00:00:00.000000000 Z
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
25
25
  name: benchmark-ips