panda-core 0.1.5 → 0.1.7
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/README.md +19 -1
- data/config/initializers/panda_core.rb +10 -0
- data/lib/generators/panda/core/authentication/templates/reek_spec.rb +43 -0
- data/lib/generators/panda/core/install_generator.rb +44 -0
- data/lib/generators/panda/core/templates/initializer.rb +10 -0
- data/lib/panda/core/configuration.rb +40 -0
- data/lib/panda/core/engine.rb +27 -0
- data/lib/panda/core/oauth_providers.rb +32 -0
- data/lib/panda/core/version.rb +1 -1
- data/lib/panda/core.rb +5 -3
- metadata +290 -255
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6caaec9b10d05eb513af5156b3b71961ee3ec4f0dcc2d5cfc1eb6a3e0fcb15d2
|
4
|
+
data.tar.gz: ed3e2d3482f25b115dc4a637e5929c5a2461e8b7ae62c9610eb28395b6443644
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c3d5c494c3bb42f0b8d41c61d1f4b6a751b06a90c0970abdf6f6b434bbdaef1b3b485631e66e0a4b3c9fd61671734edc99f0675ecde44a8763a407652aee513
|
7
|
+
data.tar.gz: 127c60ae55cc3a1906f0fa8add24d9fec24d1c67e698b992acbd75883c0488e26e499d070cd1f8523adf464b032dfe57101e917bed71003e1dfcfa965b55078a
|
data/README.md
CHANGED
@@ -113,7 +113,25 @@ bundle exec rspec spec/system
|
|
113
113
|
4. Push to the branch (`git push origin feature/my-new-feature`)
|
114
114
|
5. Create new Pull Request
|
115
115
|
|
116
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/tastybamboo/
|
116
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tastybamboo/panda-core.
|
117
|
+
|
118
|
+
## Releasing
|
119
|
+
|
120
|
+
For e.g. v0.1.7, first update the version in `lib/panda/core/version.rb`. Then run:
|
121
|
+
|
122
|
+
```
|
123
|
+
bundle update
|
124
|
+
git add .
|
125
|
+
git commit -m "v0.1.7"
|
126
|
+
git tag -a v0.1.7 -m "v0.1.7"
|
127
|
+
git push origin v0.1.7
|
128
|
+
```
|
129
|
+
|
130
|
+
Then, run the following command to create a new release:
|
131
|
+
|
132
|
+
```
|
133
|
+
bundle exec rake release
|
134
|
+
```
|
117
135
|
|
118
136
|
## License
|
119
137
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Panda::Core.configure do |config|
|
2
|
+
# Configure the user class for the application
|
3
|
+
# config.user_class = "User"
|
4
|
+
|
5
|
+
# Configure the storage provider (default: :active_storage)
|
6
|
+
# config.storage_provider = :active_storage
|
7
|
+
|
8
|
+
# Configure the cache store (default: :memory_store)
|
9
|
+
# config.cache_store = :memory_store
|
10
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "Reek" do
|
4
|
+
RUBY_FILE_PATTERN = File.expand_path("../../**/*.rb", __dir__)
|
5
|
+
EXCLUDED_PATHS = [
|
6
|
+
"db/schema.rb",
|
7
|
+
"bin/",
|
8
|
+
"script/",
|
9
|
+
"log/",
|
10
|
+
"public/",
|
11
|
+
"tmp/",
|
12
|
+
"doc/",
|
13
|
+
"vendor/",
|
14
|
+
"storage/",
|
15
|
+
"node_modules/",
|
16
|
+
".git/",
|
17
|
+
"spec/dummy/"
|
18
|
+
].freeze
|
19
|
+
|
20
|
+
it "contains no code smells" do
|
21
|
+
failures = []
|
22
|
+
|
23
|
+
Dir.glob(RUBY_FILE_PATTERN).each do |file|
|
24
|
+
next if EXCLUDED_PATHS.any? { |path| file.include?(path) }
|
25
|
+
|
26
|
+
IO.popen(["bundle", "exec", "reek", file], err: [:child, :out]) do |io|
|
27
|
+
output = io.read
|
28
|
+
next if output.empty?
|
29
|
+
|
30
|
+
failures << {file: file, output: output}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
failures.each do |failure|
|
35
|
+
puts "\nCode smells found in #{failure[:file]}:"
|
36
|
+
puts failure[:output]
|
37
|
+
end
|
38
|
+
|
39
|
+
failures.each do |failure|
|
40
|
+
expect(failure).to be_nil, "Found code smells in #{failure[:file]}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Panda
|
2
|
+
module Core
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
include Rails::Generators::Migration
|
5
|
+
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
namespace "panda:core:install"
|
9
|
+
|
10
|
+
# Allow incompatible default types for Thor options
|
11
|
+
def self.allow_incompatible_default_type!
|
12
|
+
true
|
13
|
+
end
|
14
|
+
|
15
|
+
class_option :skip_migrations, type: :boolean, default: false,
|
16
|
+
desc: "Skip migrations installation"
|
17
|
+
class_option :orm, type: :string, default: "active_record",
|
18
|
+
desc: "ORM to be used for migrations"
|
19
|
+
|
20
|
+
def self.next_migration_number(dirname)
|
21
|
+
next_migration_number = current_migration_number(dirname) + 1
|
22
|
+
ActiveRecord::Migration.next_migration_number(next_migration_number)
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_initializer
|
26
|
+
template "initializer.rb", "config/initializers/panda_core.rb"
|
27
|
+
end
|
28
|
+
|
29
|
+
def mount_engine
|
30
|
+
route 'mount Panda::Core::Engine => "/"'
|
31
|
+
end
|
32
|
+
|
33
|
+
def copy_migrations
|
34
|
+
return if options[:skip_migrations]
|
35
|
+
return unless options[:orm] == "active_record"
|
36
|
+
|
37
|
+
migrations_path = File.expand_path("../../../../db/migrate", __dir__)
|
38
|
+
Dir.glob("#{migrations_path}/*.rb").each do |migration|
|
39
|
+
migration_template migration, "db/migrate/#{File.basename(migration)}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Panda::Core.configure do |config|
|
2
|
+
# Configure the user class for the application
|
3
|
+
# config.user_class = "User"
|
4
|
+
|
5
|
+
# Configure the storage provider (default: :active_storage)
|
6
|
+
# config.storage_provider = :active_storage
|
7
|
+
|
8
|
+
# Configure the cache store (default: :memory_store)
|
9
|
+
# config.cache_store = :memory_store
|
10
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Panda
|
2
|
+
module Core
|
3
|
+
class Configuration
|
4
|
+
attr_accessor :user_class,
|
5
|
+
:storage_provider,
|
6
|
+
:cache_store,
|
7
|
+
:parent_controller,
|
8
|
+
:parent_mailer,
|
9
|
+
:mailer_sender,
|
10
|
+
:mailer_default_url_options,
|
11
|
+
:session_token_cookie
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@storage_provider = :active_storage
|
15
|
+
@cache_store = :memory_store
|
16
|
+
@parent_controller = "ActionController::API"
|
17
|
+
@parent_mailer = "ActionMailer::Base"
|
18
|
+
@mailer_sender = "support@example.com"
|
19
|
+
@mailer_default_url_options = {host: "localhost:3000"}
|
20
|
+
@session_token_cookie = :session_token
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class << self
|
25
|
+
attr_writer :configuration
|
26
|
+
|
27
|
+
def configuration
|
28
|
+
@configuration ||= Configuration.new
|
29
|
+
end
|
30
|
+
|
31
|
+
def configure
|
32
|
+
yield(configuration)
|
33
|
+
end
|
34
|
+
|
35
|
+
def reset_configuration!
|
36
|
+
@configuration = Configuration.new
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "rails/engine"
|
2
|
+
|
3
|
+
module Panda
|
4
|
+
module Core
|
5
|
+
class Engine < ::Rails::Engine
|
6
|
+
isolate_namespace Panda::Core
|
7
|
+
|
8
|
+
config.generators do |g|
|
9
|
+
g.test_framework :rspec
|
10
|
+
g.fixture_replacement :factory_bot
|
11
|
+
g.factory_bot dir: "spec/factories"
|
12
|
+
end
|
13
|
+
|
14
|
+
initializer "panda_core.configuration" do |app|
|
15
|
+
config.after_initialize do
|
16
|
+
Panda::Core.configure do |config|
|
17
|
+
config.parent_controller ||= "ActionController::API"
|
18
|
+
config.parent_mailer ||= "ActionMailer::Base"
|
19
|
+
config.mailer_sender ||= "support@example.com"
|
20
|
+
config.mailer_default_url_options ||= {host: "localhost:3000"}
|
21
|
+
config.session_token_cookie ||= :session_token
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Panda
|
2
|
+
module Core
|
3
|
+
module OAuthProviders
|
4
|
+
def self.setup
|
5
|
+
providers = []
|
6
|
+
|
7
|
+
begin
|
8
|
+
require "omniauth-github"
|
9
|
+
providers << :github
|
10
|
+
rescue LoadError
|
11
|
+
# GitHub OAuth functionality not available
|
12
|
+
end
|
13
|
+
|
14
|
+
begin
|
15
|
+
require "omniauth-google-oauth2"
|
16
|
+
providers << :google_oauth2
|
17
|
+
rescue LoadError
|
18
|
+
# Google OAuth functionality not available
|
19
|
+
end
|
20
|
+
|
21
|
+
begin
|
22
|
+
require "omniauth-microsoft_graph"
|
23
|
+
providers << :microsoft_graph
|
24
|
+
rescue LoadError
|
25
|
+
# Microsoft OAuth functionality not available
|
26
|
+
end
|
27
|
+
|
28
|
+
providers
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/panda/core/version.rb
CHANGED
data/lib/panda/core.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "rails"
|
3
4
|
require "dry-configurable"
|
4
|
-
require_relative "core/version"
|
5
|
-
require "panda/core/railtie"
|
6
5
|
|
7
6
|
module Panda
|
8
7
|
module Core
|
@@ -14,7 +13,10 @@ module Panda
|
|
14
13
|
setting :cache_store, default: :memory_store
|
15
14
|
|
16
15
|
def self.root
|
17
|
-
File.expand_path("
|
16
|
+
File.expand_path("../..", __FILE__)
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
20
|
+
|
21
|
+
require_relative "core/configuration"
|
22
|
+
require_relative "core/engine" if defined?(Rails)
|