attic 1.0.0.pre.RC3 → 1.0.0
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/instance_methods.rb +1 -0
- data/lib/attic.rb +1 -1
- 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: ba2c5122967296a766b52ac046951567c4daf3845596533f297936bb094155d4
|
4
|
+
data.tar.gz: ad4d86d50d03b6b48c8f05f5cf06c27ed2df348a2adf7ef3b038b4efed3c9337
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d884ee454dd855cb09315b995c0705bbc4c327dc5ea397589e3b8e6143ed54d7cfb36bf01f62ba99404a62243523a1ee4c35c3d95ca53b319a5acbecab64d9b5
|
7
|
+
data.tar.gz: 6e2391ebb5e6ff55b1c27c475bacadbb9c67f5d1e770b79e762dfdf2cb9bc8a4c982b370cacb2ca2436d9f291101eef733a2af11b9727436f51415876f8af33f
|
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.0
|
3
|
+
s.version = "1.0.0"
|
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.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 = '1.0.0
|
103
|
+
VERSION = '1.0.0'.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.
|
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.0
|
4
|
+
version: 1.0.0
|
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:
|