vector2d 2.2.4 → 3.0.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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +39 -0
  3. data/.github/workflows/build.yml +48 -10
  4. data/.gitignore +3 -1
  5. data/.release-please-manifest.json +3 -0
  6. data/.rubocop.yml +5 -2
  7. data/.tool-versions +1 -0
  8. data/.yardopts +11 -0
  9. data/CHANGELOG.md +224 -0
  10. data/CODE_OF_CONDUCT.md +92 -0
  11. data/CONTRIBUTING.md +30 -0
  12. data/Gemfile +6 -2
  13. data/Gemfile.lock +85 -51
  14. data/README.md +330 -13
  15. data/Rakefile +21 -0
  16. data/benchmark/vector_comparison.rb +129 -0
  17. data/lib/vector2d/angles.rb +315 -0
  18. data/lib/vector2d/arithmetic.rb +97 -0
  19. data/lib/vector2d/comparison.rb +188 -0
  20. data/lib/vector2d/componentwise.rb +239 -0
  21. data/lib/vector2d/constructors.rb +137 -0
  22. data/lib/vector2d/conversions.rb +139 -0
  23. data/lib/vector2d/coordinates.rb +22 -0
  24. data/lib/vector2d/deprecation.rb +16 -0
  25. data/lib/vector2d/dimensions.rb +297 -0
  26. data/lib/vector2d/interpolation.rb +191 -0
  27. data/lib/vector2d/lengths.rb +284 -0
  28. data/lib/vector2d/matrix_interop.rb +93 -0
  29. data/lib/vector2d/parsing.rb +142 -0
  30. data/lib/vector2d/projection.rb +208 -0
  31. data/lib/vector2d/version.rb +2 -1
  32. data/lib/vector2d.rb +174 -62
  33. data/release-please-config.json +10 -0
  34. data/spec/lib/vector2d/angles_spec.rb +441 -0
  35. data/spec/lib/vector2d/{calculations_spec.rb → arithmetic_spec.rb} +48 -58
  36. data/spec/lib/vector2d/comparison_spec.rb +358 -0
  37. data/spec/lib/vector2d/componentwise_spec.rb +300 -0
  38. data/spec/lib/vector2d/constructors_spec.rb +299 -0
  39. data/spec/lib/vector2d/conversions_spec.rb +234 -0
  40. data/spec/lib/vector2d/dimensions_spec.rb +820 -0
  41. data/spec/lib/vector2d/interpolation_spec.rb +322 -0
  42. data/spec/lib/vector2d/lengths_spec.rb +457 -0
  43. data/spec/lib/vector2d/matrix_interop_spec.rb +92 -0
  44. data/spec/lib/vector2d/parsing_spec.rb +329 -0
  45. data/spec/lib/vector2d/projection_spec.rb +306 -0
  46. data/spec/lib/vector2d_documentation_spec.rb +38 -0
  47. data/spec/lib/vector2d_immutability_spec.rb +263 -0
  48. data/spec/lib/vector2d_spec.rb +90 -50
  49. data/spec/lib/vector2d_subclassing_spec.rb +210 -0
  50. data/spec/lib/vector2d_tags_spec.rb +43 -0
  51. data/spec/spec_helper.rb +2 -0
  52. data/spec/support/doc_examples/comments.rb +65 -0
  53. data/spec/support/doc_examples/markdown.rb +50 -0
  54. data/spec/support/doc_examples.rb +94 -0
  55. data/spec/support/doc_tags.rb +151 -0
  56. data/spec/support/shared_examples/class_preserving_method.rb +10 -0
  57. data/spec/support/shared_examples/deprecated_method.rb +25 -0
  58. data/spec/support/shared_examples/parsed_vector.rb +11 -0
  59. data/vector2d.gemspec +9 -3
  60. metadata +55 -19
  61. data/.travis.yml +0 -10
  62. data/lib/vector2d/calculations.rb +0 -141
  63. data/lib/vector2d/coercions.rb +0 -64
  64. data/lib/vector2d/fitting.rb +0 -60
  65. data/lib/vector2d/properties.rb +0 -46
  66. data/lib/vector2d/transformations.rb +0 -85
  67. data/spec/lib/vector2d/coercions_spec.rb +0 -59
  68. data/spec/lib/vector2d/fitting_spec.rb +0 -70
  69. data/spec/lib/vector2d/properties_spec.rb +0 -47
  70. data/spec/lib/vector2d/transformations_spec.rb +0 -122
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc16e15dbb07e3fe138a13fdc3cc8edd6c1369e53bf337a47b8034359b826fa2
4
- data.tar.gz: b4077e6730cd248749960253a22b78a89a9f876ebfd5ca4a097d42c44c246aa7
3
+ metadata.gz: 02eaa1a646eca603d58bc80b84ad7c1d3f4973df2a9837caa722a6e706b8ad4b
4
+ data.tar.gz: 29b5dbc22b83bc53946c9da06caf119fa07d5e2c8cf39d940e7f751ec4426065
5
5
  SHA512:
6
- metadata.gz: a93da54adf875ed88cc5f2fc7ab31a8f919d8352ddf2ee7259290ac2ed0a160b8edbf178f40788fd0e1f57c1c125877a20b6f3bbc3f8320d3929efb64da6862c
7
- data.tar.gz: d1ed6fab76e6c0cd4c74104ed997927fb377dad0fd75790f576777392fc73d235b5e828a73b2d7c3bc2b00c54246c21a48fc36539f00870eb23c07767a80b477
6
+ metadata.gz: 206db7be3e3cd57909d8200f09504dc8c539ec1a6c1f4fa6e1015cd21496577445004c3cb319547d1bbdab3dd8bf25fb6fa94428bb564432c41d86a32016f234
7
+ data.tar.gz: 94213c539359dd0f7ccac221a5a3361838d84612115d20c7bdc91788a579cccbe397b8bc8d6147ab06420f72fbaa566f18f4e700654633b152833029ac9e73a9
@@ -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.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
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
+ .yardoc
1
2
  coverage
2
- rdoc
3
+ doc
3
4
  pkg
5
+ rdoc
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "3.0.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.4
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/.yardopts ADDED
@@ -0,0 +1,11 @@
1
+ --markup rdoc
2
+ --readme README.md
3
+ --title "Vector2d"
4
+ --output-dir doc
5
+ lib/vector2d.rb
6
+ lib/vector2d/**/*.rb
7
+ -
8
+ CHANGELOG.md
9
+ CONTRIBUTING.md
10
+ CODE_OF_CONDUCT.md
11
+ LICENSE
data/CHANGELOG.md ADDED
@@ -0,0 +1,224 @@
1
+ # Changelog
2
+
3
+ ## [3.0.0](https://github.com/elektronaut/vector2d/compare/vector2d/v2.3.0...vector2d/v3.0.0) (2026-09-20)
4
+
5
+ The public API grows from 43 methods to 115. Vectors are now genuinely
6
+ immutable and safe to share between ractors, they can be pattern matched,
7
+ and they convert to and from the standard library `Matrix` and `Vector`.
8
+
9
+ Nothing was removed. The seven deprecated methods still work, and stay
10
+ silent unless deprecation warnings are enabled.
11
+
12
+ Most of the breaking changes correct behavior that was undefined or plainly
13
+ wrong in 2.x: input that used to produce an unusable vector now raises where
14
+ the bad input is, rather than somewhere further along. Four changes can
15
+ affect code that works today, and they come first.
16
+
17
+ ### Breaking changes
18
+
19
+ #### Ruby 3.4 is now the minimum, up from 3.2
20
+
21
+ `MatrixInterop#to_matrix`, `#to_vector` and `#transform` are not
22
+ ractor-safe before 3.4. Ruby 3.2 raises `Ractor::IsolationError` from the
23
+ `require`, and 3.3 raises out of `::Vector[]` even with `matrix` already
24
+ loaded. The floor moves so the matrix paths are safe across the whole
25
+ supported range, and the gemspec stops claiming versions CI never ran.
26
+
27
+ #### Vectors are frozen
28
+
29
+ Instances are frozen on construction, which is what makes them shareable
30
+ between ractors when their coordinates are. `#dup` and `clone(freeze: false)`
31
+ return frozen objects, matching `Data`, `Rational` and `Complex`.
32
+
33
+ A subclass that adds instance variables must assign them before calling
34
+ `super`, as the object is frozen by the time `super` returns.
35
+
36
+ #### Strings keep their coordinate type
37
+
38
+ `Vector2d.parse("50x70")` returns `Vector2d(50,70)` with `Integer`
39
+ coordinates. It previously returned floats, which made strings the one
40
+ input type that did not preserve what it was given.
41
+
42
+ Parsing is stricter about malformed input and more permissive about valid
43
+ input. `"1.2.3x4"` was accepted and silently truncated, and now raises.
44
+ Negative coordinates, an uppercase `X` separator and comma-separated pairs
45
+ are now accepted.
46
+
47
+ #### Coordinates must be `Numeric`
48
+
49
+ Coordinates were never validated, so any unrecognized argument fell through
50
+ to the constructor. `Vector2d.parse(nil)` returned `Vector2d(nil,nil)` and
51
+ raised `NoMethodError` later at an unrelated call site.
52
+
53
+ Every parse path now checks both coordinates. `Integer`, `Float`, `Rational`,
54
+ `BigDecimal` and custom `Numeric` subclasses are unaffected. Objects that
55
+ are numeric by duck typing alone are no longer accepted.
56
+
57
+ #### Tightened validation
58
+
59
+ These raise where 2.x returned something unusable. Code that was working is
60
+ unlikely to notice.
61
+
62
+ - `Vector2d(2, 0).aspect_ratio` returned `Infinity` and the zero vector
63
+ returned `NaN`. Both now raise `ArgumentError`.
64
+ - `Complex` passed the coordinate check, and the resulting vector raised
65
+ `RangeError` out of `Math` from `#aspect_ratio` and `.from_angle`. It is
66
+ now rejected: `ArgumentError` from `.parse`, `.new` and `.from_angle`,
67
+ `TypeError` from the operators.
68
+ - `Vector2d.parse(5, nil)` read the explicit `nil` as an omitted argument
69
+ and returned `Vector2d(5,5)`. An explicit `nil` second argument now
70
+ raises `ArgumentError`.
71
+ - `Vector2d(2, 3).clamp_length(-1.0)` returned a reversed unit vector
72
+ rather than anything shorter. A negative maximum now raises
73
+ `ArgumentError`, following `Comparable#clamp`. This applies to
74
+ `#truncate` as well. Pass `max.clamp(0..)` to saturate instead.
75
+ `#resize` is unchanged, where a negative length is a signed magnitude
76
+ that reverses the vector.
77
+ - `#fit` and `#fit_either` returned early on the zero vector, before the
78
+ argument was coerced, so `Vector2d(0, 0).fit("garbage")` returned the
79
+ zero vector. Both now raise `ArgumentError`, as every other receiver
80
+ already did.
81
+
82
+ #### Subclasses
83
+
84
+ Two places where a subclass could be dropped on the way through:
85
+
86
+ - `#coerce` built the left-hand operand with `.parse`, so `2 * subvector`
87
+ returned a `Vector2d` where `subvector * 2` returned the subclass. It now
88
+ builds through `#build`, so coercion is symmetric. `#coerce_vector` is
89
+ unchanged, so methods that only read an operand's coordinates still parse
90
+ into the base class.
91
+ - `.parse` returned any `Vector2d` argument untouched, so `Sub.parse(vector)`
92
+ handed back the plain vector. An argument is returned as it is only when
93
+ it is already an instance of the class parsing it; anything else is
94
+ rebuilt through `.build`.
95
+
96
+ ### Deprecations
97
+
98
+ All of these still work. They warn under `Warning[:deprecated] = true` or
99
+ `ruby -w`, and each one names its replacement.
100
+
101
+ | Deprecated | Replacement |
102
+ | ------------------- | ------------------------------- |
103
+ | `#truncate` | `#limit_length` |
104
+ | `#squared_length` | `#length_squared` |
105
+ | `#squared_distance` | `#distance_squared` |
106
+ | `#fit_either` | `#cover` |
107
+ | `#constrain_both` | `#fit` |
108
+ | `#constrain_one` | `#cover` |
109
+ | `#contain` | `other.fit(self, upscale: false)` |
110
+
111
+ `#truncate` is the one worth looking at. It took a maximum length, where
112
+ `Numeric#truncate` takes a digit count, and the name went to the wrong
113
+ method. `#limit_length` replaces it.
114
+
115
+ ### Features
116
+
117
+ #### Construction
118
+
119
+ `.build` and `#build` are the hooks every returning method routes through,
120
+ so a subclass overrides construction in one place.
121
+
122
+ - `Vector2d.from_angle(angle, length = 1.0)` and `#to_polar`
123
+ - `Vector2d.from_degrees(angle, length = 1.0)`
124
+ - `Vector2d.random(length = 1.0, random: Random)`
125
+ - `Vector2d.zero`, `.one`, `.up`, `.down`, `.left` and `.right`
126
+
127
+ #### Angles and rotation
128
+
129
+ - `#angle_to` returns a signed angle in `-PI..PI`, positive when the other
130
+ vector is counterclockwise. `#angle_between` stays unsigned in `0..PI`.
131
+ - `Vector2d.degrees` and `.radians` convert between the two
132
+ - `#angle_in_degrees` and `#rotate_degrees`
133
+ - `#rotate_around(center, angle)`
134
+ - `#perpendicular_cw`, alongside the existing counterclockwise
135
+ `#perpendicular`
136
+
137
+ #### Length and distance
138
+
139
+ - `#length_squared` and `#distance_squared`, which skip the square root
140
+ - `#manhattan_distance` and `#chebyshev_distance`
141
+ - `#limit_length(max)` scales down only if longer
142
+ - `#clamp_length(min, max = nil)` takes a range or a pair, mirroring
143
+ `Comparable#clamp`
144
+ - `#direction_to`
145
+ - `#magnitude` and `#norm` as aliases of `#length`
146
+
147
+ #### Projection and reflection
148
+
149
+ - `#project`, `#reject` and `#scalar_projection`
150
+ - `#reflect(normal)` and `#refract(normal, refractive_index)`
151
+ - `#dot` and `#inner_product` as aliases of `#dot_product`
152
+
153
+ #### Interpolation
154
+
155
+ - `#lerp`, `#inverse_lerp` and `#slerp`
156
+ - `#midpoint`
157
+ - `#move_toward(target, distance)`
158
+
159
+ #### Comparison
160
+
161
+ - `#eql?` and `#hash`, so vectors work as hash keys
162
+ - `#approx_equal?(other, tolerance = nil)` and `#approx_zero?`
163
+ - `#zero?`, `#finite?` and `#nan?`
164
+ - `#parallel?`, `#perpendicular?`, `#opposite?` and `#independent?`
165
+
166
+ #### Component-wise operations
167
+
168
+ - Unary `+@` and `-@`
169
+ - `#abs`, `#sign` and `#snap(step)`
170
+ - `#with_x` and `#with_y`
171
+ - `#min` and `#max`
172
+ - `#floor` and `#ceil` take a digit count
173
+
174
+ #### Dimensions and fitting
175
+
176
+ - `#cover(other, upscale: true)` scales to the smallest size that fills the
177
+ box, the counterpart to `#fit`
178
+ - `#fit(other, upscale: false)` never scales up
179
+ - `#fits?` and `#covers?`
180
+ - `#area`, `#square?`, `#portrait?` and `#landscape?`
181
+
182
+ #### Standard library compatibility
183
+
184
+ - `#to_matrix`, `#to_vector` and `#transform(matrix)`
185
+ - `#deconstruct` and `#deconstruct_keys` for pattern matching
186
+
187
+ ### Bug fixes
188
+
189
+ - `#angle_between` is computed with `atan2` rather than
190
+ `Math.acos(dot_product)`, which raised `Math::DomainError` whenever float
191
+ normalization pushed the dot product past ±1.0. That happened for roughly
192
+ 15% of parallel and antiparallel pairs in a random probe. The zero vector
193
+ now gives `0.0` instead of `NaN`. The range is unchanged.
194
+ - The angle converters always return floats, so a `BigDecimal` angle no
195
+ longer leaks through.
196
+ - `#perpendicular` and `#rotate` preserve the receiver's class.
197
+ - `#inspect` renders the receiver's class.
198
+ - `#normalize` and `#resize` return the zero vector unchanged, where they
199
+ previously returned `NaN` coordinates.
200
+ - `#reflect` guards against a zero normal, returning the vector unchanged.
201
+ - `#project` returns a float zero when projecting onto the zero vector.
202
+ - `#lerp` requires a real number as the amount.
203
+ - `#fit` and `#fit_either` handle negative vectors and zero coordinates by
204
+ magnitude.
205
+ - `#==` returns false for non-vectors instead of raising.
206
+ - Scalar arguments are validated in the transformations.
207
+ - Internal files are loaded with `require_relative`.
208
+ - The gemspec has a `changelog_uri`.
209
+
210
+ ### Performance improvements
211
+
212
+ Roughly 1.6x faster than the standard library `Vector` on the common
213
+ operations.
214
+
215
+ - Operands that are already usable skip the parser
216
+ - Coercion skips the parser for vectors
217
+ - The common coordinate types are checked first
218
+
219
+ ## [2.3.0](https://github.com/elektronaut/vector2d/compare/vector2d-v2.2.4...vector2d/v2.3.0) (2026-08-30)
220
+
221
+
222
+ ### Features
223
+
224
+ * 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
@@ -5,11 +5,15 @@ source "https://rubygems.org"
5
5
  gemspec
6
6
 
7
7
  group :development, :test do
8
+ gem "bigdecimal"
9
+ gem "irb"
10
+ gem "matrix"
8
11
  gem "rake"
9
12
  gem "rspec", "~> 3.8"
10
- gem "rspec-its", "~> 1.3"
13
+ gem "rspec-its", "~> 2.0"
11
14
  gem "rubocop", require: false
12
15
  gem "rubocop-rake", require: false
13
16
  gem "rubocop-rspec", require: false
14
- gem "simplecov", "~> 0.17.1"
17
+ gem "simplecov", "~> 1.2.0"
18
+ gem "yard", require: false
15
19
  end