wref 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +50 -3
- data/VERSION +1 -1
- data/lib/wref/implementations/id_class_unique.rb +7 -1
- data/wref.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fd35b6dde49ae9d2e93ba05435a677d1289a1ad
|
4
|
+
data.tar.gz: c8d2a3520f12ac4e9d0b38283a5642bd033fb8f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cff6d3ca7ca87cb73c5cd8d2b34de4992cf4e00d0a98f079e847f0211126e1749318a76c150176d7c459346e3d394c1164da064c748e13363fbd0c3337988b6
|
7
|
+
data.tar.gz: 232ca024fbf7e8e9c4657fe07d383a6ff2aafdb5fb62526a84233ab67e8e628fd784463d71a49074770156dac9ac46dbd1d0d99c5815622d049b2d305c6e2059
|
data/README.md
CHANGED
@@ -29,23 +29,70 @@ weak_ref = Wref.new(str)
|
|
29
29
|
weak_ref.alive? #=> true | false
|
30
30
|
```
|
31
31
|
|
32
|
-
###
|
32
|
+
### Spawn a weak map
|
33
33
|
|
34
34
|
```ruby
|
35
35
|
weak_map = Wref::Map.new
|
36
|
+
```
|
37
|
+
|
38
|
+
### Set a key and value in a weak map
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
str = "Test"
|
36
42
|
map[1] = str
|
43
|
+
map.set(1, str)
|
44
|
+
```
|
45
|
+
|
46
|
+
### Get values from a weak map
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
map.get(1) #=> "Test" | nil
|
50
|
+
map.get!(1) #=> "Test" | Wref::Recycled error
|
51
|
+
```
|
52
|
+
|
53
|
+
### Loop over all valid pairs in a weak map
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
map.each do |key, value|
|
57
|
+
puts "Valid pair: #{key}: #{value}"
|
58
|
+
end
|
37
59
|
```
|
38
60
|
|
39
61
|
### Check if key is valid in a weak map.
|
40
62
|
|
41
63
|
```ruby
|
42
|
-
|
64
|
+
map.valid?(1) #=> true | false
|
65
|
+
```
|
66
|
+
|
67
|
+
### Getting length of both valid and invalid and the current time in a weak map (fastest)
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
map.length #=> 1
|
71
|
+
```
|
72
|
+
|
73
|
+
### Getting length of valid options in a weak map
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
map.length_valid #=> 0
|
43
77
|
```
|
44
78
|
|
45
79
|
### Get from a key
|
46
80
|
|
47
81
|
```ruby
|
48
|
-
|
82
|
+
map.get(1) #=> "Test" | nil
|
83
|
+
map.get!(1) #=> "Test" | Error - Wref::Recycled
|
84
|
+
```
|
85
|
+
|
86
|
+
### Delete a key from a weak map
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
map.delete(1) #=> "Test" | nil if recycled
|
90
|
+
```
|
91
|
+
|
92
|
+
### Delete all recycled options
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
map.clean
|
49
96
|
```
|
50
97
|
|
51
98
|
## Contributing to wref
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
@@ -14,7 +14,13 @@ class Wref::Implementations::IdClassUnique
|
|
14
14
|
|
15
15
|
def get
|
16
16
|
return nil if !@class_name || !@id
|
17
|
-
|
17
|
+
|
18
|
+
begin
|
19
|
+
object = ObjectSpace._id2ref(@id)
|
20
|
+
rescue RangeError
|
21
|
+
destroy
|
22
|
+
return nil
|
23
|
+
end
|
18
24
|
|
19
25
|
#Some times this class-name will be nil for some reason - knj
|
20
26
|
object_class_name = object.class.name
|
data/wref.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: wref 0.0.
|
5
|
+
# stub: wref 0.0.8 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "wref"
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.8"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Kasper Johansen"]
|
14
|
-
s.date = "2015-04-
|
14
|
+
s.date = "2015-04-13"
|
15
15
|
s.description = "Lightweight weak reference and weak hash that works in 1.9 and JRuby."
|
16
16
|
s.email = "k@spernj.org"
|
17
17
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wref
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kasper Johansen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|