attic 1.0.0.pre.RC3 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Gemfile +2 -4
- data/Gemfile.lock +2 -1
- data/attic.gemspec +2 -3
- data/lib/attic/errors.rb +2 -0
- data/lib/attic/instance_methods.rb +1 -0
- data/lib/attic.rb +4 -4
- data/try/10_attic_tryouts.rb +11 -0
- data/try/15_frozen_attic_tryouts.rb +67 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7f9e75dae934f9f5bdc8c760837499eb758b4e4495aa01b6a5b9e0d10460394
|
4
|
+
data.tar.gz: b88385f6f1a5003557b4b8a93ab5c5c0f58133d2e3eb24646a3bee986342fcc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9aebe3c2d04df2fbc548414bfbce7e8e724db7191cf05f4282bd13746cc525c1934f8c784d3f179c12876c863cf7d80fa1257834516c40e392d6e9ed87ef3fe0
|
7
|
+
data.tar.gz: ef441853c477d295f7bddc0c2b03fd1043e2ae5b185fa60f4b5dfdb31f70803983e692b2865591a380efc842568b4837f32988333755c4e134114d986bb4332d
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -2,9 +2,7 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
ruby '>=
|
6
|
-
|
7
|
-
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
5
|
+
ruby '>= 2.6.8', '< 4.0'
|
8
6
|
|
9
7
|
# bundle install --without production
|
10
8
|
# bundle install --with development
|
@@ -14,5 +12,5 @@ group "development" do
|
|
14
12
|
gem "pry"
|
15
13
|
gem "pry-doc"
|
16
14
|
gem "rubocop"
|
17
|
-
gem "tryouts", '2.2.0
|
15
|
+
gem "tryouts", '~> 2.2.0'
|
18
16
|
end
|
data/Gemfile.lock
CHANGED
data/attic.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "attic"
|
3
|
-
s.version = "1.0.
|
3
|
+
s.version = "1.0.1"
|
4
4
|
s.summary = "When in doubt, store it in the attic"
|
5
5
|
s.description = "Attic: a place to hide metadata about the class or variable itself (e.g. SHA hash summaries)."
|
6
6
|
s.authors = ["Delano Mandelbaum"]
|
@@ -15,9 +15,8 @@ Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
17
17
|
|
18
|
-
s.add_dependency "rake", "
|
18
|
+
s.add_dependency "rake", "~> 13.0.6"
|
19
19
|
|
20
|
-
# Add development dependencies
|
21
20
|
s.add_development_dependency "rspec", "~> 3.0"
|
22
21
|
s.add_development_dependency "rubocop", "~> 1.0"
|
23
22
|
end
|
data/lib/attic/errors.rb
CHANGED
data/lib/attic.rb
CHANGED
@@ -100,7 +100,7 @@ require_relative "attic/instance_methods"
|
|
100
100
|
# nil.attic.object_id #=> 800
|
101
101
|
#
|
102
102
|
module Attic
|
103
|
-
VERSION =
|
103
|
+
VERSION = "1.0.1".freeze unless defined?(VERSION)
|
104
104
|
|
105
105
|
# A convenince method at the class level for including
|
106
106
|
# ConstructMethods in the given object specifically.
|
@@ -221,8 +221,8 @@ module Attic
|
|
221
221
|
# String.attic_variables # => [:timestamp]
|
222
222
|
#
|
223
223
|
def attic_variables
|
224
|
-
a = attic.instance_variable_get(
|
225
|
-
a ||= attic.instance_variable_set(
|
224
|
+
a = attic.instance_variable_get("@attic_variables")
|
225
|
+
a ||= attic.instance_variable_set("@attic_variables", [])
|
226
226
|
a
|
227
227
|
end
|
228
228
|
|
@@ -236,7 +236,7 @@ end
|
|
236
236
|
|
237
237
|
# Add some candy when we're in irb
|
238
238
|
if defined?(IRB)
|
239
|
-
require
|
239
|
+
require "irb/completion"
|
240
240
|
IRB.conf[:PROMPT][:ATTIC] = {
|
241
241
|
PROMPT_I: "attic> ",
|
242
242
|
PROMPT_S: "attic%l> ",
|
data/try/10_attic_tryouts.rb
CHANGED
@@ -49,3 +49,14 @@ ExampleClass.attic :kind
|
|
49
49
|
a = ExampleClass.new
|
50
50
|
a.kind
|
51
51
|
#=> :unlikely_value
|
52
|
+
|
53
|
+
# If we try to add an attic variable to an instance,
|
54
|
+
# we get an ArgumentError (we can only add attic vars
|
55
|
+
# at the class level).
|
56
|
+
a = ExampleClass.new
|
57
|
+
begin
|
58
|
+
a.attic :colour
|
59
|
+
rescue => e
|
60
|
+
e.class
|
61
|
+
end
|
62
|
+
#=> ArgumentError
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require_relative '../lib/attic'
|
2
|
+
|
3
|
+
# Tests for the frozen objects
|
4
|
+
|
5
|
+
# A class we define can extend Attic
|
6
|
+
class ::ExampleClass
|
7
|
+
extend Attic
|
8
|
+
end
|
9
|
+
|
10
|
+
ExampleClass.methods.member?(:attic)
|
11
|
+
#=> true
|
12
|
+
|
13
|
+
# Classes that extend Attic don't spawn frozen instances
|
14
|
+
a = ExampleClass.new
|
15
|
+
a.frozen?
|
16
|
+
#=> false
|
17
|
+
|
18
|
+
# Classes that extend Attic and have attic variables
|
19
|
+
# also don't spawn frozen instances
|
20
|
+
ExampleClass.attic :size
|
21
|
+
a = ExampleClass.new
|
22
|
+
a.frozen?
|
23
|
+
#=> false
|
24
|
+
|
25
|
+
# Instances can still freeze normally
|
26
|
+
a = ExampleClass.new
|
27
|
+
a.freeze
|
28
|
+
a.frozen?
|
29
|
+
#=> true
|
30
|
+
|
31
|
+
# Instances can still freeze normally even if they
|
32
|
+
# have attic with values
|
33
|
+
ExampleClass.attic :size
|
34
|
+
a = ExampleClass.new
|
35
|
+
a.size = 2
|
36
|
+
a.freeze
|
37
|
+
[a.frozen?, a.size]
|
38
|
+
#=> [true, 2]
|
39
|
+
|
40
|
+
# Frozen instances can't have their attic vars changed either
|
41
|
+
a = ExampleClass.new
|
42
|
+
a.size = 2
|
43
|
+
a.freeze
|
44
|
+
begin
|
45
|
+
a.size = 3
|
46
|
+
rescue => e
|
47
|
+
e.class
|
48
|
+
end
|
49
|
+
#=> FrozenError
|
50
|
+
|
51
|
+
# Regardless of the behaviour of the instance itself, once
|
52
|
+
# it's frozen, its singleton class is frozen too!
|
53
|
+
a = ExampleClass.new
|
54
|
+
a.freeze
|
55
|
+
a.singleton_class.frozen?
|
56
|
+
#=> true
|
57
|
+
|
58
|
+
# Frozen instances can't have their attic vars changed either
|
59
|
+
a = ExampleClass.new
|
60
|
+
a.size = 2
|
61
|
+
a.freeze
|
62
|
+
begin
|
63
|
+
a.size = 3
|
64
|
+
rescue => e
|
65
|
+
e.class
|
66
|
+
end
|
67
|
+
#=> FrozenError
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Delano Mandelbaum
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 13.0.6
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 13.0.6
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/attic/instance_methods.rb
|
74
74
|
- try/01_mixins_tryouts.rb
|
75
75
|
- try/10_attic_tryouts.rb
|
76
|
+
- try/15_frozen_attic_tryouts.rb
|
76
77
|
- try/20_accessing_tryouts.rb
|
77
78
|
- try/25_string_tryouts.rb
|
78
79
|
- try/30_nometaclass_tryouts.rb
|
@@ -92,9 +93,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
93
|
version: 2.6.0
|
93
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
95
|
requirements:
|
95
|
-
- - "
|
96
|
+
- - ">="
|
96
97
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
98
|
+
version: '0'
|
98
99
|
requirements: []
|
99
100
|
rubygems_version: 3.4.12
|
100
101
|
signing_key:
|