cats_core 1.0.5 → 1.0.6

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: b6ff0706b8636cf94fea0714f73ed8fead005d08a2647f5365f43ac7ba6a53b6
4
- data.tar.gz: ab055e9fc942f99eed1e28ab7a755e0c5f54098a854705cf46c6c9bc880d0cff
3
+ metadata.gz: d34a61d070d789f175697fa32b8d763c04908b7bdb031c577fa35ba7eceedc88
4
+ data.tar.gz: 36039d25f798567b2e9196ffb37189b99f4bfa7406c66abccb0dbc2b614dcfdc
5
5
  SHA512:
6
- metadata.gz: 82950facfa04e42a6aa4e934bfe9f950c158db65dbf55e61c6aff04ad2c9041354e2560a61222817864c5cd8288649282e099f362e7014f7abf65d3ba628a441
7
- data.tar.gz: 8e951eebc249a57a1868dbc9155c1818bfc791ef6a0c987aaccf203c34e2d9fab7a3598b138c70de6e6c5f910cd8d2970e838c9719198f9ccd1d6380b9989143
6
+ metadata.gz: 8fb02566443952aca7ec7e45c1e665206b4eb8edbc7058ef444c1c7b65e2a946b9005f8284c50fbb5a6dea820286ffbf7a52b6904c02e081512828f48dc2803b
7
+ data.tar.gz: 06cde81638ce5e693929122574b7dc32079370c4a481651f8b9d26159709ceb91d2b60451874cfe733807fb44fd9707705e78b1385657a90bde759f7e80a4aec
@@ -12,6 +12,7 @@ module Cats
12
12
  belongs_to :unit_of_measure
13
13
 
14
14
  validates :quantity, presence: true, numericality: { greater_than: 0 }
15
+ validates :volume_per_metric_ton, numericality: { greater_than: 0, allow_nil: true }
15
16
  end
16
17
  end
17
18
  end
@@ -4,6 +4,10 @@ module Cats
4
4
  include Noticed::Model
5
5
 
6
6
  belongs_to :recipient, polymorphic: true
7
+
8
+ def message
9
+ to_notification.message
10
+ end
7
11
  end
8
12
  end
9
13
  end
@@ -37,7 +37,18 @@ module Cats
37
37
  end
38
38
 
39
39
  def stacking_rules
40
- rule ||= Cats::Core::StackingRule.first
40
+ rule = Cats::Core::StackingRule.first
41
+
42
+ # If no rule is defined, then define a default rule
43
+ rule ||= Cats::Core::StackingRule(
44
+ space_between_stack: 1,
45
+ distance_from_gangway: 2,
46
+ distance_from_ceiling: 1,
47
+ maximum_height: 5,
48
+ maximum_length: 5,
49
+ maximum_width: 5,
50
+ distance_from_wall: 1
51
+ )
41
52
  rule
42
53
  end
43
54
 
@@ -25,16 +25,20 @@ module Cats
25
25
  NOTIFICATION_RULES
26
26
  end
27
27
 
28
+ def create_notifier(rule)
29
+ clazz = rule[:notification].constantize
30
+ clazz.with(**@params)
31
+ end
32
+
28
33
  def notify
29
- rules = notification_rules
30
- clazz = rules[@code][:notification].constantize
31
- app_code = rules[@code][:application]
32
- roles = rules[@code][:recipients]
34
+ rule = notification_rules[@code]
35
+ notifier = create_notifier(rule)
36
+ app_code = rule[:application]
37
+ roles = rule[:recipients]
33
38
 
34
- notification = clazz.with(**@params)
35
39
  users = Cats::Core::User.joins(:application_module)
36
40
  .where(application_module: { prefix: app_code }).with_all_roles(*roles)
37
- notification.deliver(users)
41
+ notifier.deliver(users)
38
42
  end
39
43
  end
40
44
  end
@@ -21,6 +21,7 @@ class CreateCatsCoreCommodities < ActiveRecord::Migration[6.1]
21
21
  t.string :description
22
22
  t.boolean :hazardous, null: false, default: false
23
23
  t.date :best_use_before
24
+ t.float :volume_per_metric_ton
24
25
 
25
26
  t.timestamps
26
27
  end
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.0.5'.freeze
3
+ VERSION = '1.0.6'.freeze
4
4
  end
5
5
  end
@@ -8,5 +8,6 @@ FactoryBot.define do
8
8
  quantity { 100 }
9
9
  hazardous { false }
10
10
  best_use_before { Date.today + 2.month }
11
+ volume_per_metric_ton { 10 }
11
12
  end
12
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cats_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-29 00:00:00.000000000 Z
11
+ date: 2021-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ancestry