lighterpack-parser 1.0.0 → 1.0.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: 85fed15af6ad0ccfbba49c9960cf80e47fee71cbdce5166746e5788df489127d
4
- data.tar.gz: dbf4da779516e9ba651846a1457fcdfa52142313643235f5cbc7500778d9baec
3
+ metadata.gz: b692835b5b950b2892cc8ea192966625ff52d5237ff94715b9c63689ccb9cec4
4
+ data.tar.gz: dbff07f7be838fcc24a04d116d359bc880cb59aa5992434abf904262247d206d
5
5
  SHA512:
6
- metadata.gz: 1e35ae9d5211815cef892b469d26e4e79163698465e2b213e8f394a0d2f9546ddc007e7a182684513aff24579281fe719581d3156c3fc6323134f48af2d6067f
7
- data.tar.gz: c90687504af99ace152a1bf2749362d70d004e37e3cd9baf50aee6adbe0fbce4869ba57ea7b6b7b74b617a6bac7ece5954dc4fe1c2e365377ffc110711efb8bb
6
+ metadata.gz: 3defc27122c9cf2c813e3869f7c5a3ab4172ffe3da706da64de7e6e92d4c771849efadcdabce1af8e2b989dcedd9c91acf14ef6da1c126f873674bc068e4e144
7
+ data.tar.gz: f198b1e0d4c4776f48b178bfdf76fc3281d48e383adf709011eca040d43473b75b74f0a5b76aa748eef2bc0293430e7d4f4cb1d14bb22844e7ac74725e363584
data/README.md CHANGED
@@ -2,41 +2,81 @@
2
2
 
3
3
  A Ruby gem for parsing Lighterpack lists from HTML or URLs.
4
4
 
5
+ Used by [Goulight](https://goulight.com). Source: [github.com/goulight/lighterpack-parser](https://github.com/goulight/lighterpack-parser).
6
+
5
7
  ## Installation
6
8
 
7
- This gem is used as a local dependency in the Packlista project. It's referenced in the backend `Gemfile`:
9
+ Add to your `Gemfile`:
8
10
 
9
11
  ```ruby
10
- gem 'lighterpack_parser', path: '../lighterpack-parser'
12
+ gem 'lighterpack-parser', '~> 1.0'
13
+ ```
14
+
15
+ Then:
16
+
17
+ ```bash
18
+ bundle install
19
+ ```
20
+
21
+ Or install directly:
22
+
23
+ ```bash
24
+ gem install lighterpack-parser
11
25
  ```
12
26
 
13
27
  ## Usage
14
28
 
29
+ `LighterpackParser::Parser#parse` (and `LighterpackParser.parse_url`) return a **`LighterpackParser::List`** object with readers `name`, `description`, and `categories`. Each category is a **`LighterpackParser::Category`**; each item is a **`LighterpackParser::Item`**.
30
+
31
+ Call **`#to_h`** on the list (or on categories/items) if you need nested hashes (for example JSON APIs).
32
+
15
33
  ### Parse from HTML string
16
34
 
17
35
  ```ruby
18
36
  require 'lighterpack_parser'
19
37
 
20
38
  html = File.read('path/to/lighterpack.html')
21
- result = LighterpackParser::Parser.new(html: html).parse
22
-
23
- # Result structure:
24
- # {
39
+ list = LighterpackParser::Parser.new(html: html).parse
40
+
41
+ list.name # => "List Name"
42
+ list.description # => "List description" or nil
43
+ list.categories.first.name # => "Category Name"
44
+
45
+ item = list.categories.first.items.first
46
+ item.name # => "Item Name"
47
+ item.description # => "Item description" or nil
48
+ item.weight # => 476.0 # grams per unit
49
+ item.total_weight # => 476.0 # weight * quantity (grams)
50
+ item.quantity # => 1
51
+ item.image_url # => "https://..." or nil
52
+ item.consumable # => false
53
+ item.total_consumable_weight # => nil (or total grams if consumable)
54
+ item.worn # => false
55
+ item.worn_quantity # => nil (or 1 if worn)
56
+ item.total_worn_weight # => nil (or grams worn, weight × 1)
57
+
58
+ # Hash shape (matches nested #to_h):
59
+ list.to_h
60
+ # => {
25
61
  # name: "List Name",
26
- # description: "List description (optional)",
62
+ # description: nil,
27
63
  # categories: [
28
64
  # {
29
65
  # name: "Category Name",
30
- # description: "Category description (optional)",
66
+ # description: nil,
31
67
  # items: [
32
68
  # {
33
69
  # name: "Item Name",
34
70
  # description: "Item description",
35
- # weight: 476.0, # in grams
71
+ # weight: 476.0,
72
+ # total_weight: 476.0,
36
73
  # quantity: 1,
37
74
  # image_url: "https://...",
38
75
  # consumable: false,
39
- # worn: false
76
+ # total_consumable_weight: nil,
77
+ # worn: false,
78
+ # worn_quantity: nil,
79
+ # total_worn_weight: nil
40
80
  # }
41
81
  # ]
42
82
  # }
@@ -49,11 +89,10 @@ result = LighterpackParser::Parser.new(html: html).parse
49
89
  ```ruby
50
90
  require 'lighterpack_parser'
51
91
 
52
- # Using the parser directly
53
- result = LighterpackParser::Parser.new(url: 'https://lighterpack.com/r/b6q1kr').parse
92
+ list = LighterpackParser::Parser.new(url: 'https://lighterpack.com/r/b6q1kr').parse
54
93
 
55
94
  # Or using the convenience method
56
- result = LighterpackParser.parse_url('https://lighterpack.com/r/b6q1kr')
95
+ list = LighterpackParser.parse_url('https://lighterpack.com/r/b6q1kr')
57
96
  ```
58
97
 
59
98
  ## Running Tests
@@ -66,7 +105,8 @@ rspec
66
105
 
67
106
  ## Test Fixtures
68
107
 
69
- Test fixtures are stored in `test/fixtures/` and contain HTML from example Lighterpack lists:
108
+ Test fixtures are stored in `spec/fixtures/` and contain HTML from example Lighterpack lists:
109
+
70
110
  - `b6q1kr.html` - Ultimate Hike 2025
71
111
  - `adbf7c.html` - Example list 2
72
112
  - `h23rxt.html` - Example list 3
@@ -74,7 +114,7 @@ Test fixtures are stored in `test/fixtures/` and contain HTML from example Light
74
114
  To update fixtures, download fresh HTML:
75
115
 
76
116
  ```bash
77
- curl -s "https://lighterpack.com/r/b6q1kr" > test/fixtures/b6q1kr.html
117
+ curl -s "https://lighterpack.com/r/b6q1kr" > spec/fixtures/b6q1kr.html
78
118
  ```
79
119
 
80
120
  ## Features
@@ -83,17 +123,18 @@ curl -s "https://lighterpack.com/r/b6q1kr" > test/fixtures/b6q1kr.html
83
123
  - Extracts categories with descriptions
84
124
  - Extracts items with:
85
125
  - Name and description
86
- - Weight (automatically converted to grams)
126
+ - Weight per unit and total weight (automatically converted to grams)
87
127
  - Quantity
88
128
  - Image URLs
89
- - Consumable flag
90
- - Worn flag
129
+ - Consumable flag and total consumable weight when applicable
130
+ - Worn flag, worn quantity, and total worn weight when applicable
91
131
  - Supports weight units: oz, lb, g, kg (all converted to grams)
92
132
  - Handles both HTML strings and URLs
93
133
 
94
134
  ## Weight Conversion
95
135
 
96
136
  The parser automatically converts all weights to grams:
137
+
97
138
  - `oz` → multiply by 28.3495
98
139
  - `lb` → multiply by 453.592
99
140
  - `g` → use as-is
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LighterpackParser
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
@@ -10,9 +10,13 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = 'Parser for Lighterpack lists'
12
12
  spec.description = 'Parse Lighterpack HTML to extract list data including categories, items, weights, and metadata'
13
- spec.homepage = 'https://github.com/alex-ross/lighterpack-parser'
13
+ spec.homepage = 'https://github.com/goulight/lighterpack-parser'
14
14
  spec.license = 'MIT'
15
15
 
16
+ spec.metadata = {
17
+ 'source_code_uri' => 'https://github.com/goulight/lighterpack-parser'
18
+ }
19
+
16
20
  spec.required_ruby_version = '>= 3.0'
17
21
 
18
22
  spec.files = Dir['lib/**/*', 'spec/**/*', '*.md', '*.gemspec']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lighterpack-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Packlista Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-02 00:00:00.000000000 Z
11
+ date: 2026-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -77,10 +77,11 @@ files:
77
77
  - spec/fixtures/h23rxt.html
78
78
  - spec/parser_spec.rb
79
79
  - spec/spec_helper.rb
80
- homepage: https://github.com/alex-ross/lighterpack-parser
80
+ homepage: https://github.com/goulight/lighterpack-parser
81
81
  licenses:
82
82
  - MIT
83
- metadata: {}
83
+ metadata:
84
+ source_code_uri: https://github.com/goulight/lighterpack-parser
84
85
  post_install_message:
85
86
  rdoc_options: []
86
87
  require_paths: