mize 0.4.0 → 0.5.0

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: dcfd4e246719f8931a0e654722a01dc8d091831ddf38659d2109e1150e59842f
4
- data.tar.gz: 4681c082ae4c0d90e693b7596c57cf16fc6923c7e000edb18d595da7f187601c
3
+ metadata.gz: 9eddd37dbe3b1119706e25a105cfd49256c42a401ded5ddba30d479c36ba93b5
4
+ data.tar.gz: 936a9c5c05083e2f30c1dd1f007b65de80ed2cfb5019a39db948329d6529f5a1
5
5
  SHA512:
6
- metadata.gz: 458d9164d55a7fe85a04eb9b79868243235e4f46a24206f7e35b49d7e36d02318735298ce6c2feca8ebfc147159c0c37c6afe0220fcc9d537b06a9c4ede78738
7
- data.tar.gz: a31876ac329016bd93317cb3defa0699e9f18afba57d103df8d074941b2bd4c3b3cc2dd08e2e9c6885cc4b372d7a091e7480666b1b4134b7b0492cca7bce010f
6
+ metadata.gz: df782c8ad0f19a9fc3deb9fb7131d5be1f0eb917d25820396e0e98a06ec7c3acda41f3345c4492dac770130d69bbd8099e58763db5edf5a7ff3d38f6fc9a2ff5
7
+ data.tar.gz: 44395da5d9a27704881ae98d3b029cac200e4d29af29b9cda24cd2b304b7254be7a159032a53aa0deb46830aaee790a06252e220c9ef2beb2eaf5a34083f43d1
data/.all_images.yml ADDED
@@ -0,0 +1,29 @@
1
+ dockerfile: |-
2
+ RUN apk add --no-cache build-base git bash
3
+ RUN bash <<NUR
4
+ if [[ "$(ruby -e 'print RUBY_VERSION')" > '3' ]]
5
+ then
6
+ gem update --system
7
+ gem install gem_hadar bundler
8
+ else
9
+ gem install gem_hadar
10
+ gem install bundler -v 2.4.22
11
+ fi
12
+ NUR
13
+
14
+ script: &script |-
15
+ echo -e "\e[1m"
16
+ ruby -v
17
+ echo -e "\e[0m"
18
+ bundle
19
+ rake spec
20
+
21
+ fail_fast: yes
22
+
23
+ images:
24
+ ruby:3.3-alpine: *script
25
+ ruby:3.2-alpine: *script
26
+ ruby:3.1-alpine: *script
27
+ ruby:3.0-alpine: *script
28
+ ruby:2.7-alpine: *script
29
+ ruby:2.6-alpine: *script
data/.gitignore CHANGED
@@ -5,6 +5,8 @@
5
5
  .yard*
6
6
  Gemfile.lock
7
7
  coverage
8
+ doc
8
9
  errors.lst
9
10
  pkg
10
11
  tags
12
+ yard
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.3.4
data/.travis.yml CHANGED
@@ -1,5 +1,4 @@
1
1
  rvm:
2
- - 2.0
3
2
  - 2.1
4
3
  - 2.2
5
4
  - 2.3
data/.utilsrc CHANGED
@@ -1,12 +1,12 @@
1
1
  # vim: set ft=ruby:
2
2
 
3
3
  search do
4
- prune_dirs /\A(\.svn|\.git|CVS|tmp|tags|coverage|pkg)\z/
4
+ prune_dirs /\A(\.svn|\.git|CVS|tmp|tags|coverage|doc|pkg)\z/
5
5
  skip_files /(\A\.|\.sw[pon]\z|\.(log|fnm|jpg|jpeg|png|pdf|svg)\z|tags|~\z)/i
6
6
  end
7
7
 
8
8
  discover do
9
- prune_dirs /\A(\.svn|\.git|CVS|tmp|tags|coverage|pkg)\z/
9
+ prune_dirs /\A(\.svn|\.git|CVS|tmp|tags|coverage|doc|pkg)\z/
10
10
  skip_files /(\A\.|\.sw[pon]\z|\.log\z|~\z)/
11
11
  binary false
12
12
  end
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Description
4
4
 
5
- TODO
5
+ Library to memoize methods or functions in Ruby.
6
6
 
7
7
  ## Installation
8
8
 
@@ -18,7 +18,52 @@ and bundle.
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO
21
+ Memoizes methods, that is the values depend on the receiver, like this:
22
+
23
+ ```
24
+ class A
25
+ @@c = 0
26
+
27
+ memoize method:
28
+ def foo(x)
29
+ "foo #{x} #{@@c += 1}"
30
+ end
31
+ end
32
+
33
+ a1 = A.new
34
+ a1.foo(23) # => "foo 23 1"
35
+ a1.foo(23) # => "foo 23 1"
36
+ a2 = A.new
37
+ a2.foo(23) # => "foo 23 2"
38
+ a2.foo(23) # => "foo 23 2"
39
+ a2.mize_cache_clear
40
+ a2.foo(23) # => "foo 23 3"
41
+ a1.foo(23) # => "foo 23 1"
42
+ ```
43
+
44
+ Memoizes functions, that is the values do not depend on the receiver, like
45
+ this:
46
+
47
+ ```
48
+ class B
49
+ @@c = 0
50
+
51
+ memoize function:
52
+ def foo(x)
53
+ "foo #{x} #{@@c += 1}"
54
+ end
55
+ end
56
+
57
+ b1 = B.new
58
+ b1.foo(23) # => "foo 23 1"
59
+ b1.foo(23) # => "foo 23 1"
60
+ b2 = B.new
61
+ b2.foo(23) # => "foo 23 1"
62
+ b2.foo(23) # => "foo 23 1"
63
+ B.mize_cache_clear
64
+ b2.foo(23) # => "foo 23 2"
65
+ b1.foo(23) # => "foo 23 2"
66
+ ```
22
67
 
23
68
  ## Download
24
69
 
data/Rakefile CHANGED
@@ -6,49 +6,27 @@ GemHadar do
6
6
  name 'mize'
7
7
  author 'Florian Frank'
8
8
  email 'flori@ping.de'
9
- homepage "http://flori.github.com/#{name}"
9
+ homepage "https://github.com/flori/#{name}"
10
10
  summary 'Library that provides memoziation for methods and functions'
11
11
  description "#{summary} for Ruby."
12
12
  readme 'README.md'
13
13
  licenses << 'MIT'
14
14
 
15
15
  test_dir 'spec'
16
+ yard_dir 'doc'
17
+
16
18
  ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', 'coverage', '.rvmrc',
17
- '.AppleDouble', 'tags', '.byebug_history', '.yard*', 'errors.lst'
19
+ '.AppleDouble', 'tags', '.byebug_history', '.yard*', 'yard', 'doc',
20
+ 'errors.lst'
18
21
 
19
22
 
20
- dependency 'protocol', '~> 2.0'
21
23
  development_dependency 'rake'
22
24
  development_dependency 'simplecov'
23
25
  development_dependency 'rspec'
24
26
  development_dependency 'yard'
27
+ development_dependency 'all_images'
25
28
 
26
29
  required_ruby_version '>= 2'
27
30
  end
28
31
 
29
- namespace :yard do
30
- require 'pathname'
31
-
32
- yard_dir = Pathname.new('yard')
33
-
34
- desc 'Create yard documentation'
35
- task :create do
36
- sh 'yardoc'
37
- end
38
-
39
- desc 'View the yard documentation'
40
- task :view do
41
- index_file = yard_dir + 'index.html'
42
- File.exist?(index_file)
43
- sh "open #{index_file}"
44
- end
45
-
46
- desc 'Clean the yard documentation'
47
- task :clean do
48
- rm_rf yard_dir
49
- end
50
- end
51
-
52
- task :yard => %i[ yard:create yard:view ]
53
-
54
32
  task :default => :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
@@ -21,7 +21,6 @@ module Mize::CacheMethods
21
21
 
22
22
  # Set the cache object to +cache+.
23
23
  def __mize_cache__=(cache)
24
- Mize::CacheProtocol =~ cache
25
24
  @__mize_cache__ = cache
26
25
  end
27
26
 
@@ -1,32 +1,2 @@
1
- require 'protocol'
2
-
3
- # The protocol the cache object has to conform to. This is a minimal subset of
4
- # the ActiveSupport::Cache::Store protocol.
5
- Mize::CacheProtocol = Protocol do
6
- # Clear the entire cache.
7
- def clear(options = nil)
8
- end
9
-
10
- # Returns true if the cache contains an entry for the given key.
11
- def exist?(name, options = nil)
12
- end
13
-
14
- # Fetches data from the cache, using the given key. If there is data in the
15
- # cache with the given key, then that data is returned. Otherwise, nil is
16
- # returned.
17
- def read(name, options = nil)
18
- end
19
-
20
- # Writes the value to the cache, with the key.
21
- def write(name, value, options = nil)
22
- end
23
-
24
- # Iterate over all cache entries and yield to their names.
25
- def each_name(&block)
26
- end
27
-
28
- # Return another cache instance that was correctly configured.
29
- def prototype
30
- dup
31
- end
1
+ module Mize::CacheProtocol
32
2
  end
@@ -1,44 +1,68 @@
1
1
  require 'monitor'
2
2
 
3
3
  class Mize::DefaultCache
4
+ include Mize::CacheProtocol
4
5
  include MonitorMixin
5
6
 
6
7
  def initialize
7
8
  @data = {}
8
9
  end
9
10
 
11
+ # Clear the cache by removing all entries from the cache
10
12
  def clear(options = nil)
11
13
  @data.clear
12
14
  self
13
15
  end
14
16
 
17
+ # Determine whether a cache entry exists in this cache.
18
+ #
19
+ # @param name [String] The name of the cache entry to check.
20
+ # @return [Boolean] Whether or not the cache entry exists.
15
21
  def exist?(name, options = nil)
16
22
  @data.key?(name)
17
23
  end
18
24
 
25
+ # Read a value from the cache by name. If the entry does not exist in the
26
+ # cache, it will return nil.
27
+ #
28
+ # @param name [String] The name of the cache entry to read.
29
+ # @return [Object] The value stored in the cache for the given name.
19
30
  def read(name, options = nil)
20
31
  @data.fetch(name, nil)
21
32
  end
22
33
 
34
+ # Write a value to the cache by name. If an entry with the same name already
35
+ # exists in the cache, it will be overwritten.
36
+ #
37
+ # @param name [String] The name of the cache entry to write.
38
+ # @param value [Object] The value to store in the cache for the given name.
39
+ # @return [Object] The value stored in the chache.
23
40
  def write(name, value, options = nil)
24
41
  @data.store(name, value)
25
42
  end
26
43
 
44
+ # Delete a cache entry by name. If the entry does not exist in the cache, it
45
+ # will do nothing.
46
+ #
47
+ # @param name [String] The name of the cache entry to delete.
48
+ # @return [Object] The value stored in the chache before deletion.
27
49
  def delete(name, options = nil)
28
50
  @data.delete(name)
29
51
  end
30
52
 
53
+ # Each name of the cache is yielded to the block.
54
+ # @return [self]
31
55
  def each_name(&block)
32
56
  @data.each_key(&block)
33
57
  self
34
58
  end
35
59
 
60
+ # Initialize a duplicate of this cache.
61
+ # @param other [Mize::DefaultCache] The other cache to initialize a duplicate of.
36
62
  def initialize_dup(other)
37
63
  super
38
64
  other.instance_variable_set :@data, @data.dup
39
65
  end
40
66
 
41
67
  alias prototype dup
42
-
43
- conform_to Mize::CacheProtocol
44
68
  end
data/lib/mize/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Mize
2
2
  # Mize version
3
- VERSION = '0.4.0'
3
+ VERSION = '0.5.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/mize.gemspec CHANGED
@@ -1,50 +1,32 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: mize 0.4.0 ruby lib
2
+ # stub: mize 0.5.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "mize".freeze
6
- s.version = "0.4.0"
6
+ s.version = "0.5.0".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Florian Frank".freeze]
11
- s.date = "2019-11-15"
11
+ s.date = "2024-07-15"
12
12
  s.description = "Library that provides memoziation for methods and functions for Ruby.".freeze
13
13
  s.email = "flori@ping.de".freeze
14
14
  s.extra_rdoc_files = ["README.md".freeze, "lib/mize.rb".freeze, "lib/mize/cache_methods.rb".freeze, "lib/mize/cache_protocol.rb".freeze, "lib/mize/configure.rb".freeze, "lib/mize/default_cache.rb".freeze, "lib/mize/global_clear.rb".freeze, "lib/mize/memoize.rb".freeze, "lib/mize/railtie.rb".freeze, "lib/mize/reload.rb".freeze, "lib/mize/version.rb".freeze]
15
- s.files = [".gitignore".freeze, ".rspec".freeze, ".travis.yml".freeze, ".utilsrc".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "config/broken_config.yml".freeze, "config/config.yml".freeze, "lib/mize.rb".freeze, "lib/mize/cache_methods.rb".freeze, "lib/mize/cache_protocol.rb".freeze, "lib/mize/configure.rb".freeze, "lib/mize/default_cache.rb".freeze, "lib/mize/global_clear.rb".freeze, "lib/mize/memoize.rb".freeze, "lib/mize/railtie.rb".freeze, "lib/mize/reload.rb".freeze, "lib/mize/version.rb".freeze, "mize.gemspec".freeze, "spec/mize/global_clear_spec.rb".freeze, "spec/mize/memoize_method_spec.rb".freeze, "spec/mize/memoize_reload_spec.rb".freeze, "spec/mize/version_spec.rb".freeze, "spec/spec_helper.rb".freeze]
16
- s.homepage = "http://flori.github.com/mize".freeze
15
+ s.files = [".all_images.yml".freeze, ".gitignore".freeze, ".rspec".freeze, ".tool-versions".freeze, ".travis.yml".freeze, ".utilsrc".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "config/broken_config.yml".freeze, "config/config.yml".freeze, "lib/mize.rb".freeze, "lib/mize/cache_methods.rb".freeze, "lib/mize/cache_protocol.rb".freeze, "lib/mize/configure.rb".freeze, "lib/mize/default_cache.rb".freeze, "lib/mize/global_clear.rb".freeze, "lib/mize/memoize.rb".freeze, "lib/mize/railtie.rb".freeze, "lib/mize/reload.rb".freeze, "lib/mize/version.rb".freeze, "mize.gemspec".freeze, "spec/mize/global_clear_spec.rb".freeze, "spec/mize/memoize_method_spec.rb".freeze, "spec/mize/memoize_reload_spec.rb".freeze, "spec/mize/version_spec.rb".freeze, "spec/spec_helper.rb".freeze]
16
+ s.homepage = "https://github.com/flori/mize".freeze
17
17
  s.licenses = ["MIT".freeze]
18
18
  s.rdoc_options = ["--title".freeze, "Mize - Library that provides memoziation for methods and functions".freeze, "--main".freeze, "README.md".freeze]
19
19
  s.required_ruby_version = Gem::Requirement.new(">= 2".freeze)
20
- s.rubygems_version = "3.0.6".freeze
20
+ s.rubygems_version = "3.5.11".freeze
21
21
  s.summary = "Library that provides memoziation for methods and functions".freeze
22
22
  s.test_files = ["spec/mize/global_clear_spec.rb".freeze, "spec/mize/memoize_method_spec.rb".freeze, "spec/mize/memoize_reload_spec.rb".freeze, "spec/mize/version_spec.rb".freeze, "spec/spec_helper.rb".freeze]
23
23
 
24
- if s.respond_to? :specification_version then
25
- s.specification_version = 4
24
+ s.specification_version = 4
26
25
 
27
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
28
- s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.10.0"])
29
- s.add_development_dependency(%q<rake>.freeze, [">= 0"])
30
- s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
31
- s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
32
- s.add_development_dependency(%q<yard>.freeze, [">= 0"])
33
- s.add_runtime_dependency(%q<protocol>.freeze, ["~> 2.0"])
34
- else
35
- s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.10.0"])
36
- s.add_dependency(%q<rake>.freeze, [">= 0"])
37
- s.add_dependency(%q<simplecov>.freeze, [">= 0"])
38
- s.add_dependency(%q<rspec>.freeze, [">= 0"])
39
- s.add_dependency(%q<yard>.freeze, [">= 0"])
40
- s.add_dependency(%q<protocol>.freeze, ["~> 2.0"])
41
- end
42
- else
43
- s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.10.0"])
44
- s.add_dependency(%q<rake>.freeze, [">= 0"])
45
- s.add_dependency(%q<simplecov>.freeze, [">= 0"])
46
- s.add_dependency(%q<rspec>.freeze, [">= 0"])
47
- s.add_dependency(%q<yard>.freeze, [">= 0"])
48
- s.add_dependency(%q<protocol>.freeze, ["~> 2.0"])
49
- end
26
+ s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.16.0".freeze])
27
+ s.add_development_dependency(%q<rake>.freeze, [">= 0".freeze])
28
+ s.add_development_dependency(%q<simplecov>.freeze, [">= 0".freeze])
29
+ s.add_development_dependency(%q<rspec>.freeze, [">= 0".freeze])
30
+ s.add_development_dependency(%q<yard>.freeze, [">= 0".freeze])
31
+ s.add_development_dependency(%q<all_images>.freeze, [">= 0".freeze])
50
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-15 00:00:00.000000000 Z
11
+ date: 2024-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.10.0
19
+ version: 1.16.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.10.0
26
+ version: 1.16.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -81,19 +81,19 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: protocol
84
+ name: all_images
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '2.0'
90
- type: :runtime
89
+ version: '0'
90
+ type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '2.0'
96
+ version: '0'
97
97
  description: Library that provides memoziation for methods and functions for Ruby.
98
98
  email: flori@ping.de
99
99
  executables: []
@@ -111,8 +111,10 @@ extra_rdoc_files:
111
111
  - lib/mize/reload.rb
112
112
  - lib/mize/version.rb
113
113
  files:
114
+ - ".all_images.yml"
114
115
  - ".gitignore"
115
116
  - ".rspec"
117
+ - ".tool-versions"
116
118
  - ".travis.yml"
117
119
  - ".utilsrc"
118
120
  - Gemfile
@@ -137,11 +139,11 @@ files:
137
139
  - spec/mize/memoize_reload_spec.rb
138
140
  - spec/mize/version_spec.rb
139
141
  - spec/spec_helper.rb
140
- homepage: http://flori.github.com/mize
142
+ homepage: https://github.com/flori/mize
141
143
  licenses:
142
144
  - MIT
143
145
  metadata: {}
144
- post_install_message:
146
+ post_install_message:
145
147
  rdoc_options:
146
148
  - "--title"
147
149
  - Mize - Library that provides memoziation for methods and functions
@@ -160,8 +162,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
162
  - !ruby/object:Gem::Version
161
163
  version: '0'
162
164
  requirements: []
163
- rubygems_version: 3.0.6
164
- signing_key:
165
+ rubygems_version: 3.5.11
166
+ signing_key:
165
167
  specification_version: 4
166
168
  summary: Library that provides memoziation for methods and functions
167
169
  test_files: