unidom-stapar 0.1 → 0.2

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: 4b00f98eafa343c20a5017288189ecfc68c4e846f5551842191776c5e957334c
4
- data.tar.gz: 827fff4cfad04aef8e628f17748bd22e4d6fca2dceec93a0df913e76cf76bc69
3
+ metadata.gz: e673f9b0f1c435abff99992f0c6296037a091ed93400b6e52fa23c7099b354f1
4
+ data.tar.gz: 191a261f084087107fd4133eab25fa1a950bb3dd930aff585e685f7700db4e21
5
5
  SHA512:
6
- metadata.gz: d0f070d97298ed5b2a478a95db27be7563fe3dbe3bfd0e07507c0c3d808d3ae7ee0dd3fc2048a934099f2e008ab34ca8f133cabec80f9320afa442d1df764872
7
- data.tar.gz: fbff180d1304dc3e7c9095deb8d921043978bdd5b56418bfa5e22b1bcf503f9d720c54ede68e20cebc5aedd4a28d4ef5b56395dff1c4c9159f8e6fcbf9fd3b07
6
+ metadata.gz: 5cae2006e5fc7102d04907bbaccc32bab0776906ce6eb819f1d96c135e265b181afff2f6f54409f939827fc36aa6ef97eab2de136b1522e780426cc0818ff533
7
+ data.tar.gz: bcb8049fc2361c057064016e2c2cb8e4bda7aa568ed62b81087f272bf0d366c20737f94770ac3cd49f26d619518e92e8e645673f0b1f8fc9d12d99c0049612d4
@@ -0,0 +1,25 @@
1
+ ##
2
+ # Classifier 表示模式识别分类器。
3
+
4
+ class Unidom::Stapar::Classifier < Unidom::Stapar::ApplicationRecord
5
+
6
+ self.table_name = 'unidom_classifiers'
7
+
8
+ include Unidom::Common::Concerns::ModelExtension
9
+ include ProgneTapera::EnumCode
10
+
11
+ validates :supplier_name, presence: true, length: { in: 2..self.columns_hash['supplier_name'].limit }
12
+ validates :algorithm_name, presence: true, length: { in: 2..self.columns_hash['algorithm_name'].limit }
13
+ validates :data_format_version, presence: true, numericality: { greater_than: 0, less_than_or_equal_to: Unidom::Common::MAXIMUM_AMOUNT, only_integer: true }
14
+ validates :applied_species, presence: true, length: { in: 2..self.columns_hash['applied_species'].limit }
15
+
16
+ #has_many :features
17
+
18
+ code :applied_field, Unidom::Stapar::AppliedField
19
+
20
+ scope :supplier_name_is, -> (supplier_name) { where supplier_name: supplier_name }
21
+ scope :algorithm_name_is, -> (algorithm_name) { where algorithm_name: algorithm_name }
22
+ scope :data_format_version_is, -> (data_format_version) { where data_format_version: data_format_version }
23
+ scope :applied_species_is, -> (applied_species) { where applied_species: applied_species }
24
+
25
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::Classifier'
@@ -0,0 +1,31 @@
1
+ ##
2
+ # As Feature 是特征的领域逻辑关注点。
3
+
4
+ module Unidom::Stapar::Concerns::AsFeature
5
+
6
+ extend ActiveSupport::Concern
7
+
8
+ included do |includer|
9
+
10
+ validates :extracted_link, allow_blank: true, length: { in: 4..self.class.columns_hash[:extracted_link].limit }
11
+ validates :feature_link, presence: true, length: { in: 4..self.class.columns_hash[:feature_link].limit }
12
+
13
+ belongs_to :classifier, class_name: 'Unidom::Stapar::Classifier'
14
+ belongs_to :sample, polymorphic: true
15
+
16
+ scope :classified_by, -> (classifier) { where classifier_id: to_id(classifier) }
17
+ scope :extracted_from, -> (sample) { where sample: sample }
18
+ scope :extracted_link_is, -> (extracted_link) { where extracted_link: extracted_link }
19
+ scope :feature_link_is, -> (feature_link) { where feature_link: feature_link }
20
+
21
+ end
22
+
23
+ module ClassMethods
24
+
25
+ def classify!(sample, by: nil, extracted: nil, into: nil, at: Time.now)
26
+ create! sample: sample, classifier: by, extracted_link: extracted, feature_link: into, opened_at: at
27
+ end
28
+
29
+ end
30
+
31
+ end
@@ -0,0 +1,22 @@
1
+ ##
2
+ # As Sample 是采样的领域逻辑关注点。
3
+
4
+ module Unidom::Stapar::Concerns::AsSample
5
+
6
+ extend ActiveSupport::Concern
7
+
8
+ included do |includer|
9
+
10
+ validates :raw_data_link, presence: true, length: { in: 4..self.class.columns_hash[:raw_data_link].limit }
11
+ validates :sampled_at, presence: true
12
+
13
+ has_many :features, polymorphic: true
14
+
15
+ scope :raw_data_link_is, -> (raw_data_link) { where raw_data_link: raw_data_link }
16
+
17
+ end
18
+
19
+ module ClassMethods
20
+ end
21
+
22
+ end
@@ -0,0 +1,30 @@
1
+ class CreateUnidomClassifiers < ActiveRecord::Migration[6.0]
2
+
3
+ def change
4
+
5
+ create_table :unidom_classifiers, id: :uuid do |t|
6
+
7
+ t.string :supplier_name, null: false, default: '', limit: 200
8
+
9
+ t.string :algorithm_name, null: false, default: '', limit: 200
10
+ t.integer :data_format_version, null: false, default: 0
11
+
12
+ t.string :applied_species, null: false, default: '', limit: 200
13
+ t.column :applied_field_code, 'char(4)', null: false, default: 'FACE'
14
+
15
+ t.text :instruction
16
+ t.text :description
17
+
18
+ t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
19
+ t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
20
+ t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
21
+ t.boolean :defunct, null: false, default: false
22
+ t.jsonb :notation, null: false, default: {}
23
+
24
+ t.timestamps null: false
25
+
26
+ end
27
+
28
+ end
29
+
30
+ end
@@ -0,0 +1,36 @@
1
+ require 'rails_helper'
2
+
3
+ describe Unidom::Stapar::Classifier, type: :model do
4
+
5
+ before :each do
6
+ end
7
+
8
+ after :each do
9
+ end
10
+
11
+ context do
12
+
13
+ model_attributes = {
14
+ supplier_name: 'Intelligent Works',
15
+ algorithm_name: 'FR Pro',
16
+ data_format_version: 1,
17
+ applied_species: 'Homo sapiens',
18
+ applied_field_code: 'FACE'
19
+ }
20
+
21
+ it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
22
+
23
+ it_behaves_like 'validates text', model_attributes, :supplier_name,
24
+ length: 2..described_class.columns_hash['supplier_name'].limit
25
+ it_behaves_like 'validates text', model_attributes, :algorithm_name,
26
+ length: 2..described_class.columns_hash['algorithm_name'].limit
27
+ it_behaves_like 'validates numericality', model_attributes, :data_format_version,
28
+ range: 1..1_000_000_000, minimum_inclusive: true, maximum_inclusive: true, only_integer: true
29
+ it_behaves_like 'validates text', model_attributes, :applied_species,
30
+ length: 2..described_class.columns_hash['applied_species'].limit
31
+
32
+ it_behaves_like 'ProgneTapera::EnumCode', described_class.new(model_attributes), :applied_field, Unidom::Stapar::AppliedField
33
+
34
+ end
35
+
36
+ end
@@ -0,0 +1,28 @@
1
+ shared_examples 'Unidom::Stapar::Concerns::AsFeature' do |model_attributes|
2
+
3
+ context do
4
+ =begin
5
+ target_product_associating_1_attribtues = {
6
+ target_id: SecureRandom.uuid,
7
+ product_association_code: 'CPLM',
8
+ ordinal: 1,
9
+ quantity: 1
10
+ }
11
+
12
+ target_product_associating_2_attribtues = {
13
+ target_id: SecureRandom.uuid,
14
+ product_association_code: 'ICPT',
15
+ ordinal: 2,
16
+ quantity: 2
17
+ }
18
+
19
+ it_behaves_like 'has_many', model_attributes, :target_product_associatings, Unidom::Product::ProductAssociating, [ target_product_associating_1_attribtues, target_product_associating_2_attribtues ]
20
+
21
+ model = described_class.create! model_attributes
22
+ target = described_class.create! model_attributes
23
+ it_behaves_like 'assert_present!', model, :associate!, [ target, { due_to: 'CPLM', at: Time.now } ], [ { 0 => :target }, :due_to, :at ]
24
+ it_behaves_like 'assert_present!', model, :associate?, [ target, { due_to: 'CPLM', at: Time.now } ], [ { 0 => :target }, :due_to, :at ]
25
+ =end
26
+ end
27
+
28
+ end
@@ -0,0 +1,28 @@
1
+ shared_examples 'Unidom::Stapar::Concerns::AsSample' do |model_attributes|
2
+
3
+ context do
4
+ =begin
5
+ target_product_associating_1_attribtues = {
6
+ target_id: SecureRandom.uuid,
7
+ product_association_code: 'CPLM',
8
+ ordinal: 1,
9
+ quantity: 1
10
+ }
11
+
12
+ target_product_associating_2_attribtues = {
13
+ target_id: SecureRandom.uuid,
14
+ product_association_code: 'ICPT',
15
+ ordinal: 2,
16
+ quantity: 2
17
+ }
18
+
19
+ it_behaves_like 'has_many', model_attributes, :target_product_associatings, Unidom::Product::ProductAssociating, [ target_product_associating_1_attribtues, target_product_associating_2_attribtues ]
20
+
21
+ model = described_class.create! model_attributes
22
+ target = described_class.create! model_attributes
23
+ it_behaves_like 'assert_present!', model, :associate!, [ target, { due_to: 'CPLM', at: Time.now } ], [ { 0 => :target }, :due_to, :at ]
24
+ it_behaves_like 'assert_present!', model, :associate?, [ target, { due_to: 'CPLM', at: Time.now } ], [ { 0 => :target }, :due_to, :at ]
25
+ =end
26
+ end
27
+
28
+ end
@@ -1,3 +1,5 @@
1
+ require 'unidom/common'
2
+
1
3
  module Unidom
2
4
  module Stapar
3
5
  class Engine < ::Rails::Engine
@@ -0,0 +1 @@
1
+ require 'rspec/models/unidom/stapar/classifier_spec' unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::Classifier'
@@ -0,0 +1,2 @@
1
+ #require 'rspec/models/unidom/stapar/concerns/as_sample_shared_examples'
2
+ #require 'rspec/models/unidom/stapar/concerns/as_feature_shared_examples'
File without changes
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Stapar
3
- VERSION = '0.1'
3
+ VERSION = '0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-stapar
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
@@ -43,16 +43,26 @@ files:
43
43
  - app/jobs/unidom/stapar/application_job.rb
44
44
  - app/mailers/unidom/stapar/application_mailer.rb
45
45
  - app/models/unidom/stapar/application_record.rb
46
+ - app/models/unidom/stapar/classifier.rb
47
+ - app/models/unidom/stapar/concerns/as_feature.rb
48
+ - app/models/unidom/stapar/concerns/as_sample.rb
46
49
  - app/types/unidom/stapar/applied_field.rb
47
50
  - app/views/layouts/unidom/stapar/application.html.erb
48
51
  - config/enum.yml
49
52
  - config/locales/enum.zh-CN.yml
50
53
  - config/routes.rb
54
+ - db/migrate/20060101000000_create_unidom_classifiers.rb
55
+ - lib/rspec/models/unidom/stapar/classifier_spec.rb
56
+ - lib/rspec/models/unidom/stapar/concerns/as_feature_shared_examples.rb
57
+ - lib/rspec/models/unidom/stapar/concerns/as_sample_shared_examples.rb
51
58
  - lib/rspec/types/unidom/stapar/applied_field_spec.rb
52
59
  - lib/tasks/unidom/stapar_tasks.rake
53
60
  - lib/unidom/stapar.rb
54
61
  - lib/unidom/stapar/engine.rb
62
+ - lib/unidom/stapar/models_rspec.rb
63
+ - lib/unidom/stapar/rspec_shared_examples.rb
55
64
  - lib/unidom/stapar/types_rspec.rb
65
+ - lib/unidom/stapar/validators_rspec.rb
56
66
  - lib/unidom/stapar/version.rb
57
67
  homepage: https://github.com/topbitdu/unidom-stapar
58
68
  licenses: