taskgration 0.1.5
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +44 -0
- data/Rakefile +10 -0
- data/app/assets/config/taskgration_manifest.js +1 -0
- data/app/assets/stylesheets/taskgration/application.css +15 -0
- data/app/controllers/taskgration/application_controller.rb +4 -0
- data/app/helpers/taskgration/application_helper.rb +4 -0
- data/app/jobs/taskgration/application_job.rb +4 -0
- data/app/models/taskgration/application_record.rb +5 -0
- data/app/models/taskgration/task_migration.rb +16 -0
- data/app/views/layouts/taskgration/application.html.erb +15 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20220514194721_create_taskgration_task_migrations.rb +11 -0
- data/lib/generators/taskgration/create_generator.rb +22 -0
- data/lib/generators/taskgration/templates/create.rb.tt +9 -0
- data/lib/taskgration/engine.rb +5 -0
- data/lib/taskgration/version.rb +3 -0
- data/lib/taskgration.rb +11 -0
- data/lib/tasks/down.rake +41 -0
- data/lib/tasks/up.rake +41 -0
- metadata +80 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: db281d7628cf64179cd3c6f30db90c409b60e88864efdea8e0c6f1a8467583ab
|
|
4
|
+
data.tar.gz: f5290844bf6b6a4dd77b14b98ba6e70daed08b49766f9d37cd7bbbcda634049b
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 53dce7ce73fb29d106989b2693fecb1ddbc0abffad968d5eef35a8ee991e3dc7f34174912b15243e338086491914d2c610b85328a3989a0c86085b8ee845df70
|
|
7
|
+
data.tar.gz: 712742982362b81a6fd8c4be291613e7a4f38728414d294048a965ab7b54164fdd8e9b5f53b99d9ae6678db565b4400a606557ed3e75560b245a0a3fde10e3e4
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2022 Fábio Araújo
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Taskgration
|
|
2
|
+
Short description and motivation.
|
|
3
|
+
|
|
4
|
+
## Usage
|
|
5
|
+
How to use my plugin.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
Add this line to your application's Gemfile:
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
gem 'taskgration'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
And then execute:
|
|
15
|
+
```bash
|
|
16
|
+
$ bundle
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
```bash
|
|
21
|
+
$ rake taskgration:install:migrations
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### 1. Creating a task to migrate
|
|
27
|
+
```bash
|
|
28
|
+
$ rails generate taskgration:create YOUR_TASK_MIGRATION_NAME
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 2. Running the unapplied tasks migrations
|
|
32
|
+
```bash
|
|
33
|
+
$ rake taskgration:up
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 3. Rolling back applied tasks migrations
|
|
37
|
+
```bash
|
|
38
|
+
$ rake taskgration:down TASKGRATION_VERSION=YOUR_VERSION_NUMBER #=> Rollback 1 specific version
|
|
39
|
+
$ rake taskgration:down TASKGRATION_STEPS=QUANTITY_OF_STEPS #=> Rollback the number of times passed
|
|
40
|
+
$ rake taskgration:down #=> Rollback always the newest created migration
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//= link_directory ../stylesheets/taskgration .css
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
|
11
|
+
* It is generally better to create a new file per style scope.
|
|
12
|
+
*
|
|
13
|
+
*= require_tree .
|
|
14
|
+
*= require_self
|
|
15
|
+
*/
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'rails/generators'
|
|
2
|
+
module Taskgration
|
|
3
|
+
module Generators
|
|
4
|
+
class CreateGenerator < Rails::Generators::NamedBase
|
|
5
|
+
source_root File.expand_path('templates', __dir__)
|
|
6
|
+
|
|
7
|
+
argument :name
|
|
8
|
+
|
|
9
|
+
def set_version
|
|
10
|
+
@version = Time.now.strftime("%Y%m%d%H%M%S")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def set_file_name
|
|
14
|
+
@file_name = "#{@version}_#{name.underscore}"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def copy_file_to_main_app
|
|
18
|
+
template('create.rb.tt', "lib/tasks/migrations/#{@file_name}.rb")
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/taskgration.rb
ADDED
data/lib/tasks/down.rake
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'pathname'
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
|
|
4
|
+
namespace :taskgration do
|
|
5
|
+
desc 'Run this task if you want to apply the latest tasks migrations'
|
|
6
|
+
task down: :environment do
|
|
7
|
+
started_at = Time.now
|
|
8
|
+
root_path = 'lib/tasks/migrations'
|
|
9
|
+
files_to_run = []
|
|
10
|
+
|
|
11
|
+
if ENV['TASKGRATION_VERSION'].present?
|
|
12
|
+
target_version = ENV['TASKGRATION_VERSION'].to_i
|
|
13
|
+
taskgration = Taskgration::TaskMigration.find_by_version!(target_version)
|
|
14
|
+
files_to_run << "#{target_version}_#{taskgration.name}"
|
|
15
|
+
elsif ENV['TASKGRATION_STEPS'].present?
|
|
16
|
+
quantity = ENV['TASKGRATION_STEPS'].to_i
|
|
17
|
+
taskgration = Taskgration::TaskMigration.newest.limit(quantity)
|
|
18
|
+
|
|
19
|
+
taskgration.each { |t| files_to_run << "#{t.version}_#{t.name}" }
|
|
20
|
+
else
|
|
21
|
+
taskgration = Taskgration::TaskMigration.newest.first
|
|
22
|
+
files_to_run << "#{taskgration.version}_#{taskgration.name}"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
files_to_run.each do |filename|
|
|
26
|
+
load "#{Dir.pwd}/#{root_path}/#{filename}.rb"
|
|
27
|
+
|
|
28
|
+
module_name = filename.split(/_/)[1..-1]
|
|
29
|
+
module_name = module_name.join('_').camelcase
|
|
30
|
+
|
|
31
|
+
module_name.constantize.new.down
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
print "\n\nTasks migrated in #{Time.at(Time.now - started_at).utc.strftime('%H hours %M minutes and %S seconds')}.\n"
|
|
35
|
+
|
|
36
|
+
abort("NOTHING TO RUN...") if files_to_run.empty?
|
|
37
|
+
|
|
38
|
+
print "FILES MIGRATED:\n"
|
|
39
|
+
print files_to_run.map{ |name| " #{name}" }.join("\n")
|
|
40
|
+
end
|
|
41
|
+
end
|
data/lib/tasks/up.rake
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'pathname'
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
|
|
4
|
+
namespace :taskgration do
|
|
5
|
+
desc 'Run this task if you want to apply the latest tasks migrations'
|
|
6
|
+
task up: :environment do
|
|
7
|
+
started_at = Time.now
|
|
8
|
+
root_path = 'lib/tasks/migrations'
|
|
9
|
+
executed_files = []
|
|
10
|
+
all_versions = Taskgration::TaskMigration.pluck(:version)
|
|
11
|
+
|
|
12
|
+
Dir.foreach(root_path).sort.each do |filename|
|
|
13
|
+
next if filename == '.' || filename == '..'
|
|
14
|
+
|
|
15
|
+
basename = File.basename(filename, '.rb')
|
|
16
|
+
version = basename.split(/_/).first.to_i
|
|
17
|
+
|
|
18
|
+
if all_versions.exclude?(version)
|
|
19
|
+
load "#{Dir.pwd}/#{root_path}/#{filename}"
|
|
20
|
+
|
|
21
|
+
basename = File.basename(filename, '.rb')
|
|
22
|
+
module_name = basename.split(/_/)[1..-1]
|
|
23
|
+
module_name = module_name.join('_').camelcase
|
|
24
|
+
|
|
25
|
+
module_name.constantize.new.up
|
|
26
|
+
|
|
27
|
+
executed_files << filename
|
|
28
|
+
|
|
29
|
+
Taskgration::TaskMigration.create!(name: module_name.underscore, version: version)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
print "\n\nTasks migrated in #{Time.at(Time.now - started_at).utc.strftime('%H hours %M minutes and %S seconds')}.\n"
|
|
34
|
+
print "Current version is: #{Taskgration::TaskMigration.current_version}\n\n"
|
|
35
|
+
|
|
36
|
+
abort("NOTHING NEW TO RUN...") if executed_files.empty?
|
|
37
|
+
|
|
38
|
+
print "FILES MIGRATED:\n"
|
|
39
|
+
print executed_files.map{ |name| " #{name}" }.join("\n")
|
|
40
|
+
end
|
|
41
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: taskgration
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.5
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Fábio Araújo
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2022-07-11 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rails
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '5.2'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '5.2'
|
|
27
|
+
description: Know what tasks ran and keep the track of it
|
|
28
|
+
email:
|
|
29
|
+
- fabioaraujo121@gmail.com
|
|
30
|
+
executables: []
|
|
31
|
+
extensions: []
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- MIT-LICENSE
|
|
35
|
+
- README.md
|
|
36
|
+
- Rakefile
|
|
37
|
+
- app/assets/config/taskgration_manifest.js
|
|
38
|
+
- app/assets/stylesheets/taskgration/application.css
|
|
39
|
+
- app/controllers/taskgration/application_controller.rb
|
|
40
|
+
- app/helpers/taskgration/application_helper.rb
|
|
41
|
+
- app/jobs/taskgration/application_job.rb
|
|
42
|
+
- app/models/taskgration/application_record.rb
|
|
43
|
+
- app/models/taskgration/task_migration.rb
|
|
44
|
+
- app/views/layouts/taskgration/application.html.erb
|
|
45
|
+
- config/routes.rb
|
|
46
|
+
- db/migrate/20220514194721_create_taskgration_task_migrations.rb
|
|
47
|
+
- lib/generators/taskgration/create_generator.rb
|
|
48
|
+
- lib/generators/taskgration/templates/create.rb.tt
|
|
49
|
+
- lib/taskgration.rb
|
|
50
|
+
- lib/taskgration/engine.rb
|
|
51
|
+
- lib/taskgration/version.rb
|
|
52
|
+
- lib/tasks/down.rake
|
|
53
|
+
- lib/tasks/up.rake
|
|
54
|
+
homepage: https://github.com/fabioaraujo121/taskgration
|
|
55
|
+
licenses:
|
|
56
|
+
- MIT
|
|
57
|
+
metadata:
|
|
58
|
+
homepage_uri: https://github.com/fabioaraujo121/taskgration
|
|
59
|
+
source_code_uri: https://github.com/fabioaraujo121/taskgration
|
|
60
|
+
changelog_uri: https://github.com/fabioaraujo121/taskgration/CHANGELOG.md
|
|
61
|
+
post_install_message:
|
|
62
|
+
rdoc_options: []
|
|
63
|
+
require_paths:
|
|
64
|
+
- lib
|
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
|
+
requirements:
|
|
67
|
+
- - ">="
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0'
|
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '0'
|
|
75
|
+
requirements: []
|
|
76
|
+
rubygems_version: 3.2.3
|
|
77
|
+
signing_key:
|
|
78
|
+
specification_version: 4
|
|
79
|
+
summary: Track tasks like migrations
|
|
80
|
+
test_files: []
|