setting_store 0.1.0 → 0.1.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
  SHA1:
3
- metadata.gz: 7ba55f11ec462c5d10f99460ed47809d324e5070
4
- data.tar.gz: df3f329a84669e8baf5f74d9a6f3b03617b5508b
3
+ metadata.gz: 1b34315c8867891ae6e780908ed15aade249d45c
4
+ data.tar.gz: ad9f52d9f709c492932d0a9d60ae237f2026cdac
5
5
  SHA512:
6
- metadata.gz: 4336b0829b72523c9473df5f7713bec3a1f9f0935b2627d42af91be2ee485d22ce963b4b809b68d910fbfe47d14c0c986428fe04ab48bad6ec4dc56ccc7903ce
7
- data.tar.gz: b674cdde0ef565674161f67a8811de4c4e5edc9ba024dcc2d6fc7e3f2496f4fec97269c24da661fe041ae23fa78fa649b45b994fa6d6541243889cf4ee613b2e
6
+ metadata.gz: 6b791b01cf23dd4d3ea5192820d9365d3a826f4c766491c5641a735aeeadc16e2935a8aa03180f641e44925fa8493013c364ce118a81f8104ac233cde2d42f34
7
+ data.tar.gz: f710f7b950e7e03d9e9197d4a3a07550e826c8e31e5fbd68192cbca2acf99fd479a1495a39e5b20da56ceb7fa97cb27c3f8fe37bf7703facbf6961726197f3a0
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # SettingStore
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/setting_store`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Write usage instructions here
23
+ To set a new key value pair
24
+ ```
25
+ SettingStore.set(:feature, value: 'Hello World')
26
+ ```
26
27
 
27
- ## Development
28
+ To retrieve a set key value
29
+ ```
30
+ SettingStore.get(:feature)
31
+ => 'Hello World'
32
+ ```
28
33
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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/[USERNAME]/setting_store.
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Owenhorner/setting_store.
36
50
 
37
51
 
38
52
  ## License
@@ -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.store
20
- @store ||= PStore.new(store_filename)
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
@@ -1,3 +1,3 @@
1
1
  module SettingStore
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-25 00:00:00.000000000 Z
11
+ date: 2016-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler