unidom-standard 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
  SHA1:
3
- metadata.gz: 63796122569dfb462219ef191e897184fe0bb142
4
- data.tar.gz: ebc21855c7233fb3f6a38afafb427133c7188f22
3
+ metadata.gz: beb9c96a32c4e73edbd9386f7957973d5eb1cbd2
4
+ data.tar.gz: 132472d93047b81ee0d3607007fae55eec345050
5
5
  SHA512:
6
- metadata.gz: e4c1a6a65ca9b6934d891e9c008f3bbc8681f3f9750b95cb9bc0402677a16bebaf08cc92cab433ce9d27d5d724914d838415d1ec062ad6b47cf769c55234e851
7
- data.tar.gz: 9e061436416d8e40ad7ec66e19c449f2d2da36488deedd5fe956544e19e830253dbea2f1dcf9b21aea841158f43db1dd6588a7e06e315839e21dc08a516bc44d
6
+ metadata.gz: 54729bb33923534fe779fd3526be03f4947eb2d84d1fffbc41349ce9f24e3c34f39a9673e722383b9ce3cc7b94cac480da4c470262aab621dc93955809824893
7
+ data.tar.gz: 59f46b255ef3c137a2a89c8b6488f70941da6de65405ae7d6bb0c5bd5a197a2c218d8a0df9b695bd6123e14f1fcc37b5dfc5ccc6d9db52f477a9cb65b87209e9
data/README.md CHANGED
@@ -18,6 +18,9 @@ rake db:migrate
18
18
 
19
19
  ## Call the Model
20
20
  ```ruby
21
- Unidom::Standard::Standard.valid_at.alive.first
22
- Unidom::Standard::StandardAssociation.valid_at.alive.first
21
+ gbk = Unidom::Standard::Standard.number_is('GBK').first
22
+ gbk.source_standards.merge(Unidom::Standard::StandardAssociating.association_coded_as('REVS').valid_at.alive).valid_at.alive
23
+ # The standards revises GBK.
24
+ gbk.target_standards.merge(Unidom::Standard::StandardAssociating.association_coded_as('REVS').valid_at.alive).valid_at.alive
25
+ # The standards revised by GBK, such as GB2312.
23
26
  ```
@@ -16,4 +16,11 @@ class Unidom::Standard::Standard < ActiveRecord::Base
16
16
 
17
17
  scope :number_is, ->(number) { where number: number }
18
18
 
19
+ has_many :target_associatings, class_name: 'Unidom::Standard::StandardAssociating', foreign_key: :source_id # as: :source
20
+ has_many :target_standards, through: :target_associatings, source: :target
21
+ has_many :source_associatings, class_name: 'Unidom::Standard::StandardAssociating', foreign_key: :target_id # as: :target
22
+ has_many :source_standards, through: :source_associatings, source: :source
23
+
24
+ include Unidom::Common::Concerns::ModelExtension
25
+
19
26
  end
@@ -0,0 +1,15 @@
1
+ # Standard Association 是标准之间的关联关系。
2
+ # association_code: REVS 修订,RFRC 引用。
3
+ class Unidom::Standard::StandardAssociating < ActiveRecord::Base
4
+
5
+ self.table_name = 'unidom_standard_associatings'
6
+
7
+ scope :source_is, ->(source) { where source_id: (source.respond_to?(:id) ? source.id : source) }
8
+ scope :target_is, ->(target) { where target_id: (target.respond_to?(:id) ? target.id : target) }
9
+
10
+ belongs_to :source, class_name: 'Unidom::Standard::Standard', foreign_key: :source_id
11
+ belongs_to :target, class_name: 'Unidom::Standard::Standard', foreign_key: :target_id
12
+
13
+ include Unidom::Common::Concerns::ModelExtension
14
+
15
+ end
@@ -9,10 +9,11 @@ class CreateUnidomStandards < ActiveRecord::Migration
9
9
  t.string :ics_code, null: true, default: nil, limit: 9
10
10
 
11
11
  t.text :scope_definition
12
+ t.text :corrigenda
12
13
  t.text :instruction
13
14
  t.text :description
14
15
 
15
- t.date :issued_on, null: false, default: '3000-01-01'
16
+ t.date :published_on, null: false, default: '3000-01-01'
16
17
  t.date :applied_on, null: false, default: '3000-01-01'
17
18
  t.date :obsoleted_on, null: false, default: '3000-01-01'
18
19
 
@@ -0,0 +1,27 @@
1
+ class CreateUnidomStandardAssociatings < ActiveRecord::Migration
2
+
3
+ def change
4
+
5
+ create_table :unidom_standard_associatings, id: :uuid do |t|
6
+
7
+ t.references :source, type: :uuid, null: false
8
+ t.references :target, type: :uuid, null: false
9
+
10
+ t.column :association_code, 'char(4)', null: false, default: 'REVS'
11
+
12
+ t.column :state, 'char(1)', null: false, default: 'C'
13
+ t.datetime :opened_at, null: false, default: ::Time.utc(1970)
14
+ t.datetime :closed_at, null: false, default: ::Time.utc(3000)
15
+ t.boolean :defunct, null: false, default: false
16
+ t.jsonb :notation, null: false, default: {}
17
+
18
+ t.timestamps null: false
19
+
20
+ end
21
+
22
+ add_index :unidom_standard_associatings, [ :source_id, :target_id ], unique: true
23
+ add_index :unidom_standard_associatings, :target_id
24
+
25
+ end
26
+
27
+ end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Standard
3
- VERSION = '0.1'.freeze
3
+ VERSION = '0.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-standard
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
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-08 00:00:00.000000000 Z
11
+ date: 2016-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -41,9 +41,11 @@ files:
41
41
  - app/controllers/unidom/standard/application_controller.rb
42
42
  - app/helpers/unidom/standard/application_helper.rb
43
43
  - app/models/unidom/standard/standard.rb
44
+ - app/models/unidom/standard/standard_associating.rb
44
45
  - app/views/layouts/unidom/standard/application.html.erb
45
46
  - config/routes.rb
46
47
  - db/migrate/20000601000000_create_unidom_standards.rb
48
+ - db/migrate/20000602000000_create_unidom_standard_associatings.rb
47
49
  - lib/tasks/standard_tasks.rake
48
50
  - lib/unidom/standard.rb
49
51
  - lib/unidom/standard/engine.rb