hash_cabinet 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/hash_cabinet.rb +7 -4
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cf8339502c63e8313cd47f2fddcf2956d673f3ebe6d0b723d2095925b7d857e
|
4
|
+
data.tar.gz: 032c1541962d2d994636ec05fba0e4f97696414689e8db8bf876501a4e533977
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 477ba1f33f8343d927420a27a9bc932bfda577fc814968c897bde4fc362bc199def57966a64b5e16af846ffc158d39a2b223ccbd93a1c68de719ec76a754c7ed
|
7
|
+
data.tar.gz: a254472281b4f323b7a78ed17c0c272a741cad1bbd3ddb5e800bc4ff26561a15447c58cc7341703ea4f3b3a044f2c9649927d3925c33d9ba05c320a79b276400
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@ Hash Cabinet - File based key-object store
|
|
2
2
|
==================================================
|
3
3
|
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/hash_cabinet.svg)](https://badge.fury.io/rb/hash_cabinet)
|
5
|
-
[![Build Status](https://
|
5
|
+
[![Build Status](https://github.com/DannyBen/hash_cabinet/workflows/Test/badge.svg)](https://github.com/DannyBen/hash_cabinet/actions?query=workflow%3ATest)
|
6
6
|
[![Maintainability](https://api.codeclimate.com/v1/badges/c69f9676cd8cd5fc33bc/maintainability)](https://codeclimate.com/github/DannyBen/hash_cabinet/maintainability)
|
7
7
|
|
8
8
|
---
|
@@ -41,7 +41,7 @@ cabinet['another-key'] = { color: 'yellow' }
|
|
41
41
|
|
42
42
|
# Retrieve values
|
43
43
|
p cabinet['another-key']
|
44
|
-
#=> {:color=>"yellow"
|
44
|
+
#=> {:color=>"yellow"}
|
45
45
|
|
46
46
|
# Show all values
|
47
47
|
p cabinet.to_h
|
data/lib/hash_cabinet.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'sdbm'
|
2
2
|
require 'yaml'
|
3
3
|
|
4
|
+
# @!attribute [r] path
|
5
|
+
# @return [String] the path to the database file
|
4
6
|
class HashCabinet
|
5
7
|
|
6
8
|
# Refinements for internal use
|
@@ -20,10 +22,11 @@ class HashCabinet
|
|
20
22
|
|
21
23
|
using Refinements
|
22
24
|
|
23
|
-
# Returns the path to the database file.
|
24
25
|
attr_reader :path
|
25
26
|
|
26
|
-
#
|
27
|
+
# Initializes a new database file at {path}
|
28
|
+
#
|
29
|
+
# @param [String] path the path to the database file
|
27
30
|
def initialize(path)
|
28
31
|
@path = path
|
29
32
|
end
|
@@ -46,7 +49,7 @@ class HashCabinet
|
|
46
49
|
SDBM.open path, &block
|
47
50
|
end
|
48
51
|
|
49
|
-
#
|
52
|
+
# @return [Object] the value in the database associated with the given +key+.
|
50
53
|
def [](key)
|
51
54
|
transaction { |db| db[key.to_s].from_yaml }
|
52
55
|
end
|
@@ -102,7 +105,7 @@ class HashCabinet
|
|
102
105
|
#
|
103
106
|
# @yieldparam [String] key the pair key
|
104
107
|
def each_key(&block)
|
105
|
-
transaction { |db| db.each_key
|
108
|
+
transaction { |db| db.each_key(&block) }
|
106
109
|
end
|
107
110
|
|
108
111
|
# Iterates over each key-value pair in the database.
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_cabinet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2020-12-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sdbm
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
13
27
|
description: Store objects in a file using hash-like syntax
|
14
28
|
email: db@dannyben.com
|
15
29
|
executables: []
|
@@ -40,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
54
|
- !ruby/object:Gem::Version
|
41
55
|
version: '0'
|
42
56
|
requirements: []
|
43
|
-
rubygems_version: 3.
|
57
|
+
rubygems_version: 3.1.4
|
44
58
|
signing_key:
|
45
59
|
specification_version: 4
|
46
60
|
summary: Key-object file database with hash-like access
|