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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd963a291df8b9b731adac87c5886f9f25b83606c7a171347d0e6e8396c98533
4
- data.tar.gz: '0113974e4554b99b6061005f7d0218398592384d7bcd85f2fe4899b0d51232e9'
3
+ metadata.gz: f7f9e75dae934f9f5bdc8c760837499eb758b4e4495aa01b6a5b9e0d10460394
4
+ data.tar.gz: b88385f6f1a5003557b4b8a93ab5c5c0f58133d2e3eb24646a3bee986342fcc7
5
5
  SHA512:
6
- metadata.gz: 92fcb090695086fcfa85472d69f8f2631054c035c99f3024f7cebc67b730e418c6ed650f2c8042f4c6882e6782c1febea6fc73768c43258e6e84d28d6219c149
7
- data.tar.gz: a22f7131a2aca63c30bde0546c3ad0fdf77ef095b3d2cd5ed23853da02b314535c26771a900df059de056a76e32d50ad5e4802eab943736e9b423719ad036731
6
+ metadata.gz: 9aebe3c2d04df2fbc548414bfbce7e8e724db7191cf05f4282bd13746cc525c1934f8c784d3f179c12876c863cf7d80fa1257834516c40e392d6e9ed87ef3fe0
7
+ data.tar.gz: ef441853c477d295f7bddc0c2b03fd1043e2ae5b185fa60f4b5dfdb31f70803983e692b2865591a380efc842568b4837f32988333755c4e134114d986bb4332d
data/.gitignore CHANGED
@@ -11,8 +11,8 @@
11
11
  !LICENSE.txt
12
12
  .ruby-version
13
13
  appendonlydir
14
- Gemfile.lock
15
14
  etc/config
16
15
  log
17
16
  tmp
18
17
  vendor
18
+ *.gem
data/Gemfile CHANGED
@@ -2,9 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- ruby '>= 3.1'
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.pre.RC1'
15
+ gem "tryouts", '~> 2.2.0'
18
16
  end
data/Gemfile.lock CHANGED
@@ -47,6 +47,7 @@ GEM
47
47
 
48
48
  PLATFORMS
49
49
  arm64-darwin-22
50
+ ruby
50
51
 
51
52
  DEPENDENCIES
52
53
  byebug
@@ -59,4 +60,4 @@ RUBY VERSION
59
60
  ruby 3.2.0p0
60
61
 
61
62
  BUNDLED WITH
62
- 2.4.12
63
+ 2.5.7
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-RC3"
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", ">= 13.0.6"
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
@@ -1,6 +1,8 @@
1
1
 
2
2
  # Attic: A special place to store instance variables.
3
3
 
4
+ require "set"
5
+
4
6
  class NoMetaClass < RuntimeError
5
7
  end
6
8
 
@@ -52,6 +52,7 @@ module Attic
52
52
  end
53
53
 
54
54
  def attic_variable_set(name, val)
55
+ raise FrozenError, self, caller if frozen?
55
56
  attic_variables << name unless attic_variable? name
56
57
  attic.instance_variable_set("@___attic_#{name}", val)
57
58
  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-RC3'.freeze unless defined?(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('@attic_variables')
225
- a ||= attic.instance_variable_set('@attic_variables', [])
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 'irb/completion'
239
+ require "irb/completion"
240
240
  IRB.conf[:PROMPT][:ATTIC] = {
241
241
  PROMPT_I: "attic> ",
242
242
  PROMPT_S: "attic%l> ",
@@ -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.pre.RC3
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-04 00:00:00.000000000 Z
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: 1.3.1
98
+ version: '0'
98
99
  requirements: []
99
100
  rubygems_version: 3.4.12
100
101
  signing_key: