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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a30a55cccff750bceb89411ea9fcbddd1112c8e45b1362488a9699ce45d8b2ad
4
- data.tar.gz: 4dc63be3bf00dfec4ecf378edf56e6de8839e90a3d669d6a0254aa0ea8995f42
3
+ metadata.gz: 033c38e7c14b748ea7223f525d9b22874b3dfa962fae4a05f58f271562168172
4
+ data.tar.gz: fa79944e0879179001592fb38eba803f418b7d66adf0ea7e88e36fc9f6f655c8
5
5
  SHA512:
6
- metadata.gz: 8f591d7a61f69f612803a03578db33e6de0ba8e2e6a08a0379cb44095d1d52cf38b06de896aec11390ef142657c5f9e3c1d8cda3bf505053a0c5dcddc5abcfa0
7
- data.tar.gz: 4c90dcfc86246d1fd89b8ea08657a9a1a182449ce535c2ee9669e452df3402f4b5c6111ebcae227549ad1e3959b10281d0f4a2dafd3835725615fae7198534c9
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
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013-2022 Andrew Kane
1
+ Copyright (c) 2013-2025 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
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
- [![Build Status](https://github.com/ankane/plu/workflows/build/badge.svg?branch=master)](https://github.com/ankane/plu/actions)
11
+ [![Build Status](https://github.com/ankane/plu/actions/workflows/build.yml/badge.svg)](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
@@ -1,3 +1,3 @@
1
1
  class PLU
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.1"
3
3
  end
data/lib/plu.rb CHANGED
@@ -1,4 +1,8 @@
1
- require "csv"
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 ||= begin
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