metar-parser 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9cd36dbde3df4b92e6a196ef774fe54ac20877b942bc04f49a9cc12e9ce9d1f
4
- data.tar.gz: a6e77ae8a9ead64ab0877f204d858731e45f29aa7fd2fc8e2fff7a87672eab17
3
+ metadata.gz: e7f1558724e63f52aee14e0f1775c7f4dc90eb187c9d3060426d7ab14de16fe4
4
+ data.tar.gz: 189365393cc681c9398dc78fe9d941fb56166276dea4645f1f56a93fef19394f
5
5
  SHA512:
6
- metadata.gz: 357e2d2187207db5ca6db35a084698eed370a537d8bbbd1ff4293da5748b71c7e9886d3ad45647069a44dcc5454c18878f3799a814a344a760f1c9846e7c6d9f
7
- data.tar.gz: fe2acd2ccb94821e6a6c06e283bc131bdb6bc7a99fb646018f8bd7bb85a3a026bce30d6d72af7870cc049d26623adefebcffea0f702a2f39ae5181d3596c1fad
6
+ metadata.gz: 376de6502034e38fa3581b4c0b7c6cc0df72d4067ae20337c12f3f5f294ca926587628a0a1769848a682545ad04a59b2547fd2697db5aafe73d67e4497c9adb5
7
+ data.tar.gz: 55bc69ff0cf47c5b7c6a207fe6d56327bc3e0c4c9b9f6b262807c32e13ff554ee611a21158d62acb92426a0223533590a2a221c7dcfab2cced49e8748eb4cdff
data/lib/metar/station.rb CHANGED
@@ -53,7 +53,7 @@ module Metar
53
53
  m = latitude.match(/^(\d+)-(\d+)([SN])/)
54
54
  return nil if !m
55
55
 
56
- (m[3] == 'E' ? 1.0 : -1.0) * (m[1].to_f + m[2].to_f / 60.0)
56
+ (m[3] == 'N' ? 1.0 : -1.0) * (m[1].to_f + m[2].to_f / 60.0)
57
57
  end
58
58
  end
59
59
 
data/lib/metar/version.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Metar
4
4
  module VERSION #:nodoc:
5
5
  MAJOR = 1
6
- MINOR = 6
6
+ MINOR = 7
7
7
  TINY = 0
8
8
 
9
9
  STRING = [MAJOR, MINOR, TINY].join('.')
data/spec/station_spec.rb CHANGED
@@ -104,6 +104,12 @@ describe Metar::Station do
104
104
  expect(Metar::Station.to_longitude("055-24E")).to eq(55.4)
105
105
  end
106
106
 
107
+ context "with Western values" do
108
+ it "returns negative results" do
109
+ expect(Metar::Station.to_longitude("055-24W")).to eq(-55.4)
110
+ end
111
+ end
112
+
107
113
  it "returns nil for badly formed strings" do
108
114
  expect(Metar::Station.to_longitude("aaa")).to be_nil
109
115
  end
@@ -111,7 +117,13 @@ describe Metar::Station do
111
117
 
112
118
  context ".to_latitude" do
113
119
  it "converts strings to latitude" do
114
- expect(Metar::Station.to_latitude("11-03S")).to eq(-11.05)
120
+ expect(Metar::Station.to_latitude("11-03N")).to eq(11.05)
121
+ end
122
+
123
+ context "with Southern values" do
124
+ it "returns negative results" do
125
+ expect(Metar::Station.to_latitude("11-03S")).to eq(-11.05)
126
+ end
115
127
  end
116
128
 
117
129
  it "returns nil for badly formed strings" do
@@ -123,12 +135,25 @@ describe Metar::Station do
123
135
  let(:name) { "Station name" }
124
136
  let(:state) { "State" }
125
137
  let(:country) { "Country" }
138
+ let(:longitude) { "055-24E" }
139
+ let(:latitude) { "11-03N" }
126
140
  let(:noaa_raw) do
127
- cccc +
128
- ";00;000;" +
129
- name + ";" +
130
- state + ";" +
131
- country + ";1;11-03S;055-24E;11-03S;055-24E;000;000;P"
141
+ [
142
+ cccc,
143
+ "00",
144
+ "000",
145
+ name,
146
+ state,
147
+ country,
148
+ "1",
149
+ latitude,
150
+ longitude,
151
+ latitude,
152
+ longitude,
153
+ "000",
154
+ "000",
155
+ "P"
156
+ ].join(";")
132
157
  end
133
158
  let(:noaa_data) do
134
159
  {
@@ -136,8 +161,8 @@ describe Metar::Station do
136
161
  name: name,
137
162
  state: state,
138
163
  country: country,
139
- longitude: "055-24E",
140
- latitude: "11-03S",
164
+ longitude: longitude,
165
+ latitude: latitude,
141
166
  raw: noaa_raw
142
167
  }
143
168
  end
@@ -175,8 +200,24 @@ describe Metar::Station do
175
200
  specify { expect(subject.state).to eq(state) }
176
201
  specify { expect(subject.country).to eq(country) }
177
202
  specify { expect(subject.longitude).to eq(55.4) }
178
- specify { expect(subject.latitude).to eq(-11.05) }
203
+ specify { expect(subject.latitude).to eq(11.05) }
179
204
  specify { expect(subject.raw).to eq(noaa_raw) }
205
+
206
+ context "when longitude is Western" do
207
+ let(:longitude) { "055-24W" }
208
+
209
+ it "is parsed as negative" do
210
+ expect(subject.longitude).to eq(-55.4)
211
+ end
212
+ end
213
+
214
+ context "When latitude is Southern" do
215
+ let(:latitude) { "11-03S" }
216
+
217
+ it "is parsed as negative" do
218
+ expect(subject.latitude).to eq(-11.05)
219
+ end
220
+ end
180
221
  end
181
222
  end
182
223
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metar-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Yates
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-03 00:00:00.000000000 Z
11
+ date: 2023-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -235,7 +235,7 @@ files:
235
235
  homepage: https://github.com/joeyates/metar-parser
236
236
  licenses: []
237
237
  metadata: {}
238
- post_install_message:
238
+ post_install_message:
239
239
  rdoc_options: []
240
240
  require_paths:
241
241
  - lib
@@ -250,8 +250,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
250
  - !ruby/object:Gem::Version
251
251
  version: '0'
252
252
  requirements: []
253
- rubygems_version: 3.1.6
254
- signing_key:
253
+ rubygems_version: 3.0.3.1
254
+ signing_key:
255
255
  specification_version: 4
256
256
  summary: A Ruby gem for worldwide weather reports
257
257
  test_files: