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
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "dotenv"
|
4
|
-
require "rails/command"
|
5
|
-
|
6
|
-
module Rails
|
7
|
-
module Command
|
8
|
-
module Rhino
|
9
|
-
module Module
|
10
|
-
class CoverageCommand < Base # :nodoc:
|
11
|
-
include Thor::Actions
|
12
|
-
|
13
|
-
def perform(*args)
|
14
|
-
ENV["COVERAGE"] = "1"
|
15
|
-
test(*args)
|
16
|
-
end
|
17
|
-
|
18
|
-
protected
|
19
|
-
def rhino_command(extra_path, base_command, *args) # rubocop:todo Metrics/MethodLength
|
20
|
-
module_name = if Dir.exist?(args[0])
|
21
|
-
args.shift
|
22
|
-
else
|
23
|
-
abort "No module specified"
|
24
|
-
end
|
25
|
-
module_path = [module_name, extra_path].compact.join("/")
|
26
|
-
db_name = "#{module_name}_dummy"
|
27
|
-
gem_file_path = File.join(Dir.pwd, "Gemfile")
|
28
|
-
|
29
|
-
# Getting existing variables and re-use
|
30
|
-
::Dotenv.load
|
31
|
-
|
32
|
-
inside(module_path) do
|
33
|
-
# Override DB_NAME so multiple can run in parallel
|
34
|
-
run(
|
35
|
-
"DB_NAME=#{db_name} BUNDLE_GEMFILE='#{gem_file_path}' bin/rails #{base_command} #{args.join(' ')}",
|
36
|
-
{ abort_on_failure: true }
|
37
|
-
)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "dotenv"
|
4
|
-
require "rails/command"
|
5
|
-
|
6
|
-
module Rails
|
7
|
-
module Command
|
8
|
-
module Rhino
|
9
|
-
module Module
|
10
|
-
class DummyCommand < Base # :nodoc:
|
11
|
-
include Thor::Actions
|
12
|
-
|
13
|
-
def perform(*args)
|
14
|
-
rhino_command("test/dummy", nil, *args)
|
15
|
-
end
|
16
|
-
|
17
|
-
protected
|
18
|
-
def rhino_command(extra_path, base_command, *args) # rubocop:todo Metrics/MethodLength
|
19
|
-
module_name = if Dir.exist?(args[0])
|
20
|
-
args.shift
|
21
|
-
else
|
22
|
-
abort "No module specified"
|
23
|
-
end
|
24
|
-
module_path = [module_name, extra_path].compact.join("/")
|
25
|
-
db_name = "#{module_name}_dummy"
|
26
|
-
gem_file_path = File.join(Dir.pwd, "Gemfile")
|
27
|
-
|
28
|
-
# Getting existing variables and re-use
|
29
|
-
::Dotenv.load
|
30
|
-
|
31
|
-
inside(module_path) do
|
32
|
-
# Override DB_NAME so multiple can run in parallel
|
33
|
-
run(
|
34
|
-
"DB_NAME=#{db_name} BUNDLE_GEMFILE='#{gem_file_path}' bin/rails #{base_command} #{args.join(' ')}",
|
35
|
-
{ abort_on_failure: true }
|
36
|
-
)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "dotenv"
|
4
|
-
require "rails/command"
|
5
|
-
|
6
|
-
module Rails
|
7
|
-
module Command
|
8
|
-
module Rhino
|
9
|
-
module Module
|
10
|
-
class NewCommand < Base # :nodoc:
|
11
|
-
no_commands do
|
12
|
-
def help
|
13
|
-
run_module_generator %w[--help]
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.banner(*) # :nodoc:
|
18
|
-
"#{executable} new [options]"
|
19
|
-
end
|
20
|
-
|
21
|
-
def perform(*args)
|
22
|
-
run_module_generator(args)
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
def run_module_generator(plugin_args)
|
27
|
-
require "generators/rhino/module/module_generator"
|
28
|
-
::Rhino::Generators::ModuleGenerator.start plugin_args
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "dotenv"
|
4
|
-
require "rails/command"
|
5
|
-
|
6
|
-
module Rails
|
7
|
-
module Command
|
8
|
-
module Rhino
|
9
|
-
module Module
|
10
|
-
class RailsCommand < Base # :nodoc:
|
11
|
-
include Thor::Actions
|
12
|
-
|
13
|
-
def perform(*args)
|
14
|
-
rhino_command(nil, nil, *args)
|
15
|
-
end
|
16
|
-
|
17
|
-
protected
|
18
|
-
def rhino_command(extra_path, base_command, *args) # rubocop:todo Metrics/MethodLength
|
19
|
-
module_name = if Dir.exist?(args[0])
|
20
|
-
args.shift
|
21
|
-
else
|
22
|
-
abort "No module specified"
|
23
|
-
end
|
24
|
-
module_path = [module_name, extra_path].compact.join("/")
|
25
|
-
db_name = "#{module_name}_dummy"
|
26
|
-
gem_file_path = File.join(Dir.pwd, "Gemfile")
|
27
|
-
|
28
|
-
# Getting existing variables and re-use
|
29
|
-
::Dotenv.load
|
30
|
-
|
31
|
-
inside(module_path) do
|
32
|
-
# Override DB_NAME so multiple can run in parallel
|
33
|
-
run(
|
34
|
-
"DB_NAME=#{db_name} BUNDLE_GEMFILE='#{gem_file_path}' bin/rails #{base_command} #{args.join(' ')}",
|
35
|
-
{ abort_on_failure: true }
|
36
|
-
)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "dotenv"
|
4
|
-
require "rails/command"
|
5
|
-
|
6
|
-
module Rails
|
7
|
-
module Command
|
8
|
-
module Rhino
|
9
|
-
module Module
|
10
|
-
class TestCommand < Base # :nodoc:
|
11
|
-
include Thor::Actions
|
12
|
-
|
13
|
-
def test(*args)
|
14
|
-
rhino_command(nil, "test", *args)
|
15
|
-
end
|
16
|
-
|
17
|
-
protected
|
18
|
-
def rhino_command(extra_path, base_command, *args) # rubocop:todo Metrics/MethodLength
|
19
|
-
module_name = if Dir.exist?(args[0])
|
20
|
-
args.shift
|
21
|
-
else
|
22
|
-
abort "No module specified"
|
23
|
-
end
|
24
|
-
module_path = [module_name, extra_path].compact.join("/")
|
25
|
-
db_name = "#{module_name}_dummy"
|
26
|
-
gem_file_path = File.join(Dir.pwd, "Gemfile")
|
27
|
-
|
28
|
-
# Getting existing variables and re-use
|
29
|
-
::Dotenv.load
|
30
|
-
|
31
|
-
inside(module_path) do
|
32
|
-
# Override DB_NAME so multiple can run in parallel
|
33
|
-
run(
|
34
|
-
"DB_NAME=#{db_name} BUNDLE_GEMFILE='#{gem_file_path}' bin/rails #{base_command} #{args.join(' ')}",
|
35
|
-
{ abort_on_failure: true }
|
36
|
-
)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
COMPOSE_PROJECT_NAME=<%= project_name %>
|
@@ -1,96 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rails/generators"
|
4
|
-
require "rails/generators/active_record/model/model_generator"
|
5
|
-
|
6
|
-
module Rhino
|
7
|
-
class ModelGenerator < ::ActiveRecord::Generators::ModelGenerator
|
8
|
-
source_root File.expand_path("templates", __dir__)
|
9
|
-
|
10
|
-
class_option :owner, type: :string, desc: "The model is owned by the reference attribute", group: :owner
|
11
|
-
class_option :base_owner, type: :boolean, default: false, desc: "The model is owned by the base owner", group: :owner
|
12
|
-
class_option :global_owner, type: :boolean, default: false, desc: "The model is globally owned", group: :owner
|
13
|
-
|
14
|
-
# Parent source paths
|
15
|
-
def source_paths
|
16
|
-
[
|
17
|
-
File.expand_path("templates", __dir__),
|
18
|
-
::ActiveRecord::Generators::ModelGenerator.source_root
|
19
|
-
]
|
20
|
-
end
|
21
|
-
|
22
|
-
def create_migration_file
|
23
|
-
# We check the ownership of the reference attributes before creating the migration
|
24
|
-
check_ownership
|
25
|
-
|
26
|
-
super
|
27
|
-
end
|
28
|
-
|
29
|
-
def inject_into_rhino_initializer
|
30
|
-
# FIXME: Can we do better on indentation?
|
31
|
-
inject_into_file "config/initializers/rhino.rb", before: /^end\s*$/ do
|
32
|
-
" config.resources += ['#{class_name}']\n"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def inject_rhino_owner_into_model
|
37
|
-
# Write 'rhino_owner :<attribute name>' to the model file
|
38
|
-
model_file = File.join("app/models", "#{file_path}.rb")
|
39
|
-
|
40
|
-
# FIXME: Can we do better on indentation?
|
41
|
-
inject_into_file model_file, before: /^end\s*$/ do
|
42
|
-
"\n #{owner_call}\n"
|
43
|
-
end
|
44
|
-
|
45
|
-
# Global owned don't need a reference
|
46
|
-
return if global_owner?
|
47
|
-
|
48
|
-
inject_into_file model_file, after: /#{owner_call}/ do
|
49
|
-
"\n rhino_references %i[#{owner_name}]"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
protected
|
54
|
-
def check_ownership
|
55
|
-
raise Thor::Error, "Exactly one owner must be defined on a reference or globally" unless base_owner? ^ global_owner? ^ reference_owner?
|
56
|
-
|
57
|
-
return if global_owner? || reference_attributes.find { |attr| attr.name == owner_name }
|
58
|
-
|
59
|
-
raise Thor::Error, "The owner attribute must be a reference attribute"
|
60
|
-
end
|
61
|
-
|
62
|
-
private
|
63
|
-
def global_owner?
|
64
|
-
@global_owner = options[:global_owner]
|
65
|
-
end
|
66
|
-
|
67
|
-
def base_owner?
|
68
|
-
@global_owner = options[:base_owner] || Rhino.base_owner.model_name.singular == options[:owner]
|
69
|
-
end
|
70
|
-
|
71
|
-
def reference_owner?
|
72
|
-
@reference_owner = options[:owner].present? && !base_owner?
|
73
|
-
end
|
74
|
-
|
75
|
-
def owner_name
|
76
|
-
@owner_name ||= if global_owner?
|
77
|
-
"global"
|
78
|
-
elsif base_owner?
|
79
|
-
Rhino.base_owner.model_name.singular
|
80
|
-
else
|
81
|
-
options[:owner]
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def owner_call
|
86
|
-
return "rhino_owner_global" if global_owner?
|
87
|
-
return "rhino_owner_base" if base_owner?
|
88
|
-
|
89
|
-
"rhino_owner :#{owner_name}"
|
90
|
-
end
|
91
|
-
|
92
|
-
def reference_attributes
|
93
|
-
@reference_attributes ||= attributes.filter(&:reference?)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require_relative "lib/<%= namespaced_name %>/version"
|
2
|
-
|
3
|
-
Gem::Specification.new do |spec|
|
4
|
-
spec.name = <%= name.inspect %>
|
5
|
-
spec.version = <%= camelized_modules %>::VERSION
|
6
|
-
spec.authors = [ <%= author.inspect %> ]
|
7
|
-
spec.email = [ <%= email.inspect %> ]
|
8
|
-
spec.summary = "Summary of <%= camelized_modules %>."
|
9
|
-
spec.description = "Description of <%= camelized_modules %>."
|
10
|
-
<%- unless inside_application? -%>
|
11
|
-
spec.license = "MIT"
|
12
|
-
<%- end -%>
|
13
|
-
|
14
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the "allowed_push_host"
|
15
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
16
|
-
spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
17
|
-
|
18
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
19
|
-
Dir["{app,config,db,lib}/**/*", <%- unless inside_application? -%> "MIT-LICENSE", <%- end -%>"Rakefile", "README.md"]
|
20
|
-
end
|
21
|
-
|
22
|
-
<%= "# " if rails_prerelease? -%>spec.add_dependency "rails", "<%= Array(rails_version_specifier).join('", "') %>"
|
23
|
-
spec.add_dependency "rhino_project_core", ">= <%= rhino_version %>"
|
24
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rhino/engine"
|
4
|
-
|
5
|
-
module <%= camelized_modules %>
|
6
|
-
class Engine < ::Rails::Engine
|
7
|
-
<%= engine_config -%>
|
8
|
-
config.autoload_paths << File.expand_path("../../lib", __dir__)
|
9
|
-
|
10
|
-
initializer "<%= namespaced_name %>.register_module" do
|
11
|
-
config.after_initialize do
|
12
|
-
Rhino.registered_modules[:<%= namespaced_name %>] = {
|
13
|
-
version: <%= camelized_modules %>::VERSION
|
14
|
-
}
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
namespace :<%= namespaced_name %> do
|
4
|
-
# Prevent migration installation task from showing up twice.
|
5
|
-
Rake::Task["<%= namespaced_name %>_engine:install:migrations"].clear_comments if Rake::Task.task_defined?("<%= namespaced_name %>_engine:install:migrations")
|
6
|
-
|
7
|
-
desc "Install <%= namespaced_name %>"
|
8
|
-
task install: :environment do
|
9
|
-
Rake::Task["<%= namespaced_name %>_engine:install:migrations"].invoke if Rake::Task.task_defined?("<%= namespaced_name %>_engine:install:migrations")
|
10
|
-
|
11
|
-
Rails::Command.invoke :generate, ["<%= namespaced_name %>:install"]
|
12
|
-
end
|
13
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
default: &default
|
2
|
-
adapter: postgresql
|
3
|
-
encoding: unicode
|
4
|
-
pool: 5
|
5
|
-
username: <%%= ENV["DB_USERNAME"] %>
|
6
|
-
password: <%%= ENV["DB_PASSWORD"] %>
|
7
|
-
database: <%%= ENV["DB_NAME"] %>
|
8
|
-
port: <%%= ENV["DB_PORT"] || 5432 %>
|
9
|
-
host: <%%= ENV["DB_HOST"] || "localhost" %>
|
10
|
-
|
11
|
-
development:
|
12
|
-
<<: *default
|
13
|
-
database: <%%= ENV["DB_NAME"] %>_development
|
14
|
-
|
15
|
-
# Warning: The database defined as "test" will be erased and
|
16
|
-
# re-generated from your development database when you run "rake".
|
17
|
-
# Do not set this db to the same as development or production.
|
18
|
-
test:
|
19
|
-
<<: *default
|
20
|
-
# https://github.com/ged/ruby-pg/issues/311#issuecomment-1615084569
|
21
|
-
gssencmode: disable
|
22
|
-
database: <%%= ENV["DB_NAME"] %>_test
|
23
|
-
|
24
|
-
production:
|
25
|
-
<<: *default
|