admin_script 0.2.0 → 0.3.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 +4 -4
- data/lib/admin_script.rb +1 -0
- data/lib/admin_script/configuration.rb +0 -3
- data/lib/admin_script/engine.rb +24 -14
- data/lib/admin_script/reloader.rb +14 -0
- data/lib/admin_script/version.rb +1 -1
- data/lib/generators/admin_script/install/templates/initializer.rb +0 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 869e5f1cf2ecbdada5116840bdabb72b6ce8aadc
|
4
|
+
data.tar.gz: 3ad84752ea0ec91af8dd95683081d4ab15434fae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fd0be08d51e57412302273c025afa201b23611e8dae995f6de804f17be0c0e388e8428b5146179ee091969e0b4bb2031a9f1e2e274ac12d900755025f63d54f
|
7
|
+
data.tar.gz: ff52b57576aedb19e3d08f8997abbd764497cbf0b98f48715d3208da1f0bdfc6b79f65145915009d348f82f27d93cc99b31ef9f86675c7c50f2ebb06a9f3e416
|
data/lib/admin_script.rb
CHANGED
@@ -6,6 +6,7 @@ module AdminScript
|
|
6
6
|
autoload :TypeAttributes, 'admin_script/type_attributes'
|
7
7
|
autoload :Controller, 'admin_script/controller'
|
8
8
|
autoload :Configuration, 'admin_script/configuration'
|
9
|
+
autoload :Reloader, 'admin_script/reloader'
|
9
10
|
|
10
11
|
def self.configure
|
11
12
|
yield(configuration)
|
@@ -22,9 +22,6 @@ module AdminScript
|
|
22
22
|
@configurations = self.class.default_configurations.clone
|
23
23
|
end
|
24
24
|
|
25
|
-
define_configuration(:admin_script_paths, default: [
|
26
|
-
(Rails.root.join('app', 'models', 'admin_script').to_s if defined?(Rails))
|
27
|
-
])
|
28
25
|
define_configuration(:parent_controller, default: 'ActionController::Base')
|
29
26
|
define_configuration(:default_url_options, default: {})
|
30
27
|
define_configuration(:controller_path, default: 'admin_scripts')
|
data/lib/admin_script/engine.rb
CHANGED
@@ -9,13 +9,23 @@ module AdminScript
|
|
9
9
|
AdminScript::Bootstrap.new.load!
|
10
10
|
|
11
11
|
initializer 'admin_script.i18n' do |app|
|
12
|
-
|
13
|
-
|
12
|
+
app.config.i18n.load_path += gem_locale_files(app)
|
13
|
+
end
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
initializer 'admin_script.load_subclasses', before: :set_clear_dependencies_hook do |app|
|
16
|
+
path = app.paths['app/models'].first
|
17
17
|
|
18
|
-
|
18
|
+
reloader = AdminScript::Reloader.file_watcher.new([], { "#{path}/admin_script" => [:rb] }) do
|
19
|
+
Dir["#{path}/admin_script/**/*.rb"].each do |full_path|
|
20
|
+
load(full_path)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
config.to_prepare do
|
25
|
+
reloader.execute_if_updated
|
26
|
+
end
|
27
|
+
|
28
|
+
app.reloaders << reloader
|
19
29
|
end
|
20
30
|
|
21
31
|
config.assets.paths += %w(stylesheets javascripts fonts).map do |path|
|
@@ -23,18 +33,18 @@ module AdminScript
|
|
23
33
|
end
|
24
34
|
|
25
35
|
config.after_initialize do
|
26
|
-
AdminScript::Engine.routes.default_url_options =
|
27
|
-
Rails.application.routes.default_url_options
|
36
|
+
AdminScript::Engine.routes.default_url_options =
|
37
|
+
AdminScript.configuration.default_url_options.presence || Rails.application.routes.default_url_options
|
28
38
|
end
|
29
39
|
|
30
|
-
|
31
|
-
AdminScript.configuration.admin_script_paths.each do |path|
|
32
|
-
finder = Pathname.new(path).join('**', '*.rb')
|
40
|
+
private
|
33
41
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
42
|
+
def gem_locale_files(app)
|
43
|
+
array = Array.wrap(app.config.i18n.available_locales)
|
44
|
+
available_locales = array.blank? ? '*' : "{#{array.join ','}}"
|
45
|
+
|
46
|
+
locale_pattern = File.expand_path("../../../config/locales/admin_script/#{available_locales}.yml", __FILE__)
|
47
|
+
Dir[locale_pattern]
|
38
48
|
end
|
39
49
|
end
|
40
50
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module AdminScript
|
2
|
+
module Reloader
|
3
|
+
def self.file_watcher
|
4
|
+
case Rails.version[0]
|
5
|
+
when '4'
|
6
|
+
ActiveSupport::FileUpdateChecker
|
7
|
+
when '5'
|
8
|
+
Rails.application.config.file_watcher || ActiveSupport::FileUpdateChecker
|
9
|
+
else
|
10
|
+
raise 'Unsupported rails version!'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/admin_script/version.rb
CHANGED
@@ -2,9 +2,6 @@ AdminScript.configure do |config|
|
|
2
2
|
# Configure the parent class responsible to render views.
|
3
3
|
# config.parent_controller = 'ActionController::Base'
|
4
4
|
|
5
|
-
# Configure the path to admin script classes.
|
6
|
-
# config.admin_script_paths = [Rails.root.join('app', 'models', 'admin_script').to_s]
|
7
|
-
|
8
5
|
# Custom controller. Default controller is AdminScript::AdminScriptsController
|
9
6
|
# config.controller_path = 'admin_scripts'
|
10
7
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: admin_script
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alpaca-tc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -257,6 +257,7 @@ files:
|
|
257
257
|
- lib/admin_script/bootstrap.rb
|
258
258
|
- lib/admin_script/configuration.rb
|
259
259
|
- lib/admin_script/engine.rb
|
260
|
+
- lib/admin_script/reloader.rb
|
260
261
|
- lib/admin_script/type_attributes.rb
|
261
262
|
- lib/admin_script/version.rb
|
262
263
|
- lib/generators/admin_script/controller/controller_generator.rb
|