trestle-rake 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ead7db88f90068c328c29a6b143e88babf7975c10b6047741446de95edc2573c
4
+ data.tar.gz: deb5b57c63b27cf9538e32965f0374007a63620f1859c8bcd2c30be1a398364c
5
+ SHA512:
6
+ metadata.gz: f11564ea1ce8d6915e750faa69bde33fcb1cb64c4e2f282b51edb8f5a17458bd31b01bd886a7078942ef6efa8c7f0ffaf1bdcd7b7dc23bb9d01fd31cfe14e8f3
7
+ data.tar.gz: 46941b8ddbc564bd25604265a8dd64fbc7c71d352aed11193ed6f474d94829d9f91cb566ab14931d88d1e8b06cc4285bf24a3daa962f0b918317b85428fc5967
data/.gitignore ADDED
@@ -0,0 +1,59 @@
1
+ .DS_Store
2
+ *.gem
3
+ *.rbc
4
+ /.config
5
+ /coverage/
6
+ /InstalledFiles
7
+ /pkg/
8
+ /spec/reports/
9
+ /spec/examples.txt
10
+ /test/tmp/
11
+ /test/version_tmp/
12
+ /tmp/
13
+
14
+ # Used by dotenv library to load environment variables.
15
+ # .env
16
+
17
+ # Ignore Byebug command history file.
18
+ .byebug_history
19
+
20
+ ## Specific to RubyMotion:
21
+ .dat*
22
+ .repl_history
23
+ build/
24
+ *.bridgesupport
25
+ build-iPhoneOS/
26
+ build-iPhoneSimulator/
27
+
28
+ ## Specific to RubyMotion (use of CocoaPods):
29
+ #
30
+ # We recommend against adding the Pods directory to your .gitignore. However
31
+ # you should judge for yourself, the pros and cons are mentioned at:
32
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
33
+ #
34
+ # vendor/Pods/
35
+
36
+ ## Documentation cache and generated files:
37
+ /.yardoc/
38
+ /_yardoc/
39
+ /doc/
40
+ /rdoc/
41
+
42
+ ## Environment normalization:
43
+ /.bundle/
44
+ /vendor/bundle
45
+ /lib/bundler/man/
46
+
47
+ # for a library or gem, you might want to ignore these files since the code is
48
+ # intended to run in multiple environments; otherwise, check them in:
49
+ # Gemfile.lock
50
+ # .ruby-version
51
+ # .ruby-gemset
52
+
53
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
54
+ .rvmrc
55
+
56
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
57
+ # .rubocop-https?--*
58
+
59
+ .idea
data/.travis.yml ADDED
@@ -0,0 +1,24 @@
1
+ language: ruby
2
+
3
+ cache: bundler
4
+
5
+ before_install:
6
+ - gem update --system
7
+ - gem install bundler
8
+
9
+ rvm:
10
+ - 2.6.5
11
+
12
+ gemfile:
13
+ - gemfiles/rails-5.0.gemfile
14
+ - gemfiles/rails-5.1.gemfile
15
+ - gemfiles/rails-5.2.gemfile
16
+ - gemfiles/rails-6.0.gemfile
17
+ - gemfiles/rails-6.1.gemfile
18
+ - gemfiles/rails-6.2.gemfile
19
+
20
+ jobs:
21
+ include:
22
+ gemfile: gemfiles/rails-4.2.gemfile
23
+ before_install:
24
+ - gem install bundler -v '< 2'
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in trestle-auth.gemspec
4
+ gemspec
5
+
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Matthieu "Ezveus" Ciappara
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # Trestle Rake Tasks (trestle-rake)
2
+
3
+ > Add an interface to Trestle to spawn Rake tasks
4
+
5
+ ## Getting Started
6
+
7
+ These instructions assume you have a working Trestle application. To integrate trestle-rake, first add it to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'trestle-rake'
11
+ ```
12
+
13
+ Run `bundle install`, and then restart your Rails server.
14
+
15
+ ## License
16
+
17
+ 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,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,42 @@
1
+ require 'rake'
2
+
3
+ Rake::Task.clear # Necessary to avoid tasks being loaded several times in dev mode
4
+ Rails.application.load_tasks
5
+
6
+ Trestle.admin(:rake, scope: Trestle::Rake, path: 'rake') do
7
+ routes do
8
+ post :run_task
9
+ end
10
+
11
+ controller do
12
+ before_action :fetch_tasks
13
+
14
+ def index
15
+ end
16
+
17
+ def run_task
18
+ task = params[:task]
19
+
20
+ if @rake.include?(task)
21
+ Rake::Task[task].reenable # In case the same task is invoked a second time.
22
+ Rake::Task[task].invoke
23
+
24
+ redirect_to admin.path(:index),
25
+ notice: I18n.t('run_success', scope: 'trestle_rake',
26
+ default: "'%{task_name}' was launched",
27
+ task_name: I18n.t(task, scope: 'trestle_rake', default: task))
28
+ else
29
+ redirect_to admin.path(:index),
30
+ notice: I18n.t('unknown_task', scope: 'trestle_rake',
31
+ default: "'%{task_name}' does not exists",
32
+ task_name: I18n.t(task, scope: 'trestle_rake', default: task))
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def fetch_tasks
39
+ @rake = Rake::Task.tasks.map(&:name)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,17 @@
1
+ .rake-tasks-header-button {
2
+ float: right;
3
+ margin: 6px 16px;
4
+ font-size: 26px;
5
+ }
6
+
7
+ .rake-tasks-grid {
8
+ display: grid;
9
+ gap: 1rem;
10
+ grid-template-columns: 7fr 3fr;
11
+ grid-template-rows: auto;
12
+ margin-top: 1rem;
13
+ }
14
+
15
+ .rake-tasks-grid .rake-tasks-task-name {
16
+ margin-left: 1rem;
17
+ }
@@ -0,0 +1,27 @@
1
+ <%= content_for(:title, "Rake tasks") %>
2
+
3
+ <% if flash[:notice] %>
4
+ <div class="alert alert-dismissible alert-success">
5
+ <button type="button" class="close" data-dismiss="alert" aria-label="Close">
6
+ <span aria-hidden="true">&times;</span>
7
+ </button>
8
+ <div class="text-center d-flex align-items-center justify-content-center">
9
+ <i class="fa fa-check-circle fa-2x margin-right-md"></i>
10
+ <span><%= flash[:notice] %></span>
11
+ </div>
12
+ </div>
13
+ <% end %>
14
+
15
+ <div class="rake-tasks-grid">
16
+ <% @rake.each do |task| %>
17
+ <div class="rake-tasks-task-name">
18
+ <%= t(task, scope: 'trestle_rake', default: task) %>
19
+ </div>
20
+ <div class="rake-tasks-task-spawn">
21
+ <%= form_tag admin.path(:run_task), id: "update_#{task}_form", method: :post, class: 'form-inline mb-2', style: 'width: 100%;' do %>
22
+ <%= hidden_field_tag('task', task, id: "task_#{task}", class: 'form-check-input') %>
23
+ <%= submit_tag(t('run', scope: 'trestle_rake', default: 'Run'), class: 'btn btn-success') %>
24
+ <% end %>
25
+ </div>
26
+ <% end %>
27
+ </div>
@@ -0,0 +1 @@
1
+ <%= link_to icon("fa fa-tasks"), Trestle::Rake::RakeAdmin.path, class: "rake-tasks-header-button", title: "Rake tasks", data: { toggle: "tooltip", placement: "bottom" } %>
@@ -0,0 +1,9 @@
1
+ Trestle.configure do |config|
2
+ config.hook("stylesheets") do
3
+ stylesheet_link_tag "trestle/rake"
4
+ end
5
+
6
+ config.hook("view.header") do
7
+ render "trestle/rake/header"
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ en:
2
+ trestle_rake:
3
+ run: Run
4
+ run_success: "The task '%{task_name}' was launched"
5
+ unknown_task: "The task '%{task_name}' does not exists"
@@ -0,0 +1,5 @@
1
+ fr:
2
+ trestle_rake:
3
+ run: Lancer
4
+ run_success: "La tâche '%{task_name}' a été lancée"
5
+ unknown_task: "La tâche '%{task_name}' n'existe pas"
@@ -0,0 +1,7 @@
1
+ module Trestle
2
+ module Rake
3
+ class Engine < Rails::Engine
4
+ config.assets.precompile << 'trestle/rake.css'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Trestle
2
+ module Rake
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ require_relative 'rake/version'
2
+
3
+ require 'trestle'
4
+
5
+ require_relative 'rake/engine' if defined?(Rails)
@@ -0,0 +1,29 @@
1
+ require_relative 'lib/trestle/rake/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "trestle-rake"
5
+ spec.version = Trestle::Rake::VERSION
6
+
7
+ spec.authors = ["Matthieu Ciappara"]
8
+ spec.email = ["matthieu.ciappara@outlook.com"]
9
+
10
+ spec.summary = "Add an interface to Trestle to spawn Rake tasks"
11
+ spec.homepage = "https://github.com/Ezveus/trestle-rake.git"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
15
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
16
+ end
17
+
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
21
+
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = "https://github.com/Ezveus/trestle-rake"
24
+
25
+ spec.add_dependency 'rails', '>= 5.2', '< 7'
26
+ spec.add_dependency "trestle", "~> 0.9.0", ">= 0.9.3"
27
+
28
+ spec.add_development_dependency "rspec-rails", "~> 4.0"
29
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trestle-rake
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Matthieu Ciappara
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-06-14 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
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '5.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7'
33
+ - !ruby/object:Gem::Dependency
34
+ name: trestle
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.9.0
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.9.3
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: 0.9.0
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.9.3
53
+ - !ruby/object:Gem::Dependency
54
+ name: rspec-rails
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '4.0'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '4.0'
67
+ description:
68
+ email:
69
+ - matthieu.ciappara@outlook.com
70
+ executables: []
71
+ extensions: []
72
+ extra_rdoc_files: []
73
+ files:
74
+ - ".gitignore"
75
+ - ".travis.yml"
76
+ - Gemfile
77
+ - LICENSE
78
+ - README.md
79
+ - Rakefile
80
+ - app/admin/trestle/rake/rake_admin.rb
81
+ - app/assets/stylesheets/trestle/rake.css
82
+ - app/views/admin/trestle/rake/rake/index.html.erb
83
+ - app/views/trestle/rake/_header.html.erb
84
+ - config/initializers/trestle.rb
85
+ - config/locales/en.yml
86
+ - config/locales/fr.yml
87
+ - lib/trestle/rake.rb
88
+ - lib/trestle/rake/engine.rb
89
+ - lib/trestle/rake/version.rb
90
+ - trestle-rake.gemspec
91
+ homepage: https://github.com/Ezveus/trestle-rake.git
92
+ licenses:
93
+ - MIT
94
+ metadata:
95
+ homepage_uri: https://github.com/Ezveus/trestle-rake.git
96
+ source_code_uri: https://github.com/Ezveus/trestle-rake
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: 2.3.0
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubygems_version: 3.0.3.1
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Add an interface to Trestle to spawn Rake tasks
116
+ test_files: []