Skip to content

Commit

Permalink
Merge pull request #22 from shivam091/3.2.0
Browse files Browse the repository at this point in the history
3.2.0
  • Loading branch information
shivam091 authored Sep 27, 2023
2 parents cac2ebc + 5670d1f commit df47df6
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 4 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [3.2.0](https://github.com/shivam091/unit_measurements/compare/v3.1.0...v3.2.0) - 2023-08-27

### What's new

- Added unit group for `acceleration` units.
- Added unit group for `angular acceleration` units.

----------

## [3.1.0](https://github.com/shivam091/unit_measurements/compare/v3.0.0...v3.1.0) - 2023-08-26

### What's new
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
unit_measurements (3.1.0)
unit_measurements (3.2.0)
activesupport (~> 7.0)

GEM
Expand Down
11 changes: 11 additions & 0 deletions lib/unit_measurements/unit_groups/acceleration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- encoding: utf-8 -*-
# -*- frozen_string_literal: true -*-
# -*- warn_indent: true -*-

UnitMeasurements::Acceleration = UnitMeasurements.build do
si_unit :"m/s²", aliases: [:"m/s^2", :"m·s⁻²", :"meter per second squared", :"meters per second squared", :"metre per second squared", :"metres per second squared"]

unit :"in/s²", value: "0.0254 m/s²", aliases: [:"in/s^2", :"in·s⁻²", :"inch per second squared", :"inches per second squared"]
unit :"ft/s²", value: "0.3048 m/s²", aliases: [:"ft/s^2", :"ft·s⁻²", :"foot per second squared", :"feet per second squared"]
unit :"Kn/s", value: "0.5144444 m/s²", aliases: [:"knot per second", :"knots per second"]
end
2 changes: 2 additions & 0 deletions lib/unit_measurements/unit_groups/all.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
require_relative "force"
require_relative "voltage"
require_relative "velocity"
require_relative "acceleration"
require_relative "angular_acceleration"

## Other units

Expand Down
10 changes: 10 additions & 0 deletions lib/unit_measurements/unit_groups/angular_acceleration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- encoding: utf-8 -*-
# -*- frozen_string_literal: true -*-
# -*- warn_indent: true -*-

UnitMeasurements::AngularAcceleration = UnitMeasurements.build do
si_unit :"rad/s²", aliases: [:"rad/s^2", :"rad·s⁻²", :"radian per second squared", :"radians per second squared"]

unit :"deg/s²", value: [(Math::PI / 180), :"rad/s²"], aliases: [:"deg/s^2", :"°/s²", :"deg·s⁻²", :"degree per second squared", :"degrees per second squared"]
unit :"gon/s²", value: [(Math::PI / 200), :"rad/s²"], aliases: [:"gon/s^2", :"ᵍ/s²", :"gon·s⁻²", :"gradian per second squared", :"gradians per second squared"]
end
2 changes: 1 addition & 1 deletion lib/unit_measurements/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# -*- warn_indent: true -*-

module UnitMeasurements
VERSION = "3.1.0"
VERSION = "3.2.0"
end
71 changes: 71 additions & 0 deletions spec/unit_measurements/unit_groups/acceleration_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# -*- encoding: utf-8 -*-
# -*- frozen_string_literal: true -*-
# -*- warn_indent: true -*-

# spec/unit_measurements/unit_groups/acceleration_spec.rb

RSpec.describe UnitMeasurements::Acceleration do
describe "m/s²" do
subject { described_class.new(2, "m/s²") }

it "converts to in/s²" do
expect(subject.convert_to("in/s²").quantity).to eq(78.740157480315)
end

it "converts to ft/s²" do
expect(subject.convert_to("ft/s²").quantity).to eq(6.56167979002625)
end

it "converts to Kn/s" do
expect(subject.convert_to("Kn/s").quantity).to eq(3.8876893207507)
end
end

describe "in/s²" do
subject { described_class.new(2, "in/s²") }

it "converts to m/s²" do
expect(subject.convert_to("m/s²").quantity).to eq(0.0508)
end

it "converts to ft/s²" do
expect(subject.convert_to("ft/s²").quantity).to eq(0.166666666666667)
end

it "converts to Kn/s" do
expect(subject.convert_to("Kn/s").quantity).to eq(0.0987473087470677)
end
end

describe "ft/s²" do
subject { described_class.new(2, "ft/s²") }

it "converts to m/s²" do
expect(subject.convert_to("m/s²").quantity).to eq(0.6096)
end

it "converts to in/s²" do
expect(subject.convert_to("in/s²").quantity).to eq(24)
end

it "converts to Kn/s" do
expect(subject.convert_to("Kn/s").quantity).to eq(1.18496770496481)
end
end

describe "Kn/s" do
subject { described_class.new(2, "Kn/s") }

it "converts to m/s²" do
expect(subject.convert_to("m/s²").quantity).to eq(1.0288888)
end

it "converts to in/s²" do
expect(subject.convert_to("in/s²").quantity).to eq(40.5074330708661)
end

it "converts to ft/s²" do
expect(subject.convert_to("ft/s²").quantity).to eq(3.37561942257218)
end
end
end
43 changes: 43 additions & 0 deletions spec/unit_measurements/unit_groups/angular_acceleration_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- encoding: utf-8 -*-
# -*- frozen_string_literal: true -*-
# -*- warn_indent: true -*-

# spec/unit_measurements/unit_groups/angular_acceleration_spec.rb

RSpec.describe UnitMeasurements::AngularAcceleration do
describe "rad/s²" do
subject { described_class.new(2, "rad/s²") }

it "converts to deg/s²" do
expect(subject.convert_to("deg/s²").quantity).to eq(114.591559026165)
end

it "converts to gon/s²" do
expect(subject.convert_to("gon/s²").quantity).to eq(127.323954473516)
end
end

describe "deg/s²" do
subject { described_class.new(2, "deg/s²") }

it "converts to rad/s²" do
expect(subject.convert_to("rad/s²").quantity).to eq(0.0349065850398866)
end

it "converts to gon/s²" do
expect(subject.convert_to("gon/s²").quantity).to eq(2.22222222222222)
end
end

describe "gon/s²" do
subject { described_class.new(2, "gon/s²") }

it "converts to rad/s²" do
expect(subject.convert_to("rad/s²").quantity).to eq(0.0314159265358979)
end

it "converts to deg/s²" do
expect(subject.convert_to("deg/s²").quantity).to eq(1.8)
end
end
end
2 changes: 1 addition & 1 deletion spec/unit_measurements_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

RSpec.describe UnitMeasurements do
it "has a valid version number" do
expect(UnitMeasurements::VERSION).to eq("3.1.0")
expect(UnitMeasurements::VERSION).to eq("3.2.0")
end
end
23 changes: 22 additions & 1 deletion units.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ These units are defined in `UnitMeasurements::Voltage`.

| # | Name | Aliases |
|:--|:--|:--|
| 1 | V\* | volt, volts |
| 1 | V* | volt, volts |
| 2 | abV | abvolt, abvolts |
| 3 | statV | statvolt, statvolts |
| 4 | W/A | W·A⁻¹, watt per ampere, watts per ampere |
Expand All @@ -219,3 +219,24 @@ These units are defined in `UnitMeasurements::Velocity`.
| 8 | ft/s | ft·s⁻¹, foot per second, feet per second |
| 9 | ft/min | ft·min⁻¹, foot per minute, feet per minute |
| 10 | ft/h | ft·h⁻¹, foot per hour, feet per hour |

## 18. Acceleration

These units are defined in `UnitMeasurements::Acceleration`.

| # | Name | Aliases |
|:--|:--|:--|
| 1 | m/s² | m/s^2, m·s⁻², meter per second squared, meters per second squared, metre per second squared, metres per second squared |
| 2 | in/s² | in/s^2, in·s⁻², inch per second squared, inches per second squared |
| 3 | ft/s² | ft/s^2, ft·s⁻², foot per second squared, feet per second squared |
| 4 | Kn/s | knot per second, knots per second |

## 19. Angular acceleration

These units are defined in `UnitMeasurements::AngularAcceleration`.

| # | Name | Aliases |
|:--|:--|:--|
| 1 | rad/s² | rad/s^2, rad·s⁻², radian per second squared, radians per second squared |
| 2 | deg/s² | deg/s^2, °/s², deg·s⁻², degree per second squared, degrees per second squared |
| 3 | gon/s² | gon/s^2, ᵍ/s², gon·s⁻², gradian per second squared, gradians per second squared |

0 comments on commit df47df6

Please sign in to comment.