unit_measurements-rails 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88cfa69f2d7ec7ba60a19ac6a4519f38d928ae4cff9df64d72035e76b21cc975
4
- data.tar.gz: 3bad903fa5c6fbc6f0404be8b85dc96a369ff3bb49a29229c8d57c4927835010
3
+ metadata.gz: 02e353f4bcd5f1cad16b7bebee4a1d46dc226ece9768ffc6f08a05bc62448cab
4
+ data.tar.gz: f2d6ab2245a058aef8552669085b3086c682653cb1647f799af3a98c8e4b84c8
5
5
  SHA512:
6
- metadata.gz: c8bdc95a6136ee7d39ea0eb55c2ba3420632e7be2511c15eb7fca96b1083687005c2c08359bb0ee2bc5508070239b0dd60f1e5c588f150efd6b224ab40f1f260
7
- data.tar.gz: 409dc3a9e99814361e1d97953118dfae1b4971da9c16da5bac8d77c81e4cd907a9d303aa883a22b040bb19f799291df5ef74644c9f21987c9c997599bc9e0f0e
6
+ metadata.gz: 30f7dccc1823251bafb0dea416bca202c2870b1031e393c845d8f708ea27862eead58392fb6740455cb918785302fb614834bd0b7c05db8f3abc13211432bda4
7
+ data.tar.gz: 2c74e56f900a0d540359ce69ccf25afa232eea4a1a00ca39b8546877dd00d7cd40b1f9976fe5b6998da8f2f986a9b5b4872ec0112c4feb97dde547fbe263fd99
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [1.6.0](https://github.com/shivam091/unit_measurements-rails/compare/v1.5.0...v1.6.0) - 2023-12-10
2
+
3
+ ### What's new
4
+
5
+ - Added tests for `measured_*` methods.
6
+
7
+ -----------
8
+
1
9
  ## [1.5.0](https://github.com/shivam091/unit_measurements-rails/compare/v1.4.0...v1.5.0) - 2023-11-27
2
10
 
3
11
  ### What's new
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- unit_measurements-rails (1.5.0)
4
+ unit_measurements-rails (1.6.0)
5
5
  activemodel (>= 7)
6
6
  activerecord (>= 7)
7
7
  railties (>= 7)
data/README.md CHANGED
@@ -14,7 +14,7 @@ A Rails adaptor that encapsulate measurements and their units in Ruby on Rails.
14
14
  ## Introduction
15
15
 
16
16
  This gem is designed as a Rails integration for the [unit_measurements](https://github.com/shivam091/unit_measurements) gem.
17
- It provides an `ActiveRecord` adapter for persisting and retrieving measurements along with their units, simplifying complex
17
+ It provides an `ActiveRecord` adapter for persisting and retrieving measurement quantity along with its unit, simplifying complex
18
18
  measurement handling within your Rails applications.
19
19
 
20
20
  ## Minimum Requirements
@@ -42,8 +42,8 @@ Or otherwise simply install it yourself as:
42
42
 
43
43
  ### ActiveRecord
44
44
 
45
- This gem provides an ActiveRecord integration allowing you to declare measurement attributes with their
46
- corresponding units in your database schema:
45
+ This gem provides an ActiveRecord integration allowing you to declare measurement
46
+ attributes along with their corresponding units in your database schema:
47
47
 
48
48
  ```ruby
49
49
  class CreateCubes < ActiveRecord::Migration[7.0]
@@ -76,6 +76,9 @@ cube.length_unit #=> "ft"
76
76
  cube.length #=> 5.0 ft
77
77
  ```
78
78
 
79
+ Attribute accessor names are expected to have the `_quantity` and `_unit` suffix,
80
+ and be `DECIMAL` and `VARCHAR` types, respectively, and defaults values are accepted.
81
+
79
82
  You can specify multiple measurement attributes simultaneously:
80
83
 
81
84
  ```ruby
@@ -84,28 +87,36 @@ class Cube < ActiveRecord::Base
84
87
  end
85
88
  ```
86
89
 
87
- Attribute names are expected to have the `_quantity` and `_unit` suffix, and be
88
- `DECIMAL` and `VARCHAR` types, respectively, and defaults values are accepted.
89
-
90
- You can customize the model's quantity and unit accessors by specifying them in the
91
- `quantity_attribute_name` and `unit_attribute_name` options, respectively.
90
+ You can customize the quantity and unit accessors of the measurement attribute by
91
+ specifying them in the `quantity_attribute_name` and `unit_attribute_name` options,
92
+ respectively.
92
93
 
93
94
  ```ruby
94
95
  class CubeWithCustomAccessor < ActiveRecord::Base
95
- measured_length :length, unit_attribute_name: :length_uom
96
- measured_length :width, quantity_attribute_name: :width_value
96
+ measured UnitMeasurements::Length, :length, :width, :height, unit_attribute_name: :size_uom
97
+ measured UnitMeasurements::Weight, :weight, quantity_attribute_name: :width_quantity
97
98
  end
98
99
  ```
99
100
 
100
101
  For a more streamlined approach, predefined methods are available for commonly used
101
- types like `length`, `weight`, `area`, `volume`, etc.:
102
+ types:
103
+
104
+ | # | Unit group | Method name |
105
+ | :- | :---------- | :----------- |
106
+ | 1 | Length or distance | measured_length |
107
+ | 2 | Weight or mass | measured_weight |
108
+ | 3 | Time or duration | measured_time |
109
+ | 4 | Temperature | measured_temperature |
110
+ | 5 | Area | measured_area |
111
+ | 6 | Volume | measured_volume |
112
+ | 7 | Density | measured_density |
102
113
 
103
114
  ```ruby
104
- class Package < ActiveRecord::Base
115
+ class CubeWithPredefinedMethods < ActiveRecord::Base
105
116
  measured_length :size
106
- measured_area :carpet_area
107
- measured_volume :total_volume
108
- measured_weight :item_weight, :package_weight
117
+ measured_volume :volume
118
+ measured_weight :weight
119
+ measured_density :density
109
120
  end
110
121
  ```
111
122
 
@@ -121,4 +132,4 @@ Contributions to this project are welcomed! To contribute:
121
132
 
122
133
  ## License
123
134
 
124
- Copyright 2023 [Harshal V. LADHE]((https://shivam091.github.io)), Released under the [MIT License](http://opensource.org/licenses/MIT).
135
+ Copyright 2023 [Harshal V. LADHE](https://shivam091.github.io), Released under the [MIT License](http://opensource.org/licenses/MIT).
@@ -5,6 +5,6 @@
5
5
  module UnitMeasurements
6
6
  module Rails
7
7
  # Current stable version.
8
- VERSION = "1.5.0"
8
+ VERSION = "1.6.0"
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unit_measurements-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harshal LADHE
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-27 00:00:00.000000000 Z
11
+ date: 2023-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties