dis 1.0.3 → 1.0.4
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 +4 -4
- data/lib/dis.rb +2 -0
- data/lib/dis/engine.rb +6 -0
- data/lib/dis/layer.rb +7 -0
- data/lib/dis/version.rb +1 -1
- data/lib/tasks/dis.rake +39 -0
- metadata +18 -3
- data/lib/dis/sparse_layer.rb +0 -98
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 835c04f15f51b3e319654d2a8040df778c62cc8a
|
4
|
+
data.tar.gz: 2dee85c2af96d2804140d449a79e1d43fc3da22a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1f15973ebba3a27e077c3cbcfc779d3e42be633663c5fe1bc64b4662ac37af18da246aac11644e20303b440b649aa53021a5aeadfd284f1b75961c6a1a22ced
|
7
|
+
data.tar.gz: dd16af7aacf26faeeaf9052acc7e7ca2a91df3c2b9ed4b526cbb7b4b85b155aa1e024e00f9f06c79ca890a0a556253ca353e3639e0849f90fbedada66c545417
|
data/lib/dis.rb
CHANGED
data/lib/dis/engine.rb
ADDED
data/lib/dis/layer.rb
CHANGED
@@ -125,6 +125,13 @@ module Dis
|
|
125
125
|
delete!(type, hash)
|
126
126
|
end
|
127
127
|
|
128
|
+
# Returns a name for the layer.
|
129
|
+
#
|
130
|
+
# layer.name # => "Fog::Storage::Local::Real/development"
|
131
|
+
def name
|
132
|
+
"#{connection.class.name}/#{path}"
|
133
|
+
end
|
134
|
+
|
128
135
|
private
|
129
136
|
|
130
137
|
def default_options
|
data/lib/dis/version.rb
CHANGED
data/lib/tasks/dis.rake
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
namespace :dis do
|
4
|
+
desc "Check stuff"
|
5
|
+
task consistency_check: :environment do
|
6
|
+
unless ENV["MODELS"]
|
7
|
+
puts "Usage: #{$PROGRAM_NAME} dis:consistency_check " \
|
8
|
+
"MODELS=Avatar,Document"
|
9
|
+
exit
|
10
|
+
end
|
11
|
+
|
12
|
+
models = ENV["MODELS"].split(",").map(&:strip).map(&:constantize)
|
13
|
+
|
14
|
+
models.each do |model|
|
15
|
+
puts "-- #{model.name} --"
|
16
|
+
|
17
|
+
content_hash_attr = model.dis_attributes[:content_hash]
|
18
|
+
objects = model
|
19
|
+
.select(content_hash_attr)
|
20
|
+
.uniq
|
21
|
+
.map { |r| r.send(content_hash_attr) }
|
22
|
+
|
23
|
+
puts "Unique objects: #{objects.length}"
|
24
|
+
|
25
|
+
Dis::Storage.layers.each do |layer|
|
26
|
+
existing = objects
|
27
|
+
.pmap { |hash| [hash, layer.exists?(model.dis_type, hash)] }
|
28
|
+
.select(&:last)
|
29
|
+
.map(&:first)
|
30
|
+
missing = objects - existing
|
31
|
+
puts "#{layer.name}: #{existing.length} (#{missing.length} missing)"
|
32
|
+
|
33
|
+
puts "Missing objects:\n#{missing.inspect}" if missing.any?
|
34
|
+
end
|
35
|
+
|
36
|
+
puts
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Inge Jørgensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.26.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pmap
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.2
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.2
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: sqlite3
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,6 +91,7 @@ files:
|
|
77
91
|
- MIT-LICENSE
|
78
92
|
- README.md
|
79
93
|
- lib/dis.rb
|
94
|
+
- lib/dis/engine.rb
|
80
95
|
- lib/dis/errors.rb
|
81
96
|
- lib/dis/jobs.rb
|
82
97
|
- lib/dis/jobs/delete.rb
|
@@ -86,7 +101,6 @@ files:
|
|
86
101
|
- lib/dis/model.rb
|
87
102
|
- lib/dis/model/class_methods.rb
|
88
103
|
- lib/dis/model/data.rb
|
89
|
-
- lib/dis/sparse_layer.rb
|
90
104
|
- lib/dis/storage.rb
|
91
105
|
- lib/dis/validations.rb
|
92
106
|
- lib/dis/validations/data_presence.rb
|
@@ -94,6 +108,7 @@ files:
|
|
94
108
|
- lib/rails/generators/dis/install/install_generator.rb
|
95
109
|
- lib/rails/generators/dis/install/templates/initializer.rb
|
96
110
|
- lib/rails/generators/dis/model/model_generator.rb
|
111
|
+
- lib/tasks/dis.rake
|
97
112
|
homepage: https://github.com/elektronaut/dis
|
98
113
|
licenses:
|
99
114
|
- MIT
|
data/lib/dis/sparse_layer.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Dis
|
4
|
-
# = Dis SparseLayer
|
5
|
-
#
|
6
|
-
# A special case of Dis::Layer intended to be sparsely populated.
|
7
|
-
# Can be configured with a size limit, objects that have been transferred
|
8
|
-
# to other layers will be evicted based on a Least Recently Used basis.
|
9
|
-
#
|
10
|
-
# ==== Example
|
11
|
-
#
|
12
|
-
# Dis::SparseLayer.new(
|
13
|
-
# Fog::Storage.new({
|
14
|
-
# provider: 'Local',
|
15
|
-
# local_root: Rails.root.join('db', 'dis')
|
16
|
-
# }),
|
17
|
-
# path: Rails.env,
|
18
|
-
# limit: 10.gigabytes
|
19
|
-
# )
|
20
|
-
class SparseLayer < Layer
|
21
|
-
def initialize(connection, options={})
|
22
|
-
super
|
23
|
-
@limit = options[:limit]
|
24
|
-
end
|
25
|
-
|
26
|
-
def limit?
|
27
|
-
@limit ? true : false
|
28
|
-
end
|
29
|
-
|
30
|
-
def store(type, hash, file)
|
31
|
-
super.tap do
|
32
|
-
update_timestamp(type, hash)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def get(type, hash)
|
37
|
-
super.tap do |result|
|
38
|
-
update_timestamp(type, hash) if result
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def delete(type, hash)
|
43
|
-
super.tap do
|
44
|
-
delete_timestamp(type, hash)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def delete_timestamp(type, path)
|
51
|
-
return false unless timestamp_exists?(type, path)
|
52
|
-
get_timestamp(type, path).destroy
|
53
|
-
end
|
54
|
-
|
55
|
-
def get_timestamp(type, hash)
|
56
|
-
if dir = directory(type, hash)
|
57
|
-
dir.files.get(timestamp_path(type, hash))
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def outdated_timestamp?(timestamp)
|
62
|
-
!timestamp || timestamp < 5.minutes.ago
|
63
|
-
end
|
64
|
-
|
65
|
-
def read_timestamp(type, hash)
|
66
|
-
if timestamp = get_timestamp(type, hash)
|
67
|
-
DateTime.parse(timestamp.body)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def timestamp_exists?(type, hash)
|
72
|
-
if (directory(type, hash) &&
|
73
|
-
directory(type, hash).files.head(timestamp_path(type, hash)))
|
74
|
-
true
|
75
|
-
else
|
76
|
-
false
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def timestamp_path(type, hash)
|
81
|
-
key_component(type, hash) + ".timestamp"
|
82
|
-
end
|
83
|
-
|
84
|
-
def update_timestamp(type, hash)
|
85
|
-
if outdated_timestamp?(read_timestamp(type, hash))
|
86
|
-
write_timestamp(type, hash)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def write_timestamp(type, hash)
|
91
|
-
directory!(type, hash).files.create(
|
92
|
-
key: timestamp_path(type, hash),
|
93
|
-
body: DateTime.now.to_s,
|
94
|
-
public: public?
|
95
|
-
)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|