unidom-stapar 0.4 → 0.5
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 +4 -4
- data/app/models/unidom/stapar/classifier.rb +1 -1
- data/app/models/unidom/stapar/concerns/as_feature.rb +17 -14
- data/app/models/unidom/stapar/concerns/as_input_feature.rb +23 -0
- data/app/models/unidom/stapar/concerns/as_input_sample.rb +29 -0
- data/app/models/unidom/stapar/concerns/as_matched_feature.rb +23 -0
- data/app/models/unidom/stapar/concerns/as_matched_sample.rb +29 -0
- data/app/models/unidom/stapar/concerns/as_pattern.rb +23 -0
- data/app/models/unidom/stapar/concerns/as_sample.rb +12 -15
- data/app/models/unidom/stapar/concerns/as_substance.rb +24 -0
- data/app/models/unidom/stapar/feature.rb +27 -0
- data/app/models/unidom/stapar/sample.rb +23 -0
- data/db/migrate/20060102000000_create_unidom_pattern_matchings.rb +1 -0
- data/db/migrate/20060103000000_create_unidom_samples.rb +32 -0
- data/db/migrate/20060104000000_create_unidom_features.rb +35 -0
- data/db/migrate/20060112000000_create_unidom_pattern_library_inclusions.rb +2 -0
- data/lib/rspec/models/unidom/stapar/feature_spec.rb +60 -0
- data/lib/rspec/models/unidom/stapar/pattern_matching_spec.rb +2 -0
- data/lib/rspec/models/unidom/stapar/sample_spec.rb +40 -0
- data/lib/unidom/stapar/models_rspec.rb +2 -0
- data/lib/unidom/stapar/version.rb +1 -1
- metadata +14 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dbfcbda29d967437d90d3d8578b33a801600a050ccb72f32ef81e801c2e101ce
|
|
4
|
+
data.tar.gz: e93dd8faf4d27b239fd6f4b1d3af472428875aab451b871ff0fd038831a31bc4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 323b9e86fe4c642f7e3c4a58b5582bb772a546116b6f071fa3b6e69b920807e6d8c6b1f11257e3edff3f5d43d101ed426848a4811266558a9a5bc8dd859a5dcc
|
|
7
|
+
data.tar.gz: 80d4fd85e3f7a682b423a01d9da92b0814540f0d1d01aafca504c7e1ba35bea5951462ca5819b7be4441cc6011ebdf7956e1d272512fc7f28c477a55611e440b
|
|
@@ -14,7 +14,7 @@ module Unidom::Stapar
|
|
|
14
14
|
validates :data_format_version, presence: true, numericality: { greater_than: 0, less_than_or_equal_to: Unidom::Common::MAXIMUM_AMOUNT, only_integer: true }
|
|
15
15
|
validates :applied_species, presence: true, length: { in: 2..self.columns_hash['applied_species'].limit }
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
has_many :features, class_name: 'Unidom::Stapar::Feature'
|
|
18
18
|
|
|
19
19
|
code :applied_field, Unidom::Stapar::AppliedField
|
|
20
20
|
|
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
##
|
|
2
2
|
# As Feature 是特征的领域逻辑关注点。
|
|
3
3
|
|
|
4
|
-
module Unidom::Stapar
|
|
4
|
+
module Unidom::Stapar
|
|
5
|
+
module Concerns
|
|
6
|
+
module AsFeature
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
extend ActiveSupport::Concern
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
included do |includer|
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
belongs_to :sample, class_name: 'Unidom::Stapar::Sample'
|
|
13
|
+
belongs_to :classifier, class_name: 'Unidom::Stapar::Classifier'
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
scope :classified_by, -> (classifier) { where classifier_id: to_id(classifier) }
|
|
16
|
+
scope :extracted_from, -> (sample) { where sample: sample }
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
scope :feature_link_is, -> (feature_link) { where feature_link: feature_link }
|
|
18
|
+
#def is_classified!(into: nil, per: nil, by: nil, at: Time.now)
|
|
19
|
+
# create! sample: self, classifier: by, extracted_link: per, feature_link: into, opened_at: at
|
|
20
|
+
#end
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
end
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
module ClassMethods
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
end
|
|
26
27
|
|
|
28
|
+
end
|
|
29
|
+
end
|
|
27
30
|
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
##
|
|
2
|
+
# As Input Feature 是模式匹配中输入模式的逻辑关注点。
|
|
3
|
+
|
|
4
|
+
module Unidom::Stapar
|
|
5
|
+
module Concerns
|
|
6
|
+
module AsInputFeature
|
|
7
|
+
|
|
8
|
+
extend ActiveSupport::Concern
|
|
9
|
+
|
|
10
|
+
included do |includer|
|
|
11
|
+
|
|
12
|
+
has_many :matched_pattern_matchings, class_name: 'Unidom::Stapar::PatternMatching', as: :input
|
|
13
|
+
has_many :matched_patterns, through: :matched_pattern_matchings, source: :matched, source_type: 'Unidom::Stapar::Feature'
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
module ClassMethods
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
##
|
|
2
|
+
# As Input Sample 是模式匹配中输入样本的逻辑关注点。
|
|
3
|
+
|
|
4
|
+
module Unidom::Stapar
|
|
5
|
+
module Concerns
|
|
6
|
+
module AsInputSample
|
|
7
|
+
|
|
8
|
+
extend ActiveSupport::Concern
|
|
9
|
+
extend AsSample
|
|
10
|
+
|
|
11
|
+
included do |includer|
|
|
12
|
+
|
|
13
|
+
#includer.class_eval do
|
|
14
|
+
# include AsSample
|
|
15
|
+
#end
|
|
16
|
+
|
|
17
|
+
has_many :matched_pattern_matchings, through: :features, as: :input #, class_name: 'Unidom::Stapar::PatternMatching'
|
|
18
|
+
has_many :matched_patterns, through: :matched_pattern_matchings, source: :matched, source_type: 'Unidom::Stapar::Feature'
|
|
19
|
+
has_many :matched_samples, through: :matched_patterns, source: :sample
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
module ClassMethods
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
##
|
|
2
|
+
# As Matched Feature 是模式匹配中匹配模式的逻辑关注点。
|
|
3
|
+
|
|
4
|
+
module Unidom::Stapar
|
|
5
|
+
module Concerns
|
|
6
|
+
module AsMatchedFeature
|
|
7
|
+
|
|
8
|
+
extend ActiveSupport::Concern
|
|
9
|
+
|
|
10
|
+
included do |includer|
|
|
11
|
+
|
|
12
|
+
has_many :input_pattern_matchings, class_name: 'Unidom::Stapar::PatternMatching', as: :matched
|
|
13
|
+
has_many :input_patterns, through: :matched_pattern_matchings, source: :input, source_type: 'Unidom::Stapar::Feature'
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
module ClassMethods
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
##
|
|
2
|
+
# As Matched Sample 是模式匹配中匹配样本的逻辑关注点。
|
|
3
|
+
|
|
4
|
+
module Unidom::Stapar
|
|
5
|
+
module Concerns
|
|
6
|
+
module AsMatchedSample
|
|
7
|
+
|
|
8
|
+
extend ActiveSupport::Concern
|
|
9
|
+
extend AsSample
|
|
10
|
+
|
|
11
|
+
included do |includer|
|
|
12
|
+
|
|
13
|
+
#includer.class_eval do
|
|
14
|
+
# include AsSample
|
|
15
|
+
#end
|
|
16
|
+
|
|
17
|
+
has_many :input_pattern_matchings, through: :features, as: :matched #, class_name: 'Unidom::Stapar::PatternMatching'
|
|
18
|
+
has_many :input_patterns, through: :input_pattern_matchings, source: :input, source_type: 'Unidom::Stapar::Feature'
|
|
19
|
+
has_many :input_samples, through: :input_patterns, source: :sample
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
module ClassMethods
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
##
|
|
2
|
+
# As Pattern 是模式的领域逻辑关注点,主要与模式库交互。
|
|
3
|
+
|
|
4
|
+
module Unidom::Stapar
|
|
5
|
+
module Concerns
|
|
6
|
+
module AsPattern
|
|
7
|
+
|
|
8
|
+
extend ActiveSupport::Concern
|
|
9
|
+
|
|
10
|
+
included do |includer|
|
|
11
|
+
|
|
12
|
+
has_many :pattern_library_inclusions, class_name: 'Unidom::Stapar::PatternLibraryInclusion'
|
|
13
|
+
has_many :pattern_libraries, through: :pattern_library_inclusions
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
module ClassMethods
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
##
|
|
2
2
|
# As Sample 是采样的领域逻辑关注点。
|
|
3
3
|
|
|
4
|
-
module Unidom::Stapar
|
|
4
|
+
module Unidom::Stapar
|
|
5
|
+
module Concerns
|
|
6
|
+
module AsSample
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
extend ActiveSupport::Concern
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
included do |includer|
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
belongs_to :substance, polymorphic: true
|
|
13
|
+
has_many :features, class_name: 'Unidom::Stapar::Feature'
|
|
14
|
+
#has_many :pattern_library_inclusions, through: :features
|
|
15
|
+
#has_many :pattern_libraries, through: :pattern_library_inclusions
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
end
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
module ClassMethods
|
|
20
|
+
end
|
|
16
21
|
|
|
17
|
-
def is_classified!(into: nil, per: nil, by: nil, at: Time.now)
|
|
18
|
-
create! sample: self, classifier: by, extracted_link: per, feature_link: into, opened_at: at
|
|
19
22
|
end
|
|
20
|
-
|
|
21
23
|
end
|
|
22
|
-
|
|
23
|
-
module ClassMethods
|
|
24
|
-
|
|
25
|
-
end
|
|
26
|
-
|
|
27
24
|
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
##
|
|
2
|
+
# As Substance 是被取样的客体的领域逻辑关注点。
|
|
3
|
+
|
|
4
|
+
module Unidom::Stapar
|
|
5
|
+
module Concerns
|
|
6
|
+
module AsSubstance
|
|
7
|
+
|
|
8
|
+
extend ActiveSupport::Concern
|
|
9
|
+
|
|
10
|
+
included do |includer|
|
|
11
|
+
|
|
12
|
+
has_many :samples, class_name: 'Unidom::Stapar::Sample'
|
|
13
|
+
# has_many :features, through: :samples
|
|
14
|
+
# has_many :classifiers, through: :features, distinct: true
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
module ClassMethods
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Feature 表示特征记录。
|
|
2
|
+
|
|
3
|
+
module Unidom::Stapar
|
|
4
|
+
class Feature < ApplicationRecord
|
|
5
|
+
|
|
6
|
+
self.table_name = 'unidom_features'
|
|
7
|
+
|
|
8
|
+
include Unidom::Common::Concerns::ModelExtension
|
|
9
|
+
include ProgneTapera::EnumCode
|
|
10
|
+
include Unidom::Stapar::Concerns::AsFeature
|
|
11
|
+
include Unidom::Stapar::Concerns::AsPattern
|
|
12
|
+
include Unidom::Stapar::Concerns::AsInputFeature
|
|
13
|
+
include Unidom::Stapar::Concerns::AsMatchedFeature
|
|
14
|
+
|
|
15
|
+
validates :extracted_link, presence: true, length: { in: 4..self.columns_hash['extracted_link'].limit }
|
|
16
|
+
validates :extracted_mime_type, presence: true, length: { in: 4..self.columns_hash['extracted_mime_type'].limit }
|
|
17
|
+
validates :extracted_file_size, presence: true, numericality: { greater_than_or_equal_to: -1, less_than_or_equal_to: Unidom::Common::MAXIMUM_AMOUNT, only_integer: true }
|
|
18
|
+
|
|
19
|
+
validates :feature_link, presence: true, length: { in: 4..self.columns_hash['feature_link'].limit }
|
|
20
|
+
validates :feature_mime_type, presence: true, length: { in: 4..self.columns_hash['feature_mime_type'].limit }
|
|
21
|
+
validates :feature_file_size, presence: true, numericality: { greater_than_or_equal_to: -1, less_than_or_equal_to: Unidom::Common::MAXIMUM_AMOUNT, only_integer: true }
|
|
22
|
+
|
|
23
|
+
scope :extracted_link_is, -> (extracted_link) { where extracted_link: extracted_link }
|
|
24
|
+
scope :feature_link_is, -> (feature_link) { where feature_link: feature_link }
|
|
25
|
+
|
|
26
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::Feature'
|
|
27
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Sample 表示采样记录。
|
|
2
|
+
|
|
3
|
+
module Unidom::Stapar
|
|
4
|
+
class Sample < ApplicationRecord
|
|
5
|
+
|
|
6
|
+
self.table_name = 'unidom_samples'
|
|
7
|
+
|
|
8
|
+
include Unidom::Common::Concerns::ModelExtension
|
|
9
|
+
include ProgneTapera::EnumCode
|
|
10
|
+
#include Unidom::Stapar::Concerns::AsSample
|
|
11
|
+
include Unidom::Stapar::Concerns::AsInputSample
|
|
12
|
+
include Unidom::Stapar::Concerns::AsMatchedSample
|
|
13
|
+
|
|
14
|
+
validates :raw_data_link, presence: true, length: { in: 4..self.columns_hash['raw_data_link'].limit }
|
|
15
|
+
validates :raw_data_mime_type, presence: true, length: { in: 4..self.columns_hash['raw_data_mime_type'].limit }
|
|
16
|
+
validates :raw_data_file_size, presence: true, numericality: { greater_than_or_equal_to: -1, less_than_or_equal_to: Unidom::Common::MAXIMUM_AMOUNT, only_integer: true }
|
|
17
|
+
|
|
18
|
+
validates :sampled_at, presence: true
|
|
19
|
+
|
|
20
|
+
scope :raw_data_link_is, -> (raw_data_link) { where raw_data_link: raw_data_link }
|
|
21
|
+
|
|
22
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::Sample'
|
|
23
|
+
end
|
|
@@ -11,6 +11,7 @@ class CreateUnidomPatternMatchings < ActiveRecord::Migration[6.0]
|
|
|
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
|
|
14
|
+
t.integer :priority, null: false, default: 0
|
|
14
15
|
|
|
15
16
|
t.text :instruction
|
|
16
17
|
t.text :description
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class CreateUnidomSamples < ActiveRecord::Migration[6.0]
|
|
2
|
+
|
|
3
|
+
def change
|
|
4
|
+
|
|
5
|
+
create_table :unidom_samples, id: :uuid do |t|
|
|
6
|
+
|
|
7
|
+
t.references :substance, type: :uuid, null: false,
|
|
8
|
+
polymorphic: { null: false, default: '', limit: 200 }, index: false
|
|
9
|
+
|
|
10
|
+
t.string :raw_data_link, null: false, default: '', limit: 200
|
|
11
|
+
t.string :raw_data_mime_type, null: false, default: '', limit: 200
|
|
12
|
+
t.integer :raw_data_file_size, null: false, default: 0
|
|
13
|
+
t.datetime :sampled_at, null: false, default: Unidom::Common::CLOSED_AT
|
|
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
|
+
add_index :unidom_samples, :substance_id
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
class CreateUnidomFeatures < ActiveRecord::Migration[6.0]
|
|
2
|
+
|
|
3
|
+
def change
|
|
4
|
+
|
|
5
|
+
create_table :unidom_features, id: :uuid do |t|
|
|
6
|
+
|
|
7
|
+
t.references :sample, type: :uuid, null: false
|
|
8
|
+
t.references :classifier, type: :uuid, null: false
|
|
9
|
+
|
|
10
|
+
t.string :extracted_link, null: false, default: '', limit: 200
|
|
11
|
+
t.string :extracted_mime_type, null: false, default: '', limit: 200
|
|
12
|
+
t.integer :extracted_file_size, null: false, default: 0
|
|
13
|
+
|
|
14
|
+
t.string :feature_link, null: false, default: '', limit: 200
|
|
15
|
+
t.string :feature_mime_type, null: false, default: '', limit: 200
|
|
16
|
+
t.integer :feature_file_size, null: false, default: 0
|
|
17
|
+
|
|
18
|
+
t.integer :grade, null: false, default: 0
|
|
19
|
+
|
|
20
|
+
t.text :instruction
|
|
21
|
+
t.text :description
|
|
22
|
+
|
|
23
|
+
t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
|
|
24
|
+
t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
|
|
25
|
+
t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
|
|
26
|
+
t.boolean :defunct, null: false, default: false
|
|
27
|
+
t.jsonb :notation, null: false, default: {}
|
|
28
|
+
|
|
29
|
+
t.timestamps null: false
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
@@ -8,6 +8,8 @@ class CreateUnidomPatternLibraryInclusions < ActiveRecord::Migration[6.0]
|
|
|
8
8
|
t.references :pattern, type: :uuid, null: false,
|
|
9
9
|
polymorphic: { null: false, default: '', limit: 200 }, index: false
|
|
10
10
|
|
|
11
|
+
t.integer :priority, null: false, default: 0
|
|
12
|
+
|
|
11
13
|
t.text :instruction
|
|
12
14
|
t.text :description
|
|
13
15
|
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
describe Unidom::Stapar::Feature, 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
|
+
substance = classifier
|
|
19
|
+
|
|
20
|
+
sample = Unidom::Stapar::Sample.first_or_create! substance_id: substance.id,
|
|
21
|
+
substance_type: substance.class.name,
|
|
22
|
+
raw_data_link: 'https://objectstore/{id}.jpg',
|
|
23
|
+
raw_data_mime_type: 'image/jpeg',
|
|
24
|
+
raw_data_file_size: 1.megabytes,
|
|
25
|
+
sampled_at: Time.now
|
|
26
|
+
|
|
27
|
+
model_attributes = {
|
|
28
|
+
sample_id: sample.id,
|
|
29
|
+
classifier_id: classifier.id,
|
|
30
|
+
extracted_link: 'https://objectstore/{id}/extracted/{sequence}.jpg',
|
|
31
|
+
extracted_mime_type: 'image/jpeg',
|
|
32
|
+
extracted_file_size: 64.kilobytes,
|
|
33
|
+
feature_link: 'https://objectstore/{id}/feature/{sequence}.bin',
|
|
34
|
+
feature_mime_type: 'application/octet-stream',
|
|
35
|
+
feature_file_size: 2.kilobytes,
|
|
36
|
+
grade: 60
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
|
|
40
|
+
|
|
41
|
+
it_behaves_like 'validates text', model_attributes, :extracted_link,
|
|
42
|
+
length: 4..described_class.columns_hash['extracted_link'].limit
|
|
43
|
+
it_behaves_like 'validates text', model_attributes, :extracted_mime_type,
|
|
44
|
+
length: 4..described_class.columns_hash['extracted_mime_type'].limit
|
|
45
|
+
it_behaves_like 'validates numericality', model_attributes, :extracted_file_size,
|
|
46
|
+
range: -1..Unidom::Common::MAXIMUM_AMOUNT, minimum_inclusive: true, maximum_inclusive: true, only_integer: true
|
|
47
|
+
|
|
48
|
+
it_behaves_like 'validates text', model_attributes, :feature_link,
|
|
49
|
+
length: 4..described_class.columns_hash['feature_link'].limit
|
|
50
|
+
it_behaves_like 'validates text', model_attributes, :feature_mime_type,
|
|
51
|
+
length: 4..described_class.columns_hash['feature_mime_type'].limit
|
|
52
|
+
it_behaves_like 'validates numericality', model_attributes, :feature_file_size,
|
|
53
|
+
range: -1..Unidom::Common::MAXIMUM_AMOUNT, minimum_inclusive: true, maximum_inclusive: true, only_integer: true
|
|
54
|
+
|
|
55
|
+
#it_behaves_like 'validates numericality', model_attributes, :grade,
|
|
56
|
+
# range: 0..Unidom::Common::MAXIMUM_AMOUNT, minimum_inclusive: true, maximum_inclusive: true, only_integer: true
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::Feature'
|
|
@@ -31,6 +31,8 @@ describe Unidom::Stapar::PatternMatching, type: :model do
|
|
|
31
31
|
range: 0..100, minimum_inclusive: false, maximum_inclusive: true, only_integer: false
|
|
32
32
|
it_behaves_like 'validates numericality', model_attributes, :valve_percentage,
|
|
33
33
|
range: 0..100, minimum_inclusive: false, maximum_inclusive: true, only_integer: true
|
|
34
|
+
#it_behaves_like 'validates numericality', model_attributes, :priority,
|
|
35
|
+
# range: 0..100, minimum_inclusive: false, maximum_inclusive: true, only_integer: true
|
|
34
36
|
|
|
35
37
|
end
|
|
36
38
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
describe Unidom::Stapar::Sample, 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
|
+
substance = classifier
|
|
19
|
+
|
|
20
|
+
model_attributes = {
|
|
21
|
+
substance_id: substance.id,
|
|
22
|
+
substance_type: substance.class.name,
|
|
23
|
+
raw_data_link: 'https://objectstore/{id}.jpg',
|
|
24
|
+
raw_data_mime_type: 'image/jpeg',
|
|
25
|
+
raw_data_file_size: 1.megabytes,
|
|
26
|
+
sampled_at: Time.now,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
|
|
30
|
+
|
|
31
|
+
it_behaves_like 'validates text', model_attributes, :raw_data_link,
|
|
32
|
+
length: 4..described_class.columns_hash['raw_data_link'].limit
|
|
33
|
+
it_behaves_like 'validates text', model_attributes, :raw_data_mime_type,
|
|
34
|
+
length: 4..described_class.columns_hash['raw_data_mime_type'].limit
|
|
35
|
+
it_behaves_like 'validates numericality', model_attributes, :raw_data_file_size,
|
|
36
|
+
range: -1..Unidom::Common::MAXIMUM_AMOUNT, minimum_inclusive: true, maximum_inclusive: true, only_integer: true
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::Sample'
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
require 'rspec/models/unidom/stapar/classifier_spec' unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::Classifier'
|
|
2
2
|
require 'rspec/models/unidom/stapar/pattern_matching_spec' unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::PatternMatching'
|
|
3
|
+
require 'rspec/models/unidom/stapar/sample_spec' unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::Sample'
|
|
4
|
+
require 'rspec/models/unidom/stapar/feature_spec' unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::Feature'
|
|
3
5
|
require 'rspec/models/unidom/stapar/pattern_library_spec' unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::PatternLibrary'
|
|
4
6
|
require 'rspec/models/unidom/stapar/pattern_library_inclusion_spec' unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Stapar::PatternLibraryInclusion'
|
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.
|
|
4
|
+
version: '0.5'
|
|
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-
|
|
11
|
+
date: 2020-05-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: unidom-common
|
|
@@ -45,11 +45,19 @@ 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_input_feature.rb
|
|
49
|
+
- app/models/unidom/stapar/concerns/as_input_sample.rb
|
|
50
|
+
- app/models/unidom/stapar/concerns/as_matched_feature.rb
|
|
48
51
|
- app/models/unidom/stapar/concerns/as_matched_processor.rb
|
|
52
|
+
- app/models/unidom/stapar/concerns/as_matched_sample.rb
|
|
53
|
+
- app/models/unidom/stapar/concerns/as_pattern.rb
|
|
49
54
|
- app/models/unidom/stapar/concerns/as_sample.rb
|
|
55
|
+
- app/models/unidom/stapar/concerns/as_substance.rb
|
|
56
|
+
- app/models/unidom/stapar/feature.rb
|
|
50
57
|
- app/models/unidom/stapar/pattern_library.rb
|
|
51
58
|
- app/models/unidom/stapar/pattern_library_inclusion.rb
|
|
52
59
|
- app/models/unidom/stapar/pattern_matching.rb
|
|
60
|
+
- app/models/unidom/stapar/sample.rb
|
|
53
61
|
- app/types/unidom/stapar/applied_field.rb
|
|
54
62
|
- app/views/layouts/unidom/stapar/application.html.erb
|
|
55
63
|
- config/enum.yml
|
|
@@ -57,14 +65,18 @@ files:
|
|
|
57
65
|
- config/routes.rb
|
|
58
66
|
- db/migrate/20060101000000_create_unidom_classifiers.rb
|
|
59
67
|
- db/migrate/20060102000000_create_unidom_pattern_matchings.rb
|
|
68
|
+
- db/migrate/20060103000000_create_unidom_samples.rb
|
|
69
|
+
- db/migrate/20060104000000_create_unidom_features.rb
|
|
60
70
|
- db/migrate/20060111000000_create_unidom_pattern_libraries.rb
|
|
61
71
|
- db/migrate/20060112000000_create_unidom_pattern_library_inclusions.rb
|
|
62
72
|
- lib/rspec/models/unidom/stapar/classifier_spec.rb
|
|
63
73
|
- lib/rspec/models/unidom/stapar/concerns/as_feature_shared_examples.rb
|
|
64
74
|
- lib/rspec/models/unidom/stapar/concerns/as_sample_shared_examples.rb
|
|
75
|
+
- lib/rspec/models/unidom/stapar/feature_spec.rb
|
|
65
76
|
- lib/rspec/models/unidom/stapar/pattern_library_inclusion_spec.rb
|
|
66
77
|
- lib/rspec/models/unidom/stapar/pattern_library_spec.rb
|
|
67
78
|
- lib/rspec/models/unidom/stapar/pattern_matching_spec.rb
|
|
79
|
+
- lib/rspec/models/unidom/stapar/sample_spec.rb
|
|
68
80
|
- lib/rspec/types/unidom/stapar/applied_field_spec.rb
|
|
69
81
|
- lib/tasks/unidom/stapar_tasks.rake
|
|
70
82
|
- lib/unidom/stapar.rb
|