activeadmin 1.4.3 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activeadmin might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +70 -10
- data/CONTRIBUTING.md +12 -11
- data/README.md +34 -8
- data/app/assets/javascripts/active_admin/base.es6 +23 -0
- data/app/assets/javascripts/active_admin/ext/jquery-ui.es6 +7 -0
- data/app/assets/javascripts/active_admin/ext/jquery.es6 +9 -0
- data/app/assets/javascripts/active_admin/initializers/datepicker.es6 +16 -0
- data/app/assets/javascripts/active_admin/initializers/filters.es6 +45 -0
- data/app/assets/javascripts/active_admin/initializers/tabs.es6 +6 -0
- data/app/assets/javascripts/active_admin/lib/active_admin.es6 +41 -0
- data/app/assets/javascripts/active_admin/lib/batch_actions.es6 +55 -0
- data/app/assets/javascripts/active_admin/lib/checkbox-toggler.es6 +49 -0
- data/app/assets/javascripts/active_admin/lib/dropdown-menu.es6 +123 -0
- data/app/assets/javascripts/active_admin/lib/has_many.es6 +95 -0
- data/app/assets/javascripts/active_admin/lib/modal_dialog.es6 +61 -0
- data/app/assets/javascripts/active_admin/lib/per_page.es6 +47 -0
- data/app/assets/javascripts/active_admin/lib/table-checkbox-toggler.es6 +36 -0
- data/app/assets/stylesheets/active_admin/_forms.scss +2 -14
- data/app/assets/stylesheets/active_admin/components/_status_tags.scss +0 -5
- data/app/assets/stylesheets/active_admin/components/_tabs.scss +1 -1
- data/app/assets/stylesheets/active_admin/mixins/_gradients.scss +1 -1
- data/app/views/active_admin/devise/confirmations/new.html.erb +1 -1
- data/app/views/active_admin/devise/passwords/edit.html.erb +1 -1
- data/app/views/active_admin/devise/passwords/new.html.erb +1 -1
- data/app/views/active_admin/devise/registrations/new.html.erb +1 -2
- data/app/views/active_admin/devise/shared/_error_messages.html.erb +15 -0
- data/app/views/active_admin/devise/unlocks/new.html.erb +1 -1
- data/app/views/layouts/active_admin_logged_out.html.erb +1 -1
- data/config/locales/bg.yml +0 -1
- data/config/locales/he.yml +0 -1
- data/config/locales/hu.yml +4 -0
- data/config/locales/lt.yml +2 -2
- data/config/locales/uk.yml +2 -0
- data/docs/0-installation.md +2 -2
- data/docs/13-authorization-adapter.md +4 -4
- data/docs/CNAME +1 -1
- data/docs/index.html +2 -2
- data/lib/active_admin.rb +9 -4
- data/lib/active_admin/application.rb +8 -14
- data/lib/active_admin/application_settings.rb +3 -0
- data/lib/active_admin/asset_registration.rb +0 -8
- data/lib/active_admin/base_controller.rb +6 -6
- data/lib/active_admin/base_controller/authorization.rb +2 -4
- data/lib/active_admin/batch_actions/controller.rb +1 -1
- data/lib/active_admin/batch_actions/resource_extension.rb +4 -4
- data/lib/active_admin/callbacks.rb +1 -1
- data/lib/active_admin/csv_builder.rb +1 -1
- data/lib/active_admin/dependency.rb +1 -77
- data/lib/active_admin/dsl.rb +1 -8
- data/lib/active_admin/error.rb +1 -1
- data/lib/active_admin/filters/active_filter.rb +3 -1
- data/lib/active_admin/filters/active_sidebar.rb +5 -1
- data/lib/active_admin/filters/forms.rb +2 -2
- data/lib/active_admin/filters/formtastic_addons.rb +1 -1
- data/lib/active_admin/filters/resource_extension.rb +3 -3
- data/lib/active_admin/form_builder.rb +3 -3
- data/lib/active_admin/generators/boilerplate.rb +1 -1
- data/lib/active_admin/helpers/scope_chain.rb +1 -0
- data/lib/active_admin/inputs/datepicker_input.rb +1 -1
- data/lib/active_admin/inputs/filters/base/search_method_select.rb +2 -2
- data/lib/active_admin/menu_item.rb +1 -1
- data/lib/active_admin/namespace.rb +2 -2
- data/lib/active_admin/namespace_settings.rb +7 -4
- data/lib/active_admin/orm/active_record/comments.rb +4 -4
- data/lib/active_admin/orm/active_record/comments/comment.rb +2 -2
- data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +10 -5
- data/lib/active_admin/page_dsl.rb +1 -1
- data/lib/active_admin/pundit_adapter.rb +13 -4
- data/lib/active_admin/resource.rb +2 -2
- data/lib/active_admin/resource/action_items.rb +1 -1
- data/lib/active_admin/resource/attributes.rb +7 -4
- data/lib/active_admin/resource/menu.rb +3 -3
- data/lib/active_admin/resource/naming.rb +3 -3
- data/lib/active_admin/resource/routes.rb +9 -4
- data/lib/active_admin/resource/scopes.rb +3 -3
- data/lib/active_admin/resource/sidebars.rb +1 -1
- data/lib/active_admin/resource_collection.rb +2 -2
- data/lib/active_admin/resource_controller/action_builder.rb +10 -0
- data/lib/active_admin/resource_controller/resource_class_methods.rb +2 -0
- data/lib/active_admin/resource_dsl.rb +5 -3
- data/lib/active_admin/router.rb +1 -1
- data/lib/active_admin/scope.rb +4 -4
- data/lib/active_admin/settings_node.rb +1 -1
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_helpers.rb +1 -1
- data/lib/active_admin/view_helpers/display_helper.rb +10 -2
- data/lib/active_admin/view_helpers/download_format_links_helper.rb +1 -0
- data/lib/active_admin/view_helpers/method_or_proc_helper.rb +2 -0
- data/lib/active_admin/views.rb +1 -1
- data/lib/active_admin/views/components/active_admin_form.rb +7 -1
- data/lib/active_admin/views/components/attributes_table.rb +3 -3
- data/lib/active_admin/views/components/paginated_collection.rb +1 -1
- data/lib/active_admin/views/components/sidebar_section.rb +0 -3
- data/lib/active_admin/views/components/status_tag.rb +1 -18
- data/lib/active_admin/views/components/table_for.rb +2 -2
- data/lib/active_admin/views/components/tabs.rb +11 -2
- data/lib/active_admin/views/footer.rb +1 -1
- data/lib/active_admin/views/index_as_table.rb +5 -4
- data/lib/active_admin/views/pages/base.rb +3 -0
- data/lib/generators/active_admin/assets/assets_generator.rb +2 -2
- data/lib/generators/active_admin/assets/templates/active_admin.js +1 -0
- data/lib/generators/active_admin/install/install_generator.rb +6 -2
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +20 -1
- data/lib/generators/active_admin/install/templates/dashboard.rb +2 -3
- data/lib/generators/active_admin/install/templates/migrations/create_active_admin_comments.rb.erb +1 -15
- data/lib/generators/active_admin/page/page_generator.rb +1 -1
- data/lib/generators/active_admin/resource/resource_generator.rb +1 -1
- data/lib/ransack_ext.rb +3 -3
- data/vendor/assets/javascripts/jquery-ui/form-reset-mixin.js +80 -0
- data/vendor/assets/javascripts/jquery-ui/form.js +22 -0
- data/vendor/assets/javascripts/jquery-ui/labels.js +65 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/checkboxradio.js +274 -283
- metadata +107 -96
- data/.circleci/config.yml +0 -572
- data/.github/ISSUE_TEMPLATE.md +0 -20
- data/.gitignore +0 -16
- data/.mdlrc +0 -1
- data/.rspec +0 -1
- data/.rspec_parallel +0 -2
- data/.rubocop.yml +0 -99
- data/.simplecov +0 -9
- data/.yardopts +0 -7
- data/Gemfile +0 -30
- data/Gemfile.common +0 -26
- data/Gemfile.lock +0 -433
- data/Rakefile +0 -24
- data/activeadmin.gemspec +0 -32
- data/app/assets/javascripts/active_admin/base.js.coffee +0 -13
- data/app/assets/javascripts/active_admin/ext/jquery-ui.js.coffee +0 -6
- data/app/assets/javascripts/active_admin/ext/jquery.js.coffee +0 -7
- data/app/assets/javascripts/active_admin/initializers/batch_actions.js.coffee +0 -11
- data/app/assets/javascripts/active_admin/initializers/datepicker.js.coffee +0 -14
- data/app/assets/javascripts/active_admin/initializers/filters.js.coffee +0 -26
- data/app/assets/javascripts/active_admin/initializers/tabs.js.coffee +0 -7
- data/app/assets/javascripts/active_admin/lib/batch_actions.js.coffee +0 -42
- data/app/assets/javascripts/active_admin/lib/checkbox-toggler.js.coffee +0 -46
- data/app/assets/javascripts/active_admin/lib/dropdown-menu.js.coffee +0 -104
- data/app/assets/javascripts/active_admin/lib/flash.js.coffee +0 -19
- data/app/assets/javascripts/active_admin/lib/has_many.js.coffee +0 -79
- data/app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee +0 -45
- data/app/assets/javascripts/active_admin/lib/per_page.js.coffee +0 -46
- data/app/assets/javascripts/active_admin/lib/table-checkbox-toggler.js.coffee +0 -22
- data/bin/install_chromedriver.sh +0 -17
- data/config/i18n-tasks.yml +0 -26
- data/config/mdl_style.rb +0 -11
- data/cucumber.yml +0 -7
- data/gemfiles/rails_42.gemfile +0 -10
- data/gemfiles/rails_42.gemfile.lock +0 -339
- data/gemfiles/rails_50.gemfile +0 -10
- data/gemfiles/rails_50.gemfile.lock +0 -353
- data/gemfiles/rails_51.gemfile +0 -10
- data/gemfiles/rails_51.gemfile.lock +0 -353
- data/lib/active_admin/event.rb +0 -24
- data/lib/active_admin/helpers/output_safety_helper.rb +0 -35
- data/lib/bug_report_templates/active_admin_master.rb +0 -111
- data/lib/generators/active_admin/assets/templates/active_admin.js.coffee +0 -1
- data/tasks/application_generator.rb +0 -50
- data/tasks/docs.rake +0 -64
- data/tasks/gemfiles.rake +0 -8
- data/tasks/lint.rake +0 -110
- data/tasks/local.rake +0 -27
- data/tasks/release.rake +0 -6
- data/tasks/test.rake +0 -42
data/lib/active_admin/event.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module ActiveAdmin
|
2
|
-
|
3
|
-
class EventDispatcher
|
4
|
-
def subscribe(*event_names, &block)
|
5
|
-
Deprecation.warn "`ActiveAdmin::Event.subscribe` is deprecated, use `ActiveSupport::Notifications.subscribe`"
|
6
|
-
event_names.each do |event|
|
7
|
-
ActiveSupport::Notifications.subscribe event,
|
8
|
-
&wrap_block_for_active_support_notifications(block)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def dispatch(event, *args)
|
13
|
-
Deprecation.warn "`ActiveAdmin::Event.dispatch` is deprecated, use `ActiveSupport::Notifications.publish`"
|
14
|
-
ActiveSupport::Notifications.publish event, *args
|
15
|
-
end
|
16
|
-
|
17
|
-
def wrap_block_for_active_support_notifications block
|
18
|
-
proc { |event, *args| block.call *args }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# ActiveAdmin::Event is set to a dispatcher
|
23
|
-
Event = EventDispatcher.new
|
24
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module ActiveAdmin
|
2
|
-
module OutputSafetyHelper
|
3
|
-
# Converts the array to a comma-separated sentence where the last element is
|
4
|
-
# joined by the connector word. This is the html_safe-aware version of
|
5
|
-
# ActiveSupport's {Array#to_sentence}[http://api.rubyonrails.org/classes/Array.html#method-i-to_sentence].
|
6
|
-
#
|
7
|
-
# Copied from Rails 5 to support Rails 4.
|
8
|
-
# https://github.com/rails/rails/blob/9c35bf2a6a27431c6aa283db781c19f61c5155be/actionview/lib/action_view/helpers/output_safety_helper.rb#L43
|
9
|
-
def to_sentence(array, options = {})
|
10
|
-
options.assert_valid_keys(:words_connector, :two_words_connector, :last_word_connector, :locale)
|
11
|
-
|
12
|
-
default_connectors = {
|
13
|
-
words_connector: ", ",
|
14
|
-
two_words_connector: " and ",
|
15
|
-
last_word_connector: ", and "
|
16
|
-
}
|
17
|
-
if defined?(::I18n)
|
18
|
-
i18n_connectors = ::I18n.translate(:'support.array', locale: options[:locale], default: {})
|
19
|
-
default_connectors.merge!(i18n_connectors)
|
20
|
-
end
|
21
|
-
options = default_connectors.merge!(options)
|
22
|
-
|
23
|
-
case array.length
|
24
|
-
when 0
|
25
|
-
"".html_safe
|
26
|
-
when 1
|
27
|
-
ERB::Util.html_escape(array[0])
|
28
|
-
when 2
|
29
|
-
safe_join([array[0], array[1]], options[:two_words_connector])
|
30
|
-
else
|
31
|
-
safe_join([safe_join(array[0...-1], options[:words_connector]), options[:last_word_connector], array[-1]], nil)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,111 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'bundler/inline'
|
3
|
-
rescue LoadError => e
|
4
|
-
STDERR.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
|
5
|
-
raise e
|
6
|
-
end
|
7
|
-
|
8
|
-
gemfile(true) do
|
9
|
-
source 'https://rubygems.org'
|
10
|
-
|
11
|
-
# Use local changes or ActiveAdmin master.
|
12
|
-
if ENV['ACTIVE_ADMIN_PATH']
|
13
|
-
gem 'activeadmin', path: ENV['ACTIVE_ADMIN_PATH'], require: false
|
14
|
-
else
|
15
|
-
gem 'activeadmin', github: 'activeadmin/activeadmin', require: false
|
16
|
-
end
|
17
|
-
|
18
|
-
# Change Rails version if necessary.
|
19
|
-
gem 'rails', '~> 5.1.0'
|
20
|
-
|
21
|
-
gem 'sass-rails'
|
22
|
-
gem 'sqlite3', platform: :mri
|
23
|
-
gem 'activerecord-jdbcsqlite3-adapter', "~> 51.0", platform: :jruby
|
24
|
-
gem 'jruby-openssl', '~> 0.10.1', platforms: :jruby
|
25
|
-
end
|
26
|
-
|
27
|
-
require 'active_record'
|
28
|
-
|
29
|
-
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
|
30
|
-
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
31
|
-
|
32
|
-
ActiveRecord::Schema.define do
|
33
|
-
create_table :active_admin_comments, force: true do |_t|
|
34
|
-
end
|
35
|
-
|
36
|
-
create_table :users, force: true do |t|
|
37
|
-
t.string :full_name
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
require 'action_controller/railtie'
|
42
|
-
require 'action_view/railtie'
|
43
|
-
require 'active_admin'
|
44
|
-
|
45
|
-
class TestApp < Rails::Application
|
46
|
-
config.root = __dir__
|
47
|
-
config.session_store :cookie_store, key: "cookie_store_key"
|
48
|
-
secrets.secret_token = 'secret_token'
|
49
|
-
secrets.secret_key_base = 'secret_key_base'
|
50
|
-
|
51
|
-
config.eager_load = false
|
52
|
-
config.logger = Logger.new($stdout)
|
53
|
-
Rails.logger = config.logger
|
54
|
-
end
|
55
|
-
|
56
|
-
class ApplicationController < ActionController::Base
|
57
|
-
include Rails.application.routes.url_helpers
|
58
|
-
end
|
59
|
-
|
60
|
-
class User < ActiveRecord::Base
|
61
|
-
end
|
62
|
-
|
63
|
-
ActiveAdmin.setup do |config|
|
64
|
-
# Authentication disabled by default. Override if necessary.
|
65
|
-
config.authentication_method = false
|
66
|
-
config.current_user_method = false
|
67
|
-
end
|
68
|
-
|
69
|
-
Rails.application.initialize!
|
70
|
-
|
71
|
-
ActiveAdmin.register_page 'Dashboard' do
|
72
|
-
menu priority: 1, label: proc { I18n.t('active_admin.dashboard') }
|
73
|
-
content do
|
74
|
-
'Test Me'
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
ActiveAdmin.register User do
|
79
|
-
end
|
80
|
-
|
81
|
-
Rails.application.routes.draw do
|
82
|
-
ActiveAdmin.routes(self)
|
83
|
-
end
|
84
|
-
|
85
|
-
require 'minitest/autorun'
|
86
|
-
require 'rack/test'
|
87
|
-
require 'rails/test_help'
|
88
|
-
|
89
|
-
# Replace this with the code necessary to make your test fail.
|
90
|
-
class BugTest < ActionDispatch::IntegrationTest
|
91
|
-
|
92
|
-
def test_admin_root_success?
|
93
|
-
get admin_root_url
|
94
|
-
assert_response :success
|
95
|
-
assert_match 'Test Me', response.body # has content
|
96
|
-
assert_match 'Users', response.body # has 'Your Models' in menu
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_admin_users
|
100
|
-
User.create! full_name: 'John Doe'
|
101
|
-
get admin_users_url
|
102
|
-
assert_response :success
|
103
|
-
assert_match 'John Doe', response.body # has created row
|
104
|
-
end
|
105
|
-
|
106
|
-
private
|
107
|
-
|
108
|
-
def app
|
109
|
-
Rails.application
|
110
|
-
end
|
111
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
#= require active_admin/base
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
module ActiveAdmin
|
4
|
-
class ApplicationGenerator
|
5
|
-
attr_reader :rails_env, :template
|
6
|
-
|
7
|
-
def initialize(opts = {})
|
8
|
-
@rails_env = opts[:rails_env] || 'test'
|
9
|
-
@template = opts[:template] || 'rails_template'
|
10
|
-
end
|
11
|
-
|
12
|
-
def generate
|
13
|
-
if File.exist? app_dir
|
14
|
-
puts "test app #{app_dir} already exists; skipping test app generation"
|
15
|
-
else
|
16
|
-
FileUtils.mkdir_p base_dir
|
17
|
-
args = %W(
|
18
|
-
-m spec/support/#{template}.rb
|
19
|
-
--skip-bootsnap
|
20
|
-
--skip-bundle
|
21
|
-
--skip-gemfile
|
22
|
-
--skip-listen
|
23
|
-
--skip-turbolinks
|
24
|
-
--skip-test-unit
|
25
|
-
)
|
26
|
-
|
27
|
-
command = ['bundle', 'exec', 'rails', 'new', app_dir, *args].join(' ')
|
28
|
-
|
29
|
-
env = { 'BUNDLE_GEMFILE' => ENV['BUNDLE_GEMFILE'], 'RAILS_ENV' => rails_env }
|
30
|
-
|
31
|
-
Bundler.with_original_env { abort unless Kernel.system(env, command) }
|
32
|
-
end
|
33
|
-
|
34
|
-
app_dir
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def base_dir
|
40
|
-
@base_dir ||= rails_env == 'test' ? 'spec/rails' : '.test-rails-apps'
|
41
|
-
end
|
42
|
-
|
43
|
-
def app_dir
|
44
|
-
@app_dir ||= begin
|
45
|
-
require 'rails/version'
|
46
|
-
"#{base_dir}/rails-#{Rails::VERSION::STRING}"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/tasks/docs.rake
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'yard'
|
2
|
-
require 'yard/rake/yardoc_task'
|
3
|
-
|
4
|
-
namespace :docs do
|
5
|
-
|
6
|
-
YARD::Rake::YardocTask.new do |t|
|
7
|
-
t.files = ['lib/**/*.rb']
|
8
|
-
t.options = ['--no-output']
|
9
|
-
end
|
10
|
-
|
11
|
-
def jekyll_redirect_string(filename)
|
12
|
-
<<-EOD.strip_heredoc
|
13
|
-
---
|
14
|
-
redirect_from: /docs/3-index-pages/#{filename}
|
15
|
-
---
|
16
|
-
|
17
|
-
EOD
|
18
|
-
end
|
19
|
-
|
20
|
-
def filename_from_module(mod)
|
21
|
-
mod.name.to_s.underscore.tr('_', '-')
|
22
|
-
end
|
23
|
-
|
24
|
-
def write_docstrings_to(path, mods)
|
25
|
-
mods.each do |mod|
|
26
|
-
filename = filename_from_module(mod)
|
27
|
-
|
28
|
-
File.open("#{path}/#{filename}.md", 'w+') do |f|
|
29
|
-
f << jekyll_redirect_string("#{filename}.html") + mod.docstring + "\n"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def docs_syncronized?
|
35
|
-
# Do not print diff and yield whether exit code was zero
|
36
|
-
sh('git diff --quiet docs/3-index-pages') do |outcome, _|
|
37
|
-
return if outcome
|
38
|
-
|
39
|
-
# Output diff before raising error
|
40
|
-
sh('git diff docs/3-index-pages')
|
41
|
-
|
42
|
-
raise <<-MSG.strip_heredoc
|
43
|
-
The docs/3-index-pages directory is out of sync.
|
44
|
-
Run rake generate_cops_documentation and commit the results.
|
45
|
-
MSG
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
desc "Update docs in the docs folder"
|
50
|
-
task build: :yard do
|
51
|
-
require 'yard'
|
52
|
-
require 'active_support/all'
|
53
|
-
|
54
|
-
YARD::Registry.load!
|
55
|
-
views = YARD::Registry.at("ActiveAdmin::Views")
|
56
|
-
|
57
|
-
# Index Types
|
58
|
-
index_types = views.children.select{|obj| obj.name.to_s =~ /^IndexAs/ }
|
59
|
-
write_docstrings_to "docs/3-index-pages", index_types
|
60
|
-
|
61
|
-
docs_syncronized? if ENV["CI"]
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
data/tasks/gemfiles.rake
DELETED
data/tasks/lint.rake
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
require "open3"
|
2
|
-
|
3
|
-
#
|
4
|
-
# Common stuff for a linter
|
5
|
-
#
|
6
|
-
module LinterMixin
|
7
|
-
def run
|
8
|
-
offenses = []
|
9
|
-
|
10
|
-
applicable_files.each do |file|
|
11
|
-
if clean?(file)
|
12
|
-
print "."
|
13
|
-
else
|
14
|
-
offenses << file
|
15
|
-
print "F"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
print "\n"
|
20
|
-
|
21
|
-
return if offenses.empty?
|
22
|
-
|
23
|
-
raise failure_message_for(offenses)
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def applicable_files
|
29
|
-
Open3.capture2("git grep -Il ''")[0].split.reject { |file| file =~ %r{vendor/} }
|
30
|
-
end
|
31
|
-
|
32
|
-
def failure_message_for(offenses)
|
33
|
-
msg = "#{self.class.name} detected offenses. "
|
34
|
-
|
35
|
-
msg += if respond_to?(:fixing_cmd)
|
36
|
-
"Run `#{fixing_cmd(offenses)}` to fix them."
|
37
|
-
else
|
38
|
-
"Affected files: #{offenses.join(' ')}"
|
39
|
-
end
|
40
|
-
|
41
|
-
msg
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
#
|
46
|
-
# Checks trailing whitespace
|
47
|
-
#
|
48
|
-
class TrailingWhitespaceLinter
|
49
|
-
include LinterMixin
|
50
|
-
|
51
|
-
def clean?(file)
|
52
|
-
File.read(file, encoding: Encoding::UTF_8) !~ / +$/
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
#
|
57
|
-
# Checks trailing whitespace
|
58
|
-
#
|
59
|
-
class FixmeLinter
|
60
|
-
include LinterMixin
|
61
|
-
|
62
|
-
def clean?(file)
|
63
|
-
relative_path = Pathname.new(__FILE__).relative_path_from(Pathname.new(File.dirname(__dir__))).to_s
|
64
|
-
|
65
|
-
file == relative_path || File.read(file, encoding: Encoding::UTF_8) !~ /(BUG|FIXME)/
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
desc "Lints ActiveAdmin code base"
|
70
|
-
task lint: ["lint:rubocop", "lint:mdl", "lint:trailing_whitespace", "lint:fixme", "lint:rspec"]
|
71
|
-
|
72
|
-
namespace :lint do
|
73
|
-
require "rubocop/rake_task"
|
74
|
-
desc "Checks ruby code style with RuboCop"
|
75
|
-
RuboCop::RakeTask.new
|
76
|
-
|
77
|
-
desc "Checks markdown code style with Markdownlint"
|
78
|
-
task :mdl do
|
79
|
-
puts "Running mdl..."
|
80
|
-
|
81
|
-
sh("mdl", "--git-recurse", ".")
|
82
|
-
end
|
83
|
-
|
84
|
-
desc "Check for unnecessary trailing whitespace across all repo files"
|
85
|
-
task :trailing_whitespace do
|
86
|
-
puts "Checking for unnecessary trailing whitespace..."
|
87
|
-
|
88
|
-
TrailingWhitespaceLinter.new.run
|
89
|
-
end
|
90
|
-
|
91
|
-
desc "Check for FIXME strings that should be fixed now, not later"
|
92
|
-
task :fixme do
|
93
|
-
puts "Checking for FIXME strings..."
|
94
|
-
|
95
|
-
FixmeLinter.new.run
|
96
|
-
end
|
97
|
-
|
98
|
-
desc "RSpec specs for linting project files"
|
99
|
-
task :rspec do
|
100
|
-
puts "Linting project files..."
|
101
|
-
|
102
|
-
sh(
|
103
|
-
{ "COVERAGE" => "true" },
|
104
|
-
"rspec",
|
105
|
-
"spec/gemfiles_spec.lint.rb",
|
106
|
-
"spec/changelog_spec.lint.rb",
|
107
|
-
"spec/i18n_spec.lint.rb"
|
108
|
-
)
|
109
|
-
end
|
110
|
-
end
|
data/tasks/local.rake
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require_relative "application_generator"
|
2
|
-
|
3
|
-
desc 'Run a command against the local sample application'
|
4
|
-
task :local do
|
5
|
-
app_folder = ActiveAdmin::ApplicationGenerator.new(
|
6
|
-
rails_env: 'development',
|
7
|
-
template: 'rails_template_with_data'
|
8
|
-
).generate
|
9
|
-
|
10
|
-
# Discard the "local" argument (name of the task)
|
11
|
-
argv = ARGV[1..-1]
|
12
|
-
|
13
|
-
# If it's a rails command, or we're using Rails 5, auto add the rails script
|
14
|
-
rails_commands = %w(generate console server db dbconsole g c s runner)
|
15
|
-
|
16
|
-
if Rails::VERSION::MAJOR >= 5 || rails_commands.include?(argv[0])
|
17
|
-
argv.unshift('rails')
|
18
|
-
end
|
19
|
-
|
20
|
-
command = ['bundle', 'exec', *argv].join(' ')
|
21
|
-
gemfile = ENV['BUNDLE_GEMFILE'] || File.expand_path("../Gemfile", __dir__)
|
22
|
-
env = { 'BUNDLE_GEMFILE' => gemfile }
|
23
|
-
|
24
|
-
Dir.chdir(app_folder) do
|
25
|
-
Bundler.with_original_env { Kernel.exec(env, command) }
|
26
|
-
end
|
27
|
-
end
|