dis 1.1.6 → 1.1.11

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: 75c6c1d614d13eaa8ae3b3fd30762e1a22069fb60629ebc2bb6b396caf72a25e
4
- data.tar.gz: fa6552876ae2e87d50416d004b34ee9039ceabfe459a2dbff899028650346a43
3
+ metadata.gz: 3a86353570fb3cc0e1beaade66c81c6f257589aae15311c0b8a9e4902cbd0e13
4
+ data.tar.gz: e3152f444d330fea8b18c8fd0aae990960a2ad9cdbbded148bd035a43c4d78d1
5
5
  SHA512:
6
- metadata.gz: 3e299491b62a599f7e0cb16e2de1ad67152e96fd6496b58e01d407f728c3739530822626c551405fd06585f0d7590ea7ca438a2bf0774770776d4ce4dc8b288f
7
- data.tar.gz: 78e7d8efea50cff8bc50d4a412166b2f814644781e2c86b99041a554eb29bab70ff81f61f0898039b9c108072669ecbe17247aed3706805fdada761e51345941
6
+ metadata.gz: d927cea9f4e1549528e6052301a6d568355487955f20425024b38c059bf72c9e4aedc0c93c8e598ad2d9028877f61abb71ef7cef875f1edca44de4f4bce79314
7
+ data.tar.gz: 7c42f028029cf055f679542ebf476d1a6e100f1a03bb782f7f605c45b9f8569eba3eb32c55be99cf2e656255fb7c679f4d8bf2b440c2beac1ec27a820227b597
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Version](https://img.shields.io/gem/v/dis.svg?style=flat)](https://rubygems.org/gems/dis)
2
- [![Build Status](https://travis-ci.org/elektronaut/dis.svg?branch=master)](https://travis-ci.org/elektronaut/dis)
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
5
  [![Inline docs](http://inch-ci.org/github/elektronaut/dis.svg)](http://inch-ci.org/github/elektronaut/dis)
data/lib/dis/errors.rb CHANGED
@@ -3,9 +3,13 @@
3
3
  module Dis
4
4
  module Errors
5
5
  class Error < StandardError; end
6
+
6
7
  class ReadOnlyError < Dis::Errors::Error; end
8
+
7
9
  class NoLayersError < Dis::Errors::Error; end
10
+
8
11
  class NotFoundError < Dis::Errors::Error; end
12
+
9
13
  class NoDataError < Dis::Errors::Error; end
10
14
  end
11
15
  end
@@ -12,6 +12,10 @@ module Dis
12
12
 
13
13
  def perform(type, key)
14
14
  Dis::Storage.delayed_store(type, key)
15
+ rescue Dis::Errors::NotFoundError
16
+ Rails.logger.warn(
17
+ "Delayed store failed, object not found: #{[type, key].inspect}"
18
+ )
15
19
  end
16
20
  end
17
21
  end
data/lib/dis/layers.rb CHANGED
@@ -22,8 +22,8 @@ module Dis
22
22
  end
23
23
 
24
24
  # Iterates over the layers.
25
- def each
26
- @layers.each { |layer| yield layer }
25
+ def each(&block)
26
+ @layers.each { |layer| block.call(layer) }
27
27
  end
28
28
 
29
29
  # Returns a new instance containing only the delayed layers.
data/lib/dis/model.rb CHANGED
@@ -131,6 +131,9 @@ module Dis
131
131
  dis_set :filename, file.original_filename
132
132
  end
133
133
 
134
+ # Returns the data as a temporary file.
135
+ delegate :tempfile, to: :dis_data
136
+
134
137
  private
135
138
 
136
139
  def cleanup_data
@@ -64,6 +64,16 @@ module Dis
64
64
  Dis::Storage.store(storage_type, raw)
65
65
  end
66
66
 
67
+ # Writes the data to a temporary file.
68
+ def tempfile
69
+ unless @tempfile
70
+ @tempfile = Tempfile.new(binmode: true)
71
+ @tempfile.write(@read || read_from(closest))
72
+ @tempfile.open
73
+ end
74
+ @tempfile
75
+ end
76
+
67
77
  private
68
78
 
69
79
  def closest
@@ -106,14 +116,13 @@ module Dis
106
116
  end
107
117
 
108
118
  def stored?
109
- @record.dis_stored? && content_hash.present?
119
+ content_hash.present? &&
120
+ (@record.dis_stored? ||
121
+ Dis::Storage.exists?(storage_type, content_hash))
110
122
  end
111
123
 
112
124
  def stored
113
- Dis::Storage.get(
114
- storage_type,
115
- content_hash
116
- )
125
+ Dis::Storage.get(storage_type, content_hash)
117
126
  end
118
127
 
119
128
  attr_reader :raw
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.6"
4
+ VERSION = "1.1.11"
5
5
  end
@@ -5,7 +5,7 @@
5
5
  # Creates a local storage layer in db/dis:
6
6
 
7
7
  Dis::Storage.layers << Dis::Layer.new(
8
- Fog::Storage.new(provider: "Local", local_root: Rails.root.join("db", "dis")),
8
+ Fog::Storage.new(provider: "Local", local_root: Rails.root.join("db/dis")),
9
9
  path: Rails.env
10
10
  )
11
11
 
data/lib/tasks/dis.rake CHANGED
@@ -17,10 +17,7 @@ namespace :dis do
17
17
  puts "-- #{model.name} --"
18
18
 
19
19
  content_hash_attr = model.dis_attributes[:content_hash]
20
- objects = model
21
- .select(content_hash_attr)
22
- .uniq
23
- .map { |r| r.send(content_hash_attr) }
20
+ objects = model.pluck(content_hash_attr).uniq
24
21
  global_missing = objects.dup
25
22
 
26
23
  puts "Unique objects: #{objects.length}"
@@ -31,9 +28,10 @@ namespace :dis do
31
28
  existing = layer.existing(model.dis_type, objects)
32
29
  missing = objects - existing
33
30
  global_missing -= existing
34
- puts "#{existing.length} existing, #{missing.length} missing"
31
+ puts "#{existing.length} existing, #{missing.length} missing" +
32
+ (layer.readonly? ? " (read-only)" : "")
35
33
 
36
- next unless layer.delayed?
34
+ next unless layer.delayed? && !layer.readonly?
37
35
 
38
36
  jobs += (missing - global_missing).pmap do |hash|
39
37
  [model.dis_type, hash]
@@ -51,7 +49,7 @@ namespace :dis do
51
49
  if jobs.any?
52
50
  print "#{jobs.length} objects can be transferred to delayed layers, " \
53
51
  "queue now? (y/n) "
54
- response = STDIN.gets.chomp
52
+ response = $stdin.gets.chomp
55
53
  if /^y/i.match?(response)
56
54
  puts "Queueing jobs..."
57
55
  jobs.each { |type, hash| Dis::Jobs::Store.perform_later(type, hash) }
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.6
4
+ version: 1.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Inge Jørgensen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-17 00:00:00.000000000 Z
11
+ date: 2021-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
@@ -68,18 +68,32 @@ dependencies:
68
68
  version: '5.0'
69
69
  - !ruby/object:Gem::Dependency
70
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
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '3.5'
89
+ version: 0.17.1
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '3.5'
96
+ version: 0.17.1
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: sqlite3
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -127,7 +141,7 @@ homepage: https://github.com/elektronaut/dis
127
141
  licenses:
128
142
  - MIT
129
143
  metadata: {}
130
- post_install_message:
144
+ post_install_message:
131
145
  rdoc_options: []
132
146
  require_paths:
133
147
  - lib
@@ -135,15 +149,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - ">="
137
151
  - !ruby/object:Gem::Version
138
- version: 2.4.0
152
+ version: 2.7.0
139
153
  required_rubygems_version: !ruby/object:Gem::Requirement
140
154
  requirements:
141
155
  - - ">="
142
156
  - !ruby/object:Gem::Version
143
157
  version: '0'
144
158
  requirements: []
145
- rubygems_version: 3.0.1
146
- signing_key:
159
+ rubygems_version: 3.2.3
160
+ signing_key:
147
161
  specification_version: 4
148
162
  summary: A file store for your Rails app
149
163
  test_files: []