general_store 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba8eedc02580250094988ac68b234dfc49200fda
4
- data.tar.gz: c7baaed5d8665d33effc0671ad3dcfbf1d0a464e
3
+ metadata.gz: e0fcdc610162d8cfc8ce79887f9a6b7e5dfbbf91
4
+ data.tar.gz: 339c04790979665714fbf03160d46240d97e5959
5
5
  SHA512:
6
- metadata.gz: a22a2a7d18fb72f9f0a76b8892cbc9082c113d4e928daf54a9e0709a0de4d6149f1937a8b745e2cc508b244e98b5015616c1c7bb44e28bce00b61e326d39e550
7
- data.tar.gz: 809ee641aa6ef8da2157084faedb0e8304e656507e28f6bbdfc6c46a2c86200a8495281d856306ac8c779d29359062a3db5e5c95ec5c13e220a83b165878e3ad
6
+ metadata.gz: 8df4f776ab2f006532a6d50eb183756fdf975edacfd52ee40cacb47470e55de89ec74622842c10474e8c18c76eda3f49933034e30de2f958904ee13903c57e8b
7
+ data.tar.gz: 6b0441024dd5cec88771137b8e8da5645626e590cbd92b2b399133e744469e93a80b7566a446a453f7e5cc03344aafc8b70529c808015a38f497353e7b325a5d
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # GeneralStore
2
2
 
3
- TODO: Write a gem description
3
+ General Store is an easy way to store user-specific credentials for an
4
+ app on a user's machine.
4
5
 
5
6
  ## Installation
6
7
 
@@ -18,7 +19,41 @@ Or install it yourself as:
18
19
 
19
20
  ## Usage
20
21
 
21
- TODO: Write usage instructions here
22
+ Set the directory you want your `config.yml` file saved in, and push in
23
+ the values you want to store:
24
+
25
+ ``` ruby
26
+ GeneralStore.create '~/.your_directory' do |gs|
27
+ gs.consumer_key = 'my key'
28
+ gs.consumer_secret = 'my secret'
29
+ gs.oauth_token = 'oauth token'
30
+ gs.oauth_token_secret = 'oauth token secret'
31
+ end
32
+ ```
33
+
34
+ And then access them:
35
+
36
+ ``` ruby
37
+ store = GeneralStore.read '~/.your_directory'
38
+
39
+ store.consumer_key
40
+ => 'my key'
41
+ store.consumer_secret
42
+ => 'my secret'
43
+ ```
44
+
45
+ Apply any arbitrary name to your attributes when going into your store;
46
+ they will be accessible when you take them out:
47
+
48
+ ``` ruby
49
+ GeneralStore.create '~/.some_other_dir' do |gs|
50
+ gs.SoMethIngCRAZY = 'I couldnt think of a good example'
51
+ end
52
+
53
+ store = GeneralStore.read '~/.some_other_dir'
54
+ store.SoMethIngCRAZY
55
+ => 'I couldnt think of a good example'
56
+ ```
22
57
 
23
58
  ## Contributing
24
59
 
data/lib/general_store.rb CHANGED
@@ -38,7 +38,8 @@ class GeneralStore
38
38
  end
39
39
 
40
40
  def set dir
41
- File.write self.class.config_file(dir), YAML.dump(config)
41
+ klass = self.class
42
+ klass.write_file klass.config_file(dir), config
42
43
  end
43
44
 
44
45
  def self.create_config_file
@@ -46,6 +47,12 @@ class GeneralStore
46
47
  check_file_existence
47
48
  end
48
49
 
50
+ def self.write_file file, data
51
+ File.open file, File::RDWR|File::TRUNC|File::CREAT, 0600 do |config|
52
+ config.write YAML.dump data
53
+ end
54
+ end
55
+
49
56
  def self.check_dir_existence
50
57
  unless Dir.exists? config_dir
51
58
  Dir.mkdir config_dir
@@ -55,7 +62,7 @@ class GeneralStore
55
62
  def self.check_file_existence
56
63
  file = config_file @dir
57
64
  unless File.exists? file
58
- File.write file, YAML.dump({})
65
+ write_file file, {}
59
66
  end
60
67
  end
61
68
  end
@@ -1,3 +1,3 @@
1
1
  module GeneralStore
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: general_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Nelson