Skip to content

Commit

Permalink
Merge pull request #58 from shivam091/5.8.0
Browse files Browse the repository at this point in the history
5.8.0
  • Loading branch information
shivam091 authored Nov 4, 2023
2 parents 11dbd69 + f5d9cc9 commit 1833c7f
Show file tree
Hide file tree
Showing 8 changed files with 297 additions and 27 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [5.8.0](https://github.com/shivam091/unit_measurements/compare/v5.7.0...v5.8.0) - 2023-11-06

### What's new

- Added new units of `pressure`.
- Added new units of `power`.

----------

## [5.7.0](https://github.com/shivam091/unit_measurements/compare/v5.6.1...v5.7.0) - 2023-11-04

### 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 (5.7.0)
unit_measurements (5.8.0)
activesupport (~> 7.0)

GEM
Expand Down
32 changes: 31 additions & 1 deletion lib/unit_measurements/unit_groups/power.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,46 @@
system :metric do
si_unit "W", aliases: ["watt", "watts"]

unit "p", value: "980.665 W", aliases: ["poncelet", "poncelets"]

unit "hp (M)", value: "735.49875 W", aliases: ["PS", "metric horsepower"]

unit "kgf⋅m", value: "9.80665 W", aliases: ["kgf*m", "kilogramme-force meter", "kilogram-force meter"]

unit "cal/s", value: "4.1868 W", aliases: ["calorie per second", "calories per second"]
unit "cal/min", value: "0.06978 W", aliases: ["calorie per minute", "calories per minute"]
unit "cal/h", value: "0.001163 W", aliases: ["calorie per hour", "calories per hour"]

unit "l·atm/s", value: "101.325 W", aliases: ["l*atm/s", "litre-atmosphere per second", "liter-atmosphere per second"]
unit "l·atm/min", value: "1.68875 W", aliases: ["l*atm/min", "litre-atmosphere per minute", "liter-atmosphere per minute"]
unit "l·atm/h", value: "0.028145833333333335 W", aliases: ["l*atm/h", "litre-atmosphere per hour", "liter-atmosphere per hour"]

unit "atm⋅cm³/s", value: "0.101325 W", aliases: ["atm*cm^3/s", "atmosphere-cubic centimetre per second", "atmosphere-cubic centimeter per second"]
unit "atm⋅cm³/min", value: "1.68875e-3 W", aliases: ["atm*cm^3/min", "atmosphere-cubic centimetre per minute", "atmosphere-cubic centimeter per minute"]
unit "atm⋅cm³/h", value: "2.814583333333333e-5 W", aliases: ["atm*cm^3/h", "atmosphere-cubic centimetre per hour", "atmosphere-cubic centimeter per hour"]
end

system :imperial do
unit "hp", value: "745.69987158227022 W", aliases: ["hp (I)", "horsepower"]

unit "ft⋅lbf/s", value: "1.3558179483314004 W", aliases: ["ft*lbf/s", "foot pound-force per second"]
unit "ft⋅lbf/min", value: "0.02259696580552334 W", aliases: ["ft*lbf/min", "foot pound-force per minute"]
unit "ft⋅lbf/h", value: "0.00037661609675872 W", aliases: ["ft*lbf/h", "foot pound-force per hour"]

unit "atm⋅ft³/s", value: "2.8692044809344e+3 W", aliases: ["atm*ft^3/s", "atmosphere-cubic foot per second"]
unit "atm⋅ft³/min", value: "47.82007468224 W", aliases: ["atm*ft^3/min", "atmosphere-cubic foot per minute"]
unit "atm⋅ft³/h", value: "0.79700124704 W", aliases: ["atm*ft^3/h", "atmosphere-cubic foot per hour"]
end

system :us_customary do
unit "BTU/s", value: "1055.05585262 W", aliases: ["british thermal unit per second", "british thermal units per second"]
unit "BTU/min", value: "17.584264210333 W", aliases: ["british thermal unit per minute", "british thermal units per minute"]
unit "BTU/h", value: "0.29307107017222 W", aliases: ["british thermal unit per hour", "british thermal units per hour"]
end

system :centimetre_gram_second do
unit "erg/s", value: "1e-7 W", aliases: ["erg per second", "ergs per second"]
end

unit "cal/s", value: "4.1868 W", aliases: ["calorie per second", "calories per second"]
unit "lusec", value: "133.3224 μW", aliases: ["lusecs"]
end
37 changes: 34 additions & 3 deletions lib/unit_measurements/unit_groups/pressure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,40 @@
si_unit "Pa", aliases: ["pascal", "pascals"]

unit "bar", value: "100 kPa", aliases: ["bars"]
unit "atm", value: "101325 Pa", aliases: ["atmosphere", "atmospheres"]
unit "Torr", value: "1/760 atm", aliases: ["torr"]

unit "μmHg", value: "0.133322387415 Pa", aliases: ["micrometer of mercury", "micrometers of mercury", "micrometre of mercury", "micrometres of mercury"]
unit "mmHg", value: "133.322387415 Pa", aliases: ["millimeter of mercury", "millimeters of mercury", "millimetre of mercury", "millimetres of mercury"]
unit "cmHg", value: "1333.22387415 Pa", aliases: ["centimeter of mercury", "centimeters of mercury", "centimetre of mercury", "centimetres of mercury"]

unit "mH₂O", value: "9.80665 kPa", aliases: ["mH2O", "meter of water", "meters of water", "metre of water", "metres of water"]
unit "dmH₂O", value: "980.665 Pa", aliases: ["dmH2O", "decimeter of water", "decimeters of water", "decimetre of water", "decimetres of water"]
unit "cmH₂O", value: "98.0665 Pa", aliases: ["cmH2O", "centimeter of water", "centimeters of water", "centimetre of water", "centimetres of water"]
unit "mmH₂O", value: "9.80665 Pa", aliases: ["mmH2O", "millimeter of water", "millimeters of water", "millimetre of water", "millimetres of water"]

unit "kgf/m²", value: "9.80665 Pa", aliases: ["kgf/m^2", "kilogram-force per square metre", "kilogramme-force per square metre"]
unit "kgf/mm²", value: "9.80665 MPa", aliases: ["kgf/mm^2", "kilogram-force per square millimetre", "kilogramme-force per square millimetre"]
unit "kgf/dm²", value: "980.665 Pa", aliases: ["kgf/dm^2", "kilogram-force per square decimetre", "kilogramme-force per square decimetre"]
end

system :imperial do
unit "psf", value: "47.880259 Pa", aliases: ["lb/ft²", "lb/ft^2", "pound per square foot", "pounds per square foot"]
unit "psi", value: "6.894757 kPa", aliases: ["lb/in²", "lb/in^2", "pound per square inch", "pounds per square inch"]
unit "ksi", value: "1000 psi", aliases: ["kip per square inch", "kilopound per square inch", "kilopounds per square inch"]

unit "LT/ft²", value: "1.0725178011595e+5 Pa", aliases: ["LT/ft^2", "long ton per square foot", "long tons per square foot"]
unit "pdl/ft²", value: "1.488164 Pa", aliases: ["pdl/ft^2", "poundal per square foot", "poundals per square foot"]
end

system :us_customary do
unit "inHg", value: "3.386388640341 kPa", aliases: ["″Hg", "inch of mercury", "inches of mercury"]
unit "ftHg", value: "40.636663684092 kPa", aliases: ["′Hg", "foot of mercury", "feet of mercury"]

unit "ftH₂O", value: "2.98898 kPa", aliases: ["ftH2O", "foot of water", "feet of water"]
unit "inH₂O", value: "249.0889 Pa", aliases: ["inH2O", "Aq", "inAq", "inch of water", "inches of water", "inch of water gauge", "inches of water gauge", "inch of water column", "inches of water column"]

unit "tn/ft²", value: "9.5760518e+4 Pa", aliases: ["tn/ft^2", "ton per square foot", "tons per square foot", "short ton per square foot", "short tons per square foot"]
end

system :centimetre_gram_second do
Expand All @@ -22,7 +56,4 @@
system :gravitational_metric do
unit "at", value: "98066.5 Pa", aliases: ["technical atmosphere", "technical atmospheres"]
end

unit "atm", value: "101325 Pa", aliases: ["atmosphere", "atmospheres"]
unit "Torr", value: [Rational(1, 760), "atm"], aliases: ["torr"]
end
2 changes: 1 addition & 1 deletion lib/unit_measurements/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

module UnitMeasurements
# Current stable version.
VERSION = "5.7.0"
VERSION = "5.8.0"
end
94 changes: 87 additions & 7 deletions spec/unit_measurements/unit_groups/power_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,102 @@

RSpec.describe UnitMeasurements::Power do
describe "W" do
subject { described_class.new(2, "W") }
subject { described_class.new(5, "W") }

it "converts to hp (M)" do
expect(subject.convert_to("hp (M)").quantity).to eq(0.00271924323460781)
it "converts to p" do
expect(subject.convert_to("p").quantity).to eq(0.00509858106488964)
end

it "converts to hp" do
expect(subject.convert_to("hp").quantity).to eq(0.00268204417919006)
expect(subject.convert_to("hp").quantity).to eq(0.00670511044797514)
end

it "converts to erg/s" do
expect(subject.convert_to("erg/s").quantity).to eq(2e+7)
it "converts to hp (M)" do
expect(subject.convert_to("hp (M)").quantity).to eq(0.00679810808651952)
end

it "converts to kgf⋅m" do
expect(subject.convert_to("kgf⋅m").quantity).to eq(0.509858106488964)
end

it "converts to cal/s" do
expect(subject.convert_to("cal/s").quantity).to eq(0.477691793254992)
expect(subject.convert_to("cal/s").quantity).to eq(1.19422948313748)
end

it "converts to cal/min" do
expect(subject.convert_to("cal/min").quantity).to eq(71.6537689882488)
end

it "converts to cal/h" do
expect(subject.convert_to("cal/h").quantity).to eq(4299.22613929493)
end

it "converts to l·atm/s" do
expect(subject.convert_to("l·atm/s").quantity).to eq(0.0493461633358006)
end

it "converts to l·atm/min" do
expect(subject.convert_to("l·atm/min").quantity).to eq(2.96076980014804)
end

it "converts to l·atm/h" do
expect(subject.convert_to("l·atm/h").quantity).to eq(177.646188008882)
end

it "converts to atm⋅cm³/s" do
expect(subject.convert_to("atm⋅cm³/s").quantity).to eq(49.3461633358006)
end

it "converts to atm⋅cm³/min" do
expect(subject.convert_to("atm⋅cm³/min").quantity).to eq(2960.76980014804)
end

it "converts to atm⋅cm³/h" do
expect(subject.convert_to("atm⋅cm³/h").quantity).to eq(1.77646188008882e+5)
end

it "converts to ft⋅lbf/s" do
expect(subject.convert_to("ft⋅lbf/s").quantity).to eq(3.68781074638633)
end

it "converts to ft⋅lbf/min" do
expect(subject.convert_to("ft⋅lbf/min").quantity).to eq(221.26864478318)
end

it "converts to ft⋅lbf/h" do
expect(subject.convert_to("ft⋅lbf/h").quantity).to eq(13276.1186869909)
end

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

it "converts to BTU/min" do
expect(subject.convert_to("BTU/min").quantity).to eq(0.284345136094001)
end

it "converts to BTU/h" do
expect(subject.convert_to("BTU/h").quantity).to eq(17.0607081656398)
end

it "converts to erg/s" do
expect(subject.convert_to("erg/s").quantity).to eq(5e+7)
end

it "converts to lusec" do
expect(subject.convert_to("lusec").quantity).to eq(37503.0752521707)
end

it "converts to atm⋅ft³/s" do
expect(subject.convert_to("atm⋅ft³/s").quantity).to eq(0.00174264331218794)
end

it "converts to atm⋅ft³/min" do
expect(subject.convert_to("atm⋅ft³/min").quantity).to eq(0.104558598731276)
end

it "converts to atm⋅ft³/h" do
expect(subject.convert_to("atm⋅ft³/h").quantity).to eq(6.27351590548899)
end
end
end
90 changes: 85 additions & 5 deletions spec/unit_measurements/unit_groups/pressure_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
describe "Pa" do
subject { described_class.new(5, "Pa") }

it "converts to bar" do
expect(subject.convert_to("bar").quantity).to eq(0.00005)
end

it "converts to Ba" do
expect(subject.convert_to("Ba").quantity).to eq(50)
end
Expand All @@ -21,15 +17,99 @@
end

it "converts to at" do
expect(subject.convert_to("at").quantity).to eq(0.0000509858106488964)
expect(subject.convert_to("at").quantity).to eq(5.09858106488964e-5)
end

it "converts to bar" do
expect(subject.convert_to("bar").quantity).to eq(5e-5)
end

it "converts to atm" do
expect(subject.convert_to("atm").quantity).to eq(4.93461633358006e-5)
end

it "converts to psf" do
expect(subject.convert_to("psf").quantity).to eq(0.104427171122863)
end

it "converts to psi" do
expect(subject.convert_to("psi").quantity).to eq(0.000725188719486415)
end

it "converts to ksi" do
expect(subject.convert_to("ksi").quantity).to eq(7.25188719486415e-7)
end

it "converts to Torr" do
expect(subject.convert_to("Torr").quantity).to eq(0.0375030841352085)
end

it "converts to μmHg" do
expect(subject.convert_to("μmHg").quantity).to eq(37.5030787922828)
end

it "converts to mmHg" do
expect(subject.convert_to("mmHg").quantity).to eq(0.0375030787922828)
end

it "converts to cmHg" do
expect(subject.convert_to("cmHg").quantity).to eq(0.00375030787922828)
end

it "converts to inHg" do
expect(subject.convert_to("inHg").quantity).to eq(0.0014764991650505)
end

it "converts to ftHg" do
expect(subject.convert_to("ftHg").quantity).to eq(0.000123041597087542)
end

it "converts to mH₂O" do
expect(subject.convert_to("mH₂O").quantity).to eq(0.000509858106488964)
end

it "converts to dmH₂O" do
expect(subject.convert_to("dmH₂O").quantity).to eq(0.00509858106488964)
end

it "converts to cmH₂O" do
expect(subject.convert_to("cmH₂O").quantity).to eq(0.0509858106488964)
end

it "converts to mmH₂O" do
expect(subject.convert_to("mmH₂O").quantity).to eq(0.509858106488964)
end

it "converts to ftH₂O" do
expect(subject.convert_to("ftH₂O").quantity).to eq(0.00167281146076588)
end

it "converts to inH₂O" do
expect(subject.convert_to("inH₂O").quantity).to eq(0.0200731546046412)
end

it "converts to LT/ft²" do
expect(subject.convert_to("LT/ft²").quantity).to eq(4.6619272841854e-5)
end

it "converts to tn/ft²" do
expect(subject.convert_to("tn/ft²").quantity).to eq(5.22135855614315e-5)
end

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

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

it "converts to kgf/dm²" do
expect(subject.convert_to("kgf/dm²").quantity).to eq(0.00509858106488964)
end

it "converts to kgf/mm²" do
expect(subject.convert_to("kgf/mm²").quantity).to eq(5.09858106488964e-7)
end
end
end
Loading

0 comments on commit 1833c7f

Please sign in to comment.