activerecord_hoarder 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/.travis-setup.sh +11 -0
- data/.travis.yml +2 -0
- data/Gemfile +1 -1
- data/README.md +19 -4
- data/lib/activerecord_hoarder/batch_archiver.rb +2 -1
- data/lib/activerecord_hoarder/record_collector.rb +1 -2
- data/lib/activerecord_hoarder/storage.rb +10 -10
- data/lib/activerecord_hoarder/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31a730ce894550da15cb55df86ac31187a694a33
|
4
|
+
data.tar.gz: d7787e32fe375777d46fced2d9c3d39163b32387
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74fe678349717493ca3322595a17140351ec7f27e6e02b14f0914c2202ea8356960530b73c82a322139118c823909f223f03b0ea4153fe5348913d70411ea052
|
7
|
+
data.tar.gz: 5803619c244a353214f0bdacb9d91cdf27e768940694d2a0853227e75bd44bce5bb59b6919975445e1d395b00ab47cbc20576f6fb7a50ddd7bc97bc92d016d0a
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.4.1
|
data/.travis-setup.sh
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
file_location=$(pwd)"/config/dbspec_rspec.yml"
|
2
|
+
|
3
|
+
if [ -e file_location ]
|
4
|
+
then
|
5
|
+
echo "$file_location found"
|
6
|
+
else
|
7
|
+
echo "setting up database spec"
|
8
|
+
touch config/dbspec_rspec.yml
|
9
|
+
echo "adapter: sqlite3" >> config/dbspec_rspec.yml
|
10
|
+
echo "database: activerecord_hoarder_rspec.sqlite3" >> config/dbspec_rspec.yml
|
11
|
+
fi
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,24 @@
|
|
1
1
|
# Activerecord Hoarder
|
2
|
+
[![Build Status](https://travis-ci.org/Scrimmage/gem_activerecord_hoarder.svg?branch=travis-bump)](https://travis-ci.org/Scrimmage/gem_activerecord_hoarder) [![Maintainability](https://api.codeclimate.com/v1/badges/7638f5eb8bdf48b29a30/maintainability)](https://codeclimate.com/github/Scrimmage/gem_activerecord_hoarder/maintainability)
|
2
3
|
|
3
4
|
hoard records
|
4
5
|
|
5
6
|
## 1 Use
|
6
7
|
|
8
|
+
### 1.0 configure
|
9
|
+
before performing `1.2` and `1.3` the `ActiverecordHoarder::Storage` needs to be configured with
|
10
|
+
- `storage: :aws_s3` - only storage currently implemented
|
11
|
+
- `storage_options: {...}` with s3 credentials, connection details and default permissions
|
12
|
+
|
13
|
+
#### Amazon S3 options
|
14
|
+
- `access_key_id` *required* - amazon credential
|
15
|
+
- `acl` *required* - amazon canned ACL (private, public-read, ...)*
|
16
|
+
- `bucket` *required* - amazon connection detail
|
17
|
+
- `bucket_sub_dir` *optional* - amazon key prefix
|
18
|
+
- `region` *required* - amazon connection detail
|
19
|
+
- `secret_access_key` *required* - amazon credential
|
20
|
+
|
21
|
+
|
7
22
|
### 1.1 make model a hoarder
|
8
23
|
```
|
9
24
|
class ExampleModel < ActiveRecord::Base
|
@@ -21,7 +36,7 @@ will create S3 entries with keys: `<bucket_sub_dir>/<table_name = example_models
|
|
21
36
|
### 1.3 restoring records
|
22
37
|
from console:
|
23
38
|
```
|
24
|
-
ExampleModel.
|
39
|
+
ExampleModel.restore_archive_records(Date.new(<Y>,<m>,<d>))
|
25
40
|
```
|
26
41
|
|
27
42
|
## 2 Development
|
@@ -47,9 +62,9 @@ bundler exec bin/console
|
|
47
62
|
|
48
63
|
#### bin/example
|
49
64
|
Convenience functionality
|
50
|
-
- `require_relative "
|
51
|
-
- `require_relative "
|
52
|
-
- `require_relative "
|
65
|
+
- `require_relative "example/schema"` for creating an example table `examples`
|
66
|
+
- `require_relative "example/example"` for an example archivable model `Example`
|
67
|
+
- `require_relative "example/fixture"` for a factory method `create_examples(count, start: 0, deleted: true)` for creating examples
|
53
68
|
|
54
69
|
### 2.2 testing it
|
55
70
|
|
@@ -1,16 +1,6 @@
|
|
1
1
|
class ::ActiverecordHoarder::Storage
|
2
2
|
class_attribute :storage, :storage_options
|
3
3
|
|
4
|
-
def self.configure(storage:, storage_options:)
|
5
|
-
::ActiverecordHoarder::Storages.is_valid_storage?(storage)
|
6
|
-
|
7
|
-
self.storage_options = storage_options
|
8
|
-
self.storage = storage
|
9
|
-
self
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
4
|
def self.new(table_name, storage_override: nil, storage_options_override: {})
|
15
5
|
self.check_configured
|
16
6
|
storage_class = ::ActiverecordHoarder::Storages.retrieve(storage_override || storage)
|
@@ -19,6 +9,16 @@ class ::ActiverecordHoarder::Storage
|
|
19
9
|
|
20
10
|
def self.check_configured
|
21
11
|
raise ::ActiverecordHoarder::StorageError.new("storage needs to be configured") unless is_configured?
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.configure(storage:, storage_options:)
|
16
|
+
::ActiverecordHoarder::Storages.is_valid_storage?(storage)
|
17
|
+
|
18
|
+
self.storage_options = storage_options
|
19
|
+
self.storage = storage
|
20
|
+
|
21
|
+
self
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.is_configured?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord_hoarder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthias Engh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -83,6 +83,8 @@ extra_rdoc_files: []
|
|
83
83
|
files:
|
84
84
|
- ".gitignore"
|
85
85
|
- ".rspec"
|
86
|
+
- ".ruby-version"
|
87
|
+
- ".travis-setup.sh"
|
86
88
|
- ".travis.yml"
|
87
89
|
- Gemfile
|
88
90
|
- LICENSE.txt
|