rhino_project_core 0.20.0.alpha.0 → 0.20.0.beta.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +4 -5
- data/app/controllers/concerns/rhino/error_handling.rb +0 -2
- data/app/controllers/rhino/simple_controller.rb +1 -3
- data/app/overrides/devise_token_auth/omniauth_callbacks_controller_override.rb +2 -2
- data/app/overrides/devise_token_auth/registrations_controller_override.rb +1 -1
- data/lib/commands/rhino_command.rb +59 -0
- data/lib/generators/rhino/dev/setup/setup_generator.rb +31 -55
- data/lib/generators/rhino/module/module_generator.rb +59 -58
- data/lib/generators/rhino/module/templates/engine.rb.tt +19 -0
- data/lib/generators/rhino/module/templates/{lib/generators/%namespaced_name%/install/install_generator.rb.tt → install_generator.rb.tt} +1 -1
- data/lib/generators/rhino/module/templates/module_tasks.rake.tt +17 -0
- data/lib/rhino/engine.rb +14 -40
- data/lib/rhino/resource/active_model_extension/properties.rb +0 -2
- data/lib/rhino/resource/active_record_extension/properties.rb +1 -1
- data/lib/rhino/resource/active_record_extension/properties_describe.rb +0 -2
- data/lib/rhino/resource/active_record_extension.rb +0 -2
- data/lib/rhino/resource/properties.rb +2 -2
- data/lib/rhino/resource/reference.rb +2 -0
- data/lib/rhino/resource.rb +1 -2
- data/lib/rhino/sieve.rb +0 -1
- data/lib/rhino/test_case/controller.rb +9 -20
- data/lib/rhino/test_case.rb +0 -1
- data/lib/rhino/version.rb +1 -1
- data/lib/{rhino_project_core.rb → rhino.rb} +0 -2
- data/lib/tasks/rhino.rake +14 -0
- metadata +19 -372
- data/LICENSE +0 -21
- data/lib/commands/rhino/module/coverage_command.rb +0 -44
- data/lib/commands/rhino/module/dummy_command.rb +0 -43
- data/lib/commands/rhino/module/new_command.rb +0 -34
- data/lib/commands/rhino/module/rails_command.rb +0 -43
- data/lib/commands/rhino/module/test_command.rb +0 -43
- data/lib/generators/rhino/dev/setup/templates/env.root.tt +0 -1
- data/lib/generators/rhino/model/model_generator.rb +0 -96
- data/lib/generators/rhino/module/USAGE +0 -6
- data/lib/generators/rhino/module/templates/%name%.gemspec.tt +0 -24
- data/lib/generators/rhino/module/templates/lib/%namespaced_name%/engine.rb.tt +0 -18
- data/lib/generators/rhino/module/templates/lib/tasks/%namespaced_name%_tasks.rake.tt +0 -13
- data/lib/generators/rhino/module/templates/test/dummy/app/models/user.rb +0 -4
- data/lib/generators/rhino/module/templates/test/dummy/config/database.yml +0 -25
- data/lib/generators/rhino/module/templates/test/dummy/config/initializers/devise.rb +0 -311
- data/lib/generators/rhino/module/templates/test/dummy/config/initializers/devise_token_auth.rb +0 -71
- data/lib/generators/rhino/module/templates/test/test_helper.rb +0 -54
- data/lib/rhino/resource/active_record_extension/super_admin.rb +0 -25
- data/lib/rhino/sieve/geospatial.rb +0 -45
- data/lib/rhino/test_case/model.rb +0 -86
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8779f64179f5c2a26ea37d704c7ac7355f713fc2f386aa6ab08e3e7a0ff174f
|
4
|
+
data.tar.gz: 2e6139b4b62758822ab9db651b9468af7726e0a56d0a34c1d5712b418e21db70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 877bcedc2608beaa6d9d667991858d1b3c272ff876380e1ec1c34e07504cfbc79b153f686aafecc47b8f233d7939c8310012ec99c9f160ff30bc36543d079efb
|
7
|
+
data.tar.gz: 3a63eab50a46bbfc236d1cc8d4e0f123bf908ae2a94fbaaf2e251c00817daff159c4acc0a4400730e7cb2df0c39b347595cbac6f810e7aa81c74bfa228d74a56
|
data/Rakefile
CHANGED
@@ -25,11 +25,10 @@ require 'bundler/gem_tasks'
|
|
25
25
|
|
26
26
|
require 'rake/testtask'
|
27
27
|
|
28
|
-
Rake::TestTask.new do |t|
|
29
|
-
t.libs <<
|
30
|
-
t.
|
31
|
-
t.verbose =
|
32
|
-
t.warning = false
|
28
|
+
Rake::TestTask.new(:test) do |t|
|
29
|
+
t.libs << 'test'
|
30
|
+
t.pattern = 'test/**/*_test.rb'
|
31
|
+
t.verbose = false
|
33
32
|
end
|
34
33
|
|
35
34
|
task default: :test
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# https://stackoverflow.com/questions/4470108/when-monkey-patching-an-instance-method-can-you-call-the-overridden-method-from/4471202
|
4
4
|
# Mixin Prepending
|
5
5
|
module DeviseTokenAuth::OmniauthCallbacksController::Extensions
|
6
|
-
include RhinoOrganizations::Concerns::CreateOrganization
|
6
|
+
include RhinoOrganizations::Concerns::CreateOrganization
|
7
7
|
|
8
8
|
def redirect_callbacks
|
9
9
|
# derive target redirect route from 'resource_class' param, which was set
|
@@ -30,7 +30,7 @@ module DeviseTokenAuth::OmniauthCallbacksController::Extensions
|
|
30
30
|
|
31
31
|
# set a server cookie if configured
|
32
32
|
if DeviseTokenAuth.cookie_enabled
|
33
|
-
auth_header = @resource.
|
33
|
+
auth_header = @resource.build_auth_header(@token.token, @token.client)
|
34
34
|
cookies[DeviseTokenAuth.cookie_name] = DeviseTokenAuth.cookie_attributes.merge(value: auth_header.to_json)
|
35
35
|
end
|
36
36
|
rescue ActiveRecord::RecordInvalid
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# https://stackoverflow.com/questions/4470108/when-monkey-patching-an-instance-method-can-you-call-the-overridden-method-from/4471202
|
4
4
|
# Mixin Prepending
|
5
5
|
module DeviseTokenAuth::RegistrationsController::Extensions
|
6
|
-
include RhinoOrganizations::Concerns::CreateOrganization
|
6
|
+
include RhinoOrganizations::Concerns::CreateOrganization
|
7
7
|
|
8
8
|
def create
|
9
9
|
return render_error(401, "signup is not allowed") unless Rhino.allow_signup
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "dotenv"
|
4
|
+
require "rails/command"
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
module Command
|
8
|
+
class RhinoCommand < Base # :nodoc:
|
9
|
+
include Thor::Actions
|
10
|
+
|
11
|
+
no_commands do
|
12
|
+
def help
|
13
|
+
say "rails rhino::dummy [module] command # Run rails command in dummy application, defaults to rhino"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def dummy(*args)
|
18
|
+
rhino_command("test/dummy", nil, *args)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test(*args)
|
22
|
+
rhino_command(nil, "test", *args)
|
23
|
+
end
|
24
|
+
|
25
|
+
def rails(*args)
|
26
|
+
rhino_command(nil, nil, *args)
|
27
|
+
end
|
28
|
+
|
29
|
+
def coverage(*args)
|
30
|
+
ENV["COVERAGE"] = "1"
|
31
|
+
test(*args)
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
def rhino_command(extra_path, base_command, *args) # rubocop:todo Metrics/MethodLength
|
36
|
+
# Default to just rhino/rhino if no obvious module
|
37
|
+
module_name = if Dir.exist?("rhino/rhino_#{args[0]}")
|
38
|
+
args.shift
|
39
|
+
else
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
module_base = ["rhino", module_name].compact.join("_")
|
43
|
+
module_path = ["rhino/#{module_base}", extra_path].compact.join("/")
|
44
|
+
db_name = "#{module_base}_dummy"
|
45
|
+
|
46
|
+
# Getting existing variables and re-use
|
47
|
+
::Dotenv.load
|
48
|
+
|
49
|
+
inside(module_path) do
|
50
|
+
# Override DB_NAME so multiple can run in parallel
|
51
|
+
run(
|
52
|
+
"DB_NAME=#{db_name} BUNDLE_GEMFILE='#{__dir__}/../../../../Gemfile' bin/rails #{base_command} #{args.join(' ')}",
|
53
|
+
{ abort_on_failure: true }
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -5,21 +5,16 @@ module Rhino
|
|
5
5
|
module Dev
|
6
6
|
# rubocop:disable Metrics/ClassLength
|
7
7
|
class SetupGenerator < ::Rails::Generators::Base
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
class_option :
|
12
|
-
class_option :
|
13
|
-
class_option :
|
14
|
-
class_option :
|
15
|
-
class_option :
|
16
|
-
class_option :
|
17
|
-
class_option :
|
18
|
-
class_option :db_port, type: :numeric, default: 5432, group: :database
|
19
|
-
class_option :db_user, type: :string, group: :database
|
20
|
-
class_option :db_password, type: :string, group: :database
|
21
|
-
class_option :redis_port, type: :numeric, default: 6379, group: :redis
|
22
|
-
class_option :redis_database, type: :numeric, default: 0, group: :redis
|
8
|
+
class_option :prompt, type: :boolean, default: true
|
9
|
+
class_option :server_port, type: :numeric
|
10
|
+
class_option :client_port, type: :numeric
|
11
|
+
class_option :db_host, type: :string
|
12
|
+
class_option :db_name, type: :string
|
13
|
+
class_option :db_port, type: :numeric
|
14
|
+
class_option :db_user, type: :string
|
15
|
+
class_option :db_password, type: :string
|
16
|
+
class_option :redis_port, type: :numeric
|
17
|
+
class_option :redis_database, type: :numeric
|
23
18
|
|
24
19
|
attr_reader :server_port,
|
25
20
|
:client_port,
|
@@ -35,19 +30,11 @@ module Rhino
|
|
35
30
|
|
36
31
|
source_root File.expand_path("templates", __dir__)
|
37
32
|
|
38
|
-
def check_existing
|
39
|
-
return unless options[:skip_existing] && File.exist?(server_file(".env"))
|
40
|
-
|
41
|
-
say "Skipping existing .env files"
|
42
|
-
exit(0)
|
43
|
-
end
|
44
|
-
|
45
33
|
def setup_env
|
46
34
|
say "Setting up local .env files"
|
47
35
|
|
48
36
|
collect_env_info
|
49
37
|
|
50
|
-
template "env.root", project_file(".env")
|
51
38
|
template "env.server", server_file(".env")
|
52
39
|
template "env.client", client_file(".env")
|
53
40
|
end
|
@@ -71,19 +58,17 @@ module Rhino
|
|
71
58
|
end
|
72
59
|
|
73
60
|
def server_port_default
|
74
|
-
options[:server_port] || ENV["PORT"]
|
61
|
+
options[:server_port] || ENV["PORT"] || 3000
|
75
62
|
end
|
76
63
|
|
77
64
|
def client_port_default
|
78
65
|
@server_port.to_i + 1
|
79
66
|
end
|
80
67
|
|
81
|
-
def project_name
|
82
|
-
@project_name ||= File.basename(project_dir).sub(/[-_]?mono/, "")
|
83
|
-
end
|
84
|
-
|
85
68
|
def db_name_default
|
86
|
-
db_name =
|
69
|
+
db_name =
|
70
|
+
options[:db_name] || ENV["DB_NAME"] ||
|
71
|
+
File.basename(project_dir).sub(/[-_]?mono/, "")
|
87
72
|
|
88
73
|
return db_name if db_name.present?
|
89
74
|
|
@@ -95,15 +80,15 @@ module Rhino
|
|
95
80
|
end
|
96
81
|
|
97
82
|
def db_port_default
|
98
|
-
options[:db_port] || ENV["DB_PORT"]
|
83
|
+
options[:db_port] || ENV["DB_PORT"] || 5432
|
99
84
|
end
|
100
85
|
|
101
86
|
def db_user_default
|
102
|
-
options[:db_user] || ENV["DB_USERNAME"] ||
|
87
|
+
options[:db_user] || ENV["DB_USERNAME"] || (dockerized ? "postgres" : "")
|
103
88
|
end
|
104
89
|
|
105
90
|
def db_password_default
|
106
|
-
options[:db_password] || ENV["DB_PASSWORD"] || ""
|
91
|
+
options[:db_password] || ENV["DB_PASSWORD"] || (dockerized ? "password" : "")
|
107
92
|
end
|
108
93
|
|
109
94
|
def redis_host_default
|
@@ -111,15 +96,15 @@ module Rhino
|
|
111
96
|
end
|
112
97
|
|
113
98
|
def redis_port_default
|
114
|
-
options[:redis_port] || ENV["REDIS_PORT"]
|
99
|
+
options[:redis_port] || ENV["REDIS_PORT"] || 6379
|
115
100
|
end
|
116
101
|
|
117
102
|
def redis_database_default
|
118
|
-
options[:redis_database] || ENV["REDIS_DATABASE"]
|
103
|
+
options[:redis_database] || ENV["REDIS_DATABASE"] || 0
|
119
104
|
end
|
120
105
|
|
121
106
|
def dockerized_default
|
122
|
-
|
107
|
+
"yN"
|
123
108
|
end
|
124
109
|
|
125
110
|
def collect_env_info
|
@@ -133,46 +118,37 @@ module Rhino
|
|
133
118
|
end
|
134
119
|
|
135
120
|
def collect_docker_info
|
136
|
-
@dockerized = %w[y Y].include?(ask_prompt("Run
|
121
|
+
@dockerized = %w[y Y].include?(ask_prompt("Run server on docker?", dockerized_default))
|
137
122
|
|
138
123
|
return unless dockerized
|
139
124
|
|
140
125
|
@db_host = "db"
|
141
|
-
@db_user = "postgres"
|
142
|
-
@db_password = "password"
|
143
|
-
@db_port = 5432
|
144
126
|
@redis_host = "redis"
|
145
127
|
@redis_port = 6379
|
146
|
-
@redis_database = 0
|
147
128
|
|
148
129
|
puts <<~HERE
|
149
130
|
The following docker configuration has been automatically set for you:
|
150
131
|
Database host: #{db_host}
|
151
|
-
Database port: #{db_port}
|
152
|
-
Database user: #{db_user}
|
153
|
-
Database password: #{db_password}
|
154
132
|
Redis host: #{redis_host}
|
155
133
|
Redis port: #{redis_port}
|
156
|
-
Redis database: #{redis_database}
|
157
134
|
HERE
|
158
135
|
end
|
159
136
|
|
160
|
-
def collect_database_info
|
137
|
+
def collect_database_info # rubocop:todo Metrics/AbcSize
|
161
138
|
@db_name = ask_prompt("Database?", db_name_default)
|
162
|
-
@db_host
|
163
|
-
@db_port
|
164
|
-
@db_user
|
165
|
-
@db_password
|
166
|
-
|
167
|
-
nil
|
139
|
+
@db_host = ask_prompt("Database host?", db_host_default) unless dockerized
|
140
|
+
@db_port = ask_prompt("Database port?", db_port_default)
|
141
|
+
@db_user = ask_prompt("Database User?", db_user_default) until !dockerized || db_user.present?
|
142
|
+
@db_password = ask_prompt("Database Password?", db_password_default) until !dockerized || db_password.present?
|
168
143
|
end
|
169
144
|
|
170
145
|
def collect_redis_info
|
171
|
-
|
172
|
-
|
173
|
-
|
146
|
+
unless dockerized
|
147
|
+
@redis_host = ask_prompt("Redis host?", redis_host_default)
|
148
|
+
@redis_port = ask_prompt("Redis port?", redis_port_default)
|
149
|
+
end
|
174
150
|
|
175
|
-
|
151
|
+
@redis_database = ask_prompt("Redis database?", redis_database_default)
|
176
152
|
end
|
177
153
|
|
178
154
|
def project_file(file)
|
@@ -1,90 +1,91 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "rails/generators"
|
4
|
-
require "rails/generators/rails/plugin/plugin_generator"
|
5
|
-
require "rhino/version"
|
6
|
-
|
7
3
|
module Rhino
|
8
4
|
module Generators
|
9
|
-
class
|
10
|
-
|
11
|
-
template "lib/%namespaced_name%.rb"
|
12
|
-
template "lib/%namespaced_name%/version.rb"
|
5
|
+
class ModuleGenerator < ::Rails::Generators::Base
|
6
|
+
attr_reader :module_name, :module_path
|
13
7
|
|
14
|
-
|
8
|
+
class_option :full, type: :boolean, default: false,
|
9
|
+
desc: 'Full plugin generation'
|
15
10
|
|
16
|
-
|
17
|
-
|
18
|
-
template "lib/generators/%namespaced_name%/install/install_generator.rb"
|
19
|
-
template "lib/tasks/%namespaced_name%_tasks.rake"
|
20
|
-
end
|
11
|
+
class_option :skip_plugin, type: :boolean, default: false,
|
12
|
+
desc: 'Skip plugin generation'
|
21
13
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
template "test/dummy/config/database.yml"
|
29
|
-
end
|
30
|
-
end
|
14
|
+
source_root File.expand_path('templates', __dir__)
|
15
|
+
|
16
|
+
def create_module
|
17
|
+
@module_name = ask('Module name?')
|
18
|
+
@module_name = "rhino_#{module_name}" unless module_name.starts_with?('rhino_')
|
19
|
+
@module_path = "rhino/#{module_name}"
|
31
20
|
|
32
|
-
|
33
|
-
source_root File.expand_path("templates", __dir__)
|
21
|
+
return if options[:skip_plugin]
|
34
22
|
|
35
|
-
|
36
|
-
class_option :full, type: :boolean, default: true, hide: true
|
37
|
-
remove_class_option :template
|
23
|
+
say "Creating #{module_name}"
|
38
24
|
|
39
|
-
|
40
|
-
|
25
|
+
plugin_command = "plugin new #{module_path} --skip-git"
|
26
|
+
plugin_command = "#{plugin_command} --full" if options[:full]
|
27
|
+
rails_command(plugin_command)
|
41
28
|
end
|
42
29
|
|
43
|
-
|
44
|
-
|
45
|
-
[
|
46
|
-
File.expand_path("templates", __dir__),
|
47
|
-
Rails::Generators::PluginGenerator.source_root
|
48
|
-
]
|
30
|
+
def remove_license
|
31
|
+
remove_file "#{module_path}/MIT-LICENSE"
|
49
32
|
end
|
50
33
|
|
51
|
-
|
52
|
-
|
53
|
-
|
34
|
+
def engine_registration
|
35
|
+
engine_file = "#{module_path}/lib/#{module_name}/engine.rb"
|
36
|
+
|
37
|
+
remove_file engine_file
|
38
|
+
template 'engine.rb', engine_file
|
54
39
|
end
|
55
40
|
|
56
|
-
def
|
57
|
-
|
41
|
+
def create_install_generator
|
42
|
+
generator_path = "#{module_path}/lib/generators/#{module_name}/install"
|
43
|
+
tasks_path = "#{module_path}/lib/tasks"
|
58
44
|
|
59
|
-
|
60
|
-
|
45
|
+
empty_directory "#{generator_path}/templates"
|
46
|
+
create_file("#{generator_path}/templates/.keep")
|
61
47
|
|
62
|
-
|
48
|
+
template 'install_generator.rb', "#{generator_path}/install_generator.rb"
|
49
|
+
template 'module_tasks.rake', "#{tasks_path}/#{module_name}.rake"
|
63
50
|
|
64
|
-
|
51
|
+
remove_file "#{tasks_path}/#{module_name}_tasks.rake"
|
65
52
|
end
|
66
53
|
|
67
|
-
def
|
68
|
-
|
54
|
+
def fix_gemspec
|
55
|
+
gemspec_file = "#{module_path}/#{module_name}.gemspec"
|
56
|
+
|
57
|
+
gsub_file gemspec_file, /spec.homepage.*/, 'spec.homepage = ""'
|
58
|
+
gsub_file gemspec_file, /spec.summary.*/, 'spec.summary = ""'
|
59
|
+
gsub_file gemspec_file, /spec.description.*/, 'spec.description = ""'
|
60
|
+
gsub_file gemspec_file, /spec.license.*/, 'spec.license = ""'
|
61
|
+
gsub_file gemspec_file, 'spec.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]', 'spec.files = Dir["{app,config,db,lib}/**/*", "Rakefile", "README.md"]' # rubocop:disable Layout/LineLength
|
69
62
|
end
|
70
63
|
|
71
|
-
|
72
|
-
|
64
|
+
# Gross hack for now
|
65
|
+
DUMMY_SETUP_FILES = [
|
66
|
+
'config/database.yml',
|
67
|
+
'config/initializers/devise_token_auth.rb',
|
68
|
+
'config/initializers/devise.rb',
|
69
|
+
'app/models/user.rb',
|
70
|
+
'db/migrate/20210111014230_devise_token_auth_create_users.rhino_engine.rb'
|
71
|
+
].freeze
|
72
|
+
|
73
|
+
def dummy_setup
|
74
|
+
return unless options[:full]
|
73
75
|
|
74
|
-
|
76
|
+
rhino_dummy = Rails.root.join('rhino/rhino/test/dummy')
|
77
|
+
module_dummy = Rails.root.join("#{module_path}/test/dummy")
|
75
78
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
79
|
+
remove_file "#{module_dummy}/config/database.yml"
|
80
|
+
|
81
|
+
DUMMY_SETUP_FILES.each do |file|
|
82
|
+
copy_file "#{rhino_dummy}/#{file}", "#{module_dummy}/#{file}"
|
80
83
|
end
|
81
84
|
end
|
82
85
|
|
83
86
|
def rubocop
|
84
|
-
|
85
|
-
|
86
|
-
inside(File.join(rails_app_path, namespaced_name)) do
|
87
|
-
run "bundle exec rubocop -A ", capture: true
|
87
|
+
inside(module_path) do
|
88
|
+
run 'bundle exec rubocop -a', capture: true
|
88
89
|
end
|
89
90
|
end
|
90
91
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rhino/engine"
|
4
|
+
|
5
|
+
module <%= module_name.camelize %>
|
6
|
+
class Engine < ::Rails::Engine
|
7
|
+
config.autoload_paths << File.expand_path("../../lib", __dir__)
|
8
|
+
|
9
|
+
initializer "<%= module_name %>.register_module" do
|
10
|
+
config.after_initialize do
|
11
|
+
if true
|
12
|
+
Rhino.registered_modules[:<%= module_name %>] = {
|
13
|
+
version: <%= module_name.camelize %>::VERSION
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :<%= module_name %> do
|
4
|
+
# Prevent migration installation task from showing up twice.
|
5
|
+
if Rake::Task.task_defined?("<%= module_name %>_engine:install:migrations")
|
6
|
+
Rake::Task["<%= module_name %>_engine:install:migrations"].clear_comments
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Install <%= module_name %>"
|
10
|
+
task install: :environment do
|
11
|
+
if Rake::Task.task_defined?("<%= module_name %>_engine:install:migrations")
|
12
|
+
Rake::Task["<%= module_name %>_engine:install:migrations"].invoke
|
13
|
+
end
|
14
|
+
|
15
|
+
Rails::Command.invoke :generate, ["<%= module_name %>:install"]
|
16
|
+
end
|
17
|
+
end
|
data/lib/rhino/engine.rb
CHANGED
@@ -1,31 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "rhino/version"
|
4
|
-
|
5
|
-
# https://guides.rubyonrails.org/engines.html#other-gem-dependencies
|
6
|
-
require "activeadmin"
|
7
|
-
require "acts-as-taggable-on"
|
8
|
-
require "ancestry"
|
9
|
-
require "arel-helpers"
|
10
|
-
require "countries"
|
11
|
-
require "devise"
|
12
|
-
require "devise_invitable"
|
13
|
-
require "devise_token_auth"
|
14
|
-
require "friendly_id"
|
15
|
-
require "geocoder"
|
16
|
-
require "omniauth"
|
17
|
-
require "omniauth-azure-activedirectory-v2"
|
18
|
-
require "omniauth-auth0"
|
19
|
-
require "omniauth-facebook"
|
20
|
-
require "omniauth-github"
|
21
|
-
require "omniauth-google-oauth2"
|
22
|
-
require "omniauth/rails_csrf_protection"
|
23
|
-
require "rack/cors"
|
24
|
-
require "pg_search"
|
25
|
-
require "phonelib"
|
26
|
-
require "pundit"
|
27
|
-
require "segment/analytics"
|
28
|
-
|
29
3
|
module Rhino
|
30
4
|
class Engine < ::Rails::Engine
|
31
5
|
config.before_configuration do
|
@@ -37,19 +11,19 @@ module Rhino
|
|
37
11
|
end
|
38
12
|
end
|
39
13
|
|
40
|
-
initializer
|
14
|
+
initializer 'rhino.active_record_extension' do
|
41
15
|
ActiveSupport.on_load(:active_record) do
|
42
|
-
require_relative
|
43
|
-
require_relative
|
44
|
-
require_relative
|
16
|
+
require_relative 'resource/active_record_extension'
|
17
|
+
require_relative 'resource/active_record_tree'
|
18
|
+
require_relative 'resource/active_model_extension'
|
45
19
|
|
46
20
|
include Rhino::Resource::ActiveRecordExtension if Rhino.auto_include_active_record
|
47
21
|
end
|
48
22
|
end
|
49
23
|
|
50
|
-
initializer
|
24
|
+
initializer 'rhino.active_storage_extension' do
|
51
25
|
ActiveSupport.on_load(:active_storage_attachment) do
|
52
|
-
require_relative
|
26
|
+
require_relative 'resource/active_storage_extension'
|
53
27
|
|
54
28
|
include Rhino::Resource::ActiveStorageExtension
|
55
29
|
end
|
@@ -57,7 +31,7 @@ module Rhino
|
|
57
31
|
|
58
32
|
# https://guides.rubyonrails.org/engines.html#overriding-models-and-controllers
|
59
33
|
# Use root instead of Rails.root to scope for this engine
|
60
|
-
initializer
|
34
|
+
initializer 'rhino.overrides' do
|
61
35
|
overrides = "#{root}/app/overrides"
|
62
36
|
Rails.autoloaders.main.ignore(overrides)
|
63
37
|
|
@@ -68,13 +42,13 @@ module Rhino
|
|
68
42
|
end
|
69
43
|
end
|
70
44
|
|
71
|
-
initializer
|
45
|
+
initializer 'rhino.check_resources' do
|
72
46
|
config.after_initialize do
|
73
47
|
check_resources
|
74
48
|
end
|
75
49
|
end
|
76
50
|
|
77
|
-
initializer
|
51
|
+
initializer 'rhino.resource_reloader' do
|
78
52
|
config.after_initialize do
|
79
53
|
Rails.application.reloader.to_prepare do
|
80
54
|
Rhino.resource_classes = nil
|
@@ -82,12 +56,12 @@ module Rhino
|
|
82
56
|
end
|
83
57
|
end
|
84
58
|
|
85
|
-
initializer
|
86
|
-
require
|
59
|
+
initializer 'rhino.register_module' do
|
60
|
+
require 'rhino/omniauth/strategies/azure_o_auth2'
|
87
61
|
|
88
62
|
config.after_initialize do
|
89
63
|
Rhino.registered_modules[:rhino] = {
|
90
|
-
version: Rhino::VERSION
|
64
|
+
version: Rhino::VERSION,
|
91
65
|
authOwner: Rhino.auth_owner.model_name.singular,
|
92
66
|
baseOwner: Rhino.base_owner.model_name.singular,
|
93
67
|
oauth: Rhino::OmniauthHelper.strategies_metadata,
|
@@ -156,11 +130,11 @@ module Rhino
|
|
156
130
|
end
|
157
131
|
|
158
132
|
def self.run_from_dev_setup?
|
159
|
-
|
133
|
+
Rake.application.top_level_tasks == ["rhino:dev:setup"]
|
160
134
|
end
|
161
135
|
|
162
136
|
def self.run_from_package?
|
163
|
-
|
137
|
+
Rake.application.top_level_tasks == ["package"]
|
164
138
|
end
|
165
139
|
end
|
166
140
|
end
|