measured 3.0.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +20 -0
- data/.github/workflows/ci.yml +5 -5
- data/.github/workflows/dependabot_auto_merge.yml +93 -0
- data/CHANGELOG.md +8 -0
- data/cache/weight.json +230 -0
- data/gemfiles/rails-7.1.gemfile +6 -0
- data/lib/measured/rails/validations.rb +3 -3
- data/lib/measured/units/weight.rb +2 -1
- data/lib/measured/version.rb +1 -1
- data/measured.gemspec +1 -1
- data/test/rails/validation_test.rb +28 -0
- data/test/units/weight_test.rb +74 -1
- metadata +8 -10
- data/gemfiles/rails-6.0.gemfile +0 -6
- data/gemfiles/rails-6.1.gemfile +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d08724bae7ca2587e6ac427df7588e08fcec42dfecbd5d0fd9858560b7d1ec1f
|
4
|
+
data.tar.gz: aa934b2932b9df4648acbd6d65378fdd00add45840834e5ef9119bfd2e627ff9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5aea963586e68d4806e06d98993b2122b13fd19c79a825c035d413b908c8d30213d7fe4d23d4485b7cfdcd63c448db98150f11941bbb32d461a773e781ed5120
|
7
|
+
data.tar.gz: 55dd6b127ae8dcba52fca728246116a55274549bf0ee0ac31931a12393783554cb05dd5b7521714573e9d3c24350f6c88883a30a0110921e1594325660156f42
|
@@ -0,0 +1,20 @@
|
|
1
|
+
version: 2
|
2
|
+
registries:
|
3
|
+
ruby-shopify:
|
4
|
+
type: rubygems-server
|
5
|
+
url: https://pkgs.shopify.io/basic/gems/ruby
|
6
|
+
username: ${{secrets.RUBYGEMS_SERVER_PKGS_SHOPIFY_IO_USERNAME}}
|
7
|
+
password: ${{secrets.RUBYGEMS_SERVER_PKGS_SHOPIFY_IO_PASSWORD}}
|
8
|
+
github-com:
|
9
|
+
type: git
|
10
|
+
url: https://github.com
|
11
|
+
username: ${{secrets.DEPENDENCIES_GITHUB_USER}}
|
12
|
+
password: ${{secrets.DEPENDENCIES_GITHUB_TOKEN}}
|
13
|
+
updates:
|
14
|
+
- package-ecosystem: bundler
|
15
|
+
directory: "/"
|
16
|
+
schedule:
|
17
|
+
interval: weekly
|
18
|
+
open-pull-requests-limit: 100
|
19
|
+
insecure-external-code-execution: allow
|
20
|
+
registries: "*"
|
data/.github/workflows/ci.yml
CHANGED
@@ -10,18 +10,18 @@ jobs:
|
|
10
10
|
strategy:
|
11
11
|
matrix:
|
12
12
|
ruby:
|
13
|
-
- '3.0'
|
14
13
|
- '3.1'
|
15
14
|
- '3.2'
|
15
|
+
- '3.3'
|
16
16
|
gemfile:
|
17
17
|
- Gemfile
|
18
|
-
- gemfiles/rails-6.0.gemfile
|
19
|
-
- gemfiles/rails-6.1.gemfile
|
20
18
|
- gemfiles/rails-7.0.gemfile
|
19
|
+
- gemfiles/rails-7.1.gemfile
|
21
20
|
- gemfiles/rails-edge.gemfile
|
22
21
|
exclude:
|
23
|
-
|
24
|
-
|
22
|
+
- ruby: '3.1'
|
23
|
+
gemfile: gemfiles/rails-edge.gemfile
|
24
|
+
- ruby: '3.2'
|
25
25
|
gemfile: gemfiles/rails-edge.gemfile
|
26
26
|
|
27
27
|
name: Ruby ${{ matrix.ruby }} ${{ matrix.gemfile }}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
name: Dependabot auto-merge
|
2
|
+
on: pull_request_target
|
3
|
+
|
4
|
+
jobs:
|
5
|
+
dependabot:
|
6
|
+
runs-on: shopify-ubuntu-latest
|
7
|
+
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
|
8
|
+
steps:
|
9
|
+
- name: Dependabot metadata
|
10
|
+
id: metadata
|
11
|
+
uses: dependabot/fetch-metadata@v1.6.0
|
12
|
+
with:
|
13
|
+
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
14
|
+
|
15
|
+
- name: Waiting for CI to finish
|
16
|
+
id: check_ci_failure
|
17
|
+
continue-on-error: true
|
18
|
+
if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.dependency-group == 'auto_merge' }}
|
19
|
+
uses: actions/github-script@v6
|
20
|
+
with:
|
21
|
+
script: |
|
22
|
+
function sleep(ms) {
|
23
|
+
return new Promise(resolve => setTimeout(resolve, ms))
|
24
|
+
}
|
25
|
+
const query = `query ($org: String!, $repo: String!, $pullRequestNumber: Int!) {
|
26
|
+
organization(login: $org) {
|
27
|
+
repository(name: $repo) {
|
28
|
+
pullRequest(number: $pullRequestNumber) {
|
29
|
+
commits(last: 1) {
|
30
|
+
nodes {
|
31
|
+
commit {
|
32
|
+
status {
|
33
|
+
state
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}`;
|
42
|
+
const variables = {
|
43
|
+
org: context.repo.owner,
|
44
|
+
repo: context.repo.repo,
|
45
|
+
pullRequestNumber: context.issue.number
|
46
|
+
}
|
47
|
+
// Try for 30 minutes
|
48
|
+
let attempts = 30
|
49
|
+
let ci_state = false
|
50
|
+
for (let i = 1; i <= attempts; i++) {
|
51
|
+
console.log(`Sleeping for 60 seconds`)
|
52
|
+
await sleep(60000)
|
53
|
+
const result = await github.graphql(query, variables)
|
54
|
+
const state = result["organization"]["repository"]["pullRequest"]["commits"]["nodes"][0]["commit"]["status"]["state"]
|
55
|
+
console.log(`Status is ${state} after ${i} attempts`)
|
56
|
+
if (state === "SUCCESS") {
|
57
|
+
ci_state = true
|
58
|
+
console.log("Proceeding with workflow as CI succeed")
|
59
|
+
break
|
60
|
+
}
|
61
|
+
}
|
62
|
+
core.setOutput("ci_state", ci_state)
|
63
|
+
- name: Send Slack notification if auto-merge failed
|
64
|
+
if: ${{ steps.check_ci_failure.outputs.ci_state == 'false' }}
|
65
|
+
uses: ruby/action-slack@v3.0.0
|
66
|
+
with:
|
67
|
+
payload: |
|
68
|
+
{
|
69
|
+
"attachments": [{
|
70
|
+
"text": "Auto-merge failed for pull request <${{ github.event.pull_request.html_url }}|#${{ github.event.pull_request.number }}> in repository ${{ github.repository }}",
|
71
|
+
"color": "danger"
|
72
|
+
}
|
73
|
+
]
|
74
|
+
}
|
75
|
+
env:
|
76
|
+
SLACK_WEBHOOK_URL: ${{ secrets.METRICS_SLACK_WEBHOOK_URL }}
|
77
|
+
|
78
|
+
- name: Approve and merge
|
79
|
+
if: ${{ steps.check_ci_failure.outputs.ci_state == 'true' && (steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.dependency-group == 'auto_merge') }}
|
80
|
+
uses: actions/github-script@v6
|
81
|
+
with:
|
82
|
+
script: |
|
83
|
+
await github.rest.pulls.createReview({
|
84
|
+
pull_number: context.issue.number,
|
85
|
+
owner: context.repo.owner,
|
86
|
+
repo: context.repo.repo,
|
87
|
+
event: 'APPROVE',
|
88
|
+
})
|
89
|
+
await github.rest.pulls.merge({
|
90
|
+
owner: context.repo.owner,
|
91
|
+
repo: context.repo.repo,
|
92
|
+
issue_number: context.issue.number,
|
93
|
+
})
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
Unreleased
|
2
2
|
-----
|
3
3
|
|
4
|
+
3.2.0
|
5
|
+
-----
|
6
|
+
* Make the ActiveRecord validation errors have the correct type. (@alexcarruthers)
|
7
|
+
|
8
|
+
3.1.0
|
9
|
+
-----
|
10
|
+
* Drop support for Rails 6 and Ruby 3.0.
|
11
|
+
* Add qunitals. Add aliases for UK ton/tonne. (@ragarwal6397)
|
4
12
|
|
5
13
|
|
6
14
|
3.0.0
|
data/cache/weight.json
CHANGED
@@ -89,6 +89,10 @@
|
|
89
89
|
"numerator": 1,
|
90
90
|
"denominator": 1000000
|
91
91
|
},
|
92
|
+
"q": {
|
93
|
+
"numerator": 1,
|
94
|
+
"denominator": 100000
|
95
|
+
},
|
92
96
|
"slug": {
|
93
97
|
"numerator": 1000,
|
94
98
|
"denominator": 14593903
|
@@ -203,6 +207,10 @@
|
|
203
207
|
"numerator": 1,
|
204
208
|
"denominator": 1000000000000000000000000000000
|
205
209
|
},
|
210
|
+
"q": {
|
211
|
+
"numerator": 1,
|
212
|
+
"denominator": 100000000000000000000000000000
|
213
|
+
},
|
206
214
|
"slug": {
|
207
215
|
"numerator": 1,
|
208
216
|
"denominator": 14593903000000000000000000000
|
@@ -317,6 +325,10 @@
|
|
317
325
|
"numerator": 1,
|
318
326
|
"denominator": 1000000000000000000000000000
|
319
327
|
},
|
328
|
+
"q": {
|
329
|
+
"numerator": 1,
|
330
|
+
"denominator": 100000000000000000000000000
|
331
|
+
},
|
320
332
|
"slug": {
|
321
333
|
"numerator": 1,
|
322
334
|
"denominator": 14593903000000000000000000
|
@@ -431,6 +443,10 @@
|
|
431
443
|
"numerator": 1,
|
432
444
|
"denominator": 1000000000000000000000000
|
433
445
|
},
|
446
|
+
"q": {
|
447
|
+
"numerator": 1,
|
448
|
+
"denominator": 100000000000000000000000
|
449
|
+
},
|
434
450
|
"slug": {
|
435
451
|
"numerator": 1,
|
436
452
|
"denominator": 14593903000000000000000
|
@@ -545,6 +561,10 @@
|
|
545
561
|
"numerator": 1,
|
546
562
|
"denominator": 1000000000000000000000
|
547
563
|
},
|
564
|
+
"q": {
|
565
|
+
"numerator": 1,
|
566
|
+
"denominator": 100000000000000000000
|
567
|
+
},
|
548
568
|
"slug": {
|
549
569
|
"numerator": 1,
|
550
570
|
"denominator": 14593903000000000000
|
@@ -659,6 +679,10 @@
|
|
659
679
|
"numerator": 1,
|
660
680
|
"denominator": 1000000000000000000
|
661
681
|
},
|
682
|
+
"q": {
|
683
|
+
"numerator": 1,
|
684
|
+
"denominator": 100000000000000000
|
685
|
+
},
|
662
686
|
"slug": {
|
663
687
|
"numerator": 1,
|
664
688
|
"denominator": 14593903000000000
|
@@ -773,6 +797,10 @@
|
|
773
797
|
"numerator": 1,
|
774
798
|
"denominator": 1000000000000000
|
775
799
|
},
|
800
|
+
"q": {
|
801
|
+
"numerator": 1,
|
802
|
+
"denominator": 100000000000000
|
803
|
+
},
|
776
804
|
"slug": {
|
777
805
|
"numerator": 1,
|
778
806
|
"denominator": 14593903000000
|
@@ -887,6 +915,10 @@
|
|
887
915
|
"numerator": 1,
|
888
916
|
"denominator": 1000000000000
|
889
917
|
},
|
918
|
+
"q": {
|
919
|
+
"numerator": 1,
|
920
|
+
"denominator": 100000000000
|
921
|
+
},
|
890
922
|
"slug": {
|
891
923
|
"numerator": 1,
|
892
924
|
"denominator": 14593903000
|
@@ -1001,6 +1033,10 @@
|
|
1001
1033
|
"numerator": 1,
|
1002
1034
|
"denominator": 1000000000
|
1003
1035
|
},
|
1036
|
+
"q": {
|
1037
|
+
"numerator": 1,
|
1038
|
+
"denominator": 100000000
|
1039
|
+
},
|
1004
1040
|
"slug": {
|
1005
1041
|
"numerator": 1,
|
1006
1042
|
"denominator": 14593903
|
@@ -1115,6 +1151,10 @@
|
|
1115
1151
|
"numerator": 1,
|
1116
1152
|
"denominator": 100000000
|
1117
1153
|
},
|
1154
|
+
"q": {
|
1155
|
+
"numerator": 1,
|
1156
|
+
"denominator": 10000000
|
1157
|
+
},
|
1118
1158
|
"slug": {
|
1119
1159
|
"numerator": 10,
|
1120
1160
|
"denominator": 14593903
|
@@ -1229,6 +1269,10 @@
|
|
1229
1269
|
"numerator": 1,
|
1230
1270
|
"denominator": 10000000
|
1231
1271
|
},
|
1272
|
+
"q": {
|
1273
|
+
"numerator": 1,
|
1274
|
+
"denominator": 1000000
|
1275
|
+
},
|
1232
1276
|
"slug": {
|
1233
1277
|
"numerator": 100,
|
1234
1278
|
"denominator": 14593903
|
@@ -1343,6 +1387,10 @@
|
|
1343
1387
|
"numerator": 1,
|
1344
1388
|
"denominator": 100000
|
1345
1389
|
},
|
1390
|
+
"q": {
|
1391
|
+
"numerator": 1,
|
1392
|
+
"denominator": 10000
|
1393
|
+
},
|
1346
1394
|
"slug": {
|
1347
1395
|
"numerator": 10000,
|
1348
1396
|
"denominator": 14593903
|
@@ -1457,6 +1505,10 @@
|
|
1457
1505
|
"numerator": 1,
|
1458
1506
|
"denominator": 10000
|
1459
1507
|
},
|
1508
|
+
"q": {
|
1509
|
+
"numerator": 1,
|
1510
|
+
"denominator": 1000
|
1511
|
+
},
|
1460
1512
|
"slug": {
|
1461
1513
|
"numerator": 100000,
|
1462
1514
|
"denominator": 14593903
|
@@ -1571,6 +1623,10 @@
|
|
1571
1623
|
"numerator": 1,
|
1572
1624
|
"denominator": 1000
|
1573
1625
|
},
|
1626
|
+
"q": {
|
1627
|
+
"numerator": 1,
|
1628
|
+
"denominator": 100
|
1629
|
+
},
|
1574
1630
|
"slug": {
|
1575
1631
|
"numerator": 1000000,
|
1576
1632
|
"denominator": 14593903
|
@@ -1685,6 +1741,10 @@
|
|
1685
1741
|
"numerator": 1,
|
1686
1742
|
"denominator": 1
|
1687
1743
|
},
|
1744
|
+
"q": {
|
1745
|
+
"numerator": 10,
|
1746
|
+
"denominator": 1
|
1747
|
+
},
|
1688
1748
|
"slug": {
|
1689
1749
|
"numerator": 1000000000,
|
1690
1750
|
"denominator": 14593903
|
@@ -1799,6 +1859,10 @@
|
|
1799
1859
|
"numerator": 1000,
|
1800
1860
|
"denominator": 1
|
1801
1861
|
},
|
1862
|
+
"q": {
|
1863
|
+
"numerator": 10000,
|
1864
|
+
"denominator": 1
|
1865
|
+
},
|
1802
1866
|
"slug": {
|
1803
1867
|
"numerator": 1000000000000,
|
1804
1868
|
"denominator": 14593903
|
@@ -1913,6 +1977,10 @@
|
|
1913
1977
|
"numerator": 1000000,
|
1914
1978
|
"denominator": 1
|
1915
1979
|
},
|
1980
|
+
"q": {
|
1981
|
+
"numerator": 10000000,
|
1982
|
+
"denominator": 1
|
1983
|
+
},
|
1916
1984
|
"slug": {
|
1917
1985
|
"numerator": 1000000000000000,
|
1918
1986
|
"denominator": 14593903
|
@@ -2027,6 +2095,10 @@
|
|
2027
2095
|
"numerator": 1000000000,
|
2028
2096
|
"denominator": 1
|
2029
2097
|
},
|
2098
|
+
"q": {
|
2099
|
+
"numerator": 10000000000,
|
2100
|
+
"denominator": 1
|
2101
|
+
},
|
2030
2102
|
"slug": {
|
2031
2103
|
"numerator": 1000000000000000000,
|
2032
2104
|
"denominator": 14593903
|
@@ -2141,6 +2213,10 @@
|
|
2141
2213
|
"numerator": 1000000000000,
|
2142
2214
|
"denominator": 1
|
2143
2215
|
},
|
2216
|
+
"q": {
|
2217
|
+
"numerator": 10000000000000,
|
2218
|
+
"denominator": 1
|
2219
|
+
},
|
2144
2220
|
"slug": {
|
2145
2221
|
"numerator": 1000000000000000000000,
|
2146
2222
|
"denominator": 14593903
|
@@ -2255,6 +2331,10 @@
|
|
2255
2331
|
"numerator": 1000000000000000,
|
2256
2332
|
"denominator": 1
|
2257
2333
|
},
|
2334
|
+
"q": {
|
2335
|
+
"numerator": 10000000000000000,
|
2336
|
+
"denominator": 1
|
2337
|
+
},
|
2258
2338
|
"slug": {
|
2259
2339
|
"numerator": 1000000000000000000000000,
|
2260
2340
|
"denominator": 14593903
|
@@ -2369,6 +2449,10 @@
|
|
2369
2449
|
"numerator": 1000000000000000000,
|
2370
2450
|
"denominator": 1
|
2371
2451
|
},
|
2452
|
+
"q": {
|
2453
|
+
"numerator": 10000000000000000000,
|
2454
|
+
"denominator": 1
|
2455
|
+
},
|
2372
2456
|
"slug": {
|
2373
2457
|
"numerator": 1000000000000000000000000000,
|
2374
2458
|
"denominator": 14593903
|
@@ -2483,6 +2567,10 @@
|
|
2483
2567
|
"numerator": 1,
|
2484
2568
|
"denominator": 1000000000000000000
|
2485
2569
|
},
|
2570
|
+
"q": {
|
2571
|
+
"numerator": 10,
|
2572
|
+
"denominator": 1
|
2573
|
+
},
|
2486
2574
|
"slug": {
|
2487
2575
|
"numerator": 1000000000,
|
2488
2576
|
"denominator": 14593903
|
@@ -2508,6 +2596,124 @@
|
|
2508
2596
|
"denominator": 45359237
|
2509
2597
|
}
|
2510
2598
|
},
|
2599
|
+
"q": {
|
2600
|
+
"q": {
|
2601
|
+
"numerator": 1,
|
2602
|
+
"denominator": 1
|
2603
|
+
},
|
2604
|
+
"g": {
|
2605
|
+
"numerator": 100000,
|
2606
|
+
"denominator": 1
|
2607
|
+
},
|
2608
|
+
"yg": {
|
2609
|
+
"numerator": 100000000000000000000000000000,
|
2610
|
+
"denominator": 1
|
2611
|
+
},
|
2612
|
+
"zg": {
|
2613
|
+
"numerator": 100000000000000000000000000,
|
2614
|
+
"denominator": 1
|
2615
|
+
},
|
2616
|
+
"ag": {
|
2617
|
+
"numerator": 100000000000000000000000,
|
2618
|
+
"denominator": 1
|
2619
|
+
},
|
2620
|
+
"fg": {
|
2621
|
+
"numerator": 100000000000000000000,
|
2622
|
+
"denominator": 1
|
2623
|
+
},
|
2624
|
+
"pg": {
|
2625
|
+
"numerator": 100000000000000000,
|
2626
|
+
"denominator": 1
|
2627
|
+
},
|
2628
|
+
"ng": {
|
2629
|
+
"numerator": 100000000000000,
|
2630
|
+
"denominator": 1
|
2631
|
+
},
|
2632
|
+
"μg": {
|
2633
|
+
"numerator": 100000000000,
|
2634
|
+
"denominator": 1
|
2635
|
+
},
|
2636
|
+
"mg": {
|
2637
|
+
"numerator": 100000000,
|
2638
|
+
"denominator": 1
|
2639
|
+
},
|
2640
|
+
"cg": {
|
2641
|
+
"numerator": 10000000,
|
2642
|
+
"denominator": 1
|
2643
|
+
},
|
2644
|
+
"dg": {
|
2645
|
+
"numerator": 1000000,
|
2646
|
+
"denominator": 1
|
2647
|
+
},
|
2648
|
+
"dag": {
|
2649
|
+
"numerator": 10000,
|
2650
|
+
"denominator": 1
|
2651
|
+
},
|
2652
|
+
"hg": {
|
2653
|
+
"numerator": 1000,
|
2654
|
+
"denominator": 1
|
2655
|
+
},
|
2656
|
+
"kg": {
|
2657
|
+
"numerator": 100,
|
2658
|
+
"denominator": 1
|
2659
|
+
},
|
2660
|
+
"Mg": {
|
2661
|
+
"numerator": 1,
|
2662
|
+
"denominator": 10
|
2663
|
+
},
|
2664
|
+
"Gg": {
|
2665
|
+
"numerator": 1,
|
2666
|
+
"denominator": 10000
|
2667
|
+
},
|
2668
|
+
"Tg": {
|
2669
|
+
"numerator": 1,
|
2670
|
+
"denominator": 10000000
|
2671
|
+
},
|
2672
|
+
"Pg": {
|
2673
|
+
"numerator": 1,
|
2674
|
+
"denominator": 10000000000
|
2675
|
+
},
|
2676
|
+
"Eg": {
|
2677
|
+
"numerator": 1,
|
2678
|
+
"denominator": 10000000000000
|
2679
|
+
},
|
2680
|
+
"Zg": {
|
2681
|
+
"numerator": 1,
|
2682
|
+
"denominator": 10000000000000000
|
2683
|
+
},
|
2684
|
+
"Yg": {
|
2685
|
+
"numerator": 1,
|
2686
|
+
"denominator": 10000000000000000000
|
2687
|
+
},
|
2688
|
+
"t": {
|
2689
|
+
"numerator": 1,
|
2690
|
+
"denominator": 10
|
2691
|
+
},
|
2692
|
+
"slug": {
|
2693
|
+
"numerator": 100000000,
|
2694
|
+
"denominator": 14593903
|
2695
|
+
},
|
2696
|
+
"N": {
|
2697
|
+
"numerator": 10000000000000000000,
|
2698
|
+
"denominator": 10197162129779283
|
2699
|
+
},
|
2700
|
+
"long_ton": {
|
2701
|
+
"numerator": 31250000,
|
2702
|
+
"denominator": 317514659
|
2703
|
+
},
|
2704
|
+
"short_ton": {
|
2705
|
+
"numerator": 5000000,
|
2706
|
+
"denominator": 45359237
|
2707
|
+
},
|
2708
|
+
"lb": {
|
2709
|
+
"numerator": 10000000000,
|
2710
|
+
"denominator": 45359237
|
2711
|
+
},
|
2712
|
+
"oz": {
|
2713
|
+
"numerator": 160000000000,
|
2714
|
+
"denominator": 45359237
|
2715
|
+
}
|
2716
|
+
},
|
2511
2717
|
"slug": {
|
2512
2718
|
"slug": {
|
2513
2719
|
"numerator": 1,
|
@@ -2601,6 +2807,10 @@
|
|
2601
2807
|
"numerator": 14593903,
|
2602
2808
|
"denominator": 1000000000
|
2603
2809
|
},
|
2810
|
+
"q": {
|
2811
|
+
"numerator": 14593903,
|
2812
|
+
"denominator": 100000000
|
2813
|
+
},
|
2604
2814
|
"N": {
|
2605
2815
|
"numerator": 1459390300000000000,
|
2606
2816
|
"denominator": 10197162129779283
|
@@ -2715,6 +2925,10 @@
|
|
2715
2925
|
"numerator": 10197162129779283,
|
2716
2926
|
"denominator": 100000000000000000000
|
2717
2927
|
},
|
2928
|
+
"q": {
|
2929
|
+
"numerator": 10197162129779283,
|
2930
|
+
"denominator": 10000000000000000000
|
2931
|
+
},
|
2718
2932
|
"slug": {
|
2719
2933
|
"numerator": 10197162129779283,
|
2720
2934
|
"denominator": 1459390300000000000
|
@@ -2829,6 +3043,10 @@
|
|
2829
3043
|
"numerator": 317514659,
|
2830
3044
|
"denominator": 312500000
|
2831
3045
|
},
|
3046
|
+
"q": {
|
3047
|
+
"numerator": 317514659,
|
3048
|
+
"denominator": 31250000
|
3049
|
+
},
|
2832
3050
|
"slug": {
|
2833
3051
|
"numerator": 5080234544,
|
2834
3052
|
"denominator": 72969515
|
@@ -2943,6 +3161,10 @@
|
|
2943
3161
|
"numerator": 45359237,
|
2944
3162
|
"denominator": 50000000
|
2945
3163
|
},
|
3164
|
+
"q": {
|
3165
|
+
"numerator": 45359237,
|
3166
|
+
"denominator": 5000000
|
3167
|
+
},
|
2946
3168
|
"slug": {
|
2947
3169
|
"numerator": 907184740,
|
2948
3170
|
"denominator": 14593903
|
@@ -3057,6 +3279,10 @@
|
|
3057
3279
|
"numerator": 45359237,
|
3058
3280
|
"denominator": 100000000000
|
3059
3281
|
},
|
3282
|
+
"q": {
|
3283
|
+
"numerator": 45359237,
|
3284
|
+
"denominator": 10000000000
|
3285
|
+
},
|
3060
3286
|
"slug": {
|
3061
3287
|
"numerator": 45359237,
|
3062
3288
|
"denominator": 1459390300
|
@@ -3171,6 +3397,10 @@
|
|
3171
3397
|
"numerator": 45359237,
|
3172
3398
|
"denominator": 1600000000000
|
3173
3399
|
},
|
3400
|
+
"q": {
|
3401
|
+
"numerator": 45359237,
|
3402
|
+
"denominator": 160000000000
|
3403
|
+
},
|
3174
3404
|
"slug": {
|
3175
3405
|
"numerator": 45359237,
|
3176
3406
|
"denominator": 23350244800
|
@@ -24,11 +24,11 @@ class MeasuredValidator < ActiveModel::EachValidator
|
|
24
24
|
return unless measurable_unit_name.present? || measurable_value.present?
|
25
25
|
|
26
26
|
measurable_unit = measured_class.unit_system.unit_for(measurable_unit_name)
|
27
|
-
record.errors.add(attribute, message(record, "is not a valid unit")) unless measurable_unit
|
27
|
+
record.errors.add(attribute, :invalid, message: message(record, "is not a valid unit")) unless measurable_unit
|
28
28
|
|
29
29
|
if options[:units] && measurable_unit.present?
|
30
30
|
valid_units = Array(options[:units]).map { |unit| measured_class.unit_system.unit_for(unit) }
|
31
|
-
record.errors.add(attribute, message(record, "is not a valid unit")) unless valid_units.include?(measurable_unit)
|
31
|
+
record.errors.add(attribute, :invalid, message: message(record, "is not a valid unit")) unless valid_units.include?(measurable_unit)
|
32
32
|
end
|
33
33
|
|
34
34
|
if measurable_unit && measurable_value.present?
|
@@ -36,7 +36,7 @@ class MeasuredValidator < ActiveModel::EachValidator
|
|
36
36
|
comparable_value = value_for(value, record)
|
37
37
|
comparable_value = measured_class.new(comparable_value, measurable_unit) unless comparable_value.is_a?(Measured::Measurable)
|
38
38
|
unless measurable.public_send(CHECKS[option], comparable_value)
|
39
|
-
record.errors.add(attribute, message(record, "#{measurable.to_s} must be #{CHECKS[option]} #{comparable_value}"))
|
39
|
+
record.errors.add(attribute, option, message: message(record, "#{measurable.to_s} must be #{CHECKS[option]} #{comparable_value}"))
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -2,7 +2,8 @@
|
|
2
2
|
Measured::Weight = Measured.build do
|
3
3
|
si_unit :g, aliases: [:gram, :grams, :gm, :gms]
|
4
4
|
|
5
|
-
unit :t, value: "1000 kg", aliases: [:metric_ton, :metric_tons]
|
5
|
+
unit :t, value: "1000 kg", aliases: [:metric_ton, :metric_tons, :tonne, :tonnes]
|
6
|
+
unit :q, value: "100 kg", aliases: [:quintal, :quintals]
|
6
7
|
unit :slug, value: "14.593903 kg", aliases: [:slugs]
|
7
8
|
unit :N, value: "0.10197162129779283 kg", aliases: [:newtons, :newton]
|
8
9
|
unit :long_ton, value: "2240 lb", aliases: [:long_tons, :weight_ton, :weight_tons, 'W/T', :imperial_ton, :imperial_tons, :displacement_ton, :displacement_tons]
|
data/lib/measured/version.rb
CHANGED
data/measured.gemspec
CHANGED
@@ -36,6 +36,6 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_development_dependency "mocha", ">= 1.4.0"
|
37
37
|
spec.add_development_dependency "pry"
|
38
38
|
spec.add_development_dependency "combustion"
|
39
|
-
spec.add_development_dependency "sqlite3", "
|
39
|
+
spec.add_development_dependency "sqlite3", "> 1.4"
|
40
40
|
spec.add_development_dependency "tapioca"
|
41
41
|
end
|
@@ -39,6 +39,12 @@ class Measured::Rails::ValidationTest < ActiveSupport::TestCase
|
|
39
39
|
assert_equal ["Length is not a valid unit"], thing.errors.full_messages
|
40
40
|
end
|
41
41
|
|
42
|
+
test "validation sets error codes when unit is invalid" do
|
43
|
+
thing.length_unit = "junk"
|
44
|
+
refute thing.valid?
|
45
|
+
assert thing.errors.of_kind?(:length, :invalid)
|
46
|
+
end
|
47
|
+
|
42
48
|
test "validation can override the message with a static string" do
|
43
49
|
thing.length_message_unit = "junk"
|
44
50
|
refute thing.valid?
|
@@ -181,6 +187,28 @@ class Measured::Rails::ValidationTest < ActiveSupport::TestCase
|
|
181
187
|
refute thing.valid?
|
182
188
|
end
|
183
189
|
|
190
|
+
test "validation for numericality puts the proper error types" do
|
191
|
+
thing.length_numericality_inclusive_value = 5
|
192
|
+
refute thing.valid?
|
193
|
+
assert thing.errors.of_kind?(:length_numericality_inclusive, :greater_than_or_equal_to)
|
194
|
+
|
195
|
+
thing.length_numericality_inclusive_value = 25
|
196
|
+
refute thing.valid?
|
197
|
+
assert thing.errors.of_kind?(:length_numericality_inclusive, :less_than_or_equal_to)
|
198
|
+
|
199
|
+
thing.length_numericality_exclusive_value = 2
|
200
|
+
refute thing.valid?
|
201
|
+
assert thing.errors.of_kind?(:length_numericality_exclusive, :greater_than)
|
202
|
+
|
203
|
+
thing.length_numericality_exclusive_value = 550
|
204
|
+
refute thing.valid?
|
205
|
+
assert thing.errors.of_kind?(:length_numericality_exclusive, :less_than)
|
206
|
+
|
207
|
+
thing.length_numericality_equality_value = 200
|
208
|
+
refute thing.valid?
|
209
|
+
assert thing.errors.of_kind?(:length_numericality_equality, :equal_to)
|
210
|
+
end
|
211
|
+
|
184
212
|
test "validation for numericality handles a nil unit but a valid value" do
|
185
213
|
thing.length_numericality_exclusive_unit = nil
|
186
214
|
thing.length_numericality_exclusive_value = 1
|
data/test/units/weight_test.rb
CHANGED
@@ -25,6 +25,11 @@ class Measured::WeightTest < ActiveSupport::TestCase
|
|
25
25
|
long_tons
|
26
26
|
metric_ton
|
27
27
|
metric_tons
|
28
|
+
tonne
|
29
|
+
tonnes
|
30
|
+
q
|
31
|
+
quintal
|
32
|
+
quintals
|
28
33
|
newton
|
29
34
|
newtons
|
30
35
|
ounce
|
@@ -48,7 +53,7 @@ class Measured::WeightTest < ActiveSupport::TestCase
|
|
48
53
|
end
|
49
54
|
|
50
55
|
test ".unit_names should be the list of base unit names" do
|
51
|
-
expected_units = %w(N g lb long_ton oz short_ton slug t)
|
56
|
+
expected_units = %w(N g lb long_ton oz short_ton slug t q)
|
52
57
|
expected_units += Measured::UnitSystemBuilder::SI_PREFIXES.map { |short, _, _| "#{short}g" }
|
53
58
|
assert_equal expected_units.sort, Measured::Weight.unit_names
|
54
59
|
end
|
@@ -98,6 +103,10 @@ class Measured::WeightTest < ActiveSupport::TestCase
|
|
98
103
|
assert_exact_conversion Measured::Weight, "2000 g", "0.002 t"
|
99
104
|
end
|
100
105
|
|
106
|
+
test ".convert_to from g to q" do
|
107
|
+
assert_exact_conversion Measured::Weight, "2000 g", "0.02 q"
|
108
|
+
end
|
109
|
+
|
101
110
|
test ".convert_to from kg to g" do
|
102
111
|
assert_exact_conversion Measured::Weight, "2000 kg", "2000000 g"
|
103
112
|
end
|
@@ -134,6 +143,10 @@ class Measured::WeightTest < ActiveSupport::TestCase
|
|
134
143
|
assert_exact_conversion Measured::Weight, "2000 kg", "2 t"
|
135
144
|
end
|
136
145
|
|
146
|
+
test ".convert_to from kg to q" do
|
147
|
+
assert_exact_conversion Measured::Weight, "2000 kg", "20 q"
|
148
|
+
end
|
149
|
+
|
137
150
|
test ".convert_to from lb to g" do
|
138
151
|
assert_exact_conversion Measured::Weight, "2000 lb", "907184.74 g"
|
139
152
|
end
|
@@ -170,6 +183,10 @@ class Measured::WeightTest < ActiveSupport::TestCase
|
|
170
183
|
assert_conversion Measured::Weight, "2000 lb", "0.90718474 t"
|
171
184
|
end
|
172
185
|
|
186
|
+
test ".convert_to from lb to q" do
|
187
|
+
assert_conversion Measured::Weight, "2000 lb", "9.0718474 q"
|
188
|
+
end
|
189
|
+
|
173
190
|
test ".convert_to from oz to g" do
|
174
191
|
assert_conversion Measured::Weight, "2000 oz", "56699.04625 g"
|
175
192
|
end
|
@@ -206,6 +223,10 @@ class Measured::WeightTest < ActiveSupport::TestCase
|
|
206
223
|
assert_conversion Measured::Weight, "2000 oz", "0.05669904625 t"
|
207
224
|
end
|
208
225
|
|
226
|
+
test ".convert_to from oz to q" do
|
227
|
+
assert_conversion Measured::Weight, "2000 oz", "0.5669904625 q"
|
228
|
+
end
|
229
|
+
|
209
230
|
test ".convert_to from slug to g" do
|
210
231
|
assert_conversion Measured::Weight, "2000 slug", "29187806 g"
|
211
232
|
end
|
@@ -242,6 +263,10 @@ class Measured::WeightTest < ActiveSupport::TestCase
|
|
242
263
|
assert_conversion Measured::Weight, "2000 slug", "29.187806 t"
|
243
264
|
end
|
244
265
|
|
266
|
+
test ".convert_to from slug to q" do
|
267
|
+
assert_conversion Measured::Weight, "2000 slug", "291.87806 q"
|
268
|
+
end
|
269
|
+
|
245
270
|
test ".convert_to from short_ton to g" do
|
246
271
|
assert_conversion Measured::Weight, "2000 short_ton", "1814369480 g"
|
247
272
|
end
|
@@ -278,6 +303,10 @@ class Measured::WeightTest < ActiveSupport::TestCase
|
|
278
303
|
assert_conversion Measured::Weight, "2000 short_ton", "1814.36948 t"
|
279
304
|
end
|
280
305
|
|
306
|
+
test ".convert_to from short_ton to q" do
|
307
|
+
assert_conversion Measured::Weight, "2000 short_ton", "18143.6948 q"
|
308
|
+
end
|
309
|
+
|
281
310
|
test ".convert_to from long_ton to g" do
|
282
311
|
assert_conversion Measured::Weight, "2000 long_ton", "2032093817.6 g"
|
283
312
|
end
|
@@ -314,6 +343,10 @@ class Measured::WeightTest < ActiveSupport::TestCase
|
|
314
343
|
assert_conversion Measured::Weight, "2000 long_ton", "2032.0938176 t"
|
315
344
|
end
|
316
345
|
|
346
|
+
test ".convert_to from long_ton to q" do
|
347
|
+
assert_conversion Measured::Weight, "2000 long_ton", "20320.938176 q"
|
348
|
+
end
|
349
|
+
|
317
350
|
test ".convert_to from N to g" do
|
318
351
|
assert_conversion Measured::Weight, "2000 N", "203943.24259558567 g"
|
319
352
|
end
|
@@ -350,6 +383,10 @@ class Measured::WeightTest < ActiveSupport::TestCase
|
|
350
383
|
assert_conversion Measured::Weight, "2000 N", "0.2039432425955857 t"
|
351
384
|
end
|
352
385
|
|
386
|
+
test ".convert_to from N to q" do
|
387
|
+
assert_conversion Measured::Weight, "2000 N", "2.039432425955857 q"
|
388
|
+
end
|
389
|
+
|
353
390
|
test ".convert_to from t to g" do
|
354
391
|
assert_exact_conversion Measured::Weight, "2000 t", "2000000000 g"
|
355
392
|
end
|
@@ -377,4 +414,40 @@ class Measured::WeightTest < ActiveSupport::TestCase
|
|
377
414
|
test ".convert_to from t to t" do
|
378
415
|
assert_conversion Measured::Weight, "2000 t", "2000 t"
|
379
416
|
end
|
417
|
+
|
418
|
+
test ".convert_to from t to q" do
|
419
|
+
assert_conversion Measured::Weight, "2000 t", "20000 q"
|
420
|
+
end
|
421
|
+
|
422
|
+
test ".convert_to from q to g" do
|
423
|
+
assert_exact_conversion Measured::Weight, "2000 q", "200000000 g"
|
424
|
+
end
|
425
|
+
|
426
|
+
test ".convert_to from q to kg" do
|
427
|
+
assert_exact_conversion Measured::Weight, "2000 q", "200000 kg"
|
428
|
+
end
|
429
|
+
|
430
|
+
test ".convert_to from q to lb" do
|
431
|
+
assert_conversion Measured::Weight, "2000 q", "440924.5243697552 lb"
|
432
|
+
end
|
433
|
+
|
434
|
+
test ".convert_to from q to oz" do
|
435
|
+
assert_conversion Measured::Weight, "2000 q", "7054792.389916082 oz"
|
436
|
+
end
|
437
|
+
|
438
|
+
test ".convert_to from q to slug" do
|
439
|
+
assert_conversion Measured::Weight, "2000 q", "13704.35311239221 slug"
|
440
|
+
end
|
441
|
+
|
442
|
+
test ".convert_to from q to short_ton" do
|
443
|
+
assert_conversion Measured::Weight, "2000 q", "220.4622621848 short_ton"
|
444
|
+
end
|
445
|
+
|
446
|
+
test ".convert_to from q to t" do
|
447
|
+
assert_conversion Measured::Weight, "2000 q", "200 t"
|
448
|
+
end
|
449
|
+
|
450
|
+
test ".convert_to from q to q" do
|
451
|
+
assert_conversion Measured::Weight, "2000 q", "2000 q"
|
452
|
+
end
|
380
453
|
end
|
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: measured
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin McPhillips
|
8
8
|
- Jason Gedge
|
9
9
|
- Javier Honduvilla Coto
|
10
|
-
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2025-01-28 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: activesupport
|
@@ -114,14 +113,14 @@ dependencies:
|
|
114
113
|
name: sqlite3
|
115
114
|
requirement: !ruby/object:Gem::Requirement
|
116
115
|
requirements:
|
117
|
-
- - "
|
116
|
+
- - ">"
|
118
117
|
- !ruby/object:Gem::Version
|
119
118
|
version: '1.4'
|
120
119
|
type: :development
|
121
120
|
prerelease: false
|
122
121
|
version_requirements: !ruby/object:Gem::Requirement
|
123
122
|
requirements:
|
124
|
-
- - "
|
123
|
+
- - ">"
|
125
124
|
- !ruby/object:Gem::Version
|
126
125
|
version: '1.4'
|
127
126
|
- !ruby/object:Gem::Dependency
|
@@ -146,8 +145,10 @@ executables: []
|
|
146
145
|
extensions: []
|
147
146
|
extra_rdoc_files: []
|
148
147
|
files:
|
148
|
+
- ".github/dependabot.yml"
|
149
149
|
- ".github/workflows/ci.yml"
|
150
150
|
- ".github/workflows/cla.yml"
|
151
|
+
- ".github/workflows/dependabot_auto_merge.yml"
|
151
152
|
- ".gitignore"
|
152
153
|
- ".ruby-version"
|
153
154
|
- CHANGELOG.md
|
@@ -160,9 +161,8 @@ files:
|
|
160
161
|
- cache/volume.json
|
161
162
|
- cache/weight.json
|
162
163
|
- dev.yml
|
163
|
-
- gemfiles/rails-6.0.gemfile
|
164
|
-
- gemfiles/rails-6.1.gemfile
|
165
164
|
- gemfiles/rails-7.0.gemfile
|
165
|
+
- gemfiles/rails-7.1.gemfile
|
166
166
|
- gemfiles/rails-edge.gemfile
|
167
167
|
- lib/measured.rb
|
168
168
|
- lib/measured/arithmetic.rb
|
@@ -226,7 +226,6 @@ licenses:
|
|
226
226
|
- MIT
|
227
227
|
metadata:
|
228
228
|
allowed_push_host: https://rubygems.org
|
229
|
-
post_install_message:
|
230
229
|
rdoc_options: []
|
231
230
|
require_paths:
|
232
231
|
- lib
|
@@ -241,8 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
240
|
- !ruby/object:Gem::Version
|
242
241
|
version: '0'
|
243
242
|
requirements: []
|
244
|
-
rubygems_version: 3.
|
245
|
-
signing_key:
|
243
|
+
rubygems_version: 3.6.3
|
246
244
|
specification_version: 4
|
247
245
|
summary: Encapsulate measurements with their units in Ruby
|
248
246
|
test_files:
|
data/gemfiles/rails-6.0.gemfile
DELETED