stuff_arc 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/stuff_arc/stuff_arc.rb +8 -4
- metadata +4 -4
data/Rakefile
CHANGED
data/lib/stuff_arc/stuff_arc.rb
CHANGED
@@ -13,10 +13,9 @@
|
|
13
13
|
|
14
14
|
require 'rails'
|
15
15
|
require 'active_model'
|
16
|
-
# require 'pry'
|
17
16
|
|
18
17
|
module StuffArc
|
19
|
-
VERSION = "0.0.
|
18
|
+
VERSION = "0.0.7"
|
20
19
|
module Base
|
21
20
|
def archive options = {}
|
22
21
|
return self.class.archive options unless self.class == Class
|
@@ -40,10 +39,13 @@ module StuffArc
|
|
40
39
|
end
|
41
40
|
f = File.open(fname, 'w')
|
42
41
|
list = self.all
|
42
|
+
save_include_root_in_json = include_root_in_json
|
43
|
+
self.include_root_in_json = false
|
43
44
|
list.each do |instance|
|
44
45
|
# as_json returns a hash, which we have to change to a JSON string
|
45
46
|
f.write instance.as_json.to_json + "\n"
|
46
47
|
end
|
48
|
+
self.include_root_in_json = save_include_root_in_json
|
47
49
|
f.close
|
48
50
|
list.length
|
49
51
|
end
|
@@ -69,12 +71,14 @@ module StuffArc
|
|
69
71
|
|
70
72
|
counter = 0
|
71
73
|
f.lines do |line|
|
72
|
-
tmp = self.new
|
74
|
+
tmp = self.new
|
75
|
+
hash = ActiveSupport::JSON.decode(line.chomp)
|
76
|
+
hash.each { |k,v| tmp.send("#{k}=".to_sym, v) }
|
73
77
|
begin
|
74
78
|
tmp.save!
|
75
79
|
counter += 1
|
76
80
|
rescue Exception => e
|
77
|
-
puts "exception unarchiving #{self}:
|
81
|
+
puts "exception unarchiving #{self}: #{e}\n"
|
78
82
|
end
|
79
83
|
end
|
80
84
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stuff_arc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-01 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &2165149680 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2165149680
|
25
25
|
description: stuff_arc - adds class level archiving/unarchiving to ActiveRecord::Base
|
26
26
|
children
|
27
27
|
email: mike@clove.com
|