persist 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,33 +18,37 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- Example in IRB:
21
+ Example in Pry (or IRB):
22
22
 
23
23
  ```ruby
24
24
  require 'persist'
25
+ #=> true
25
26
 
26
- db = Persist.new
27
- #=> #<Persist:0x007fa5ca29f258 @stash={}>
28
-
29
- db.stash[:siblings] = ["Katie", "Molly", "Shannnon"]
30
- #=> {:siblings=>["Katie", "Molly", "Shannnon"]}
27
+ Persist.pull
28
+ #=> {}
29
+
30
+ Persist.store[:siblings] = ["Katie", "Molly", "Shannnon"]
31
+ #=> ["Katie", "Molly", "Shannnon"]
31
32
 
32
- db.push # This saves your Stash to the persistent store.
33
+ Persist.push # This saves your Stash to the persistent store.
33
34
  #=> <File:.persistent_store (closed)>
35
+ ```
36
+
37
+ You can now quit IRB and your store will persist!
38
+
39
+ ```ruby
40
+ require 'persist'
41
+ #=> true
42
+
43
+ Persist.pull
44
+ #=> {:siblings=>["Katie", "Molly", "Shannnon"]}
34
45
 
35
- # You can now quit IRB and your stash will persist.
36
-
37
- db = Persist.new # In a new Irb session.
38
- #=> #<Persist:0x007fb8c519e7d8 @stash={:siblings=>["Katie", "Molly", "Shannnon"]}
39
-
40
- db.stash[:siblings]
46
+ Persist.pull[:siblings]
41
47
  #=> ["Katie", "Molly", "Shannnon"]
42
48
  ```
43
49
 
44
50
  ## Contributing
45
51
 
46
52
  1. Fork it
47
- 2. Create your feature branch (`git checkout -b my-new-feature`)
48
- 3. Commit your changes (`git commit -am 'Added some feature'`)
49
- 4. Push to the branch (`git push origin my-new-feature`)
50
- 5. Create new Pull Request
53
+ 2. Commit your changes (`git commit -am 'Added some feature'`)
54
+ 3. Create new Pull Request
@@ -1,3 +1,3 @@
1
- class Persist
2
- VERSION = "0.0.1"
1
+ module Persist
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/persist.rb CHANGED
@@ -1,30 +1,28 @@
1
1
  require "persist/version"
2
2
 
3
- class Persist
4
- STORE = '.persistent_store'
3
+ module Persist
4
+ class << self
5
+ STORE = '.persistent_store'
5
6
 
6
- attr_accessor :stash
7
+ attr_accessor :store
7
8
 
8
- def initialize
9
- unless File.exists? STORE
10
- self.reset!
9
+ def pull
10
+ unless File.exists? STORE
11
+ self.reset!
12
+ end
13
+ @store = Marshal.load File.read(STORE)
11
14
  end
12
- self.pull
13
- end
14
-
15
- def pull
16
- @stash = Marshal.load File.read(STORE)
17
- end
18
15
 
19
- def push
20
- File.open STORE, 'w' do |store|
21
- store << Marshal.dump(@stash)
16
+ def push
17
+ File.open STORE, 'w' do |store|
18
+ store << Marshal.dump(@store)
19
+ end
22
20
  end
23
- end
24
21
 
25
- def reset!
26
- File.open STORE, 'w' do |store|
27
- store << Marshal.dump({})
22
+ def reset!
23
+ File.open STORE, 'w' do |store|
24
+ store << Marshal.dump({})
25
+ end
28
26
  end
29
27
  end
30
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: persist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -19,7 +19,6 @@ extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
21
  - .gitignore
22
- - .persistent_store
23
22
  - Gemfile
24
23
  - LICENSE
25
24
  - README.md
data/.persistent_store DELETED
@@ -1,3 +0,0 @@
1
- {:
2
- Katie:ETI"
3
- Molly;TI"