rakeman 0.1.1 → 0.2.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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +31 -12
  4. data/Rakefile +22 -4
  5. data/app/assets/config/rakeman_manifest.js +1 -0
  6. data/app/assets/stylesheets/rakeman/application.css +15 -0
  7. data/app/controllers/rakeman/application_controller.rb +7 -0
  8. data/app/controllers/rakeman/rake_tasks_controller.rb +50 -0
  9. data/app/mailers/rakeman/application_mailer.rb +8 -0
  10. data/app/models/rakeman/application_record.rb +7 -0
  11. data/app/models/rakeman/rake_task.rb +15 -0
  12. data/app/models/rakeman/task_parameter.rb +9 -0
  13. data/app/services/rakeman/manager.rb +19 -0
  14. data/app/services/rakeman/task_creator.rb +34 -0
  15. data/app/services/rakeman/task_runner.rb +11 -0
  16. data/app/services/rakeman/task_updater.rb +38 -0
  17. data/app/views/layouts/rakeman/application.html.haml +15 -0
  18. data/app/views/rakeman/rake_tasks/index.html.haml +19 -0
  19. data/config/locales/rakeman/en.yml +18 -0
  20. data/config/locales/rakeman/errors.yml +5 -0
  21. data/config/routes.rb +10 -0
  22. data/db/migrate/20201107121839_create_rakeman_rake_tasks.rb +13 -0
  23. data/db/migrate/20201114134949_create_rakeman_task_parameters.rb +12 -0
  24. data/lib/generators/rakeman/install_generator.rb +19 -0
  25. data/lib/generators/rakeman/templates/initializer.rb +4 -0
  26. data/lib/rakeman.rb +19 -14
  27. data/lib/rakeman/configuration.rb +9 -0
  28. data/lib/rakeman/engine.rb +35 -0
  29. data/lib/rakeman/version.rb +1 -1
  30. metadata +274 -20
  31. data/.gitignore +0 -11
  32. data/.rspec +0 -3
  33. data/.travis.yml +0 -6
  34. data/CODE_OF_CONDUCT.md +0 -74
  35. data/Gemfile +0 -7
  36. data/Gemfile.lock +0 -34
  37. data/LICENSE.txt +0 -21
  38. data/bin/console +0 -14
  39. data/bin/setup +0 -8
  40. data/lib/rakeman/config/i18n.rb +0 -3
  41. data/lib/rakeman/config/locales/en.yml +0 -1
  42. data/lib/rakeman/rake_presenter.rb +0 -22
  43. data/lib/rakeman/rake_runner.rb +0 -9
  44. data/lib/rakeman/rake_updater.rb +0 -33
  45. data/rakeman-0.1.0.gem +0 -0
  46. data/rakeman.gemspec +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ef8aceea4c9467b59de790eafca97c437a34ab43da4d0c40ec3296bbee1a3f2
4
- data.tar.gz: 4321c35472ad2aed2468abc569e31132e98a9d2312d27f42cd5d4300b20f6606
3
+ metadata.gz: '09c13fcd46962ef07659e37d36209702e44812c6de174ca800b60d0499da4e81'
4
+ data.tar.gz: d9567a77a47bac52c6f26f384f40898198a4df0ee8536c565c2fd3624885f9be
5
5
  SHA512:
6
- metadata.gz: dc8cdd10fbf5c960d0f8f6c6e78c905576ea8f71c143770553e8b52e531276b6ea693c61dfde0dbaed69636d42d7aee5123992c9d735f9a4a7442f9b15c76df6
7
- data.tar.gz: 8d867b2335790de351c41a61550d111e03256765f0c5a8f7d5ed3feaac751304e3e5b916b2eaadd1efd5a1919099d9e47511121aae794f50b8631a0e168d235f
6
+ metadata.gz: 18009ac67b48138db33ed388329b6e7536116457a1e51d5409a181668987432e564b504529af452194e374c74e68daffc4e513efe17f00bd3a5cf63ef576dde3
7
+ data.tar.gz: 21e9dc2fdda7c2b13ca998526d981baf2eeed0dfeff9b4fdfb2a57cf39eca9713f20b32224d7b33302aa4cfa9431d041ea359e80505e14380124661eb0c888d6
@@ -0,0 +1,20 @@
1
+ Copyright 2020 Yaroslav
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 CHANGED
@@ -1,9 +1,5 @@
1
1
  # Rakeman
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rakeman`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
3
  ## Installation
8
4
 
9
5
  Add this line to your application's Gemfile:
@@ -20,19 +16,42 @@ Or install it yourself as:
20
16
 
21
17
  $ gem install rakeman
22
18
 
23
- ## Usage
19
+ Then run:
24
20
 
25
- TODO: Write usage instructions here
21
+ $ rails g rakeman:install
22
+ $ rails rakeman:install:migrations
23
+ $ rails db:migrate
26
24
 
27
- ## Development
25
+ Make sure your policy is allowing to access Rakeman controllers
28
26
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
27
+ ## Usage
28
+ At first time you load `/rakeman` page Rakeman will fetch all your project rake tasks and save them as `Rakeman::RakeTask` model.
29
+
30
+ Rakeman provides several actions:
31
+
32
+ Create an instance of `Rakeman::Manager` and call on it:
33
+ - `#tasks` to fetch all tasks in your project. The output data will be array of hashes:
34
+ ```ruby
35
+ [
36
+ {
37
+ name: 'task1',
38
+ description: 'Task 1 Description'
39
+ },
40
+ {
41
+ name: 'task2',
42
+ description: 'Task 2 Description'
43
+ }
44
+ ]
45
+ - `#persist_tasks(tasks_list: nil, destroy_old_tasks: true)` to save tasks to DB. By default it destroys ALL previous tasks in DB and creates new instead from all your project tasks. `tasks_list` must be an array of hashes such as above.
46
+ - `#update_tasks_list` to update DB with new tasks and destroy old ones that you don't have in project anymore.
47
+ - `#mark_as_done(task)` to mark your task as done
48
+ - `#mark_as_undone(task)` to mark your task as undone
49
+ - `#execute(task)` to execute your task. It also marks your task as done<br>
50
+ <span style="color:red">Only rake tasks without params can be executed. Feature that allows to run tasks with params will be released in next version. Sorry =(</span>
32
51
 
33
52
  ## Contributing
34
53
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rakeman. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rakeman/blob/master/CODE_OF_CONDUCT.md).
54
+ Bug reports and pull requests are welcome on GitHub at https://github.com/CaptainJNS/rakeman. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/CaptainJNS/rakeman/blob/master/CODE_OF_CONDUCT.md).
36
55
 
37
56
 
38
57
  ## License
@@ -41,4 +60,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
41
60
 
42
61
  ## Code of Conduct
43
62
 
44
- Everyone interacting in the Rakeman project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rakeman/blob/master/CODE_OF_CONDUCT.md).
63
+ Everyone interacting in the Rakeman project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/CaptainJNS/rakeman/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,6 +1,24 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
3
2
 
4
- RSpec::Core::RakeTask.new(:spec)
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
5
8
 
6
- task :default => :spec
9
+ require 'rdoc/task'
10
+
11
+ RDoc::Task.new(:rdoc) do |rdoc|
12
+ rdoc.rdoc_dir = 'rdoc'
13
+ rdoc.title = 'Rakeman'
14
+ rdoc.options << '--line-numbers'
15
+ rdoc.rdoc_files.include('README.md')
16
+ rdoc.rdoc_files.include('lib/**/*.rb')
17
+ end
18
+
19
+ APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
20
+ load 'rails/tasks/engine.rake'
21
+
22
+ load 'rails/tasks/statistics.rake'
23
+
24
+ require 'bundler/gem_tasks'
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/rakeman .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
+ */
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rakeman
4
+ class ApplicationController < ActionController::Base
5
+ protect_from_forgery with: :exception
6
+ end
7
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Rakeman::RakeTasksController < ApplicationController
4
+ delegate :update_tasks_list, to: :manager
5
+
6
+ def index
7
+ manager.persist_tasks unless Rakeman::RakeTask.any?
8
+
9
+ @tasks = Rakeman::RakeTask.order(:name)
10
+ render 'index', layout: 'layouts/rakeman/application.html.haml'
11
+ end
12
+
13
+ def mark_as_done
14
+ manager.mark_as_done(task)
15
+
16
+ redirect t('rakeman.tasks.events.marked_as_done')
17
+ end
18
+
19
+ def mark_as_undone
20
+ manager.mark_as_undone(task)
21
+
22
+ redirect t('rakeman.tasks.events.marked_as_undone')
23
+ end
24
+
25
+ def execute
26
+ manager.execute(task)
27
+
28
+ redirect t('rakeman.tasks.events.executed')
29
+ end
30
+
31
+ def update_tasks_list
32
+ manager.update_tasks_list
33
+
34
+ redirect t('rakeman.tasks.events.list_updated')
35
+ end
36
+
37
+ private
38
+
39
+ def manager
40
+ @manager ||= Rakeman::Manager.new
41
+ end
42
+
43
+ def task
44
+ @task ||= Rakeman::RakeTask.find_by(id: params[:id])
45
+ end
46
+
47
+ def redirect(message)
48
+ redirect_to index_path, notice: message
49
+ end
50
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rakeman
4
+ class ApplicationMailer < ActionMailer::Base
5
+ default from: 'from@example.com'
6
+ layout 'mailer'
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rakeman
4
+ class ApplicationRecord < ActiveRecord::Base
5
+ self.abstract_class = true
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rakeman
4
+ class RakeTask < ApplicationRecord
5
+ TASK_NAME_REGEX = /\A[\w\[\],:]+\Z/.freeze
6
+
7
+ validates :name,
8
+ format: {
9
+ with: TASK_NAME_REGEX,
10
+ message: I18n.t('rakeman.errors.validation.name_format')
11
+ }
12
+
13
+ has_many :params, foreign_key: :rakeman_rake_task_id, class_name: 'Rakeman::TaskParameter', dependent: :destroy
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rakeman
4
+ class TaskParameter < ApplicationRecord
5
+ validates :name, presence: true
6
+
7
+ belongs_to :task, class_name: 'Rakeman::RakeTask', foreign_key: :rakeman_rake_task_id
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rakeman
4
+ class Manager
5
+ include TaskCreator
6
+ include TaskUpdater
7
+ include TaskRunner
8
+
9
+ def execute(task, params = nil)
10
+ run(task.name, params)
11
+ mark_as_done(task)
12
+ end
13
+
14
+ def update_tasks_list
15
+ tasks_to_create = update_tasks(all_tasks_list)
16
+ persist_tasks(tasks_list: tasks_to_create, destroy_old_tasks: false)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rakeman::TaskCreator
4
+ def persist_tasks(tasks_list: nil, destroy_old_tasks: true)
5
+ Rakeman::RakeTask.destroy_all if destroy_old_tasks
6
+
7
+ tasks_list ||= all_tasks_list
8
+
9
+ create_from_list(tasks_list)
10
+ end
11
+
12
+ def all_tasks_list
13
+ Rails.application.load_tasks
14
+
15
+ parse_to_hash(Rake::Task.tasks)
16
+ end
17
+
18
+ private
19
+
20
+ def parse_to_hash(tasks)
21
+ tasks.map do |task|
22
+ { name: task.name, description: task.full_comment, args: task.arg_names }
23
+ end
24
+ end
25
+
26
+ def create_from_list(tasks_list)
27
+ tasks_list.each do |task_hash|
28
+ task = Rakeman::RakeTask.create(name: task_hash[:name], description: task_hash[:description])
29
+ task_hash[:args].each do |arg_name|
30
+ Rakeman::TaskParameter.create(name: arg_name, task: task)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rakeman::TaskRunner
4
+ private
5
+
6
+ def run(task_name, params)
7
+ return Rake.application.invoke_task("#{task_name}[#{params.join(',')}]") if params
8
+
9
+ Rake.application.invoke_task(task_name)
10
+ end
11
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rakeman::TaskUpdater
4
+ def mark_as_done(task)
5
+ task.update(done: true)
6
+ end
7
+
8
+ def mark_as_undone(task)
9
+ task.update(done: false)
10
+ end
11
+
12
+ private
13
+
14
+ def update_tasks(new_tasks)
15
+ @new_tasks = new_tasks
16
+
17
+ destroy_old_tasks
18
+ update_description
19
+ generate_new_tasks_hash
20
+ end
21
+
22
+ def destroy_old_tasks
23
+ new_task_names = @new_tasks.pluck(:name)
24
+ Rakeman::RakeTask.where.not(name: new_task_names).destroy_all
25
+ end
26
+
27
+ def update_description
28
+ Rakeman::RakeTask.all.each do |old_task|
29
+ description = @new_tasks.detect { |new_task| new_task[:name] == old_task[:name] }[:description]
30
+ old_task.update(description: description) if old_task.description != description
31
+ end
32
+ end
33
+
34
+ def generate_new_tasks_hash
35
+ old_task_names = Rakeman::RakeTask.pluck(:name)
36
+ @new_tasks.reject { |task| old_task_names.include?(task[:name]) }
37
+ end
38
+ end
@@ -0,0 +1,15 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %title= Rakeman
5
+ = csrf_meta_tags
6
+ = csp_meta_tag
7
+ = stylesheet_link_tag "rakeman/application", media: "all"
8
+
9
+ %body
10
+ - if notice
11
+ %p.alert.alert-success= notice
12
+ - if alert
13
+ %p.alert.alert-danger= alert
14
+
15
+ = yield
@@ -0,0 +1,19 @@
1
+ =link_to(t('rakeman.tasks.actions.update_list'), update_tasks_list_path)
2
+ %table{border: 1}
3
+ %thead
4
+ %tr
5
+ - t('rakeman.tasks.columns').each_value do |column_name|
6
+ %td= column_name
7
+ %tbody
8
+ - @tasks.each do |task|
9
+ %tr
10
+ %td= task.name
11
+ %td= task.description
12
+ %td= task.done
13
+ %td
14
+ .table_actions
15
+ -if task.done?
16
+ = link_to(t('rakeman.tasks.actions.mark_as_undone'), mark_as_undone_path(task))
17
+ -else
18
+ = link_to(t('rakeman.tasks.actions.mark_as_done'), mark_as_done_path(task))
19
+ = link_to(t('rakeman.tasks.actions.execute'), execute_task_path(task))
@@ -0,0 +1,18 @@
1
+ en:
2
+ rakeman:
3
+ tasks:
4
+ columns:
5
+ task: Task
6
+ description: Description
7
+ done: Done
8
+ actions: Actions
9
+ actions:
10
+ mark_as_done: Mark as done
11
+ mark_as_undone: Mark as undone
12
+ execute: Run task
13
+ update_list: Update tasks list
14
+ events:
15
+ marked_as_done: Task has been marked as done
16
+ marked_as_undone: Task has been marked as undone
17
+ executed: Task has been successfully executed and marked as done
18
+ list_updated: Tasks list has been updated
@@ -0,0 +1,5 @@
1
+ en:
2
+ rakeman:
3
+ errors:
4
+ validation:
5
+ name_format: Wrong name format!
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rakeman::Engine.routes.draw do
4
+ root 'rake_tasks#index', as: 'index'
5
+
6
+ get 'rake_tasks/mark_as_done/:id', to: 'rake_tasks#mark_as_done', as: 'mark_as_done'
7
+ get 'rake_tasks/mark_as_undone/:id', to: 'rake_tasks#mark_as_undone', as: 'mark_as_undone'
8
+ get 'rake_tasks/execute/:id', to: 'rake_tasks#execute', as: 'execute_task'
9
+ get 'rake_tasks/update_list', to: 'rake_tasks#update_tasks_list', as: 'update_tasks_list'
10
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateRakemanRakeTasks < ActiveRecord::Migration[6.0]
4
+ def change
5
+ create_table :rakeman_rake_tasks do |t|
6
+ t.string :name, null: false
7
+ t.string :description
8
+ t.boolean :done, default: false
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateRakemanTaskParameters < ActiveRecord::Migration[6.0]
4
+ def change
5
+ create_table :rakeman_task_parameters do |t|
6
+ t.string :name, null: false
7
+ t.references :rakeman_rake_task
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators'
4
+
5
+ module Rakeman
6
+ class InstallGenerator < Rails::Generators::Base
7
+ source_root File.expand_path('templates', __dir__)
8
+
9
+ def copy_engine_config
10
+ copy_file 'initializer.rb', 'config/initializers/rakeman.rb'
11
+ end
12
+
13
+ def setup_routes
14
+ route <<-ROUTE
15
+ mount Rakeman::Engine => '/rakeman'
16
+ ROUTE
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rakeman.configure do |config|
4
+ end
@@ -1,23 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rakeman/version'
4
- require_relative 'rakeman/rake_presenter'
5
- require_relative 'rakeman/rake_updater'
6
- require_relative 'rakeman/rake_runner'
3
+ require 'rakeman/engine'
4
+ require 'rakeman/configuration'
7
5
 
8
6
  module Rakeman
9
- class Manager
10
- TASK_REGEX = /^[\w\[\],:]+$/
7
+ module_function
11
8
 
12
- include RakePresenter
13
- include RakeUpdater
14
- include RakeRunner
9
+ def configure
10
+ yield(configuration)
11
+ end
12
+
13
+ def method_missing(method_name, *arguments, &block)
14
+ return super unless configuration.respond_to?(method_name)
15
+
16
+ configuration.public_send(method_name, *arguments, &block)
17
+ end
15
18
 
16
- def execute(task_name:, task_list:)
17
- return unless TASK_REGEX.match?(task_name)
19
+ def respond_to_missing?(method_name, include_private = false)
20
+ configuration.respond_to?(method_name) || super
21
+ end
18
22
 
19
- run(task_name)
20
- mark_as_done(task_name: task_name, task_list: task_list)
21
- end
23
+ def configuration
24
+ ::Rakeman::Configuration.instance
22
25
  end
26
+
27
+ private_class_method :configuration
23
28
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'singleton'
4
+
5
+ module Rakeman
6
+ class Configuration
7
+ include ::Singleton
8
+ end
9
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rake'
4
+
5
+ module Rakeman
6
+ class Engine < ::Rails::Engine
7
+
8
+ isolate_namespace Rakeman
9
+
10
+ config.autoload_paths += [Rakeman::Engine.root.join('config', 'initializers')]
11
+
12
+ config.generators do |g|
13
+ g.test_framework :rspec, fixture: false
14
+ g.fixture_replacement :factory_bot, dir: 'spec/factories'
15
+ g.assets false
16
+ g.helper false
17
+ end
18
+
19
+ initializer :rakeman do |app|
20
+ ActiveSupport::Notifications.subscribe('active_admin.application.before_load') do
21
+ Dir[app.root.join('app', 'models', '**', '*.rb')].each { |file| require_dependency(file) }
22
+ end
23
+ end
24
+
25
+ config.before_initialize do
26
+ ActiveSupport.on_load :action_controller do
27
+ ::ActionController::Base.helper Rakeman::Engine.helpers
28
+ end
29
+ end
30
+
31
+ Rake::TaskManager.record_task_metadata = true
32
+
33
+ config.i18n.load_path += Dir["#{config.root}/config/locales/**/*.yml"]
34
+ end
35
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rakeman
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,15 +1,261 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rakeman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - CaptainJNS
8
+ - olehvolynets
9
+ - YaroslavZahoruiko
8
10
  autorequire:
9
- bindir: exe
11
+ bindir: bin
10
12
  cert_chain: []
11
- date: 2020-11-01 00:00:00.000000000 Z
12
- dependencies: []
13
+ date: 2020-11-27 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: 5.1.5
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: 5.1.5
29
+ - !ruby/object:Gem::Dependency
30
+ name: pg
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '1.2'
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: 1.2.3
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - "~>"
44
+ - !ruby/object:Gem::Version
45
+ version: '1.2'
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 1.2.3
49
+ - !ruby/object:Gem::Dependency
50
+ name: rspec-rails
51
+ requirement: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '4.0'
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: 4.0.1
59
+ type: :development
60
+ prerelease: false
61
+ version_requirements: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - "~>"
64
+ - !ruby/object:Gem::Version
65
+ version: '4.0'
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 4.0.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: capybara
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.32'
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 3.32.1
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '3.32'
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 3.32.1
89
+ - !ruby/object:Gem::Dependency
90
+ name: factory_bot_rails
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '5.1'
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: 5.1.1
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - "~>"
104
+ - !ruby/object:Gem::Version
105
+ version: '5.1'
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: 5.1.1
109
+ - !ruby/object:Gem::Dependency
110
+ name: faker
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: '2.11'
116
+ type: :development
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: '2.11'
123
+ - !ruby/object:Gem::Dependency
124
+ name: pry-rails
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: 0.3.9
130
+ type: :development
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - "~>"
135
+ - !ruby/object:Gem::Version
136
+ version: 0.3.9
137
+ - !ruby/object:Gem::Dependency
138
+ name: rubocop
139
+ requirement: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - "~>"
142
+ - !ruby/object:Gem::Version
143
+ version: '1.2'
144
+ type: :development
145
+ prerelease: false
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - "~>"
149
+ - !ruby/object:Gem::Version
150
+ version: '1.2'
151
+ - !ruby/object:Gem::Dependency
152
+ name: rubocop-rails
153
+ requirement: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - "~>"
156
+ - !ruby/object:Gem::Version
157
+ version: '2.8'
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: 2.8.1
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: '2.8'
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: 2.8.1
171
+ - !ruby/object:Gem::Dependency
172
+ name: rubocop-rspec
173
+ requirement: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - "~>"
176
+ - !ruby/object:Gem::Version
177
+ version: '2.0'
178
+ type: :development
179
+ prerelease: false
180
+ version_requirements: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - "~>"
183
+ - !ruby/object:Gem::Version
184
+ version: '2.0'
185
+ - !ruby/object:Gem::Dependency
186
+ name: selenium-webdriver
187
+ requirement: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - "~>"
190
+ - !ruby/object:Gem::Version
191
+ version: '3.142'
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: 3.142.7
195
+ type: :development
196
+ prerelease: false
197
+ version_requirements: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '3.142'
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ version: 3.142.7
205
+ - !ruby/object:Gem::Dependency
206
+ name: shoulda-matchers
207
+ requirement: !ruby/object:Gem::Requirement
208
+ requirements:
209
+ - - "~>"
210
+ - !ruby/object:Gem::Version
211
+ version: '4.3'
212
+ type: :development
213
+ prerelease: false
214
+ version_requirements: !ruby/object:Gem::Requirement
215
+ requirements:
216
+ - - "~>"
217
+ - !ruby/object:Gem::Version
218
+ version: '4.3'
219
+ - !ruby/object:Gem::Dependency
220
+ name: haml
221
+ requirement: !ruby/object:Gem::Requirement
222
+ requirements:
223
+ - - "~>"
224
+ - !ruby/object:Gem::Version
225
+ version: '5.1'
226
+ - - ">="
227
+ - !ruby/object:Gem::Version
228
+ version: 5.1.1
229
+ type: :development
230
+ prerelease: false
231
+ version_requirements: !ruby/object:Gem::Requirement
232
+ requirements:
233
+ - - "~>"
234
+ - !ruby/object:Gem::Version
235
+ version: '5.1'
236
+ - - ">="
237
+ - !ruby/object:Gem::Version
238
+ version: 5.1.1
239
+ - !ruby/object:Gem::Dependency
240
+ name: haml-rails
241
+ requirement: !ruby/object:Gem::Requirement
242
+ requirements:
243
+ - - "~>"
244
+ - !ruby/object:Gem::Version
245
+ version: '2.0'
246
+ - - ">="
247
+ - !ruby/object:Gem::Version
248
+ version: 2.0.1
249
+ type: :development
250
+ prerelease: false
251
+ version_requirements: !ruby/object:Gem::Requirement
252
+ requirements:
253
+ - - "~>"
254
+ - !ruby/object:Gem::Version
255
+ version: '2.0'
256
+ - - ">="
257
+ - !ruby/object:Gem::Version
258
+ version: 2.0.1
13
259
  description:
14
260
  email:
15
261
  - sereda9623@gmail.com
@@ -17,26 +263,34 @@ executables: []
17
263
  extensions: []
18
264
  extra_rdoc_files: []
19
265
  files:
20
- - ".gitignore"
21
- - ".rspec"
22
- - ".travis.yml"
23
- - CODE_OF_CONDUCT.md
24
- - Gemfile
25
- - Gemfile.lock
26
- - LICENSE.txt
266
+ - MIT-LICENSE
27
267
  - README.md
28
268
  - Rakefile
29
- - bin/console
30
- - bin/setup
269
+ - app/assets/config/rakeman_manifest.js
270
+ - app/assets/stylesheets/rakeman/application.css
271
+ - app/controllers/rakeman/application_controller.rb
272
+ - app/controllers/rakeman/rake_tasks_controller.rb
273
+ - app/mailers/rakeman/application_mailer.rb
274
+ - app/models/rakeman/application_record.rb
275
+ - app/models/rakeman/rake_task.rb
276
+ - app/models/rakeman/task_parameter.rb
277
+ - app/services/rakeman/manager.rb
278
+ - app/services/rakeman/task_creator.rb
279
+ - app/services/rakeman/task_runner.rb
280
+ - app/services/rakeman/task_updater.rb
281
+ - app/views/layouts/rakeman/application.html.haml
282
+ - app/views/rakeman/rake_tasks/index.html.haml
283
+ - config/locales/rakeman/en.yml
284
+ - config/locales/rakeman/errors.yml
285
+ - config/routes.rb
286
+ - db/migrate/20201107121839_create_rakeman_rake_tasks.rb
287
+ - db/migrate/20201114134949_create_rakeman_task_parameters.rb
288
+ - lib/generators/rakeman/install_generator.rb
289
+ - lib/generators/rakeman/templates/initializer.rb
31
290
  - lib/rakeman.rb
32
- - lib/rakeman/config/i18n.rb
33
- - lib/rakeman/config/locales/en.yml
34
- - lib/rakeman/rake_presenter.rb
35
- - lib/rakeman/rake_runner.rb
36
- - lib/rakeman/rake_updater.rb
291
+ - lib/rakeman/configuration.rb
292
+ - lib/rakeman/engine.rb
37
293
  - lib/rakeman/version.rb
38
- - rakeman-0.1.0.gem
39
- - rakeman.gemspec
40
294
  homepage: https://github.com/CaptainJNS/rakeman
41
295
  licenses:
42
296
  - MIT
data/.gitignore DELETED
@@ -1,11 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.6.5
6
- before_install: gem install bundler -v 2.1.4
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at sereda9623@gmail.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [https://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: https://contributor-covenant.org
74
- [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile DELETED
@@ -1,7 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in rakeman.gemspec
4
- gemspec
5
-
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
@@ -1,34 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- rakeman (0.1.1)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- diff-lcs (1.4.4)
10
- rake (12.3.2)
11
- rspec (3.9.0)
12
- rspec-core (~> 3.9.0)
13
- rspec-expectations (~> 3.9.0)
14
- rspec-mocks (~> 3.9.0)
15
- rspec-core (3.9.3)
16
- rspec-support (~> 3.9.3)
17
- rspec-expectations (3.9.2)
18
- diff-lcs (>= 1.2.0, < 2.0)
19
- rspec-support (~> 3.9.0)
20
- rspec-mocks (3.9.1)
21
- diff-lcs (>= 1.2.0, < 2.0)
22
- rspec-support (~> 3.9.0)
23
- rspec-support (3.9.3)
24
-
25
- PLATFORMS
26
- ruby
27
-
28
- DEPENDENCIES
29
- rake (~> 12.0)
30
- rakeman!
31
- rspec (~> 3.0)
32
-
33
- BUNDLED WITH
34
- 2.1.4
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2020 CaptainJNS
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.
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "rakeman"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- I18n.load_path << Dir[File.dirname(__FILE__) + '/locales/*.yml']
@@ -1 +0,0 @@
1
- en:
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RakePresenter
4
- RAKE_REGEX = /rake ([\w\[\],:]+) #/
5
- DESC_REGEX = /# ([\w\W]+)/
6
-
7
- def get_tasks_list
8
- tasks_list = `rake -T`.split("\n").map { |task| task.squeeze(' ') }
9
-
10
- parse_to_hash(tasks_list)
11
- end
12
-
13
- private
14
-
15
- def parse_to_hash(tasks_list)
16
- result = []
17
- tasks_list.each do |task|
18
- result << {rake: RAKE_REGEX.match(task)[1],desc: DESC_REGEX.match(task)[1],done: false}
19
- end
20
- result
21
- end
22
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RakeRunner
4
- private
5
-
6
- def run(task)
7
- `rake #{task}`
8
- end
9
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RakeUpdater
4
- def update_list(old_tasks:, new_tasks:)
5
- generate_data(old_tasks, new_tasks)
6
- end
7
-
8
- def mark_as_done(task_name:, task_list:)
9
- task_to_update = task_list.detect { |task| task[:rake] == task_name }
10
- task_to_update[:done] = true if task_to_update
11
- task_list
12
- end
13
-
14
- def mark_as_undone(task_name:, task_list:)
15
- task_to_update = task_list.detect { |task| task[:rake] == task_name }
16
- task_to_update[:done] = false if task_to_update
17
- task_list
18
- end
19
-
20
- private
21
-
22
- def generate_data(old_tasks, new_tasks)
23
- result = []
24
- new_tasks.each do |new_task|
25
- overwrited_task = old_tasks.detect { |old_task| old_task[:rake] == new_task[:rake] }
26
- next result << overwrited_task.merge(desc: new_task[:desc]) if overwrited_task
27
-
28
- result << new_task
29
- end
30
-
31
- result
32
- end
33
- end
Binary file
@@ -1,28 +0,0 @@
1
- require_relative 'lib/rakeman/version'
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = "rakeman"
5
- spec.version = Rakeman::VERSION
6
- spec.authors = ["CaptainJNS"]
7
- spec.email = ["sereda9623@gmail.com"]
8
-
9
- spec.summary = %q{This gem allow to manage your project rake tasks.}
10
- spec.homepage = "https://github.com/CaptainJNS/rakeman"
11
- spec.license = "MIT"
12
- # spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
-
14
- # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
15
-
16
- # spec.metadata["homepage_uri"] = spec.homepage
17
- # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
18
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
19
-
20
- # Specify which files should be added to the gem when it is released.
21
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
- end
25
- spec.bindir = "exe"
26
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
- spec.require_paths = ["lib"]
28
- end