form_core 0.0.14 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c0ff92c104fbdbeb9f7fbd170b34868a2697ea1e
4
- data.tar.gz: 28003e17cc44fd89b86cb9c2019527332902f081
2
+ SHA256:
3
+ metadata.gz: cdba8d1415f016d5e3faee5ab97e325495080f3f68d5a9c62512f2b3fd24dcbb
4
+ data.tar.gz: f8c1dfe1b35aedc08f170035577d464564c58e8ccf15b8a1f29e147d09c854b8
5
5
  SHA512:
6
- metadata.gz: 9c9c08f314a65c66bb211e61855e0f933292897a46231cb07f21e2c637fcb6486efd6f0844759d4a6a8188ecbd874fbab161fb014a632889d2d876b2d9cb058a
7
- data.tar.gz: b1b79bd8edb0470183f4ec3c616a19d7912ef8e34fdb935e65647d1491348e6f23d86ce0ec8338850d0ab916c4dcb7bf2a40e7e0379765abbb6cb8b283c2dbfb
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: 'jasl-lab/form_core'
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/jasl-lab/form_core.git
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("../test/dummy/Rakefile", __FILE__)
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"
@@ -1,6 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateForms < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  create_table :forms do |t|
6
+ t.string :name, null: false, index: {unique: true}
4
7
  t.string :type, null: false, index: true
5
8
 
6
9
  t.timestamps
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateFields < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  create_table :fields do |t|
@@ -28,7 +28,7 @@ module FormCore
28
28
 
29
29
  def reserved_names
30
30
  @reserved_names ||= Set.new(
31
- %i(def class module private public protected allocate new parent superclass) +
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-z_][a-z_0-9]*\z/
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: self.accessibilities.keys.map(&:to_sym)}
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: {})
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FormCore
4
- VERSION = "0.0.14"
4
+ VERSION = "0.1.0"
5
5
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "duck_record"
3
+ require "active_entity"
4
4
 
5
5
  module FormCore
6
- class VirtualModel < ::DuckRecord::Base
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? DuckRecord::Reflection::EmbedsAssociationReflection }
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.14
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: 2018-02-08 00:00:00.000000000 Z
11
+ date: 2019-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: activeentity
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
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: '5.0'
26
+ version: 0.0.1.beta3
27
27
  - !ruby/object:Gem::Dependency
28
- name: duck_record
28
+ name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
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: '0'
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/jasl-lab/form_core
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
- rubyforge_project:
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.