unidom-stapar 0.3 → 0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ec81f2342288a8bcc6f131f291b216b7bebf172ae99bfddad0e4a36fe3a9f65
4
- data.tar.gz: 6cf88d8b259a16dc31e039966b49424e37e6fb35033845edf5aa5ef421450cd5
3
+ metadata.gz: 2a0e9dacdb2f6ac07c4f3dfd2c1ea51be5e0d5dabc8bba539c8c9dcacce49aae
4
+ data.tar.gz: e779aa108d78407a7a20f0a9912f9aa5282246b4f77c15708738f4717575a44b
5
5
  SHA512:
6
- metadata.gz: 504031fe67a904d4ea134ca88fe67c0e1708a60aed953a9d10e06bc41f46c61bc103638a32522ea68a6b98c712aeac10bade466f42090ef2ae422551489da04a
7
- data.tar.gz: a83b0baaeb4ec60c697f0f7f591a57827749183bd9c11dd2b669c723dd25012bf6b79683655f702487a77328097b3684f207079363ab5fe80bc0049e9224719e
6
+ metadata.gz: 1aa287850f774552ab4b96306da2fce852970e00126332f0aa8be9b05e24fd0aaa72508ef98cbc2bb16058c15060955d23dfead5aea0fdc60b048992d5183aea
7
+ data.tar.gz: ec65474ff75be570d78d892ebd595f1fb0024da6a90e75fd3ed7ef3537ab160b0894faf8a62f42245b08b1f1df179f0baa986016535979671359877ac00f743a
@@ -0,0 +1,24 @@
1
+ ##
2
+ # As Matched 是模式匹配后处理器的领域逻辑关注点。
3
+
4
+ module Unidom::Stapar::Concerns::AsMatchedProcessor
5
+
6
+ extend ActiveSupport::Concern
7
+
8
+ included do |includer|
9
+
10
+ # has_many :processors
11
+
12
+ def matched_process
13
+ processors.each do |processor|
14
+ processor.matched_process self
15
+ end
16
+ end
17
+
18
+ end
19
+
20
+ module ClassMethods
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,25 @@
1
+ ##
2
+ # Pattern Library 表示模式库。
3
+
4
+ module Unidom::Stapar
5
+ class PatternLibrary < ApplicationRecord
6
+
7
+ self.table_name = 'unidom_pattern_libraries'
8
+
9
+ include Unidom::Common::Concerns::ModelExtension
10
+ include ProgneTapera::EnumCode
11
+
12
+ belongs_to :subject, polymorphic: true
13
+ belongs_to :matched_processor, polymorphic: true
14
+
15
+ validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
16
+ validates :valve_percentage, presence: true, numericality: { greater_than: 0, less_than_or_equal_to: 100, only_integer: true }
17
+ validates :applied_species, presence: true, length: { in: 2..self.columns_hash['applied_species'].limit }
18
+
19
+ code :applied_field, Unidom::Stapar::AppliedField
20
+
21
+ scope :subject_is, -> (subject) { where subject: subject }
22
+ scope :matched_processor_is, -> (matched_processor) { where matched_processor: matched_processor }
23
+
24
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::PatternLibrary'
25
+ end
@@ -0,0 +1,19 @@
1
+ ##
2
+ # Pattern Library Inclusion 表示模式库收录。
3
+
4
+ module Unidom::Stapar
5
+ class PatternLibraryInclusion < ApplicationRecord
6
+
7
+ self.table_name = 'unidom_pattern_library_inclusions'
8
+
9
+ include Unidom::Common::Concerns::ModelExtension
10
+ include ProgneTapera::EnumCode
11
+
12
+ belongs_to :pattern_library, class_name: 'Unidom::Stapar::PatternLibrary'
13
+ belongs_to :pattern, polymorphic: true
14
+
15
+ scope :pattern_library_is, -> (pattern_library) { where pattern_library: pattern_library }
16
+ scope :pattern_is, -> (pattern) { where pattern: pattern }
17
+
18
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::PatternLibraryInclusion'
19
+ end
@@ -5,9 +5,9 @@ class CreateUnidomPatternMatchings < ActiveRecord::Migration[6.0]
5
5
  create_table :unidom_pattern_matchings, id: :uuid do |t|
6
6
 
7
7
  t.references :matched, type: :uuid, null: false,
8
- polymorphic: { null: false, default: '', limit: 200 }
8
+ polymorphic: { null: false, default: '', limit: 200 }, index: false
9
9
  t.references :input, type: :uuid, null: false,
10
- polymorphic: { null: false, default: '', limit: 200 }
10
+ polymorphic: { null: false, default: '', limit: 200 }, index: false
11
11
 
12
12
  t.decimal :similarity_percentage, null: false, default: 0.0, precision: 12, scale: 2
13
13
  t.integer :valve_percentage, null: false, default: 0
@@ -0,0 +1,36 @@
1
+ class CreateUnidomPatternLibraries < ActiveRecord::Migration[6.0]
2
+
3
+ def change
4
+
5
+ create_table :unidom_pattern_libraries, id: :uuid do |t|
6
+
7
+ t.references :subject, type: :uuid, null: false,
8
+ polymorphic: { null: false, default: '', limit: 200 }, index: false
9
+ t.references :matched_processor, type: :uuid, null: false,
10
+ polymorphic: { null: false, default: '', limit: 200 }, index: false
11
+
12
+ t.string :name, null: false, default: '', limit: 200
13
+ t.integer :valve_percentage, null: false, default: 0
14
+
15
+ t.string :applied_species, null: false, default: '', limit: 200
16
+ t.column :applied_field_code, 'char(4)', null: false, default: 'FACE'
17
+
18
+ t.text :instruction
19
+ t.text :description
20
+
21
+ t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
22
+ t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
23
+ t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
24
+ t.boolean :defunct, null: false, default: false
25
+ t.jsonb :notation, null: false, default: {}
26
+
27
+ t.timestamps null: false
28
+
29
+ end
30
+
31
+ add_index :unidom_pattern_libraries, :subject_id
32
+ add_index :unidom_pattern_libraries, :matched_processor_id
33
+
34
+ end
35
+
36
+ end
@@ -0,0 +1,28 @@
1
+ class CreateUnidomPatternLibraryInclusions < ActiveRecord::Migration[6.0]
2
+
3
+ def change
4
+
5
+ create_table :unidom_pattern_library_inclusions, id: :uuid do |t|
6
+
7
+ t.references :pattern_library, type: :uuid, null: false
8
+ t.references :pattern, type: :uuid, null: false,
9
+ polymorphic: { null: false, default: '', limit: 200 }, index: false
10
+
11
+ t.text :instruction
12
+ t.text :description
13
+
14
+ t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
15
+ t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
16
+ t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
17
+ t.boolean :defunct, null: false, default: false
18
+ t.jsonb :notation, null: false, default: {}
19
+
20
+ t.timestamps null: false
21
+
22
+ end
23
+
24
+ add_index :unidom_pattern_library_inclusions, :pattern_id
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,40 @@
1
+ require 'rails_helper'
2
+
3
+ describe Unidom::Stapar::PatternLibraryInclusion, type: :model do
4
+
5
+ before :each do
6
+ end
7
+
8
+ after :each do
9
+ end
10
+
11
+ context do
12
+
13
+ classifier = Unidom::Stapar::Classifier.first_or_create! supplier_name: 'Intelligent Works',
14
+ algorithm_name: 'FR Pro',
15
+ data_format_version: 1,
16
+ applied_species: 'Homo sapiens',
17
+ applied_field_code: 'FACE'
18
+
19
+ subject = classifier
20
+ matched_processor = classifier
21
+
22
+ pattern_library = Unidom::Stapar::PatternLibrary.first_or_create! subject: subject,
23
+ matched_processor: matched_processor,
24
+ name: 'Door Guard',
25
+ valve_percentage: 60,
26
+ applied_species: 'Homo sapiens',
27
+ applied_field_code: 'FACE'
28
+
29
+ pattern = classifier
30
+
31
+ model_attributes = {
32
+ pattern_library: pattern_library,
33
+ pattern: pattern
34
+ }
35
+
36
+ it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
37
+
38
+ end
39
+
40
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::PatternLibraryInclusion'
@@ -0,0 +1,43 @@
1
+ require 'rails_helper'
2
+
3
+ describe Unidom::Stapar::PatternLibrary, type: :model do
4
+
5
+ before :each do
6
+ end
7
+
8
+ after :each do
9
+ end
10
+
11
+ context do
12
+
13
+ classifier = Unidom::Stapar::Classifier.first_or_create! supplier_name: 'Intelligent Works',
14
+ algorithm_name: 'FR Pro',
15
+ data_format_version: 1,
16
+ applied_species: 'Homo sapiens',
17
+ applied_field_code: 'FACE'
18
+ subject = classifier
19
+ matched_processor = classifier
20
+
21
+ model_attributes = {
22
+ subject: subject,
23
+ matched_processor: matched_processor,
24
+ name: 'Door Guard',
25
+ valve_percentage: 60,
26
+ applied_species: 'Homo sapiens',
27
+ applied_field_code: 'FACE'
28
+ }
29
+
30
+ it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
31
+
32
+ it_behaves_like 'validates text', model_attributes, :name,
33
+ length: 2..described_class.columns_hash['name'].limit
34
+ it_behaves_like 'validates numericality', model_attributes, :valve_percentage,
35
+ range: 0..100, minimum_inclusive: false, maximum_inclusive: true, only_integer: true
36
+ it_behaves_like 'validates text', model_attributes, :applied_species,
37
+ length: 2..described_class.columns_hash['applied_species'].limit
38
+
39
+ it_behaves_like 'ProgneTapera::EnumCode', described_class.new(model_attributes), :applied_field, Unidom::Stapar::AppliedField
40
+
41
+ end
42
+
43
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::PatternLibrary'
@@ -1,2 +1,4 @@
1
- require 'rspec/models/unidom/stapar/classifier_spec' unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::Classifier'
2
- require 'rspec/models/unidom/stapar/pattern_matching_spec' unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::PatternMatching'
1
+ require 'rspec/models/unidom/stapar/classifier_spec' unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::Classifier'
2
+ require 'rspec/models/unidom/stapar/pattern_matching_spec' unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::PatternMatching'
3
+ require 'rspec/models/unidom/stapar/pattern_library_spec' unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::PatternLibrary'
4
+ require 'rspec/models/unidom/stapar/pattern_library_inclusion_spec' unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::PatternLibraryInclusion'
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Stapar
3
- VERSION = '0.3'
3
+ VERSION = '0.4'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-stapar
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-02 00:00:00.000000000 Z
11
+ date: 2020-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -45,7 +45,10 @@ files:
45
45
  - app/models/unidom/stapar/application_record.rb
46
46
  - app/models/unidom/stapar/classifier.rb
47
47
  - app/models/unidom/stapar/concerns/as_feature.rb
48
+ - app/models/unidom/stapar/concerns/as_matched_processor.rb
48
49
  - app/models/unidom/stapar/concerns/as_sample.rb
50
+ - app/models/unidom/stapar/pattern_library.rb
51
+ - app/models/unidom/stapar/pattern_library_inclusion.rb
49
52
  - app/models/unidom/stapar/pattern_matching.rb
50
53
  - app/types/unidom/stapar/applied_field.rb
51
54
  - app/views/layouts/unidom/stapar/application.html.erb
@@ -54,9 +57,13 @@ files:
54
57
  - config/routes.rb
55
58
  - db/migrate/20060101000000_create_unidom_classifiers.rb
56
59
  - db/migrate/20060102000000_create_unidom_pattern_matchings.rb
60
+ - db/migrate/20060111000000_create_unidom_pattern_libraries.rb
61
+ - db/migrate/20060112000000_create_unidom_pattern_library_inclusions.rb
57
62
  - lib/rspec/models/unidom/stapar/classifier_spec.rb
58
63
  - lib/rspec/models/unidom/stapar/concerns/as_feature_shared_examples.rb
59
64
  - lib/rspec/models/unidom/stapar/concerns/as_sample_shared_examples.rb
65
+ - lib/rspec/models/unidom/stapar/pattern_library_inclusion_spec.rb
66
+ - lib/rspec/models/unidom/stapar/pattern_library_spec.rb
60
67
  - lib/rspec/models/unidom/stapar/pattern_matching_spec.rb
61
68
  - lib/rspec/types/unidom/stapar/applied_field_spec.rb
62
69
  - lib/tasks/unidom/stapar_tasks.rake