object-stash 1.0.1 → 1.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.
Files changed (5) hide show
  1. data/History.txt +2 -5
  2. data/README.txt +1 -1
  3. data/Rakefile +3 -3
  4. data/lib/object-stash.rb +2 -78
  5. metadata +2 -2
@@ -1,6 +1,3 @@
1
- === 1.0.1 / 2008-03-15
2
-
3
- * First release
4
-
5
- * Birthday!
1
+ === 1.0.2 / 2008-03-15
6
2
 
3
+ * Gem listing fix
data/README.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  = object-stash
2
2
 
3
- * http://www.marcuswestin.com
3
+ * http://object-stash.rubyforge.org/
4
4
 
5
5
  == DESCRIPTION:
6
6
 
data/Rakefile CHANGED
@@ -5,9 +5,9 @@ require 'hoe'
5
5
  require './lib/object-stash.rb'
6
6
 
7
7
  Hoe.new('object-stash', ObjectStash::VERSION) do |p|
8
- #p.rubyforge_name = 'object-stash' # if different than lowercase project name
9
- p.developer('Marcus Westin', 'Marcus@MarcusWestin.com')
10
- #p.remote_rdoc_dir = '' # Release to root
8
+ # p.rubyforge_name = 'object-stashx' # if different than lowercase project name
9
+ p.developer('Marcus Westin', 'Marcus@MarcusWestin.com')
10
+ p.remote_rdoc_dir = '' # Release to root
11
11
  end
12
12
 
13
13
  # vim: syntax=Ruby
@@ -1,79 +1,3 @@
1
- require 'zlib'
2
-
3
- # Save any ruby object to disk!
4
- # Objects are stored as gzipped marshal dumps.
5
- #
6
- # Example
7
- #
8
- # # First ruby process
9
- # hash = {1 => "Entry1", 2 => "Entry2"}
10
- # ObjectStash.sotre hash, 'hash.stash'
11
- #
12
- # ...
13
- #
14
- # # Another ruby process - same_hash will be identical to the original hash
15
- # same_hash = ObjectStash.load 'hash.stash'
16
1
  class ObjectStash
17
- VERSION = '1.0.1'
18
-
19
- # Store an object as a gzipped file to disk
20
- #
21
- # Example
22
- #
23
- # hash = {1 => "Entry1", 2 => "Entry2"}
24
- # ObjectStore.store hash, 'hash.stash.gz'
25
- # ObjectStore.store hash, 'hash.stash', :gzip => false
26
- def self.store obj, file_name, options={}
27
- marshal_dump = Marshal.dump(obj)
28
- file = File.new(file_name,'w')
29
- file = Zlib::GzipWriter.new(file) unless options[:gzip] == false
30
- file.write marshal_dump
31
- file.close
32
- return obj
33
- end
34
-
35
- # Read a marshal dump from file and load it as an object
36
- #
37
- # Example
38
- #
39
- # hash = ObjectStore.get 'hash.dump.gz'
40
- # hash_no_gzip = ObjectStore.get 'hash.dump.gz'
41
- def self.load file_name
42
- begin
43
- file = Zlib::GzipReader.open(file_name)
44
- rescue Zlib::GzipFile::Error
45
- file = File.open(file_name, 'r')
46
- ensure
47
- obj = Marshal.load file.read
48
- file.close
49
- return obj
50
- end
51
- end
52
- end
53
-
54
- if $0 == __FILE__
55
- require 'test/unit'
56
- class TestObjectStash < Test::Unit::TestCase
57
- @@tmp = '/tmp/TestObjectStash.stash'
58
- def test_hash_store_load
59
- hash1 = {:test=>'test'}
60
- ObjectStash.store hash1, @@tmp
61
- hash2 = ObjectStash.load @@tmp
62
- assert hash1 == hash2
63
- end
64
- def test_hash_store_load_no_gzip
65
- hash1 = {:test=>'test'}
66
- ObjectStash.store hash1, @@tmp, :gzip => false
67
- hash2 = ObjectStash.load @@tmp
68
- assert hash1 == hash2
69
- end
70
- def test_self_stash
71
- ObjectStash.store ObjectStash, @@tmp
72
- assert ObjectStash == ObjectStash.load(@@tmp)
73
- end
74
- def test_self_stash_no_gzip
75
- ObjectStash.store ObjectStash, @@tmp, :gzip => false
76
- assert ObjectStash == ObjectStash.load(@@tmp)
77
- end
78
- end
79
- end
2
+ VERSION = '1.0.2'
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: object-stash
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Westin
@@ -41,7 +41,7 @@ files:
41
41
  - lib/object-stash.rb
42
42
  - test/test_object-stash.rb
43
43
  has_rdoc: true
44
- homepage: http://www.marcuswestin.com
44
+ homepage: http://object-stash.rubyforge.org/
45
45
  post_install_message:
46
46
  rdoc_options:
47
47
  - --main