active_storage_db 0.1.3 → 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/README.md +8 -5
- data/Rakefile +10 -7
- data/lib/active_storage_db/version.rb +1 -1
- data/lib/tasks/active_storage_db_tasks.rake +29 -3
- metadata +3 -157
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c326008fa309fa9fe2ac2768a92b5ce17eae3f907e4185d054169d54ac675d89
|
4
|
+
data.tar.gz: a495dc3271c0df2cd1b0c8ca5a6332aa052475aac6e38cc9b42b4c073e8796ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41a2e02d066df9bfa01b15f50a50ceb73ebc2af089cdc2d70fb3d7c3b0896fcc37bbac27ae0aaa648e56c556ae8e157843e4fff35e99d5d3643ba17cd10bfcd9
|
7
|
+
data.tar.gz: fe6e84d048c51b6c02db33fec2c53d95fa639ee35e654c2d3479df57884bccd56a87987780f7aa58e6f9c51dbac218ee0b18c26bcfc5c7968b594222481e890f
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Active Storage DB [![Gem Version](https://badge.fury.io/rb/active_storage_db.svg)](https://badge.fury.io/rb/active_storage_db) [![
|
1
|
+
# Active Storage DB [![Gem Version](https://badge.fury.io/rb/active_storage_db.svg)](https://badge.fury.io/rb/active_storage_db) [![Specs - Postgres](https://github.com/blocknotes/active_storage_db/actions/workflows/postgres.yml/badge.svg)](https://github.com/blocknotes/active_storage_db/actions/workflows/postgres.yml) [![Specs - MySQL](https://github.com/blocknotes/active_storage_db/actions/workflows/mysql.yml/badge.svg)](https://github.com/blocknotes/active_storage_db/actions/workflows/mysql.yml)
|
2
2
|
An Active Storage service upload/download plugin that stores files in a PostgreSQL or MySQL database.
|
3
3
|
|
4
4
|
Main features:
|
@@ -10,10 +10,8 @@ Useful also with platforms like Heroku (due to their ephemeral file system).
|
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
- Setup Active Storage in your Rails application
|
13
|
-
- Add
|
14
|
-
-
|
15
|
-
- Install gem migrations: `bin/rails active_storage_db:install:migrations`
|
16
|
-
- And execute: `bin/rails db:migrate`
|
13
|
+
- Add to your Gemfile `gem 'active_storage_db'` (and execute: `bundle`)
|
14
|
+
- Install the gem migrations: `bin/rails active_storage_db:install:migrations` (and execute: `bin/rails db:migrate`)
|
17
15
|
- Add to your `config/routes.rb`: `mount ActiveStorageDB::Engine => '/active_storage_db'`
|
18
16
|
- Change Active Storage service in *config/environments/development.rb* to: `config.active_storage.service = :db`
|
19
17
|
- Add to *config/storage.yml*:
|
@@ -22,6 +20,11 @@ db:
|
|
22
20
|
service: DB
|
23
21
|
```
|
24
22
|
|
23
|
+
## Misc
|
24
|
+
Some rake tasks are available:
|
25
|
+
- `asdb:list`: list the stored attachments
|
26
|
+
- `asdb:get`: download an attachment (ex. `bin/rails "asdb:get[ruby-logo.png,/tmp]"`)
|
27
|
+
|
25
28
|
## Do you like it? Star it!
|
26
29
|
If you use this component just star it. A developer is more motivated to improve a project when there is some interest.
|
27
30
|
|
data/Rakefile
CHANGED
@@ -23,12 +23,15 @@ load 'rails/tasks/statistics.rake'
|
|
23
23
|
|
24
24
|
require 'bundler/gem_tasks'
|
25
25
|
|
26
|
-
|
26
|
+
begin
|
27
|
+
require 'rspec/core/rake_task'
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
29
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
30
|
+
# t.ruby_opts = %w[-w]
|
31
|
+
t.rspec_opts = ['--color', '--format documentation']
|
32
|
+
end
|
33
33
|
|
34
|
-
task default: :
|
34
|
+
task default: :spec
|
35
|
+
rescue LoadError
|
36
|
+
puts '! LoadError: no RSpec available'
|
37
|
+
end
|
@@ -1,5 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
namespace :asdb do
|
4
|
+
desc 'ActiveStorageDB: list attachments'
|
5
|
+
task list: [:environment] do |_t, _args|
|
6
|
+
::ActiveStorage::Blob.order(:filename).pluck(:byte_size, :created_at, :filename).each do |size, dt, filename|
|
7
|
+
size_k = (size / 1024).to_s.rjust(7)
|
8
|
+
date = dt.strftime('%Y-%m-%d %H:%M')
|
9
|
+
puts "#{size_k}K #{date} #{filename}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'ActiveStorageDB: download attachment'
|
14
|
+
task :get, [:src, :dst] => [:environment] do |_t, args|
|
15
|
+
src = args[:src]&.strip
|
16
|
+
dst = args[:dst]&.strip
|
17
|
+
abort('Required arguments: source file, destination file') if src.blank? || dst.blank?
|
18
|
+
|
19
|
+
dst = "#{dst}/#{src}" if Dir.exist?(dst)
|
20
|
+
dir = File.dirname(dst)
|
21
|
+
abort("Can't write on: #{dir}") unless File.writable?(dir)
|
22
|
+
|
23
|
+
blob = ::ActiveStorage::Blob.order(created_at: :desc).find_by(filename: src)
|
24
|
+
abort('Source file not found') unless blob
|
25
|
+
|
26
|
+
ret = File.binwrite(dst, blob.download)
|
27
|
+
puts "#{ret} bytes written"
|
28
|
+
rescue StandardError => e
|
29
|
+
puts e
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_storage_db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mattia Roccoberton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activestorage
|
@@ -38,34 +38,6 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '6.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: capybara
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.33'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.33'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: database_cleaner-active_record
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.8'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.8'
|
69
41
|
- !ruby/object:Gem::Dependency
|
70
42
|
name: factory_bot_rails
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,132 +52,6 @@ dependencies:
|
|
80
52
|
- - "~>"
|
81
53
|
- !ruby/object:Gem::Version
|
82
54
|
version: '6.1'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: mysql2
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0.5'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0.5'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: pg
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '1.2'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '1.2'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: pry
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0.13'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0.13'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rspec_junit_formatter
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0.4'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0.4'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: rspec-rails
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '4.0'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - "~>"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '4.0'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: rubocop
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - "~>"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0.89'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - "~>"
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '0.89'
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: rubocop-rspec
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - "~>"
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '1.42'
|
174
|
-
type: :development
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - "~>"
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: '1.42'
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: selenium-webdriver
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - "~>"
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: '3.142'
|
188
|
-
type: :development
|
189
|
-
prerelease: false
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
requirements:
|
192
|
-
- - "~>"
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: '3.142'
|
195
|
-
- !ruby/object:Gem::Dependency
|
196
|
-
name: simplecov
|
197
|
-
requirement: !ruby/object:Gem::Requirement
|
198
|
-
requirements:
|
199
|
-
- - "~>"
|
200
|
-
- !ruby/object:Gem::Version
|
201
|
-
version: '0.18'
|
202
|
-
type: :development
|
203
|
-
prerelease: false
|
204
|
-
version_requirements: !ruby/object:Gem::Requirement
|
205
|
-
requirements:
|
206
|
-
- - "~>"
|
207
|
-
- !ruby/object:Gem::Version
|
208
|
-
version: '0.18'
|
209
55
|
description: An ActiveStorage service plugin to store files in database.
|
210
56
|
email:
|
211
57
|
- mat@blocknot.es
|
@@ -239,7 +85,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
239
85
|
requirements:
|
240
86
|
- - ">="
|
241
87
|
- !ruby/object:Gem::Version
|
242
|
-
version:
|
88
|
+
version: 2.5.0
|
243
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
244
90
|
requirements:
|
245
91
|
- - ">="
|