unidom-article_number 2.1 → 2.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b783c43ec02f0f07fffba394890b3453a543f8cd
|
|
4
|
+
data.tar.gz: 40c1f438bd33514ead6652352398c709d637edb3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b2bbc4cd9d42cbe650620cf4ba039083ac042fbeed9e0825775e2ecd99bcd765754a0ba6176b6ff27508e0b068b0560d073c735b63e77cc28b02e907ccbabd1d
|
|
7
|
+
data.tar.gz: f22719632f99756a0e3b7bfd34a6684238915c205a9040e66b3af7e0ee3b08bc513eae978058453afa16b75ede52f502014ce866e12fd2441374775bdaf355eb
|
data/README.md
CHANGED
|
@@ -38,12 +38,16 @@ The migration versions start with 200201.
|
|
|
38
38
|
## Call the Model
|
|
39
39
|
|
|
40
40
|
```ruby
|
|
41
|
-
ean_13_barcode = Unidom::ArticleNumber::Ean13Barcode.create code: '1234567890123'
|
|
42
|
-
ean_8_barcode = Unidom::ArticleNumber::Ean8Barcode.create code: '12345678'
|
|
41
|
+
ean_13_barcode = Unidom::ArticleNumber::Ean13Barcode.create! code: '1234567890123'
|
|
42
|
+
ean_8_barcode = Unidom::ArticleNumber::Ean8Barcode.create! code: '12345678'
|
|
43
43
|
marked = Unidom::Product::Product.create! name: 'Chocolate', abbreviation: 'Choc', packing_norm: '12 blocks', measurement_unit: 'box'
|
|
44
44
|
marker = Unidom::Party::Person.create! name: 'John'
|
|
45
45
|
ean_13_marking = Unidom::ArticleNumber::Marking.mark! barcode: ean_13_barcode, marked: marked, marker: marker, opened_at: Time.now
|
|
46
46
|
ean_8_marking = Unidom::ArticleNumber::Marking.mark! barcode: ean_8_barcode, marked: marked, marker: marker, opened_at: Time.now
|
|
47
|
+
|
|
48
|
+
vin = Unidom::ArticleNumber::VehicleIdentificationNumber.create! code: 'LVHCU165XD5002138'
|
|
49
|
+
# The Vehicle Identification Number Validator is enabled on the code field by default.
|
|
50
|
+
found_vin = Unidom::ArticleNumber::VehicleIdentificationNumber.coded_as('LVHCU165XD5002138').first
|
|
47
51
|
```
|
|
48
52
|
|
|
49
53
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# VIN (Vehicle Identification Number) 是车辆识别码。
|
|
2
|
+
# https://en.wikipedia.org/wiki/Vehicle_identification_number
|
|
3
|
+
# GB 16735-2004
|
|
4
|
+
|
|
5
|
+
class Unidom::ArticleNumber::VehicleIdentificationNumber < Unidom::ArticleNumber::ApplicationRecord
|
|
6
|
+
|
|
7
|
+
self.table_name = 'unidom_vehicle_identification_numbers'
|
|
8
|
+
|
|
9
|
+
include Unidom::Common::Concerns::ModelExtension
|
|
10
|
+
include Unidom::ArticleNumber::Concerns::AsBarcode
|
|
11
|
+
|
|
12
|
+
validates :code, uniqueness: true, 'unidom/article_number/vehicle_identification_number': true
|
|
13
|
+
validates :world_manufacturer_identifier, presence: true, length: { is: columns_hash['world_manufacturer_identifier'].limit }
|
|
14
|
+
validates :vehicle_descriptor_section, presence: true, length: { is: columns_hash['vehicle_descriptor_section'].limit }
|
|
15
|
+
validates :check_digit, presence: true, length: { is: columns_hash['check_digit'].limit }
|
|
16
|
+
validates :vehicle_identifier_section, presence: true, length: { is: columns_hash['vehicle_identifier_section'].limit }
|
|
17
|
+
|
|
18
|
+
def code=(code)
|
|
19
|
+
code = code.to_s
|
|
20
|
+
write_attribute :code, code
|
|
21
|
+
if code.present?
|
|
22
|
+
write_attribute :world_manufacturer_identifier, code[0..2]
|
|
23
|
+
write_attribute :vehicle_descriptor_section, code[3..7]
|
|
24
|
+
write_attribute :check_digit, code[8]
|
|
25
|
+
write_attribute :vehicle_identifier_section, code[9..16]
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class CreateUnidomVehicleIdentificationNumbers < ActiveRecord::Migration
|
|
2
|
+
|
|
3
|
+
def change
|
|
4
|
+
|
|
5
|
+
create_table :unidom_vehicle_identification_numbers, id: :uuid do |t|
|
|
6
|
+
|
|
7
|
+
t.column :code, 'char(17)', null: false, default: '0'*17
|
|
8
|
+
t.column :world_manufacturer_identifier, 'char(3)', null: false, default: '0'*3
|
|
9
|
+
t.column :vehicle_descriptor_section, 'char(5)', null: false, default: '0'*5
|
|
10
|
+
t.column :check_digit, 'char(1)', null: false, default: '0'
|
|
11
|
+
t.column :vehicle_identifier_section, 'char(8)', null: false, default: '0'*8
|
|
12
|
+
|
|
13
|
+
t.column :state, 'char(1)', null: false, default: 'C'
|
|
14
|
+
t.datetime :opened_at, null: false, default: ::Time.utc(1970)
|
|
15
|
+
t.datetime :closed_at, null: false, default: ::Time.utc(3000)
|
|
16
|
+
t.boolean :defunct, null: false, default: false
|
|
17
|
+
t.jsonb :notation, null: false, default: {}
|
|
18
|
+
|
|
19
|
+
t.timestamps null: false
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
add_index :unidom_vehicle_identification_numbers, :code, unique: true
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: unidom-article_number
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '2.
|
|
4
|
+
version: '2.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-12-
|
|
11
|
+
date: 2016-12-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: unidom-common
|
|
@@ -52,12 +52,14 @@ files:
|
|
|
52
52
|
- app/models/unidom/article_number/ean13_barcode.rb
|
|
53
53
|
- app/models/unidom/article_number/ean8_barcode.rb
|
|
54
54
|
- app/models/unidom/article_number/marking.rb
|
|
55
|
+
- app/models/unidom/article_number/vehicle_identification_number.rb
|
|
55
56
|
- app/validators/unidom/article_number/vehicle_identification_number_validator.rb
|
|
56
57
|
- app/views/layouts/unidom/article_number/application.html.erb
|
|
57
58
|
- config/routes.rb
|
|
58
59
|
- db/migrate/20020101000000_create_unidom_markings.rb
|
|
59
60
|
- db/migrate/20020102000000_create_unidom_ean_13_barcodes.rb
|
|
60
61
|
- db/migrate/20020103000000_create_unidom_ean_8_barcodes.rb
|
|
62
|
+
- db/migrate/20020111000000_create_unidom_vehicle_identification_numbers.rb
|
|
61
63
|
- lib/tasks/article_number_tasks.rake
|
|
62
64
|
- lib/unidom/article_number.rb
|
|
63
65
|
- lib/unidom/article_number/engine.rb
|