Skip to content

Commit 7bdd961

Browse files
committed
Rename to h3 in preparation for rubygems.org registration.
1 parent a755a64 commit 7bdd961

File tree

10 files changed

+53
-37
lines changed

10 files changed

+53
-37
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,23 @@ TODO: Add more wrapper functions.
99
* Follow the h3 instructions for installing the C lib at https://github.com/uber/h3. You will need to build from source.
1010
* Run `rake compile`.
1111

12+
## Installing
13+
14+
gem install h3
15+
16+
or
17+
18+
# Gemfile
19+
gem "h3", "~> 0.0.1pre"
20+
1221
## Running Specs
1322

1423
bin/rspec spec
1524

25+
## Usage
26+
27+
```ruby
28+
require "h3"
29+
H3.geo_to_h3([53.959130, -1.079230], 8).to_i(16)
30+
# => "8819429a9dfffff"
31+
```

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require "rake/extensiontask"
22

33
Rake::ExtensionTask.new("h3") do |ext|
4-
ext.lib_dir = "lib/h3_ruby"
4+
ext.lib_dir = "lib/h3"
55
end

ext/h3/h3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void H3_EXPORT(h3ToGeo)(H3Index h3, GeoCoord *g);
122122
/* This function has a special name and it is invoked by Ruby to initialize the extension. */
123123
void Init_h3()
124124
{
125-
VALUE h3_ruby = rb_define_module("H3Ruby");
125+
VALUE h3_ruby = rb_define_module("H3");
126126
rb_define_singleton_method(h3_ruby, "max_kring_size", h3_maxKringSize, 1);
127127
rb_define_singleton_method(h3_ruby, "geo_to_h3", h3_geoToH3, 2);
128128
rb_define_singleton_method(h3_ruby, "h3_to_geo", h3_h3ToGeo, 1);

h3_ruby.gemspec renamed to h3.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ $: << File.expand_path("lib", __dir__)
22
require "h3_ruby/version"
33

44
Gem::Specification.new do |spec|
5-
spec.name = "h3-ruby"
5+
spec.name = "h3"
66
spec.version = H3Ruby::VERSION
77
spec.licenses = ["Nonstandard"] # Avoids a warning when building the gem.
88
spec.summary = "C Bindings for Uber's H3 library"

lib/h3_ruby.rb renamed to lib/h3.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
require "h3_ruby/h3"
2-
require "h3_ruby/version"
1+
require "h3/h3"
2+
require "h3/version"
33

4-
module H3Ruby
4+
module H3
55
def self.bearing_between(from, to, options={})
66
_bearing_between(from, to, options[:method] == :spherical)
77
end

lib/h3/h3.bundle

18.4 KB
Binary file not shown.

lib/h3/version.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module H3
2+
VERSION = "0.0.1pre"
3+
end

lib/h3_ruby/version.rb

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
require "bigdecimal"
22

3-
RSpec.describe H3Ruby do
3+
RSpec.describe H3 do
44
let(:valid_h3_index) { "8819429a9dfffff".to_i(16) }
55
let(:too_long_number) { 10_000_000_000_000_000_000_000 }
66

77
describe ".max_kring_size" do
88
let(:k) { 2 }
99
let(:result) { 19 }
1010

11-
subject(:max_kring_size) { H3Ruby.max_kring_size(k) }
11+
subject(:max_kring_size) { H3.max_kring_size(k) }
1212

1313
it { is_expected.to eq(result) }
1414

@@ -34,7 +34,7 @@
3434
let(:coords) { [53.959130, -1.079230]}
3535
let(:result) { valid_h3_index }
3636

37-
subject(:geo_to_h3) { H3Ruby.geo_to_h3(coords, resolution) }
37+
subject(:geo_to_h3) { H3.geo_to_h3(coords, resolution) }
3838

3939
it { is_expected.to eq(result) }
4040

@@ -67,7 +67,7 @@
6767
let(:h3_index) { valid_h3_index }
6868
let(:result) { [53.95860421941974, -1.081195647095136] }
6969

70-
subject(:h3_to_geo) { H3Ruby.h3_to_geo(h3_index) }
70+
subject(:h3_to_geo) { H3.h3_to_geo(h3_index) }
7171

7272
it { is_expected.to eq(result) }
7373

@@ -92,7 +92,7 @@
9292
let(:h3_index) { valid_h3_index }
9393
let(:result) { true }
9494

95-
subject(:h3_valid?) { H3Ruby.h3_valid?(h3_index) }
95+
subject(:h3_valid?) { H3.h3_valid?(h3_index) }
9696

9797
it { is_expected.to eq(result) }
9898

@@ -111,7 +111,7 @@
111111
let(:resolution) { 2 }
112112
let(:result) { 5882 }
113113

114-
subject(:num_hexagons) { H3Ruby.num_hexagons(resolution) }
114+
subject(:num_hexagons) { H3.num_hexagons(resolution) }
115115

116116
it { is_expected.to eq(result) }
117117

@@ -129,7 +129,7 @@
129129
let(:degs) { 100 }
130130
let(:result) { 1.7453292519943295 }
131131

132-
subject(:degs_to_rads) { H3Ruby.degs_to_rads(degs) }
132+
subject(:degs_to_rads) { H3.degs_to_rads(degs) }
133133

134134
it { is_expected.to eq(result) }
135135
end
@@ -138,7 +138,7 @@
138138
let(:rads) { 1.7453292519943295 }
139139
let(:result) { 100 }
140140

141-
subject(:rads_to_degs) { H3Ruby.rads_to_degs(rads) }
141+
subject(:rads_to_degs) { H3.rads_to_degs(rads) }
142142

143143
it { is_expected.to eq(result) }
144144
end
@@ -147,7 +147,7 @@
147147
let(:resolution) { 2 }
148148
let(:result) { 86745.85403 }
149149

150-
subject(:hex_area_km2) { H3Ruby.hex_area_km2(resolution) }
150+
subject(:hex_area_km2) { H3.hex_area_km2(resolution) }
151151

152152
it { is_expected.to eq(result) }
153153
end
@@ -156,7 +156,7 @@
156156
let(:resolution) { 2 }
157157
let(:result) { 86745854035.0 }
158158

159-
subject(:hex_area_m2) { H3Ruby.hex_area_m2(resolution) }
159+
subject(:hex_area_m2) { H3.hex_area_m2(resolution) }
160160

161161
it { is_expected.to eq(result) }
162162
end
@@ -165,7 +165,7 @@
165165
let(:resolution) { 2 }
166166
let(:result) { 158.2446558 }
167167

168-
subject(:edge_length_km) { H3Ruby.edge_length_km(resolution) }
168+
subject(:edge_length_km) { H3.edge_length_km(resolution) }
169169

170170
it { is_expected.to eq(result) }
171171
end
@@ -174,7 +174,7 @@
174174
let(:resolution) { 2 }
175175
let(:result) { 158244.6558 }
176176

177-
subject(:edge_length_m) { H3Ruby.edge_length_m(resolution) }
177+
subject(:edge_length_m) { H3.edge_length_m(resolution) }
178178

179179
it { is_expected.to eq(result) }
180180
end
@@ -183,7 +183,7 @@
183183
let(:h3_index) { "8928308280fffff".to_i(16) }
184184
let(:result) { true }
185185

186-
subject(:h3_res_class_3) { H3Ruby.h3_res_class_3?(h3_index) }
186+
subject(:h3_res_class_3) { H3.h3_res_class_3?(h3_index) }
187187

188188
it { is_expected.to eq(result) }
189189

@@ -199,7 +199,7 @@
199199
let(:h3_index) { "821c07fffffffff".to_i(16) }
200200
let(:result) { true }
201201

202-
subject(:h3_pentagon?) { H3Ruby.h3_pentagon?(h3_index) }
202+
subject(:h3_pentagon?) { H3.h3_pentagon?(h3_index) }
203203

204204
it { is_expected.to eq(result) }
205205

@@ -215,7 +215,7 @@
215215
let(:edge) { "11928308280fffff".to_i(16) }
216216
let(:result) { true }
217217

218-
subject(:h3_unidirectional_edge_valid?) { H3Ruby.h3_unidirectional_edge_valid?(edge) }
218+
subject(:h3_unidirectional_edge_valid?) { H3.h3_unidirectional_edge_valid?(edge) }
219219

220220
it { is_expected.to eq(result) }
221221

@@ -231,7 +231,7 @@
231231
let(:h3_index) { valid_h3_index }
232232
let(:result) { 8 }
233233

234-
subject(:h3_resolution) { H3Ruby.h3_resolution(h3_index) }
234+
subject(:h3_resolution) { H3.h3_resolution(h3_index) }
235235

236236
it { is_expected.to eq(result) }
237237
end
@@ -240,7 +240,7 @@
240240
let(:h3_index) { valid_h3_index }
241241
let(:result) { 12 }
242242

243-
subject(:h3_base_cell) { H3Ruby.h3_base_cell(h3_index) }
243+
subject(:h3_base_cell) { H3.h3_base_cell(h3_index) }
244244

245245
it { is_expected.to eq(result) }
246246
end
@@ -249,7 +249,7 @@
249249
let(:edge) { "11928308280fffff".to_i(16) }
250250
let(:result) { "8928308280fffff".to_i(16) }
251251

252-
subject(:origin_from_unidirectional_edge) { H3Ruby.origin_from_unidirectional_edge(edge) }
252+
subject(:origin_from_unidirectional_edge) { H3.origin_from_unidirectional_edge(edge) }
253253

254254
it { is_expected.to eq(result) }
255255
end
@@ -258,7 +258,7 @@
258258
let(:edge) { "11928308280fffff".to_i(16) }
259259
let(:result) { "8928308283bffff".to_i(16) }
260260

261-
subject(:destination_from_unidirectional_edge) { H3Ruby.destination_from_unidirectional_edge(edge) }
261+
subject(:destination_from_unidirectional_edge) { H3.destination_from_unidirectional_edge(edge) }
262262

263263
it { is_expected.to eq(result) }
264264
end
@@ -268,7 +268,7 @@
268268
let(:destination) { "89283082827ffff".to_i(16) }
269269
let(:result) { 5 }
270270

271-
subject(:h3_distance) { H3Ruby.h3_distance(origin, destination) }
271+
subject(:h3_distance) { H3.h3_distance(origin, destination) }
272272

273273
it { is_expected.to eq(result) }
274274
end
@@ -278,7 +278,7 @@
278278
let(:parent_resolution) { 8 }
279279
let(:result) { 698351615 }
280280

281-
subject(:h3_to_parent) { H3Ruby.h3_to_parent(h3_index, parent_resolution) }
281+
subject(:h3_to_parent) { H3.h3_to_parent(h3_index, parent_resolution) }
282282

283283
it { is_expected.to eq(result) }
284284
end
@@ -288,7 +288,7 @@
288288
let(:child_resolution) { 10 }
289289
let(:result) { 7 }
290290

291-
subject(:max_h3_to_children_size) { H3Ruby.max_h3_to_children_size(h3_index, child_resolution) }
291+
subject(:max_h3_to_children_size) { H3.max_h3_to_children_size(h3_index, child_resolution) }
292292

293293
it { is_expected.to eq(result) }
294294
end
@@ -298,7 +298,7 @@
298298
let(:destination) { "8928308280bffff".to_i(16) }
299299
let(:result) { true }
300300

301-
subject(:h3_indexes_neighbors?) { H3Ruby.h3_indexes_neighbors?(origin, destination) }
301+
subject(:h3_indexes_neighbors?) { H3.h3_indexes_neighbors?(origin, destination) }
302302

303303
it { is_expected.to eq(result) }
304304

@@ -315,7 +315,7 @@
315315
let(:destination) { "8928308280bffff".to_i(16) }
316316
let(:result) { "16928308280fffff".to_i(16) }
317317

318-
subject(:h3_unidirectional_edge) { H3Ruby.h3_unidirectional_edge(origin, destination) }
318+
subject(:h3_unidirectional_edge) { H3.h3_unidirectional_edge(origin, destination) }
319319

320320
it { is_expected.to eq(result) }
321321
end
@@ -324,7 +324,7 @@
324324
let(:h3_index) { "8928308280fffff"}
325325
let(:result) { h3_index.to_i(16) }
326326

327-
subject(:string_to_h3) { H3Ruby.string_to_h3(h3_index) }
327+
subject(:string_to_h3) { H3.string_to_h3(h3_index) }
328328

329329
it { is_expected.to eq(result) }
330330
end
@@ -333,7 +333,7 @@
333333
let(:h3_index) { "8928308280fffff" }
334334
let(:result) { h3_index.to_i(16) }
335335

336-
subject(:string_to_h3) { H3Ruby.string_to_h3(h3_index) }
336+
subject(:string_to_h3) { H3.string_to_h3(h3_index) }
337337

338338
it { is_expected.to eq(result) }
339339
end
@@ -342,7 +342,7 @@
342342
let(:h3_index) { "8928308280fffff".to_i(16) }
343343
let(:result) { h3_index.to_s(16) }
344344

345-
subject(:h3_to_string) { H3Ruby.h3_to_string(h3_index) }
345+
subject(:h3_to_string) { H3.h3_to_string(h3_index) }
346346

347347
it { is_expected.to eq(result) }
348348
end

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require "h3_ruby"
1+
require "h3"
22

33
require_relative "support/models"
44
require_relative "support/matchers"

0 commit comments

Comments
 (0)