backup_retention_plan 1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 384067bf36a3f8fb22d19a84ae1dff7dfa8e7d34d08b7650cdf62e94909d667b
4
+ data.tar.gz: b481bd054a874c213a2303d526a446198c9b89c4145792c835893b5b85271cef
5
+ SHA512:
6
+ metadata.gz: 580df00c7fa40c12c905cdfe244f7544d853b8dfc3bd690f7f620cb75978836cf4ee5a3d53b6e3f0bac7959559f5aeda9c95546a63ffd1235ab8bb78bfe65054
7
+ data.tar.gz: f73f98ff8c7b2afce38019d911cf73642b5b7a01ca2eaf397f657a4633b179c5fac194ee7b97bd199492afae8d82c2114f601a24d22c9f25600d0b474179453a
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-05-19
4
+
5
+ - Initial release
data/Dockerfile ADDED
@@ -0,0 +1,23 @@
1
+ FROM secureruby/ruby:3.2.2
2
+
3
+ RUN yum install -y -q git gcc-c++ make
4
+
5
+ ARG UID=1000
6
+ ENV USER=retentio_plan
7
+ ENV GROUP=application
8
+ ENV ENVIRONMENT=development
9
+
10
+ WORKDIR /app
11
+
12
+ USER root
13
+
14
+ RUN groupadd -f "${GROUP}" -g 4444 \
15
+ && adduser -l --uid "$UID" "$USER" -G "${GROUP}" \
16
+ && chown "${USER}" /usr/local/bundle/
17
+
18
+ COPY --chown="${USER}:${GROUP}" Gemfile Gemfile.lock backup_retention_plan.gemspec ./
19
+ COPY --chown="${USER}:${GROUP}" lib/backup_retention_plan/version.rb lib/backup_retention_plan/version.rb
20
+
21
+ USER "${USER}"
22
+
23
+ RUN bundle install
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in backup_retention_plan.gemspec
6
+ gemspec
7
+
8
+ gem "byebug", "~> 9.0", ">= 9.0.6"
9
+ gem "rake", "~> 13.0"
10
+ gem "rspec", "~> 3.0"
11
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,59 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ backup_retention_plan (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ byebug (9.1.0)
11
+ diff-lcs (1.5.0)
12
+ json (2.6.3)
13
+ parallel (1.23.0)
14
+ parser (3.2.2.1)
15
+ ast (~> 2.4.1)
16
+ rainbow (3.1.1)
17
+ rake (13.0.6)
18
+ regexp_parser (2.8.0)
19
+ rexml (3.2.5)
20
+ rspec (3.12.0)
21
+ rspec-core (~> 3.12.0)
22
+ rspec-expectations (~> 3.12.0)
23
+ rspec-mocks (~> 3.12.0)
24
+ rspec-core (3.12.2)
25
+ rspec-support (~> 3.12.0)
26
+ rspec-expectations (3.12.3)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.12.0)
29
+ rspec-mocks (3.12.5)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.12.0)
32
+ rspec-support (3.12.0)
33
+ rubocop (1.51.0)
34
+ json (~> 2.3)
35
+ parallel (~> 1.10)
36
+ parser (>= 3.2.0.0)
37
+ rainbow (>= 2.2.2, < 4.0)
38
+ regexp_parser (>= 1.8, < 3.0)
39
+ rexml (>= 3.2.5, < 4.0)
40
+ rubocop-ast (>= 1.28.0, < 2.0)
41
+ ruby-progressbar (~> 1.7)
42
+ unicode-display_width (>= 2.4.0, < 3.0)
43
+ rubocop-ast (1.28.1)
44
+ parser (>= 3.2.1.0)
45
+ ruby-progressbar (1.13.0)
46
+ unicode-display_width (2.4.2)
47
+
48
+ PLATFORMS
49
+ x86_64-linux
50
+
51
+ DEPENDENCIES
52
+ backup_retention_plan!
53
+ byebug (~> 9.0, >= 9.0.6)
54
+ rake (~> 13.0)
55
+ rspec (~> 3.0)
56
+ rubocop (~> 1.21)
57
+
58
+ BUNDLED WITH
59
+ 2.4.7
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 gabriel flauzino
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # gem BackupRetentionPlan
2
+
3
+ # Development environment
4
+
5
+ Necessary to install the Docker Compose and Docker CE
6
+
7
+ ## Commands
8
+ Build the container
9
+
10
+ ```bash
11
+ docker-compose build
12
+ ```
13
+ Run application specs
14
+
15
+ ```bash
16
+ docker-compose run --rm backup_retention_plan rake spec
17
+ ```
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "backup_retention_plan"
7
+ spec.version = '1.0'
8
+ spec.authors = ["gabriel flauzino"]
9
+ spec.email = ["flaugabriel@gmail.com"]
10
+
11
+ spec.summary = "Gem become a proposit to specific plans cam be retained or deleted based on the defined rules"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = ">= 2.6.0"
14
+ spec.homepage ="https://rubygems.org/gems/backup_retention_plan"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(__dir__) do
19
+ `git ls-files -z`.split("\x0").reject do |f|
20
+ (File.expand_path(f) == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
21
+ end
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ # Uncomment to register a new dependency of your gem
28
+ # spec.add_dependency "example-gem", "~> 1.0"
29
+
30
+ # For more information and examples about making a new gem, check out our
31
+ # guide at: https://bundler.io/guides/creating_gem.html
32
+ end
@@ -0,0 +1,9 @@
1
+ version: '3'
2
+
3
+ services:
4
+ backup_retention_plan:
5
+ build:
6
+ context: .
7
+ container_name: gem_backup_retention_plan
8
+ volumes:
9
+ - .:/app
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "date"
4
+
5
+ # This class is used by call all of the events of the retention
6
+ class BackupRetentionPlan
7
+ RETENTION_PERIODS = {
8
+ 'Beginner' => [42],
9
+ 'Pro' => [42, 12],
10
+ 'Ultra' => [42, 12, 7 * 365]
11
+ }.freeze
12
+
13
+ def initialize(plan)
14
+ @plan = plan
15
+ @retention_periods = RETENTION_PERIODS[plan]
16
+ end
17
+
18
+ def self.should_retain(plan, date)
19
+ retention_plan = new(plan)
20
+ retention_plan.should_retain(date)
21
+ end
22
+
23
+ def should_retain(date)
24
+ snapshot_date = Date.strptime(date, '%Y/%m/%d')
25
+ today = Date.today
26
+
27
+ return true if within_retention_period(snapshot_date, today)
28
+
29
+ @retention_periods[1..].each do |period|
30
+ return snapshot_date.month == today.month if snapshot_date.year == today.year - period
31
+ end
32
+
33
+ false
34
+ end
35
+
36
+ private
37
+
38
+ def within_retention_period(snapshot_date, today)
39
+ retention_period = @retention_periods[0]
40
+ snapshot_date >= today - retention_period
41
+ end
42
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Version
4
+ VALUE = "0.1.0"
5
+ end
@@ -0,0 +1,4 @@
1
+ module BackupRetentionPlan
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: backup_retention_plan
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - gabriel flauzino
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-05-19 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - flaugabriel@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".rspec"
21
+ - ".rubocop.yml"
22
+ - CHANGELOG.md
23
+ - Dockerfile
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - LICENSE.txt
27
+ - README.md
28
+ - Rakefile
29
+ - backup_retention_plan.gemspec
30
+ - docker-compose.yml
31
+ - lib/backup_retention_plan.rb
32
+ - lib/version.rb
33
+ - sig/backup_retention_plan.rbs
34
+ homepage: https://rubygems.org/gems/backup_retention_plan
35
+ licenses:
36
+ - MIT
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 2.6.0
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubygems_version: 3.4.7
54
+ signing_key:
55
+ specification_version: 4
56
+ summary: Gem become a proposit to specific plans cam be retained or deleted based
57
+ on the defined rules
58
+ test_files: []