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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 476f76a46fae44bba761080f33f0c5073733de0e
4
- data.tar.gz: 5040b1ce780046408e8ab065d18452e9ff6803b1
3
+ metadata.gz: 31a730ce894550da15cb55df86ac31187a694a33
4
+ data.tar.gz: d7787e32fe375777d46fced2d9c3d39163b32387
5
5
  SHA512:
6
- metadata.gz: 195f314b03bf2f5f0e2f82da4a9c409b03ca4896d39e1bb055a8d3090d956b5ad929a69e0c1ab9015f6c5726233318062f364e2c392ccc0b58fcf662f7740370
7
- data.tar.gz: ebd4a813bb3de31d7e61f962b4ff1b5098f71857dda2d016782c91227d22725de4c31dc45c99579de60b5e2f7f374cbde7fb2c6556f6fd6e5adf4bdc7abca75d
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
@@ -1,5 +1,7 @@
1
+ # travis
1
2
  sudo: false
2
3
  language: ruby
3
4
  rvm:
4
5
  - 2.4.1
5
6
  before_install: gem install bundler -v 1.15.4
7
+ before_script: ./.travis-setup.sh
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- repo_name = "gem_batch_archiving"
3
+ repo_name = "gem_activerecord_hoarder"
4
4
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
5
5
 
6
6
  gem 'aws-sdk-s3', '~> 1'
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.restore_date(Date.new(<Y>,<m>,<d>))
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 "bin/example/schema"` for creating an example table `examples`
51
- - `require_relative "bin/example/example"` for an example archivable model `Example`
52
- - `require_relative "bin/example/fixture"` for a factory method `create_examples(count, start: 0, deleted: true)` for creating examples
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
 
@@ -6,7 +6,8 @@ class ::ActiverecordHoarder::BatchArchiver
6
6
 
7
7
  def archive_batch
8
8
  @record_collector.in_batches(delete_on_success: true) do |batch|
9
- @archive_storage.store_data(batch)
9
+ success = @archive_storage.store_data(batch)
10
+ return if !success
10
11
  end
11
12
  end
12
13
 
@@ -7,8 +7,7 @@ class ::ActiverecordHoarder::RecordCollector
7
7
 
8
8
  def in_batches(delete_on_success: false)
9
9
  while collect_batch
10
- success = yield @batch
11
- return if !success
10
+ yield @batch
12
11
  next if !delete_on_success
13
12
  destroy_current_records!
14
13
  end
@@ -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?
@@ -1,3 +1,3 @@
1
1
  module ActiverecordHoarder
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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-15 00:00:00.000000000 Z
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