geohex-v3 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,52 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+ require 'csv'
5
+
6
+ describe Geohex::V3::Zone do
7
+
8
+ it { should be_respond_to :latitude }
9
+ it { should be_respond_to :longitude }
10
+ it { should be_respond_to :lat }
11
+ it { should be_respond_to :lon }
12
+ it { should be_respond_to :level }
13
+ it { should be_respond_to :code }
14
+ it { should be_respond_to :x }
15
+ it { should be_respond_to :y }
16
+
17
+ describe :encode do
18
+
19
+ CSV.read(File.expand_path("../../../spec/fixtures/files/location2code.csv", File.dirname(__FILE__))).each do |data|
20
+
21
+ context "latitude: #{ data[0] } longitude: #{ data[1] } level: #{ data[2] }" do
22
+ let(:latitude) { data[0].to_f }
23
+ let(:longitude) { data[1].to_f }
24
+ let(:level) { data[2].to_i }
25
+ let(:code) { data[3] }
26
+
27
+ subject { Geohex::V3::Zone.encode latitude, longitude, level }
28
+
29
+ it { should be_eql code }
30
+ end
31
+ end
32
+ end
33
+
34
+ describe :decode do
35
+
36
+ CSV.read(File.expand_path("../../../spec/fixtures/files/code2location.csv", File.dirname(__FILE__))).each do |data|
37
+
38
+ context "code: #{ data[3] }" do
39
+ let(:latitude) { data[0].to_f }
40
+ let(:longitude) { data[1].to_f }
41
+ let(:level) { data[2].to_i }
42
+ let(:code) { data[3] }
43
+
44
+ subject { Geohex::V3::Zone.decode code }
45
+
46
+ its(:latitude) { should be_eql latitude }
47
+ its(:longitude) { should be_eql longitude }
48
+ its(:level) { should be_eql level }
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Geohex::V3 do
6
+ end
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Geohex do
6
+ end
@@ -0,0 +1,23 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ if ENV['COVERAGE']
4
+ require "simplecov"
5
+ end
6
+
7
+ require 'geohex'
8
+
9
+ # Requires supporting ruby files with custom matchers and macros, etc,
10
+ # in spec/support/ and its subdirectories.
11
+ Dir[File.expand_path("./support/**/*.rb", File.dirname(__FILE__))].each {|f| require f}
12
+
13
+ RSpec.configure do |config|
14
+ # == Mock Framework
15
+ #
16
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
17
+ #
18
+ # config.mock_with :mocha
19
+ # config.mock_with :flexmock
20
+ # config.mock_with :rr
21
+ # config.mock_with :rspec
22
+ config.mock_with :rr
23
+ end
@@ -0,0 +1,14 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:spec) do |t|
4
+ t.pattern = "./spec/**/*_spec.rb"
5
+ # Put spec opts in a file named .rspec in root
6
+ end
7
+
8
+ desc "Generate code examples statistics"
9
+ task :coverage do
10
+ ENV['COVERAGE'] = 'true'
11
+
12
+ Rake::Task['spec'].execute
13
+ end
14
+
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: geohex-v3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - toshiwo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rr
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: simplecov
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: The GeoHex is a latitude/longitude encoding system
79
+ email:
80
+ - toshiwo@toshiwo.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .gitignore
86
+ - Gemfile
87
+ - LICENSE.txt
88
+ - README.md
89
+ - Rakefile
90
+ - geohex.gemspec
91
+ - lib/geohex.rb
92
+ - lib/geohex/v3.rb
93
+ - lib/geohex/v3/zone.rb
94
+ - lib/geohex/version.rb
95
+ - spec/fixtures/files/code2location.csv
96
+ - spec/fixtures/files/location2code.csv
97
+ - spec/geohex/v3/zone_spec.rb
98
+ - spec/geohex/v3_spec.rb
99
+ - spec/geohex_spec.rb
100
+ - spec/spec_helper.rb
101
+ - tasks/spec.rake
102
+ homepage: https://github.com/toshiwo/geohex-v3
103
+ licenses: []
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ segments:
115
+ - 0
116
+ hash: -2054732348720920267
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ segments:
124
+ - 0
125
+ hash: -2054732348720920267
126
+ requirements: []
127
+ rubyforge_project: geohex
128
+ rubygems_version: 1.8.25
129
+ signing_key:
130
+ specification_version: 3
131
+ summary: The GeoHex is a latitude/longitude encoding system
132
+ test_files:
133
+ - spec/fixtures/files/code2location.csv
134
+ - spec/fixtures/files/location2code.csv
135
+ - spec/geohex/v3/zone_spec.rb
136
+ - spec/geohex/v3_spec.rb
137
+ - spec/geohex_spec.rb
138
+ - spec/spec_helper.rb