setting_store 0.1.0 → 0.1.1
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 +22 -8
- data/lib/setting_store.rb +10 -4
- data/lib/setting_store/version.rb +1 -1
- 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: 1b34315c8867891ae6e780908ed15aade249d45c
|
4
|
+
data.tar.gz: ad9f52d9f709c492932d0a9d60ae237f2026cdac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b791b01cf23dd4d3ea5192820d9365d3a826f4c766491c5641a735aeeadc16e2935a8aa03180f641e44925fa8493013c364ce118a81f8104ac233cde2d42f34
|
7
|
+
data.tar.gz: f710f7b950e7e03d9e9197d4a3a07550e826c8e31e5fbd68192cbca2acf99fd479a1495a39e5b20da56ceb7fa97cb27c3f8fe37bf7703facbf6961726197f3a0
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# SettingStore
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
SettingStore is a simple wrapper around PStore that allows you to set persistent data using a key value store
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,17 +20,33 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
To set a new key value pair
|
24
|
+
```
|
25
|
+
SettingStore.set(:feature, value: 'Hello World')
|
26
|
+
```
|
26
27
|
|
27
|
-
|
28
|
+
To retrieve a set key value
|
29
|
+
```
|
30
|
+
SettingStore.get(:feature)
|
31
|
+
=> 'Hello World'
|
32
|
+
```
|
28
33
|
|
29
|
-
|
34
|
+
To check if value of a specific key value is truthy
|
35
|
+
```
|
36
|
+
SettingStore.set(:simple_key, value: 'Random String')
|
37
|
+
SettingStore.active?(:simple_key)
|
38
|
+
=> false
|
39
|
+
|
40
|
+
# must be explicitly set to true for .active? to return true
|
41
|
+
SettingStore.set(:simple_key, value: true)
|
42
|
+
SettingStore.active?(:simple_key)
|
43
|
+
=> true
|
44
|
+
```
|
30
45
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
46
|
|
33
47
|
## Contributing
|
34
48
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
49
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Owenhorner/setting_store.
|
36
50
|
|
37
51
|
|
38
52
|
## License
|
data/lib/setting_store.rb
CHANGED
@@ -2,11 +2,13 @@ require "setting_store/version"
|
|
2
2
|
require 'pstore'
|
3
3
|
|
4
4
|
module SettingStore
|
5
|
-
def self.set(field, value: nil)
|
5
|
+
def self.set(field, group: nil, value: nil)
|
6
|
+
store = group ? group_pstore(group) : pstore
|
6
7
|
store.transaction { store[field.to_sym] = value }
|
7
8
|
end
|
8
9
|
|
9
|
-
def self.get(field)
|
10
|
+
def self.get(field, group: nil)
|
11
|
+
store = group ? group_pstore(group) : pstore
|
10
12
|
store.transaction { store[field.to_sym] }
|
11
13
|
end
|
12
14
|
|
@@ -16,8 +18,12 @@ module SettingStore
|
|
16
18
|
|
17
19
|
private
|
18
20
|
|
19
|
-
def self.
|
20
|
-
|
21
|
+
def self.group_pstore(group)
|
22
|
+
PStore.new(group.to_s + "_store.pstore")
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.pstore
|
26
|
+
PStore.new(store_filename)
|
21
27
|
end
|
22
28
|
|
23
29
|
def self.store_filename
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: setting_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Owen Horner
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|