plu 0.2.0 → 0.3.1
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 +4 -4
- data/CHANGELOG.md +21 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -2
- data/lib/plu/version.rb +1 -1
- data/lib/plu.rb +7 -10
- data/plu_codes.json +1522 -0
- metadata +5 -9
- data/plu_codes.csv +0 -1521
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 033c38e7c14b748ea7223f525d9b22874b3dfa962fae4a05f58f271562168172
|
4
|
+
data.tar.gz: fa79944e0879179001592fb38eba803f418b7d66adf0ea7e88e36fc9f6f655c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83bc4ac64d258356e5168b18284dfc9cbe3e41ad8520adc30ab3e56eb5da1f844b9224530d12d4baa54dc161236eb54d1faec6b23f0bf3a559927c355330074b
|
7
|
+
data.tar.gz: 4162783069f1b7ee5c634d653b3e720fd7476b742b010631a00b0452abedbcc5717789ec2d1639e9261f2093c9aea784572a884072cfc2bb736192d9abb18348
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 0.3.1 (2025-01-30)
|
2
|
+
|
3
|
+
- Fixed error with missing file
|
4
|
+
- Fixed return type of `valid?` method
|
5
|
+
|
6
|
+
## 0.3.0 (2024-10-23)
|
7
|
+
|
8
|
+
- Dropped support for Ruby < 3.1
|
9
|
+
|
1
10
|
## 0.2.0 (2022-09-03)
|
2
11
|
|
3
12
|
- Added latest PLU codes
|
@@ -7,3 +16,15 @@
|
|
7
16
|
## 0.1.0 (2019-10-08)
|
8
17
|
|
9
18
|
- Added latest PLU codes
|
19
|
+
|
20
|
+
## 0.0.3 (2013-12-30)
|
21
|
+
|
22
|
+
- Added `retailer_assigned?` method
|
23
|
+
|
24
|
+
## 0.0.2 (2013-09-20)
|
25
|
+
|
26
|
+
- Added known PLU codes
|
27
|
+
|
28
|
+
## 0.0.1 (2013-09-18)
|
29
|
+
|
30
|
+
- First release
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
Data cleaned up from the [International Federation of Produce Standards](https://www.ifpsglobal.com/)
|
10
10
|
|
11
|
-
[](https://github.com/ankane/plu/actions)
|
12
12
|
|
13
13
|
## Installation
|
14
14
|
|
@@ -67,7 +67,6 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
|
|
67
67
|
- Fix bugs and [submit pull requests](https://github.com/ankane/plu/pulls)
|
68
68
|
- Write, clarify, or fix documentation
|
69
69
|
- Suggest or add new features
|
70
|
-
- Help clean up [data](https://github.com/ankane/plu/blob/master/plu_codes.csv)
|
71
70
|
|
72
71
|
To get started with development:
|
73
72
|
|
data/lib/plu/version.rb
CHANGED
data/lib/plu.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
|
1
|
+
# stdlib
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
# modules
|
5
|
+
require_relative "plu/version"
|
2
6
|
|
3
7
|
class PLU
|
4
8
|
def initialize(number)
|
@@ -6,7 +10,7 @@ class PLU
|
|
6
10
|
end
|
7
11
|
|
8
12
|
def valid?
|
9
|
-
/\A[89]?[34]\d{3}\z/.match(@number)
|
13
|
+
/\A[89]?[34]\d{3}\z/.match?(@number)
|
10
14
|
end
|
11
15
|
|
12
16
|
def name
|
@@ -21,15 +25,8 @@ class PLU
|
|
21
25
|
name.to_s.start_with?("Retailer Assigned")
|
22
26
|
end
|
23
27
|
|
24
|
-
# TODO more items
|
25
28
|
def self.all
|
26
|
-
@all ||=
|
27
|
-
all = {}
|
28
|
-
CSV.foreach File.expand_path("../../plu_codes.csv", __FILE__), headers: true do |row|
|
29
|
-
all[row["PLU Code"]] = row["Name"]
|
30
|
-
end
|
31
|
-
all
|
32
|
-
end
|
29
|
+
@all ||= JSON.load_file(File.expand_path("../plu_codes.json", __dir__))
|
33
30
|
end
|
34
31
|
|
35
32
|
protected
|