dis 1.1.11 → 1.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/dis/layer.rb +11 -3
- data/lib/dis/logging.rb +18 -0
- data/lib/dis/validations/data_presence.rb +9 -1
- data/lib/dis/version.rb +1 -1
- data/lib/dis.rb +1 -0
- metadata +6 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ab79bc2e3e6986e1a15307f091648cba8cde50be4f4debc1d50d5977865bf0d
|
4
|
+
data.tar.gz: 6640e1a5f801fefa6ae06a9c9dcb62ae2059ca1c79ac2c9e7d3e50910caab5f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ed956050cbc242e59c362f1291ef8380e4a95e13ffc88fedfeff85681d01cef403d4a44092f7311f14dd466cdebc4a86340f9415561dcdb0d5da440a3213453
|
7
|
+
data.tar.gz: e2d5ef7b3a46b39993093841cc637b4ac24bcd2937a3231d50c967c45716078422a9560613cd31521d92cdb5a7691785c594c7ba3ed593665b3baec4c61832fd
|
data/README.md
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
![Build](https://github.com/elektronaut/dis/workflows/Build/badge.svg)
|
3
3
|
[![Code Climate](https://codeclimate.com/github/elektronaut/dis/badges/gpa.svg)](https://codeclimate.com/github/elektronaut/dis)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/elektronaut/dis/badges/coverage.svg)](https://codeclimate.com/github/elektronaut/dis)
|
5
|
-
[![Inline docs](http://inch-ci.org/github/elektronaut/dis.svg)](http://inch-ci.org/github/elektronaut/dis)
|
6
|
-
[![Security](https://hakiri.io/github/elektronaut/dis/master.svg)](https://hakiri.io/github/elektronaut/dis/master)
|
7
5
|
|
8
6
|
# Dis
|
9
7
|
|
@@ -137,6 +135,10 @@ Dis::Storage.get("documents", hash).body # => "foobar"
|
|
137
135
|
Dis::Storage.delete("documents", hash) # => true
|
138
136
|
```
|
139
137
|
|
138
|
+
## Documentation
|
139
|
+
|
140
|
+
See the [generated documentation on RubyDoc.info](https://www.rubydoc.info/gems/dis)
|
141
|
+
|
140
142
|
## License
|
141
143
|
|
142
144
|
Copyright 2014 Inge Jørgensen
|
data/lib/dis/layer.rb
CHANGED
@@ -45,6 +45,8 @@ module Dis
|
|
45
45
|
# delayed: true
|
46
46
|
# )
|
47
47
|
class Layer
|
48
|
+
include Dis::Logging
|
49
|
+
|
48
50
|
attr_reader :connection
|
49
51
|
|
50
52
|
def initialize(connection, options = {})
|
@@ -95,7 +97,9 @@ module Dis
|
|
95
97
|
def store(type, key, file)
|
96
98
|
raise Dis::Errors::ReadOnlyError if readonly?
|
97
99
|
|
98
|
-
|
100
|
+
debug_log("Store #{type}/#{key} to #{name}") do
|
101
|
+
store!(type, key, file)
|
102
|
+
end
|
99
103
|
end
|
100
104
|
|
101
105
|
# Returns all the given keys that exist in the layer.
|
@@ -130,7 +134,9 @@ module Dis
|
|
130
134
|
dir = directory(type, key)
|
131
135
|
return unless dir
|
132
136
|
|
133
|
-
|
137
|
+
debug_log("Get #{type}/#{key} from #{name}") do
|
138
|
+
dir.files.get(key_component(type, key))
|
139
|
+
end
|
134
140
|
end
|
135
141
|
|
136
142
|
# Deletes a file from the store.
|
@@ -142,7 +148,9 @@ module Dis
|
|
142
148
|
def delete(type, key)
|
143
149
|
raise Dis::Errors::ReadOnlyError if readonly?
|
144
150
|
|
145
|
-
|
151
|
+
debug_log("Delete #{type}/#{key} from #{name}") do
|
152
|
+
delete!(type, key)
|
153
|
+
end
|
146
154
|
end
|
147
155
|
|
148
156
|
# Returns a name for the layer.
|
data/lib/dis/logging.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dis
|
4
|
+
module Logging
|
5
|
+
def debug_log(message, &block)
|
6
|
+
result = nil
|
7
|
+
duration = Benchmark.ms { result = block.call }
|
8
|
+
logger.debug(format("[Dis] %<message>s (%<duration>.1fms)",
|
9
|
+
message: message,
|
10
|
+
duration: duration))
|
11
|
+
result
|
12
|
+
end
|
13
|
+
|
14
|
+
def logger
|
15
|
+
Rails.logger
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -8,7 +8,15 @@ module Dis
|
|
8
8
|
# Validates that a record has data, either freshly assigned or
|
9
9
|
# persisted in the storage. Adds a `:blank` error on `:data`if not.
|
10
10
|
def validate(record)
|
11
|
-
|
11
|
+
return if record.data? && record.content_hash != self.class.empty_hash
|
12
|
+
|
13
|
+
record.errors.add(:data, :blank)
|
14
|
+
end
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def empty_hash
|
18
|
+
@empty_hash ||= Dis::Storage.file_digest("")
|
19
|
+
end
|
12
20
|
end
|
13
21
|
end
|
14
22
|
end
|
data/lib/dis/version.rb
CHANGED
data/lib/dis.rb
CHANGED
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.1.
|
4
|
+
version: 1.1.12
|
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:
|
11
|
+
date: 2023-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-core
|
@@ -66,48 +66,6 @@ dependencies:
|
|
66
66
|
- - ">"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '5.0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec-rails
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: simplecov
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.17.1
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 0.17.1
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: sqlite3
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
69
|
description: Dis is a Rails plugin that stores your file uploads and other binary
|
112
70
|
blobs.
|
113
71
|
email:
|
@@ -126,6 +84,7 @@ files:
|
|
126
84
|
- lib/dis/jobs/store.rb
|
127
85
|
- lib/dis/layer.rb
|
128
86
|
- lib/dis/layers.rb
|
87
|
+
- lib/dis/logging.rb
|
129
88
|
- lib/dis/model.rb
|
130
89
|
- lib/dis/model/class_methods.rb
|
131
90
|
- lib/dis/model/data.rb
|
@@ -140,7 +99,8 @@ files:
|
|
140
99
|
homepage: https://github.com/elektronaut/dis
|
141
100
|
licenses:
|
142
101
|
- MIT
|
143
|
-
metadata:
|
102
|
+
metadata:
|
103
|
+
rubygems_mfa_required: 'true'
|
144
104
|
post_install_message:
|
145
105
|
rdoc_options: []
|
146
106
|
require_paths:
|
@@ -156,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
116
|
- !ruby/object:Gem::Version
|
157
117
|
version: '0'
|
158
118
|
requirements: []
|
159
|
-
rubygems_version: 3.
|
119
|
+
rubygems_version: 3.4.10
|
160
120
|
signing_key:
|
161
121
|
specification_version: 4
|
162
122
|
summary: A file store for your Rails app
|