fiber_gauge 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 25d259fdeeefe459f749e0da135112ed0fe79abcc93e6be92f673db1a55b849c
4
+ data.tar.gz: 72b16c3b65885143b9be6d612b331239160517a095b756b7c8e41ec74ce78233
5
+ SHA512:
6
+ metadata.gz: 10e93cae9df207be9262454c7bdc1f97f342a1d2e23828b3cbd471290b8f4f8c4345cda2adf9eb545e0cbcb77c4e9b543ae093f9ac97d808d9ade47494ce6a7f
7
+ data.tar.gz: bd4d73e5aacfef81e5b675f8da6c1e44dea1dde52439e943a27be05d5ef9de33aca1a6d0f9aa78931108b2ac6a4df20fc482cf019d1595298da01827cb9f410b
@@ -0,0 +1,8 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "04:00"
8
+ open-pull-requests-limit: 10
data/.github/stale.yml ADDED
@@ -0,0 +1,10 @@
1
+ daysUntilStale: 120
2
+ daysUntilClose: 7
3
+ exemptLabels:
4
+ - security
5
+ staleLabel: wontfix
6
+ markComment: >
7
+ This issue has been automatically marked as stale because it has not had
8
+ recent activity. It will be closed if no further activity occurs. Thank you
9
+ for your contributions.
10
+ only: pulls
@@ -0,0 +1,37 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ tags-ignore:
8
+ - 'v*'
9
+ pull_request:
10
+ branches:
11
+ - 'main'
12
+ schedule:
13
+ - cron: '5 12,15,18 * * 1-5'
14
+
15
+ jobs:
16
+ test:
17
+ runs-on: ubuntu-latest
18
+ env:
19
+ BUNDLE_WITHOUT: ""
20
+ if: github.repository == 'meaganewaller/fiber_gauge'
21
+ strategy:
22
+ matrix:
23
+ ruby-version: ['3.4', '4.0']
24
+
25
+ steps:
26
+ - uses: actions/checkout@v6
27
+ - name: Use Ruby ${{ matrix.ruby-version }}
28
+ uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: ${{ matrix.ruby-version }}
31
+ bundler-cache: true
32
+
33
+ - name: Run Standard
34
+ run: bin/standardrb
35
+
36
+ - name: Run RSpec
37
+ run: bin/rspec --format documentation
@@ -0,0 +1,25 @@
1
+ name: Dependabot Auto-Merge
2
+ on: pull_request
3
+
4
+ permissions:
5
+ contents: write
6
+ pull-requests: write
7
+
8
+ jobs:
9
+ dependabot:
10
+ runs-on: ubuntu-latest
11
+ if: github.actor == 'dependabot[bot]'
12
+ steps:
13
+ - name: Dependabot metadata
14
+ id: metadata
15
+ uses: dependabot/fetch-metadata@v2
16
+ with:
17
+ github-token: "${{ secrets.GITHUB_TOKEN }}"
18
+
19
+ - name: Enable auto-merge for Dependabot PRs
20
+ # auto merge only patch and minor updates, not major updates
21
+ if: steps.metadata.outputs.update_type != 'version-update:semver-major'
22
+ run: gh pr merge --auto --squash "$PR_URL"
23
+ env:
24
+ PR_URL: ${{ github.event.pull_request.html_url }}
25
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,35 @@
1
+ name: Release new version of FiberGauge
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ jobs:
9
+ release:
10
+ name: Release gem to RubyGems.org
11
+ runs-on: ubuntu-latest
12
+
13
+ permissions:
14
+ id-token: write
15
+ contents: write
16
+
17
+ steps:
18
+ - uses: actions/checkout@v6
19
+ with:
20
+ persist-credentials: false
21
+
22
+ - name: Set up Ruby
23
+ uses: ruby/setup-ruby@v1
24
+ with:
25
+ bundler-cache: true
26
+ ruby-version: ruby
27
+
28
+ # Release
29
+ - name: Release gem
30
+ uses: rubygems/release-gem@v1
31
+
32
+ - name: Create GitHub Release
33
+ uses: softprops/action-gh-release@v2
34
+ with:
35
+ generate_release_notes: true
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2026-03-14
4
+
5
+ - Initial release
@@ -0,0 +1,10 @@
1
+ # Code of Conduct
2
+
3
+ "fiber_gauge" follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
4
+
5
+ * Participants will be tolerant of opposing views.
6
+ * Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
7
+ * When interpreting the words and actions of others, participants should always assume good intentions.
8
+ * Behaviour which can be reasonably considered harassment will not be tolerated.
9
+
10
+ If you have any concerns about behaviour within this project, please contact us at ["TODO: Write your email address"](mailto:"TODO: Write your email address").
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Meagan Waller
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,171 @@
1
+ # fiber_gauge
2
+
3
+ A Ruby library for **knitting and crochet gauge calculations**.
4
+
5
+ `fiber_gauge` models gauge swatches and provides helpers for converting between:
6
+
7
+ * stitches
8
+ * rows
9
+ * width
10
+ * height
11
+
12
+ This allows you to perform the core math required for **pattern sizing, swatch calculations, and garment scaling**.
13
+
14
+ The gem integrates with **[`fiber_units`](https://github.com/meaganewaller/fiber_units)**, which provides typed units for measurements and counts.
15
+
16
+ # Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ ```ruby
21
+ gem "fiber_gauge"
22
+ ```
23
+
24
+ And then execute:
25
+
26
+ ```
27
+ bundle install
28
+ ```
29
+
30
+ Or install it directly:
31
+
32
+ ```
33
+ gem install fiber_gauge
34
+ ```
35
+
36
+ # Dependencies
37
+
38
+ `fiber_gauge` expects `fiber_units` to be installed.
39
+
40
+ `fiber_units` provides the domain primitives used throughout the API:
41
+
42
+ ```
43
+ 10.stitches
44
+ 24.rows
45
+ 4.inches
46
+ 10.centimeters
47
+ ```
48
+
49
+ # Basic Usage
50
+
51
+ A gauge swatch is defined by:
52
+
53
+ * stitch count
54
+ * row count
55
+ * swatch width
56
+
57
+ Example swatch:
58
+
59
+ ```
60
+ 18 stitches over 4 inches
61
+ 24 rows over 4 inches
62
+ ```
63
+
64
+ Create a gauge object:
65
+
66
+ ```ruby
67
+ gauge = FiberGauge::Gauge.new(
68
+ stitches: 18.stitches,
69
+ rows: 24.rows,
70
+ width: 4.inches
71
+ )
72
+ ```
73
+
74
+ # Stitches Per Inch
75
+
76
+ ```ruby
77
+ gauge.spi
78
+ # => 4.5
79
+ ```
80
+
81
+ # Rows Per Inch
82
+
83
+ ```ruby
84
+ gauge.rpi
85
+ # => 6
86
+ ```
87
+
88
+ # Calculate Width From Stitch Count
89
+
90
+ Determine how wide a piece will be given a stitch count.
91
+
92
+ ```ruby
93
+ gauge.width_for_stitches(90.stitches)
94
+ # => 20 inches
95
+ ```
96
+
97
+ # Calculate Height From Row Count
98
+
99
+ ```ruby
100
+ gauge.height_for_rows(60.rows)
101
+ # => 10 inches
102
+ ```
103
+
104
+ # Calculate Required Stitches
105
+
106
+ Determine how many stitches are needed to reach a target width.
107
+
108
+ ```ruby
109
+ gauge.required_stitches(20.inches)
110
+ # => 90 stitches
111
+ ```
112
+
113
+ # Calculate Required Rows
114
+
115
+ ```ruby
116
+ gauge.required_rows(10.inches)
117
+ # => 60 rows
118
+ ```
119
+
120
+ # Unit Conversion
121
+
122
+ Because the gem relies on `fiber_units`, you can mix units freely:
123
+
124
+ ```ruby
125
+ gauge = FiberGauge::Gauge.new(
126
+ stitches: 20.stitches,
127
+ rows: 28.rows,
128
+ width: 10.centimeters
129
+ )
130
+
131
+ gauge.required_stitches(40.centimeters)
132
+ ```
133
+
134
+ All calculations are normalized internally.
135
+
136
+ # Example: Sweater Sizing
137
+
138
+ ```ruby
139
+ gauge = FiberGauge::Gauge.new(
140
+ stitches: 18.stitches,
141
+ rows: 24.rows,
142
+ width: 4.inches
143
+ )
144
+
145
+ chest = 38.inches
146
+
147
+ cast_on = gauge.required_stitches(chest)
148
+ # => 171 stitches
149
+ ```
150
+
151
+ # Design Goals
152
+
153
+ `fiber_gauge` is designed to:
154
+
155
+ * model gauge as a **first-class domain object**
156
+ * work naturally with **typed measurement units**
157
+ * enable **pattern math and garment sizing**
158
+ * remain **small and composable**
159
+
160
+ It is intended to integrate with other fiber tools such as:
161
+
162
+ - [fiber_units](https://github.com/meaganewaller/fiber_units)
163
+ - [yarn_skein](https://github.com/meaganewaller/yarn_skein)
164
+
165
+ # Contributing
166
+
167
+ Bug reports and pull requests are welcome.
168
+
169
+ # License
170
+
171
+ MIT License
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "standard/rake"
9
+
10
+ task default: %i[spec standard]
@@ -0,0 +1,33 @@
1
+ module FiberGauge
2
+ class Gauge
3
+ attr_reader :stitches, :rows, :width
4
+
5
+ def initialize(stitches:, rows:, width:)
6
+ @stitches = stitches
7
+ @rows = rows
8
+ @width = width
9
+ end
10
+
11
+ def spi
12
+ stitches.value / width.to(:inches).value
13
+ end
14
+
15
+ def rpi
16
+ rows.value / width.to(:inches).value
17
+ end
18
+
19
+ def width_for_stitches(stitch_count)
20
+ stitches_per_inch = spi
21
+ inches = stitch_count.value / stitches_per_inch
22
+
23
+ inches.inches
24
+ end
25
+
26
+ def required_stitches(length)
27
+ inches = length.to(:inches).value
28
+ count = (inches * spi).round
29
+
30
+ count.stitches
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FiberGauge
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fiber_units"
4
+ require_relative "fiber_gauge/version"
5
+ require_relative "fiber_gauge/gauge"
6
+
7
+ module FiberGauge
8
+ class Error < StandardError; end
9
+ # Your code goes here...
10
+ end
@@ -0,0 +1,4 @@
1
+ module FiberGauge
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fiber_gauge
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Meagan Waller
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: fiber_units
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: 0.3.1
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: 0.3.1
26
+ description: FiberGauge is a Ruby gem that provides tools to measure and analyze fiber
27
+ usage in Ruby applications.
28
+ email:
29
+ - meagan@meaganwaller.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".github/dependabot.yml"
35
+ - ".github/stale.yml"
36
+ - ".github/workflows/ci.yml"
37
+ - ".github/workflows/dependabot-automerge.yml"
38
+ - ".github/workflows/release.yml"
39
+ - CHANGELOG.md
40
+ - CODE_OF_CONDUCT.md
41
+ - LICENSE
42
+ - README.md
43
+ - Rakefile
44
+ - lib/fiber_gauge.rb
45
+ - lib/fiber_gauge/gauge.rb
46
+ - lib/fiber_gauge/version.rb
47
+ - sig/fiber_gauge.rbs
48
+ homepage: https://github.com/meaganewaller/fiber_gauge
49
+ licenses:
50
+ - MIT
51
+ metadata:
52
+ homepage_uri: https://github.com/meaganewaller/fiber_gauge
53
+ source_code_uri: https://github.com/meaganewaller/fiber_gauge
54
+ changelog_uri: https://github.com/meaganewaller/fiber_gauge/blob/main/CHANGELOG.md
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 3.2.0
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubygems_version: 4.0.3
70
+ specification_version: 4
71
+ summary: A gem for measuring fiber usage in Ruby applications.
72
+ test_files: []