fiber_gauge 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25d259fdeeefe459f749e0da135112ed0fe79abcc93e6be92f673db1a55b849c
4
- data.tar.gz: 72b16c3b65885143b9be6d612b331239160517a095b756b7c8e41ec74ce78233
3
+ metadata.gz: 76c21901398021db14bd4545f0d0ff1f1592e282d04ad1763b62ff156e2cdbef
4
+ data.tar.gz: 3427f86e819ca1797f8250fdeb098c7ce3c50b158b8baf584cfc6ca3e59f5fc6
5
5
  SHA512:
6
- metadata.gz: 10e93cae9df207be9262454c7bdc1f97f342a1d2e23828b3cbd471290b8f4f8c4345cda2adf9eb545e0cbcb77c4e9b543ae093f9ac97d808d9ade47494ce6a7f
7
- data.tar.gz: bd4d73e5aacfef81e5b675f8da6c1e44dea1dde52439e943a27be05d5ef9de33aca1a6d0f9aa78931108b2ac6a4df20fc482cf019d1595298da01827cb9f410b
6
+ metadata.gz: e8dea9809ae9e3c8696d65062ed7c5ab369dea05e4e257ab83288b11de40acd306882c5d00c90915363e0adcb5264e35521e0f673a4a052ed4e253471a7795bf
7
+ data.tar.gz: f83c6ab4e51783a919b40581aee9bd9af31f1a33fb9f013acad1a145a6bc0aff65d13dabaa2b1bebbf6c3baca97e9a1500a8d70cd171afd9796f128bbfced602
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  ## [Unreleased]
2
2
 
3
+
4
+ ## [0.2.0] - 2026-03-21
5
+
6
+ ### Added
7
+ - Optional `height:` parameter on `Gauge.new` (defaults to `width`)
8
+ - `rpi` now uses `height`; `spi` continues to use `width`
9
+ - `required_rows` method for calculating row count from a target length
10
+
3
11
  ## [0.1.0] - 2026-03-14
4
12
 
13
+ ### Changed
14
+ - GitHub Actions now publishes on version tag pushes and creates a matching GitHub release
15
+ ### Added
5
16
  - Initial release
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
3
+ require "rake/testtask"
5
4
 
6
- RSpec::Core::RakeTask.new(:spec)
5
+ Rake::TestTask.new do |t|
6
+ t.libs << "test"
7
+ t.pattern = "test/**/*_test.rb"
8
+ end
7
9
 
8
- require "standard/rake"
9
-
10
- task default: %i[spec standard]
10
+ task default: :test
@@ -1,11 +1,12 @@
1
1
  module FiberGauge
2
2
  class Gauge
3
- attr_reader :stitches, :rows, :width
3
+ attr_reader :stitches, :rows, :width, :height
4
4
 
5
- def initialize(stitches:, rows:, width:)
5
+ def initialize(stitches:, rows:, width:, height: width)
6
6
  @stitches = stitches
7
7
  @rows = rows
8
8
  @width = width
9
+ @height = height
9
10
  end
10
11
 
11
12
  def spi
@@ -13,7 +14,7 @@ module FiberGauge
13
14
  end
14
15
 
15
16
  def rpi
16
- rows.value / width.to(:inches).value
17
+ rows.value / height.to(:inches).value
17
18
  end
18
19
 
19
20
  def width_for_stitches(stitch_count)
@@ -29,5 +30,12 @@ module FiberGauge
29
30
 
30
31
  count.stitches
31
32
  end
33
+
34
+ def required_rows(length)
35
+ inches = length.to(:inches).value
36
+ count = (inches * rpi).round
37
+
38
+ count.rows
39
+ end
32
40
  end
33
41
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :nocov:
3
4
  module FiberGauge
4
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
5
6
  end
7
+ # :nocov:
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class FiberGaugeGaugeTest < Minitest::Test
6
+ def gauge
7
+ FiberGauge::Gauge.new(
8
+ stitches: 18.stitches,
9
+ rows: 24.rows,
10
+ width: 4.inches
11
+ )
12
+ end
13
+
14
+ # -----------------------------
15
+ # initialization
16
+ # -----------------------------
17
+
18
+ def test_initialization_stores_values
19
+ g = gauge
20
+
21
+ assert_equal 18, g.stitches.value
22
+ assert_equal 24, g.rows.value
23
+ assert_equal 4.inches, g.width
24
+ assert_equal 4.inches, g.height
25
+ end
26
+
27
+ def test_initialization_with_separate_height
28
+ g = FiberGauge::Gauge.new(
29
+ stitches: 18.stitches,
30
+ rows: 24.rows,
31
+ width: 4.inches,
32
+ height: 5.inches
33
+ )
34
+
35
+ assert_equal 4.inches, g.width
36
+ assert_equal 5.inches, g.height
37
+ end
38
+
39
+ # -----------------------------
40
+ # spi
41
+ # -----------------------------
42
+
43
+ def test_calculates_spi
44
+ assert_equal 4.5, gauge.spi.round(2)
45
+ end
46
+
47
+ # -----------------------------
48
+ # rpi
49
+ # -----------------------------
50
+
51
+ def test_calculates_rpi
52
+ assert_equal 6, gauge.rpi
53
+ end
54
+
55
+ def test_calculates_rpi_with_separate_height
56
+ g = FiberGauge::Gauge.new(
57
+ stitches: 18.stitches,
58
+ rows: 24.rows,
59
+ width: 4.inches,
60
+ height: 6.inches
61
+ )
62
+
63
+ assert_in_delta 4.0, g.rpi, 0.001
64
+ assert_equal 4.5, g.spi.round(2)
65
+ end
66
+
67
+ # -----------------------------
68
+ # width_for_stitches
69
+ # -----------------------------
70
+
71
+ def test_calculates_width_for_stitches
72
+ width = gauge.width_for_stitches(90.stitches)
73
+
74
+ assert_equal 20.inches, width
75
+ end
76
+
77
+ # -----------------------------
78
+ # required_stitches
79
+ # -----------------------------
80
+
81
+ def test_calculates_required_stitches_for_width
82
+ stitches = gauge.required_stitches(20.inches)
83
+
84
+ assert_equal 90.stitches, stitches
85
+ end
86
+
87
+ # -----------------------------
88
+ # required_rows
89
+ # -----------------------------
90
+
91
+ def test_calculates_required_rows_for_height
92
+ rows = gauge.required_rows(10.inches)
93
+
94
+ assert_equal 60.rows, rows
95
+ end
96
+
97
+ def test_calculates_required_rows_for_metric_height
98
+ rows = gauge.required_rows(25.4.centimeters)
99
+
100
+ assert_equal 60.rows, rows
101
+ end
102
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "simplecov"
4
+ require "simplecov-json"
5
+
6
+ require "bundler/setup"
7
+ require "fiber_gauge"
8
+
9
+ require "minitest/autorun"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fiber_gauge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meagan Waller
@@ -13,16 +13,30 @@ dependencies:
13
13
  name: fiber_units
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
- - - "~>"
16
+ - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 0.3.1
18
+ version: '0.1'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
- - - "~>"
23
+ - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: 0.3.1
25
+ version: '0.1'
26
+ - !ruby/object:Gem::Dependency
27
+ name: minitest
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
26
40
  description: FiberGauge is a Ruby gem that provides tools to measure and analyze fiber
27
41
  usage in Ruby applications.
28
42
  email:
@@ -31,11 +45,6 @@ executables: []
31
45
  extensions: []
32
46
  extra_rdoc_files: []
33
47
  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
48
  - CHANGELOG.md
40
49
  - CODE_OF_CONDUCT.md
41
50
  - LICENSE
@@ -45,6 +54,8 @@ files:
45
54
  - lib/fiber_gauge/gauge.rb
46
55
  - lib/fiber_gauge/version.rb
47
56
  - sig/fiber_gauge.rbs
57
+ - test/gauge_test.rb
58
+ - test/test_helper.rb
48
59
  homepage: https://github.com/meaganewaller/fiber_gauge
49
60
  licenses:
50
61
  - MIT
@@ -66,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
77
  - !ruby/object:Gem::Version
67
78
  version: '0'
68
79
  requirements: []
69
- rubygems_version: 4.0.3
80
+ rubygems_version: 3.6.9
70
81
  specification_version: 4
71
82
  summary: A gem for measuring fiber usage in Ruby applications.
72
83
  test_files: []
@@ -1,8 +0,0 @@
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 DELETED
@@ -1,10 +0,0 @@
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
@@ -1,37 +0,0 @@
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
@@ -1,25 +0,0 @@
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 }}
@@ -1,35 +0,0 @@
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