backend 0.0.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 +7 -0
- data/README.md +41 -0
- data/lib/backend/engine.rb +7 -0
- data/lib/backend/field/base.rb +13 -0
- data/lib/backend/field/editor.rb +7 -0
- data/lib/backend/field/string.rb +7 -0
- data/lib/backend/resource.rb +68 -0
- data/lib/backend/version.rb +5 -0
- data/lib/backend.rb +31 -0
- metadata +68 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 03dad73a5e8c0fcfc1ff9356618c39b383070f0f2d1e38b0fc7ea635b763ad14
|
4
|
+
data.tar.gz: f0c1ed7b295b475ef6abd756c3c217317fe993036114152ee0a8158b1a16d590
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 92af0f420ee201dc1a742b7e0448572378b430f886ce665e250d0babdc0af09a6311b9b57a6bd1dffaba03f1fa0ba03f6b806198a5cee472afdca59b96007b08
|
7
|
+
data.tar.gz: 409f2600bcf7ae40464583bee6edf38717ecdb287c4fdfa3d91b5a9347e127cb4d8ecbfa166bee99a2bce79e6836c81f2906c14581b258fb22075d3a81d6f57e
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
Backend
|
2
|
+
==============
|
3
|
+
[](https://github.com/kiqr/backend/actions/workflows/rubocop.yml)
|
4
|
+
[](https://github.com/kiqr/backend/actions/workflows/rspec.yml)
|
5
|
+
[](LICENSE.md)
|
6
|
+
|
7
|
+
An administration panel for Ruby on Rails.
|
8
|
+
|
9
|
+
Installation
|
10
|
+
------------
|
11
|
+
|
12
|
+
Add the following line to Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem "backend", "~> 1.0"
|
16
|
+
```
|
17
|
+
|
18
|
+
and run `bundle install` from your terminal to install it.
|
19
|
+
|
20
|
+
Contributing
|
21
|
+
------------
|
22
|
+
If you are interested in reporting/fixing issues and contributing directly to the code base, please see [CONTRIBUTING.md](CONTRIBUTING.md) for more information on what we're looking for and how to get started.
|
23
|
+
|
24
|
+
Versioning
|
25
|
+
----------
|
26
|
+
This library aims to adhere to [Semantic Versioning](http://semver.org/). Violations
|
27
|
+
of this scheme should be reported as bugs. Specifically, if a minor or patch
|
28
|
+
version is released that breaks backward compatibility, that version should be
|
29
|
+
immediately yanked and/or a new version should be immediately released that
|
30
|
+
restores compatibility. Breaking changes to the public API will only be
|
31
|
+
introduced with new major versions. As a result of this policy, you can (and
|
32
|
+
should) specify a dependency on this gem using the [Pessimistic Version
|
33
|
+
Constraint](http://guides.rubygems.org/patterns/#pessimistic-version-constraint) with two digits of precision. For example:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
gem "backend", "~> 1.0"
|
37
|
+
```
|
38
|
+
|
39
|
+
License
|
40
|
+
-------
|
41
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Backend
|
4
|
+
class Resource
|
5
|
+
extend ActiveSupport::DescendantsTracker
|
6
|
+
|
7
|
+
# Define class accessors.
|
8
|
+
class_attribute :fields, instance_accessor: false
|
9
|
+
|
10
|
+
class << self
|
11
|
+
# Return demodulized and stripped class name in plural form.
|
12
|
+
def scope
|
13
|
+
@scope ||= klass_name.pluralize.underscore
|
14
|
+
end
|
15
|
+
|
16
|
+
# Return the related model class.
|
17
|
+
def klass
|
18
|
+
@klass ||= klass_name.constantize
|
19
|
+
end
|
20
|
+
|
21
|
+
# Human readable name of the resource.
|
22
|
+
def resource_name
|
23
|
+
klass.model_name.human
|
24
|
+
end
|
25
|
+
|
26
|
+
# Base parameter for form requests.
|
27
|
+
def resource_param
|
28
|
+
resource_name.downcase.underscore.to_sym
|
29
|
+
end
|
30
|
+
|
31
|
+
delegate :to_sym, to: :scope
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
# Normalized class name.
|
36
|
+
#
|
37
|
+
# Returns the demodulized and stripped class name without Resource in the end.
|
38
|
+
# Example:
|
39
|
+
# CategoryResource => Category
|
40
|
+
def klass_name
|
41
|
+
@klass_name ||= name.demodulize.chomp("Resource")
|
42
|
+
end
|
43
|
+
|
44
|
+
# Field.
|
45
|
+
#
|
46
|
+
# Register a new editable field for the resource.
|
47
|
+
# The type of field can be set with the :type option.
|
48
|
+
# The default type is :string.
|
49
|
+
#
|
50
|
+
# Example:
|
51
|
+
# field :title, type: :string => Backend::Fields::String.new(:title)
|
52
|
+
# field :body, type: :editor => Backend::Fields::Editor.new(:body)
|
53
|
+
# field :status, type: :boolean => Backend::Fields::Boolean.new(:status)
|
54
|
+
#
|
55
|
+
# :api: public
|
56
|
+
def field(name, type: :base)
|
57
|
+
klass = Backend::Field.const_get(type.to_s.classify)
|
58
|
+
field = klass.new(name)
|
59
|
+
|
60
|
+
# Create empty array if #fields is nil.
|
61
|
+
self.fields ||= []
|
62
|
+
|
63
|
+
# Insert field into the array.
|
64
|
+
self.fields << field
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/backend.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "backend/version"
|
4
|
+
require "backend/engine"
|
5
|
+
require "dry-configurable"
|
6
|
+
|
7
|
+
module Backend
|
8
|
+
extend Dry::Configurable
|
9
|
+
|
10
|
+
autoload "Resource", "backend/resource"
|
11
|
+
|
12
|
+
module Field
|
13
|
+
autoload "Base", "backend/field/base"
|
14
|
+
autoload "Editor", "backend/field/editor"
|
15
|
+
autoload "String", "backend/field/string"
|
16
|
+
end
|
17
|
+
|
18
|
+
setting :route_scope, "backend" # Default route scope for backend routes.
|
19
|
+
|
20
|
+
class << self
|
21
|
+
def resources
|
22
|
+
# Force eager load of all resources.
|
23
|
+
# Todo: this could be changed to a
|
24
|
+
# script that requires all files in app/backend.
|
25
|
+
Rails.application.eager_load!
|
26
|
+
|
27
|
+
# that has inherited from Backend::Resource.
|
28
|
+
Backend::Resource.descendants
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: backend
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- KIQR
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-03-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dry-configurable
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.11.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.11.0
|
27
|
+
description:
|
28
|
+
email: hello@kiqr.dev
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- README.md
|
34
|
+
- lib/backend.rb
|
35
|
+
- lib/backend/engine.rb
|
36
|
+
- lib/backend/field/base.rb
|
37
|
+
- lib/backend/field/editor.rb
|
38
|
+
- lib/backend/field/string.rb
|
39
|
+
- lib/backend/resource.rb
|
40
|
+
- lib/backend/version.rb
|
41
|
+
homepage: https://github.com/kiqr/backend
|
42
|
+
licenses:
|
43
|
+
- MIT
|
44
|
+
metadata:
|
45
|
+
bug_tracker_uri: https://github.com/kiqr/authenticatable/issues
|
46
|
+
documentation_uri: https://github.com/kiqr/authenticatable/issues
|
47
|
+
source_code_uri: https://github.com/kiqr/authenticatable
|
48
|
+
rubygems_mfa_required: 'true'
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '2.6'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubygems_version: 3.3.7
|
65
|
+
signing_key:
|
66
|
+
specification_version: 4
|
67
|
+
summary: An administration panel for Ruby on Rails.
|
68
|
+
test_files: []
|