dis 1.1.11 → 1.1.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a86353570fb3cc0e1beaade66c81c6f257589aae15311c0b8a9e4902cbd0e13
4
- data.tar.gz: e3152f444d330fea8b18c8fd0aae990960a2ad9cdbbded148bd035a43c4d78d1
3
+ metadata.gz: c2ca8b5aa3b6e9e27987f33e3dd32c9a912cf7fe37c9277b53f4797be13653a1
4
+ data.tar.gz: 81ce7ff7957b0afcb8bfd1be7adac9551c6fa1773470e4bb23ba0f5cf2033dbe
5
5
  SHA512:
6
- metadata.gz: d927cea9f4e1549528e6052301a6d568355487955f20425024b38c059bf72c9e4aedc0c93c8e598ad2d9028877f61abb71ef7cef875f1edca44de4f4bce79314
7
- data.tar.gz: 7c42f028029cf055f679542ebf476d1a6e100f1a03bb782f7f605c45b9f8569eba3eb32c55be99cf2e656255fb7c679f4d8bf2b440c2beac1ec27a820227b597
6
+ metadata.gz: 9dfd2f361cc55b6d7f2f8db29323d56b0cbdbf03a614c961a5ce9d8a7b6199036e678e887205df4a472536fcfe92198bb068d7d87b5d5e7c0f533b2eee20bda0
7
+ data.tar.gz: ce2a50bd934b3ca7163191e46195be42e95713864157ccc2737bfdd0db514ab2074ac3d995ebb64b24cf46ca60c53a73d59a4f853ef5a2c78728c5999ff93a93
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
- store!(type, key, file)
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
- dir.files.get(key_component(type, key))
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
- delete!(type, key)
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.
@@ -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
@@ -50,6 +50,8 @@ module Dis
50
50
  # by existing records. This is triggered from callbacks on the record
51
51
  # whenever they are changed or destroyed.
52
52
  def expire(hash)
53
+ return if hash.blank?
54
+
53
55
  unless @record.class.where(
54
56
  @record.class.dis_attributes[:content_hash] => hash
55
57
  ).any?
@@ -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
- record.errors.add(:data, :blank) if !record.data? || record.data.blank?
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dis
4
- VERSION = "1.1.11"
4
+ VERSION = "1.1.13"
5
5
  end
data/lib/dis.rb CHANGED
@@ -8,6 +8,7 @@ require "pmap"
8
8
  require "dis/engine"
9
9
  require "dis/errors"
10
10
  require "dis/jobs"
11
+ require "dis/logging"
11
12
  require "dis/layer"
12
13
  require "dis/layers"
13
14
  require "dis/model"
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.11
4
+ version: 1.1.13
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: 2021-05-05 00:00:00.000000000 Z
11
+ date: 2023-09-04 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.2.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