form_core 0.0.14 → 0.1.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 +5 -5
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/db/migrate/20170430190404_create_forms.rb +3 -0
- data/db/migrate/20170430191336_create_fields.rb +2 -0
- data/lib/form_core.rb +1 -1
- data/lib/form_core/concerns/models/field.rb +3 -4
- data/lib/form_core/concerns/models/form.rb +10 -0
- data/lib/form_core/version.rb +1 -1
- data/lib/form_core/virtual_model.rb +7 -4
- metadata +20 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cdba8d1415f016d5e3faee5ab97e325495080f3f68d5a9c62512f2b3fd24dcbb
|
4
|
+
data.tar.gz: f8c1dfe1b35aedc08f170035577d464564c58e8ccf15b8a1f29e147d09c854b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ed0c48fc7c6fb40f072d0ea7a0e08fc637899811b132c522b330b34ca970b3ed8aae30bee196fd4d128fe9d7747b9157fe107268241d1553d9b1cd9d08b19cb
|
7
|
+
data.tar.gz: d4d3e5ea13748c40bd05df704731132626311ba5e1c5f70daa680e5b4264a9af93a852ecb82988e9e64082a65825edab6573b42047bffb6d82375267a00695b7
|
data/README.md
CHANGED
@@ -23,7 +23,7 @@ gem 'form_core'
|
|
23
23
|
Or you may want to include the gem directly from GitHub:
|
24
24
|
|
25
25
|
```ruby
|
26
|
-
gem 'form_core', github: '
|
26
|
+
gem 'form_core', github: 'rails-engine/form_core'
|
27
27
|
```
|
28
28
|
|
29
29
|
And then execute:
|
@@ -49,7 +49,7 @@ $ bin/rails db:migrate
|
|
49
49
|
Clone the repository.
|
50
50
|
|
51
51
|
```sh
|
52
|
-
$ git clone https://github.com/
|
52
|
+
$ git clone https://github.com/rails-engine/form_core.git
|
53
53
|
```
|
54
54
|
|
55
55
|
Change directory
|
data/Rakefile
CHANGED
@@ -16,7 +16,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
16
16
|
rdoc.rdoc_files.include("lib/**/*.rb")
|
17
17
|
end
|
18
18
|
|
19
|
-
APP_RAKEFILE = File.expand_path("
|
19
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
20
20
|
load "rails/tasks/engine.rake"
|
21
21
|
|
22
22
|
load "rails/tasks/statistics.rake"
|
data/lib/form_core.rb
CHANGED
@@ -28,7 +28,7 @@ module FormCore
|
|
28
28
|
|
29
29
|
def reserved_names
|
30
30
|
@reserved_names ||= Set.new(
|
31
|
-
%i
|
31
|
+
%i[def class module private public protected allocate new parent superclass] +
|
32
32
|
virtual_model_class.instance_methods(true)
|
33
33
|
)
|
34
34
|
end
|
@@ -5,7 +5,7 @@ module FormCore::Concerns
|
|
5
5
|
module Field
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
|
-
NAME_REGEX = /\A[a-
|
8
|
+
NAME_REGEX = /\A[a-z][a-z_0-9]*\z/.freeze
|
9
9
|
|
10
10
|
included do
|
11
11
|
enum accessibility: {read_and_write: 0, readonly: 1, hidden: 2},
|
@@ -20,7 +20,7 @@ module FormCore::Concerns
|
|
20
20
|
exclusion: {in: FormCore.reserved_names},
|
21
21
|
format: {with: NAME_REGEX}
|
22
22
|
validates :accessibility,
|
23
|
-
inclusion: {in:
|
23
|
+
inclusion: {in: accessibilities.keys.map(&:to_sym)}
|
24
24
|
|
25
25
|
after_initialize do
|
26
26
|
self.validations ||= {}
|
@@ -75,8 +75,7 @@ module FormCore::Concerns
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
-
def interpret_extra_to(_model, _accessibility, _overrides = {})
|
79
|
-
end
|
78
|
+
def interpret_extra_to(_model, _accessibility, _overrides = {}); end
|
80
79
|
|
81
80
|
def check_model_validity!(model)
|
82
81
|
unless model.is_a?(Class) && model < ::FormCore::VirtualModel
|
@@ -5,6 +5,16 @@ module FormCore::Concerns
|
|
5
5
|
module Form
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
|
+
NAME_REGEX = /\A[a-z][a-z_0-9]*\z/.freeze
|
9
|
+
|
10
|
+
included do
|
11
|
+
validates :name,
|
12
|
+
presence: true,
|
13
|
+
uniqueness: true,
|
14
|
+
exclusion: {in: FormCore.reserved_names},
|
15
|
+
format: {with: NAME_REGEX}
|
16
|
+
end
|
17
|
+
|
8
18
|
def to_virtual_model(model_name: "Form",
|
9
19
|
fields_scope: proc { |fields| fields },
|
10
20
|
overrides: {})
|
data/lib/form_core/version.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "active_entity"
|
4
4
|
|
5
5
|
module FormCore
|
6
|
-
class VirtualModel < ::
|
6
|
+
class VirtualModel < ::ActiveEntity::Base
|
7
7
|
# Returns the contents of the record as a nicely formatted string.
|
8
8
|
def inspect
|
9
9
|
# We check defined?(@attributes) not to issue warnings if the object is
|
@@ -27,8 +27,11 @@ module FormCore
|
|
27
27
|
super options
|
28
28
|
end
|
29
29
|
|
30
|
+
# Hack
|
31
|
+
ARRAY_WITHOUT_BLANK_PATTERN = "!ruby/array:ArrayWithoutBlank"
|
32
|
+
|
30
33
|
def dump
|
31
|
-
self.class.dump(self)
|
34
|
+
self.class.dump(self).gsub(ARRAY_WITHOUT_BLANK_PATTERN, "")
|
32
35
|
end
|
33
36
|
|
34
37
|
class << self
|
@@ -70,7 +73,7 @@ module FormCore
|
|
70
73
|
end
|
71
74
|
|
72
75
|
def _embeds_reflections
|
73
|
-
_reflections.select { |_, v| v.is_a?
|
76
|
+
_reflections.select { |_, v| v.is_a? ::ActiveEntity::Reflection::EmbeddedAssociationReflection }
|
74
77
|
end
|
75
78
|
end
|
76
79
|
end
|
metadata
CHANGED
@@ -1,43 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: form_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jasl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activeentity
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.0.1.beta3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.0.1.beta3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 6.0.0.beta3
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '7'
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- - "
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 6.0.0.beta3
|
44
|
+
- - "<"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
46
|
+
version: '7'
|
41
47
|
description: |
|
42
48
|
A Rails engine providing ability to generate dynamic form.
|
43
49
|
It's would make such as dynamic fields of model or questionnaire easily.
|
@@ -66,7 +72,7 @@ files:
|
|
66
72
|
- lib/form_core/version.rb
|
67
73
|
- lib/form_core/virtual_model.rb
|
68
74
|
- lib/tasks/form_core_tasks.rake
|
69
|
-
homepage: https://github.com/
|
75
|
+
homepage: https://github.com/rails-engine/form_core
|
70
76
|
licenses:
|
71
77
|
- MIT
|
72
78
|
metadata: {}
|
@@ -85,8 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
91
|
- !ruby/object:Gem::Version
|
86
92
|
version: '0'
|
87
93
|
requirements: []
|
88
|
-
|
89
|
-
rubygems_version: 2.6.13
|
94
|
+
rubygems_version: 3.0.3
|
90
95
|
signing_key:
|
91
96
|
specification_version: 4
|
92
97
|
summary: A Rails engine providing ability to generate dynamic form.
|