geohex-v3 0.0.1 → 0.0.2

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ecce8cac7df6b2460124ba67294887a8f5bcfbb0
4
+ data.tar.gz: 689f25c1b7d486c162b6b439490fb8cc037963fc
5
+ SHA512:
6
+ metadata.gz: 3720c443a22c91089030fb5dd147c742646539f1bebd1b2da8eeecb11d337c4ae6985f5922a990340197759f83c5087f16d5113764e95ee591ee5e34e763e750
7
+ data.tar.gz: 513d49cd34873ee6e8da0fc5ace4ae1efa302479bb6a10d7b1e54739095dc9df4957a06dc789c50b3de8f01ce7cd975c4c1107fe1f8db04453ccda1ce908d7da
data/.travis.yml ADDED
@@ -0,0 +1,24 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.8.7
5
+ - 1.9.2
6
+ - 1.9.3
7
+ - 2.0.0
8
+ # - jruby
9
+ - ree
10
+
11
+ script: "bundle exec rake spec"
12
+
13
+ notifications:
14
+ # disabled: true
15
+ email: false
16
+ # email:
17
+ # recipients:
18
+ # -
19
+ # on_success: change
20
+ # on_failure: always
21
+
22
+ branches:
23
+ only:
24
+ - master
@@ -141,7 +141,7 @@ module Geohex
141
141
  h_a1 = (h_1 / 30).to_i
142
142
  h_a2 = h_1 % 30
143
143
 
144
- @code = "#{ H_KEY.slice(h_a1) }#{ H_KEY.slice(h_a2) }#{ h_2 }"
144
+ @code = "#{ H_KEY.slice(h_a1, 1) }#{ H_KEY.slice(h_a2, 1) }#{ h_2 }"
145
145
  @x = h_x
146
146
  @y = h_y
147
147
  @latitude = latitude
@@ -1,3 +1,3 @@
1
1
  module Geohex
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -33,6 +33,8 @@ describe Geohex::V3::Zone do
33
33
 
34
34
  describe :decode do
35
35
 
36
+ let(:precision) { 11 }
37
+
36
38
  CSV.read(File.expand_path("../../../spec/fixtures/files/code2location.csv", File.dirname(__FILE__))).each do |data|
37
39
 
38
40
  context "code: #{ data[3] }" do
@@ -43,8 +45,8 @@ describe Geohex::V3::Zone do
43
45
 
44
46
  subject { Geohex::V3::Zone.decode code }
45
47
 
46
- its(:latitude) { should be_eql latitude }
47
- its(:longitude) { should be_eql longitude }
48
+ its(:latitude) { should be_near_eql latitude, precision }
49
+ its(:longitude) { should be_near_eql longitude, precision }
48
50
  its(:level) { should be_eql level }
49
51
  end
50
52
  end
data/spec/spec_helper.rb CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  if ENV['COVERAGE']
4
4
  require "simplecov"
5
+
6
+ SimpleCov.start :test_frameworks do
7
+ add_filter "/vendor/bundle/"
8
+ end
5
9
  end
6
10
 
7
11
  require 'geohex'
@@ -0,0 +1,14 @@
1
+ require 'bigdecimal'
2
+
3
+ RSpec::Matchers.define :be_near_eql do |expected, precision|
4
+ match do |actual|
5
+ bigdecimal_actual = BigDecimal.new(actual.to_s).round(precision).ceil(precision)
6
+ bigdecimal_expected = BigDecimal.new(expected.to_s).round(precision).ceil(precision)
7
+
8
+ if expected == 180.0
9
+ bigdecimal_actual.abs == bigdecimal_expected.abs
10
+ else
11
+ bigdecimal_actual == bigdecimal_expected
12
+ end
13
+ end
14
+ end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geohex-v3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - toshiwo
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-16 00:00:00.000000000 Z
11
+ date: 2013-03-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rr
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - '>='
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: simplecov
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - '>='
76
67
  - !ruby/object:Gem::Version
@@ -83,6 +74,7 @@ extensions: []
83
74
  extra_rdoc_files: []
84
75
  files:
85
76
  - .gitignore
77
+ - .travis.yml
86
78
  - Gemfile
87
79
  - LICENSE.txt
88
80
  - README.md
@@ -98,36 +90,30 @@ files:
98
90
  - spec/geohex/v3_spec.rb
99
91
  - spec/geohex_spec.rb
100
92
  - spec/spec_helper.rb
93
+ - spec/support/custum_matchers.rb
101
94
  - tasks/spec.rake
102
95
  homepage: https://github.com/toshiwo/geohex-v3
103
96
  licenses: []
97
+ metadata: {}
104
98
  post_install_message:
105
99
  rdoc_options: []
106
100
  require_paths:
107
101
  - lib
108
102
  required_ruby_version: !ruby/object:Gem::Requirement
109
- none: false
110
103
  requirements:
111
104
  - - '>='
112
105
  - !ruby/object:Gem::Version
113
106
  version: '0'
114
- segments:
115
- - 0
116
- hash: -2054732348720920267
117
107
  required_rubygems_version: !ruby/object:Gem::Requirement
118
- none: false
119
108
  requirements:
120
109
  - - '>='
121
110
  - !ruby/object:Gem::Version
122
111
  version: '0'
123
- segments:
124
- - 0
125
- hash: -2054732348720920267
126
112
  requirements: []
127
113
  rubyforge_project: geohex
128
- rubygems_version: 1.8.25
114
+ rubygems_version: 2.0.0
129
115
  signing_key:
130
- specification_version: 3
116
+ specification_version: 4
131
117
  summary: The GeoHex is a latitude/longitude encoding system
132
118
  test_files:
133
119
  - spec/fixtures/files/code2location.csv
@@ -136,3 +122,4 @@ test_files:
136
122
  - spec/geohex/v3_spec.rb
137
123
  - spec/geohex_spec.rb
138
124
  - spec/spec_helper.rb
125
+ - spec/support/custum_matchers.rb