miscellany 0.1.10 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ff0b4bf631a0cd63cc733ce24d2e301506a4e53b6cbd3401a7fd0e9a1a807be
4
- data.tar.gz: 21bf9c72bcd13371194e7d889aa5c2a1b5500a2e76f2e4e808a530e98472be75
3
+ metadata.gz: 3bbb29d549980dccc437f08518643092d0f77cbac6cbfa73f0f4dc728cd9586a
4
+ data.tar.gz: b8fe8463a2ffa603036803d25a34a815087a52829ae5a2e9e1f0360c27e6f04b
5
5
  SHA512:
6
- metadata.gz: af03a68cbb2fcf535d4afb0cc2aadc4c6faafee83ca6379b7e3850210f12e4ba2bb25bd8fa9f1e725fa4f1eb79a96fe063fc0b16d8c62abd335aed346481bce0
7
- data.tar.gz: bf6a692956fde6ba1aea228c0dfaa514bffbdefa5813e59ef9fd69ceab2badfd08da03eaa82cb5378b214b0f7fb02af671402cb075c67ced0ac6f4feebeee70c
6
+ metadata.gz: 5b0fb52043a3d4bbfc1bf503661f1162b370b19a6b03b9fcca642656ac1008b2920b3858b680023c0ce986b10c9646d5ee1d419e2244f337811c2dc9ec1c9233
7
+ data.tar.gz: f634b8330eb9f290cc5e76eeebf14e3cf2178a046ddade0230c2399642528e8976cdb8b6abf6e998a199e2f6696db4849ec66e72124dcd0b9f960199d89c85cc
@@ -1,5 +1,5 @@
1
1
  module Miscellany
2
- module BatchedDestruction
2
+ module BatchedDestruction # TODO Write Specs
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
@@ -30,7 +30,7 @@
30
30
  # end
31
31
  #
32
32
  module Miscellany
33
- module CustomPreloaders
33
+ module CustomPreloaders # TODO Write Specs
34
34
  module AssociationBuilderExtension
35
35
  def self.build(model, reflection); end
36
36
 
@@ -1,5 +1,5 @@
1
1
  module Miscellany
2
- module GoldiloadValue
2
+ module GoldiloadValue # TODO Write Specs
3
3
  attr_accessor :goldi_values
4
4
 
5
5
  def goldiload_value(key, &blk)
@@ -0,0 +1,67 @@
1
+ module Miscellany
2
+ class LocalLruCache
3
+ def initialize(max_size)
4
+ @max_size = max_size
5
+ @data = {}
6
+ end
7
+
8
+ def max_size=(size)
9
+ raise ArgumentError.new(:max_size) if @max_size < 1
10
+ @max_size = size
11
+ if @max_size < @data.size
12
+ @data.keys[0..@max_size-@data.size].each do |k|
13
+ @data.delete(k)
14
+ end
15
+ end
16
+ end
17
+
18
+ def fetch(key)
19
+ if @data.key?(key)
20
+ self[key]
21
+ else
22
+ self[key] = yield
23
+ end
24
+ end
25
+
26
+ def [](key)
27
+ found = true
28
+ value = @data.delete(key){ found = false }
29
+ if found
30
+ @data[key] = value
31
+ else
32
+ nil
33
+ end
34
+ end
35
+
36
+ def []=(key,val)
37
+ @data.delete(key)
38
+ @data[key] = val
39
+ if @data.length > @max_size
40
+ @data.delete(@data.first[0])
41
+ end
42
+ val
43
+ end
44
+
45
+ def each
46
+ @data.reverse.each do |pair|
47
+ yield pair
48
+ end
49
+ end
50
+
51
+ def to_a
52
+ @data.to_a.reverse
53
+ end
54
+
55
+ def delete(k)
56
+ @data.delete(k)
57
+ end
58
+
59
+ def clear
60
+ @data.clear
61
+ end
62
+
63
+ def count
64
+ @data.count
65
+ end
66
+ end
67
+ end
@@ -1,3 +1,3 @@
1
1
  module Miscellany
2
- VERSION = "0.1.10".freeze
2
+ VERSION = "0.1.12".freeze
3
3
  end
data/miscellany.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.test_files = Dir["spec/**/*"]
23
23
  spec.require_paths = ['lib']
24
24
 
25
- spec.add_dependency 'rails', '>= 5', '< 6.3'
25
+ spec.add_dependency 'rails', '>= 5', '< 8.0'
26
26
  # spec.add_dependency 'activerecord', '>= 5', '< 6.3'
27
27
  # spec.add_dependency 'activesupport', '>= 5', '< 6.3'
28
28
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miscellany
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan Knapp
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-29 00:00:00.000000000 Z
11
+ date: 2023-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '5'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6.3'
22
+ version: '8.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '5'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6.3'
32
+ version: '8.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rake
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -100,7 +100,7 @@ dependencies:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
- description:
103
+ description:
104
104
  email:
105
105
  - eknapp@instructure.com
106
106
  executables: []
@@ -121,6 +121,7 @@ files:
121
121
  - lib/miscellany/controller/http_error_handling.rb
122
122
  - lib/miscellany/controller/json_uploads.rb
123
123
  - lib/miscellany/controller/sliced_response.rb
124
+ - lib/miscellany/local_lru_cache.rb
124
125
  - lib/miscellany/param_validator.rb
125
126
  - lib/miscellany/version.rb
126
127
  - miscellany.gemspec
@@ -132,7 +133,7 @@ files:
132
133
  homepage: https://instructure.com
133
134
  licenses: []
134
135
  metadata: {}
135
- post_install_message:
136
+ post_install_message:
136
137
  rdoc_options: []
137
138
  require_paths:
138
139
  - lib
@@ -148,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
149
  version: '0'
149
150
  requirements: []
150
151
  rubygems_version: 3.1.6
151
- signing_key:
152
+ signing_key:
152
153
  specification_version: 4
153
154
  summary: Gem for a bunch of random, re-usable Rails Concerns & Helpers
154
155
  test_files: