unidom-article_number 0.3 → 1.0

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: 31a017927192ed39cd495960a2c81cdb8615f1ab
4
- data.tar.gz: cd821c0834fe5cec1b896d160ecbcd640fe7fe29
3
+ metadata.gz: c8a1f4df40f7546982076b4da6bfbd563802a8cb
4
+ data.tar.gz: d7948dd68b302b05a260468f6abf7516caf1aafa
5
5
  SHA512:
6
- metadata.gz: 5907f7e6751d1b3c926d25a20f610f537978a30b771c179b8b67fd8231ddd56ad94d2252be8f749bf18e16572101c809cbd13e0195b1e84598938f08445b04cf
7
- data.tar.gz: 65bcdc1983891228b7f48a87824f7c78801af231582a510b754576d4aa787e3b8826dcf106a3d17bc21a6714c12641cebdb7355dfb322c4c441beef65c5a47e7
6
+ metadata.gz: 0c6a7c3640053d6b0305f0b6b72d75bcd76939e3992b7486a91ad422ef19c69dd94f6e92c3311733251b1498804f5546e097f3a0182ce28009886e55456b9f7a
7
+ data.tar.gz: ce3c56cdac51936f84e87186ba54c010c67320cd8d4d3bc77cc18c229bed05d4719f47dfbb4a17f57e55670d26b30035106c4df75c795cdbec7ad8f2ca892044
data/README.md CHANGED
@@ -8,6 +8,10 @@
8
8
  Unidom (UNIfied Domain Object Model) is a series of domain model engines. The Article Number domain model engine includes EAN-13, EAN-8, and IMEI models.
9
9
  Unidom (统一领域对象模型)是一系列的领域模型引擎。物品编码领域模型引擎包括EAN-13、EAN-8和IMEI的模型。
10
10
 
11
+ ## Recent Update
12
+ Check out the [Road Map](ROADMAP.md) to find out what's the next.
13
+ Check out the [Change Log](CHANGELOG.md) to find out what's new.
14
+
11
15
  ## Usage in Gemfile
12
16
  ```ruby
13
17
  gem 'unidom-article_number'
@@ -17,9 +21,14 @@ gem 'unidom-article_number'
17
21
  ```shell
18
22
  rake db:migrate
19
23
  ```
24
+ The migration versions start with 200201.
20
25
 
21
26
  ## Call the Model
22
27
  ```ruby
23
- Unidom::ArticleNumber::Ean13Barcode.coded_as('1234567890123').valid_at.alive.first.markings
24
- Unidom::ArticleNumber::Ean8Barcode.coded_as('12345678').valid_at.alive.first.markings
28
+ ean_13_barcode = Unidom::ArticleNumber::Ean13Barcode.create code: '1234567890123'
29
+ ean_8_barcode = Unidom::ArticleNumber::Ean8Barcode.create code: '12345678'
30
+ marked = Product.create name: 'Chocolate'
31
+ marker = Person.create name: 'John'
32
+ ean_13_marking = Unidom::ArticleNumber::Marking.barcode_is(ean_13_barcode).marked_is(marked).first_or_create marker: marker, opened_at: Time.now
33
+ ean_8_marking = Unidom::ArticleNumber::Marking.barcode_is(ean_8_barcode).marked_is(marked).first_or_create marker: marker, opened_at: Time.now
25
34
  ```
@@ -10,4 +10,4 @@
10
10
  // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
11
  // about supported directives.
12
12
  //
13
- //= require_tree .
13
+ //= require_self
@@ -10,6 +10,5 @@
10
10
  * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
11
  * file per style scope.
12
12
  *
13
- *= require_tree .
14
13
  *= require_self
15
14
  */
@@ -4,6 +4,8 @@ class Unidom::ArticleNumber::Marking < ActiveRecord::Base
4
4
 
5
5
  self.table_name = 'unidom_markings'
6
6
 
7
+ include Unidom::Common::Concerns::ModelExtension
8
+
7
9
  belongs_to :barcode, polymorphic: true
8
10
  belongs_to :marked, polymorphic: true
9
11
  belongs_to :marker, polymorphic: true
@@ -12,6 +14,21 @@ class Unidom::ArticleNumber::Marking < ActiveRecord::Base
12
14
  scope :marked_by, ->(marker) { where marker: marker }
13
15
  scope :marked_is, ->(marked) { where marked: marked }
14
16
 
15
- include Unidom::Common::Concerns::ModelExtension
17
+ def self.mark(barcode: nil, marked: nil, marker: nil, opened_at: Time.now)
18
+
19
+ raise ArgumentError.new('Barcode is required.') if barcode.blank?
20
+ raise ArgumentError.new('Marked is required.' ) if marked.blank?
21
+
22
+ query = barcode_is(barcode).marked_is(marked).valid_at.alive
23
+ creation = { opened_at: opened_at }
24
+ if marker.present? && marker.respond_to?(:id)
25
+ creation[:marker] = marker
26
+ else
27
+ creation[:marker_id] = Unidom::Common::NULL_UUID
28
+ creation[:marker_type] = ''
29
+ end
30
+ query.first_or_create! creation
31
+
32
+ end
16
33
 
17
34
  end
@@ -3,12 +3,13 @@
3
3
  <head>
4
4
  <title>ArticleNumber</title>
5
5
  <%= stylesheet_link_tag "article_number/application", media: "all" %>
6
- <%= javascript_include_tag "article_number/application" %>
7
6
  <%= csrf_meta_tags %>
8
7
  </head>
9
8
  <body>
10
9
 
11
10
  <%= yield %>
12
11
 
12
+ <%= javascript_include_tag 'article_number/application' %>
13
+
13
14
  </body>
14
15
  </html>
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module ArticleNumber
3
- VERSION = '0.3'.freeze
3
+ VERSION = '1.0'.freeze
4
4
  end
5
5
  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: '0.3'
4
+ version: '1.0'
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-13 00:00:00.000000000 Z
11
+ date: 2016-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.4'
19
+ version: '0.9'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.4'
26
+ version: '0.9'
27
27
  description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
28
28
  The Article Number domain model engine includes EAN-13, EAN-8, and IMEI models.
29
29
  Unidom (统一领域对象模型)是一系列的领域模型引擎。物品编码领域模型引擎包括EAN-13、EAN-8和IMEI的模型。
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  version: '0'
74
74
  requirements: []
75
75
  rubyforge_project:
76
- rubygems_version: 2.4.5.1
76
+ rubygems_version: 2.6.4
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: Unidom Article Number Domain Model Engine 物品编码领域模型引擎