vector2d 2.2.4 → 2.3.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: fc16e15dbb07e3fe138a13fdc3cc8edd6c1369e53bf337a47b8034359b826fa2
4
- data.tar.gz: b4077e6730cd248749960253a22b78a89a9f876ebfd5ca4a097d42c44c246aa7
3
+ metadata.gz: 6f3b7e7c1ae4279b24950e17dab944782608209e7dbdc061a2382d840a34ff59
4
+ data.tar.gz: 767737d5b485094560139148118512c9f7bd5e777f804b1d724f552212ccb485
5
5
  SHA512:
6
- metadata.gz: a93da54adf875ed88cc5f2fc7ab31a8f919d8352ddf2ee7259290ac2ed0a160b8edbf178f40788fd0e1f57c1c125877a20b6f3bbc3f8320d3929efb64da6862c
7
- data.tar.gz: d1ed6fab76e6c0cd4c74104ed997927fb377dad0fd75790f576777392fc73d235b5e828a73b2d7c3bc2b00c54246c21a48fc36539f00870eb23c07767a80b477
6
+ metadata.gz: a29a8e2e16357b5b0fea79db807c604502a6c097a835071776d15369f82ec2650b31722f2e7d9f25b38b4c929a3356f9fe5ad05236b825303bccfad724f524eb
7
+ data.tar.gz: 56c976aa96b172db1a72fea707bd8ac5c7d103c8a25e970483e4d1298e0a4675965c381c5420e018edeaf9255d70e61bd41fa663e6f508ad163b385f29df0e68
@@ -0,0 +1,39 @@
1
+ ---
2
+ version: 2
3
+
4
+ updates:
5
+ - package-ecosystem: "bundler"
6
+ directory: "/"
7
+ schedule:
8
+ interval: "weekly"
9
+ day: "tuesday"
10
+ time: "06:00"
11
+ timezone: "Europe/Oslo"
12
+ cooldown:
13
+ default-days: 3
14
+ semver-major-days: 7
15
+ semver-minor-days: 5
16
+ semver-patch-days: 3
17
+ groups:
18
+ all-dependencies:
19
+ patterns:
20
+ - "*"
21
+ open-pull-requests-limit: 5
22
+
23
+ - package-ecosystem: "github-actions"
24
+ directory: "/"
25
+ schedule:
26
+ interval: "weekly"
27
+ day: "tuesday"
28
+ time: "05:30"
29
+ timezone: "Europe/Oslo"
30
+ cooldown:
31
+ default-days: 3
32
+ ignore:
33
+ - dependency-name: "*"
34
+ update-types: ["version-update:semver-major"]
35
+ groups:
36
+ all-dependencies:
37
+ patterns:
38
+ - "*"
39
+ open-pull-requests-limit: 5
@@ -6,15 +6,20 @@ on:
6
6
  - main
7
7
  - develop
8
8
  pull_request:
9
+ permissions:
10
+ contents: write
11
+ issues: write
12
+ pull-requests: write
13
+ id-token: write
9
14
  jobs:
10
15
  rubocop-test:
11
16
  name: Rubocop
12
17
  runs-on: ubuntu-latest
13
18
  steps:
14
- - uses: actions/checkout@v1
15
- - uses: ruby/setup-ruby@v1
19
+ - uses: actions/checkout@v6.1.0
20
+ - uses: ruby/setup-ruby@v1.321.0
16
21
  with:
17
- ruby-version: 3.2
22
+ ruby-version: "4.0"
18
23
  bundler-cache: true
19
24
  - name: Check code
20
25
  run: bundle exec rubocop
@@ -24,18 +29,51 @@ jobs:
24
29
  runs-on: ubuntu-latest
25
30
  strategy:
26
31
  matrix:
27
- ruby: ['2.7', '3.0', '3.1', '3.2']
32
+ ruby: ["3.3", "3.4", "4.0"]
28
33
  steps:
29
- - uses: actions/checkout@v1
30
- - uses: ruby/setup-ruby@v1
34
+ - uses: actions/checkout@v6.1.0
35
+ - uses: ruby/setup-ruby@v1.321.0
31
36
  with:
32
37
  ruby-version: ${{ matrix.ruby }}
33
38
  bundler-cache: true
34
39
  - name: Run tests
35
40
  run: bundle exec rspec
36
- - name: Send results to Code Climate
37
- uses: paambaati/codeclimate-action@v3.2.0
41
+
42
+ automerge:
43
+ name: "Auto-merge Dependabot"
44
+ needs: [rubocop-test, rspec-test]
45
+ if: github.actor == 'dependabot[bot]'
46
+ runs-on: ubuntu-latest
47
+ steps:
48
+ - name: Enable auto-merge
49
+ run: gh pr merge --auto --squash "$PR_URL"
38
50
  env:
39
- CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
51
+ PR_URL: ${{ github.event.pull_request.html_url }}
52
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53
+
54
+ release-please:
55
+ needs: [rubocop-test, rspec-test]
56
+ if: github.ref == 'refs/heads/main' && github.event_name == 'push'
57
+ runs-on: ubuntu-latest
58
+ outputs:
59
+ release_created: ${{ steps.release.outputs.release_created }}
60
+ tag_name: ${{ steps.release.outputs.tag_name }}
61
+ steps:
62
+ - uses: googleapis/release-please-action@v4
63
+ id: release
40
64
  with:
41
- coverageCommand: ls
65
+ token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
66
+
67
+ publish:
68
+ needs: release-please
69
+ if: ${{ needs.release-please.outputs.release_created }}
70
+ runs-on: ubuntu-latest
71
+ steps:
72
+ - uses: actions/checkout@v6.1.0
73
+ with:
74
+ ref: ${{ needs.release-please.outputs.tag_name }}
75
+ - uses: ruby/setup-ruby@v1.321.0
76
+ with:
77
+ ruby-version: "4.0"
78
+ bundler-cache: true
79
+ - uses: rubygems/release-gem@v1
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "2.3.0"
3
+ }
data/.rubocop.yml CHANGED
@@ -1,10 +1,10 @@
1
- require:
1
+ plugins:
2
2
  - rubocop-rake
3
3
  - rubocop-rspec
4
4
 
5
5
  AllCops:
6
6
  NewCops: enable
7
- TargetRubyVersion: 2.7
7
+ TargetRubyVersion: 3.2
8
8
 
9
9
  Style/StringLiterals:
10
10
  EnforcedStyle: double_quotes
@@ -24,3 +24,6 @@ Naming/MethodParameterName:
24
24
  AllowedNames:
25
25
  - "x"
26
26
  - "y"
27
+
28
+ RSpec/IndexedLet:
29
+ Enabled: false
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 4.0
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## [2.3.0](https://github.com/elektronaut/vector2d/compare/vector2d-v2.2.4...vector2d/v2.3.0) (2026-08-30)
4
+
5
+
6
+ ### Features
7
+
8
+ * Add Vector2d#clamp ([de77e58](https://github.com/elektronaut/vector2d/commit/de77e584f8f5668f24186179b720b4db9a70f6d2))
@@ -0,0 +1,92 @@
1
+
2
+ # Contributor Covenant 3.0 Code of Conduct
3
+
4
+ ## Our Pledge
5
+
6
+ We pledge to make our community welcoming, safe, and equitable for all.
7
+
8
+ We are committed to fostering an environment that respects and promotes the dignity, rights, and contributions of all individuals, regardless of characteristics including race, ethnicity, caste, color, age, physical characteristics, neurodiversity, disability, sex or gender, gender identity or expression, sexual orientation, language, philosophy or religion, national or social origin, socio-economic position, level of education, or other status. The same privileges of participation are extended to everyone who participates in good faith and in accordance with this Covenant.
9
+
10
+ ## Encouraged Behaviors
11
+
12
+ While acknowledging differences in social norms, we all strive to meet our community's expectations for positive behavior. We also understand that our words and actions may be interpreted differently than we intend based on culture, background, or native language.
13
+
14
+ With these considerations in mind, we agree to behave mindfully toward each other and act in ways that center our shared values, including:
15
+
16
+ 1. Respecting the **purpose of our community**, our activities, and our ways of gathering.
17
+ 2. Engaging **kindly and honestly** with others.
18
+ 3. Respecting **different viewpoints** and experiences.
19
+ 4. **Taking responsibility** for our actions and contributions.
20
+ 5. Gracefully giving and accepting **constructive feedback**.
21
+ 6. Committing to **repairing harm** when it occurs.
22
+ 7. Behaving in other ways that promote and sustain the **well-being of our community**.
23
+
24
+
25
+ ## Restricted Behaviors
26
+
27
+ We agree to restrict the following behaviors in our community. Instances, threats, and promotion of these behaviors are violations of this Code of Conduct.
28
+
29
+ 1. **Harassment.** Violating explicitly expressed boundaries or engaging in unnecessary personal attention after any clear request to stop.
30
+ 2. **Character attacks.** Making insulting, demeaning, or pejorative comments directed at a community member or group of people.
31
+ 3. **Stereotyping or discrimination.** Characterizing anyone’s personality or behavior on the basis of immutable identities or traits.
32
+ 4. **Sexualization.** Behaving in a way that would generally be considered inappropriately intimate in the context or purpose of the community.
33
+ 5. **Violating confidentiality**. Sharing or acting on someone's personal or private information without their permission.
34
+ 6. **Endangerment.** Causing, encouraging, or threatening violence or other harm toward any person or group.
35
+ 7. Behaving in other ways that **threaten the well-being** of our community.
36
+
37
+ ### Other Restrictions
38
+
39
+ 1. **Misleading identity.** Impersonating someone else for any reason, or pretending to be someone else to evade enforcement actions.
40
+ 2. **Failing to credit sources.** Not properly crediting the sources of content you contribute.
41
+ 3. **Promotional materials**. Sharing marketing or other commercial content in a way that is outside the norms of the community.
42
+ 4. **Irresponsible communication.** Failing to responsibly present content which includes, links or describes any other restricted behaviors.
43
+
44
+
45
+ ## Reporting an Issue
46
+
47
+ Tensions can occur between community members even when they are trying their best to collaborate. Not every conflict represents a code of conduct violation, and this Code of Conduct reinforces encouraged behaviors and norms that can help avoid conflicts and minimize harm.
48
+
49
+ When an incident does occur, it is important to report it promptly. To report a possible violation, **contact the project maintainer at inge@elektronaut.no.**
50
+
51
+ Community Moderators take reports of violations seriously and will make every effort to respond in a timely manner. They will investigate all reports of code of conduct violations, reviewing messages, logs, and recordings, or interviewing witnesses and other participants. Community Moderators will keep investigation and enforcement actions as transparent as possible while prioritizing safety and confidentiality. In order to honor these values, enforcement actions are carried out in private with the involved parties, but communicating to the whole community may be part of a mutually agreed upon resolution.
52
+
53
+
54
+ ## Addressing and Repairing Harm
55
+
56
+ ****
57
+
58
+ If an investigation by the Community Moderators finds that this Code of Conduct has been violated, the following enforcement ladder may be used to determine how best to repair harm, based on the incident's impact on the individuals involved and the community as a whole. Depending on the severity of a violation, lower rungs on the ladder may be skipped.
59
+
60
+ 1) Warning
61
+ 1) Event: A violation involving a single incident or series of incidents.
62
+ 2) Consequence: A private, written warning from the Community Moderators.
63
+ 3) Repair: Examples of repair include a private written apology, acknowledgement of responsibility, and seeking clarification on expectations.
64
+ 2) Temporarily Limited Activities
65
+ 1) Event: A repeated incidence of a violation that previously resulted in a warning, or the first incidence of a more serious violation.
66
+ 2) Consequence: A private, written warning with a time-limited cooldown period designed to underscore the seriousness of the situation and give the community members involved time to process the incident. The cooldown period may be limited to particular communication channels or interactions with particular community members.
67
+ 3) Repair: Examples of repair may include making an apology, using the cooldown period to reflect on actions and impact, and being thoughtful about re-entering community spaces after the period is over.
68
+ 3) Temporary Suspension
69
+ 1) Event: A pattern of repeated violation which the Community Moderators have tried to address with warnings, or a single serious violation.
70
+ 2) Consequence: A private written warning with conditions for return from suspension. In general, temporary suspensions give the person being suspended time to reflect upon their behavior and possible corrective actions.
71
+ 3) Repair: Examples of repair include respecting the spirit of the suspension, meeting the specified conditions for return, and being thoughtful about how to reintegrate with the community when the suspension is lifted.
72
+ 4) Permanent Ban
73
+ 1) Event: A pattern of repeated code of conduct violations that other steps on the ladder have failed to resolve, or a violation so serious that the Community Moderators determine there is no way to keep the community safe with this person as a member.
74
+ 2) Consequence: Access to all community spaces, tools, and communication channels is removed. In general, permanent bans should be rarely used, should have strong reasoning behind them, and should only be resorted to if working through other remedies has failed to change the behavior.
75
+ 3) Repair: There is no possible repair in cases of this severity.
76
+
77
+ This enforcement ladder is intended as a guideline. It does not limit the ability of Community Managers to use their discretion and judgment, in keeping with the best interests of our community.
78
+
79
+
80
+ ## Scope
81
+
82
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public or other spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
83
+
84
+
85
+ ## Attribution
86
+
87
+ This Code of Conduct is adapted from the Contributor Covenant, version 3.0, permanently available at [https://www.contributor-covenant.org/version/3/0/](https://www.contributor-covenant.org/version/3/0/).
88
+
89
+ Contributor Covenant is stewarded by the Organization for Ethical Source and licensed under CC BY-SA 4.0. To view a copy of this license, visit [https://creativecommons.org/licenses/by-sa/4.0/](https://creativecommons.org/licenses/by-sa/4.0/)
90
+
91
+ For answers to common questions about Contributor Covenant, see the FAQ at [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are provided at [https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations). Additional enforcement and community guideline resources can be found at [https://www.contributor-covenant.org/resources](https://www.contributor-covenant.org/resources). The enforcement ladder was inspired by the work of [Mozilla’s code of conduct team](https://github.com/mozilla/inclusion).
92
+
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,30 @@
1
+ # Contributing
2
+
3
+ Bug reports and pull requests are welcome on
4
+ [GitHub](https://github.com/elektronaut/vector2d). Everyone participating is
5
+ expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
6
+
7
+ ## Getting started
8
+
9
+ Install the dependencies and run the test suite:
10
+
11
+ ```sh
12
+ bundle install
13
+ bundle exec rspec
14
+ ```
15
+
16
+ Check style before pushing:
17
+
18
+ ```sh
19
+ bundle exec rubocop
20
+ ```
21
+
22
+ ## Pull requests
23
+
24
+ - Add tests for any behavior you change.
25
+ - Write commit messages using
26
+ [Conventional Commits](https://www.conventionalcommits.org). The
27
+ changelog and releases are generated from them, so the `feat:` and
28
+ `fix:` prefixes decide what ends up in the next release.
29
+ - Leave the version and the changelog alone. Both are updated
30
+ automatically when a release is cut.
data/Gemfile CHANGED
@@ -7,9 +7,9 @@ gemspec
7
7
  group :development, :test do
8
8
  gem "rake"
9
9
  gem "rspec", "~> 3.8"
10
- gem "rspec-its", "~> 1.3"
10
+ gem "rspec-its", "~> 2.0"
11
11
  gem "rubocop", require: false
12
12
  gem "rubocop-rake", require: false
13
13
  gem "rubocop-rspec", require: false
14
- gem "simplecov", "~> 0.17.1"
14
+ gem "simplecov", "~> 1.1.1"
15
15
  end
data/Gemfile.lock CHANGED
@@ -1,77 +1,81 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vector2d (2.2.4)
4
+ vector2d (2.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.4.2)
10
- diff-lcs (1.5.0)
11
- docile (1.4.0)
12
- json (2.6.3)
13
- parallel (1.22.1)
14
- parser (3.2.0.0)
9
+ ast (2.4.3)
10
+ diff-lcs (1.6.2)
11
+ json (2.21.2)
12
+ language_server-protocol (3.17.0.6)
13
+ lint_roller (1.1.0)
14
+ parallel (1.28.0)
15
+ parser (3.3.12.0)
15
16
  ast (~> 2.4.1)
17
+ racc
18
+ prism (1.9.0)
19
+ racc (1.8.1)
16
20
  rainbow (3.1.1)
17
- rake (13.0.6)
18
- regexp_parser (2.6.2)
19
- rexml (3.2.5)
20
- rspec (3.12.0)
21
- rspec-core (~> 3.12.0)
22
- rspec-expectations (~> 3.12.0)
23
- rspec-mocks (~> 3.12.0)
24
- rspec-core (3.12.1)
25
- rspec-support (~> 3.12.0)
26
- rspec-expectations (3.12.2)
21
+ rake (13.4.2)
22
+ regexp_parser (2.12.0)
23
+ rspec (3.13.2)
24
+ rspec-core (~> 3.13.0)
25
+ rspec-expectations (~> 3.13.0)
26
+ rspec-mocks (~> 3.13.0)
27
+ rspec-core (3.13.6)
28
+ rspec-support (~> 3.13.0)
29
+ rspec-expectations (3.13.5)
27
30
  diff-lcs (>= 1.2.0, < 2.0)
28
- rspec-support (~> 3.12.0)
29
- rspec-its (1.3.0)
30
- rspec-core (>= 3.0.0)
31
- rspec-expectations (>= 3.0.0)
32
- rspec-mocks (3.12.3)
31
+ rspec-support (~> 3.13.0)
32
+ rspec-its (2.0.0)
33
+ rspec-core (>= 3.13.0)
34
+ rspec-expectations (>= 3.13.0)
35
+ rspec-mocks (3.13.7)
33
36
  diff-lcs (>= 1.2.0, < 2.0)
34
- rspec-support (~> 3.12.0)
35
- rspec-support (3.12.0)
36
- rubocop (1.44.1)
37
+ rspec-support (~> 3.13.0)
38
+ rspec-support (3.13.7)
39
+ rubocop (1.89.0)
37
40
  json (~> 2.3)
38
- parallel (~> 1.10)
39
- parser (>= 3.2.0.0)
41
+ language_server-protocol (~> 3.17.0.2)
42
+ lint_roller (~> 1.1.0)
43
+ parallel (>= 1.10)
44
+ parser (>= 3.3.0.2)
40
45
  rainbow (>= 2.2.2, < 4.0)
41
- regexp_parser (>= 1.8, < 3.0)
42
- rexml (>= 3.2.5, < 4.0)
43
- rubocop-ast (>= 1.24.1, < 2.0)
46
+ regexp_parser (>= 2.9.3, < 3.0)
47
+ rubocop-ast (>= 1.49.0, < 2.0)
44
48
  ruby-progressbar (~> 1.7)
45
- unicode-display_width (>= 2.4.0, < 3.0)
46
- rubocop-ast (1.24.1)
47
- parser (>= 3.1.1.0)
48
- rubocop-capybara (2.17.0)
49
- rubocop (~> 1.41)
50
- rubocop-rake (0.6.0)
51
- rubocop (~> 1.0)
52
- rubocop-rspec (2.18.1)
53
- rubocop (~> 1.33)
54
- rubocop-capybara (~> 2.17)
55
- ruby-progressbar (1.11.0)
56
- simplecov (0.17.1)
57
- docile (~> 1.1)
58
- json (>= 1.8, < 3)
59
- simplecov-html (~> 0.10.0)
60
- simplecov-html (0.10.2)
61
- unicode-display_width (2.4.2)
49
+ unicode-display_width (>= 2.4.0, < 4.0)
50
+ rubocop-ast (1.50.0)
51
+ parser (>= 3.3.7.2)
52
+ prism (~> 1.7)
53
+ rubocop-rake (0.7.1)
54
+ lint_roller (~> 1.1)
55
+ rubocop (>= 1.72.1)
56
+ rubocop-rspec (3.10.2)
57
+ lint_roller (~> 1.1)
58
+ regexp_parser (>= 2.0)
59
+ rubocop (~> 1.86, >= 1.86.2)
60
+ ruby-progressbar (1.13.0)
61
+ simplecov (1.1.1)
62
+ unicode-display_width (3.2.0)
63
+ unicode-emoji (~> 4.1)
64
+ unicode-emoji (4.2.0)
62
65
 
63
66
  PLATFORMS
67
+ arm64-darwin-23
64
68
  ruby
65
69
 
66
70
  DEPENDENCIES
67
71
  rake
68
72
  rspec (~> 3.8)
69
- rspec-its (~> 1.3)
73
+ rspec-its (~> 2.0)
70
74
  rubocop
71
75
  rubocop-rake
72
76
  rubocop-rspec
73
- simplecov (~> 0.17.1)
77
+ simplecov (~> 1.1.1)
74
78
  vector2d!
75
79
 
76
80
  BUNDLED WITH
77
- 2.2.3
81
+ 4.0.4
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  [![Version](https://img.shields.io/gem/v/vector2d.svg?style=flat)](https://rubygems.org/gems/vector2d)
2
- ![Build](https://github.com/elektronaut/vector2d/workflows/Build/badge.svg)
3
- [![Code Climate](https://codeclimate.com/github/elektronaut/vector2d/badges/gpa.svg)](https://codeclimate.com/github/elektronaut/vector2d)
4
- [![Code Climate](https://codeclimate.com/github/elektronaut/vector2d/badges/coverage.svg)](https://codeclimate.com/github/elektronaut/vector2d)
2
+ [![Build](https://github.com/elektronaut/vector2d/actions/workflows/build.yml/badge.svg)](https://github.com/elektronaut/vector2d/actions/workflows/build.yml)
5
3
 
6
4
  # Vector2d
7
5
 
@@ -29,10 +27,16 @@ Vector2d.parse("50x70") # => Vector2d(50,70)
29
27
 
30
28
  ## Documentation
31
29
 
32
- [API documentation](https://rdoc.info/github/elektronaut/vector2d/main)
30
+ [API documentation](https://rubydoc.info/gems/vector2d)
33
31
 
34
- ## License
32
+ ## Contributing
33
+
34
+ Bug reports and pull requests are welcome on
35
+ [GitHub](https://github.com/elektronaut/vector2d). See
36
+ [CONTRIBUTING.md](CONTRIBUTING.md) for how to run the tests and how
37
+ commits are formatted, and note that this project ships with a
38
+ [code of conduct](CODE_OF_CONDUCT.md).
35
39
 
36
- Copyright (c) 2006-2019 Inge Jørgensen
40
+ ## License
37
41
 
38
- Vector2d is released under the [MIT License](http://www.opensource.org/licenses/MIT).
42
+ Released under the [MIT License](LICENSE).
data/Rakefile CHANGED
@@ -3,6 +3,9 @@
3
3
  require "bundler/gem_tasks"
4
4
  require "rspec/core/rake_task"
5
5
 
6
+ # release-please creates the tag and the release commit.
7
+ Rake::Task["release:source_control_push"].clear
8
+
6
9
  RSpec::Core::RakeTask.new
7
10
 
8
11
  task default: :spec
@@ -10,6 +10,19 @@ class Vector2d
10
10
  self.class.new(x.ceil, y.ceil)
11
11
  end
12
12
 
13
+ # Clamps the vector between two others, one axis at a time.
14
+ # The bounds are coerced, so scalars work too.
15
+ #
16
+ # vector = Vector2d(2, 8)
17
+ # vector.clamp(Vector2d(3, 3), Vector2d(6, 6)) # => Vector2d(3,6)
18
+ # vector.clamp(3, 6) # => Vector2d(3,6)
19
+ #
20
+ def clamp(min, max)
21
+ min_v, = coerce(min)
22
+ max_v, = coerce(max)
23
+ self.class.new(x.clamp(min_v.x, max_v.x), y.clamp(min_v.y, max_v.y))
24
+ end
25
+
13
26
  # Rounds vector to up nearest integer.
14
27
  #
15
28
  # Vector2d(2.4, 3.6).floor # => Vector2d(2,3)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Vector2d
4
- VERSION = "2.2.4"
4
+ VERSION = "2.3.0"
5
5
  end
data/lib/vector2d.rb CHANGED
@@ -81,6 +81,6 @@ end
81
81
  #
82
82
  # Vector2d(2, 3) # => Vector2d(2,3)
83
83
  #
84
- def Vector2d(*args)
85
- Vector2d.parse(*args)
84
+ def Vector2d(*)
85
+ Vector2d.parse(*)
86
86
  end
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3
+ "packages": {
4
+ ".": {
5
+ "release-type": "ruby",
6
+ "package-name": "vector2d",
7
+ "version-file": "lib/vector2d/version.rb"
8
+ }
9
+ }
10
+ }
@@ -13,6 +13,23 @@ describe Vector2d::Transformations do
13
13
  end
14
14
  end
15
15
 
16
+ describe "#clamp" do
17
+ subject(:vector) { Vector2d.new(2, 8) }
18
+
19
+ it "clamps each axis" do
20
+ expect(vector.clamp(Vector2d.new(3, 3), Vector2d.new(6, 6)))
21
+ .to eq(Vector2d.new(3, 6))
22
+ end
23
+
24
+ it "coerces the bounds" do
25
+ expect(vector.clamp(3, 6)).to eq(Vector2d.new(3, 6))
26
+ end
27
+
28
+ it "leaves a vector within the bounds alone" do
29
+ expect(vector.clamp(0, 10)).to eq(vector)
30
+ end
31
+ end
32
+
16
33
  describe "#floor" do
17
34
  subject(:vector) { Vector2d.new(2.7, 3.6) }
18
35
 
data/vector2d.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.version = Vector2d::VERSION
9
9
  s.authors = ["Inge Jørgensen"]
10
10
  s.email = ["inge@elektronaut.no"]
11
- s.homepage = "http://github.com/elektronaut/vector2d"
11
+ s.homepage = "https://github.com/elektronaut/vector2d"
12
12
  s.summary = "Library for handling two-dimensional vectors"
13
13
  s.description = "Vector2d allows for easy handling of two-dimensional " \
14
14
  "coordinates and vectors"
@@ -20,7 +20,12 @@ Gem::Specification.new do |s|
20
20
  .map { |f| File.basename(f) }
21
21
  s.require_paths = ["lib"]
22
22
 
23
- s.required_ruby_version = ">= 2.7.0"
23
+ s.required_ruby_version = ">= 3.2.0"
24
24
 
25
- s.metadata["rubygems_mfa_required"] = "true"
25
+ s.metadata = {
26
+ "bug_tracker_uri" => "https://github.com/elektronaut/vector2d/issues",
27
+ "documentation_uri" => "https://www.rubydoc.info/gems/vector2d",
28
+ "rubygems_mfa_required" => "true",
29
+ "source_code_uri" => "https://github.com/elektronaut/vector2d"
30
+ }
26
31
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vector2d
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.4
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Inge Jørgensen
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-02-07 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: Vector2d allows for easy handling of two-dimensional coordinates and
14
13
  vectors
@@ -18,10 +17,16 @@ executables: []
18
17
  extensions: []
19
18
  extra_rdoc_files: []
20
19
  files:
20
+ - ".github/dependabot.yml"
21
21
  - ".github/workflows/build.yml"
22
22
  - ".gitignore"
23
+ - ".release-please-manifest.json"
23
24
  - ".rubocop.yml"
25
+ - ".tool-versions"
24
26
  - ".travis.yml"
27
+ - CHANGELOG.md
28
+ - CODE_OF_CONDUCT.md
29
+ - CONTRIBUTING.md
25
30
  - Gemfile
26
31
  - Gemfile.lock
27
32
  - LICENSE
@@ -34,6 +39,7 @@ files:
34
39
  - lib/vector2d/properties.rb
35
40
  - lib/vector2d/transformations.rb
36
41
  - lib/vector2d/version.rb
42
+ - release-please-config.json
37
43
  - spec/lib/vector2d/calculations_spec.rb
38
44
  - spec/lib/vector2d/coercions_spec.rb
39
45
  - spec/lib/vector2d/fitting_spec.rb
@@ -42,12 +48,14 @@ files:
42
48
  - spec/lib/vector2d_spec.rb
43
49
  - spec/spec_helper.rb
44
50
  - vector2d.gemspec
45
- homepage: http://github.com/elektronaut/vector2d
51
+ homepage: https://github.com/elektronaut/vector2d
46
52
  licenses:
47
53
  - MIT
48
54
  metadata:
55
+ bug_tracker_uri: https://github.com/elektronaut/vector2d/issues
56
+ documentation_uri: https://www.rubydoc.info/gems/vector2d
49
57
  rubygems_mfa_required: 'true'
50
- post_install_message:
58
+ source_code_uri: https://github.com/elektronaut/vector2d
51
59
  rdoc_options: []
52
60
  require_paths:
53
61
  - lib
@@ -55,15 +63,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
55
63
  requirements:
56
64
  - - ">="
57
65
  - !ruby/object:Gem::Version
58
- version: 2.7.0
66
+ version: 3.2.0
59
67
  required_rubygems_version: !ruby/object:Gem::Requirement
60
68
  requirements:
61
69
  - - ">="
62
70
  - !ruby/object:Gem::Version
63
71
  version: '0'
64
72
  requirements: []
65
- rubygems_version: 3.4.6
66
- signing_key:
73
+ rubygems_version: 4.0.16
67
74
  specification_version: 4
68
75
  summary: Library for handling two-dimensional vectors
69
76
  test_files: []