seed-snapshot 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/seed/manifest.rb +55 -0
- data/lib/seed-snapshot.rb +6 -0
- data/lib/seed_snapshot/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 367684aad510d16e7c9c393f3a3fca1155e8ef0d
|
4
|
+
data.tar.gz: d49014c5a4751082eac7f163f4fc23cfec412228
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b84529bda216ee931b36bbfd1642d75a42dcc774acad211580537080dd1973dadcf975fc8af119afc322347de0a08476d3d695102eb175afa20529c37671c2db
|
7
|
+
data.tar.gz: fd0e09772ac41c57230ef3ceb77fdced38733fa37e0f4324b294ff2d44a36b1880658bd9e6faa0fea58706f8d4505950797adc7906ad2d767dd511ebb6d6231e
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Seed
|
4
|
+
class Manifest
|
5
|
+
def initialize(configuration)
|
6
|
+
@configuration = configuration
|
7
|
+
@paths = []
|
8
|
+
end
|
9
|
+
|
10
|
+
def appends(paths = [])
|
11
|
+
@paths << paths
|
12
|
+
@paths.flatten!
|
13
|
+
end
|
14
|
+
|
15
|
+
def diff?
|
16
|
+
self.current.hash != self.latest.hash
|
17
|
+
end
|
18
|
+
|
19
|
+
def save
|
20
|
+
@configuration.make_tmp_dir
|
21
|
+
|
22
|
+
open(self.manifest_path, File::WRONLY | File::CREAT) do |io|
|
23
|
+
JSON.dump(self.current, io)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Hash]
|
28
|
+
def current
|
29
|
+
@current ||= self.generate_manifest
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [Hash]
|
33
|
+
def latest
|
34
|
+
@configuration.make_tmp_dir
|
35
|
+
|
36
|
+
open(self.manifest_path, File::RDONLY | File::CREAT) do |io|
|
37
|
+
JSON.load(io) rescue {}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def manifest_path
|
42
|
+
@configuration.base_path.join('seed_manifest.json')
|
43
|
+
end
|
44
|
+
|
45
|
+
def generate_manifest
|
46
|
+
hash = {}
|
47
|
+
@paths.each do |path|
|
48
|
+
next unless File.exist?(path)
|
49
|
+
content = File.read(path)
|
50
|
+
hash[path] = Digest::SHA256.new.update(content).hexdigest
|
51
|
+
end
|
52
|
+
hash
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/seed-snapshot.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'seed/configuration'
|
2
|
+
require 'seed/manifest'
|
2
3
|
require 'seed/mysql'
|
3
4
|
require 'seed/snapshot'
|
4
5
|
|
@@ -27,6 +28,11 @@ module SeedSnapshot
|
|
27
28
|
snapshot.clean
|
28
29
|
end
|
29
30
|
|
31
|
+
# @return Seed::Manifest
|
32
|
+
def self.manifest
|
33
|
+
Seed::Manifest.new(self.configuration)
|
34
|
+
end
|
35
|
+
|
30
36
|
# @return Seed::Configuration
|
31
37
|
def self.configuration
|
32
38
|
Seed::Configuration.new
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seed-snapshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yo_waka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- bin/setup
|
132
132
|
- lib/seed-snapshot.rb
|
133
133
|
- lib/seed/configuration.rb
|
134
|
+
- lib/seed/manifest.rb
|
134
135
|
- lib/seed/mysql.rb
|
135
136
|
- lib/seed/snapshot.rb
|
136
137
|
- lib/seed/version.rb
|
@@ -156,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
157
|
version: '0'
|
157
158
|
requirements: []
|
158
159
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.5.
|
160
|
+
rubygems_version: 2.4.5.1
|
160
161
|
signing_key:
|
161
162
|
specification_version: 4
|
162
163
|
summary: Easy dump/restore tool for ActiveRecord.
|