mapcode 1.0.0

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: 9c8c1c6828218254e940975b5bade2435f267354
4
+ data.tar.gz: 09be805153977c313b54d8d0041fc56130ac5329
5
+ SHA512:
6
+ metadata.gz: 595c0b8dd14110ac6b53e36a0a3c5113d413735faf010daa7d0e8c7eb1ed9c960465fbe968d029d3c7fbf489fc8a3c6b4c9268b2189daf2563b75a26b66012d8
7
+ data.tar.gz: 7f21a708bc075f3410080f50096b9ca2ad1cdcdfca88962ada0ee1ed70b19ceac7fa6db65242d4cf97c4aade0629a0d7fbc21d98ea67c948b1718e10b861baa9
data/.autotest ADDED
@@ -0,0 +1,11 @@
1
+ require 'autotest/restart'
2
+
3
+ Autotest.add_hook :initialize do |at|
4
+ at.add_mapping(/.*\.c/) do |f, _|
5
+ at.files_matching(/test_.*rb$/)
6
+ end
7
+ end
8
+
9
+ Autotest.add_hook :run_command do |at|
10
+ system "rake clean compile"
11
+ end
data/.gemtest ADDED
File without changes
data/History.txt ADDED
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2014-09-02
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
data/Manifest.txt ADDED
@@ -0,0 +1,9 @@
1
+ .autotest
2
+ History.txt
3
+ Manifest.txt
4
+ README.md
5
+ Rakefile
6
+ ext/mapcode/extconf.rb
7
+ ext/mapcode/mapcode.c
8
+ lib/mapcode.rb
9
+ test/test_mapcode.rb
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # Mapcode - a geolocation zipcode generator which uses open source code from mapcode.com
2
+
3
+ The Mapcode gem provides a form of zipcode (pairs of letters and digits) for geo locations similar to the maidenhead locator system used by amateur radio and originally devised at a VHF meeting in Maidenhead England. The mapcode gem returns the mapcode for a given geo location using code from mapcode.com.
4
+
5
+ ## Installing
6
+ ### OSX / Linux
7
+ ``` sh
8
+ gem install mapcode
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Generate a zipcode or mapcode for a given geolocation
14
+ ``` ruby
15
+ Mapcode.new.mapcode(37.2841, -122.1432)
16
+ ```
17
+
18
+ This returns a mapcode as a string "FH.95R9@US-CA"
19
+ - you can split on the @ to return just the location if the territory or country/state is not being used.
20
+
21
+ (The MIT License)
22
+
23
+ Copyright (c) 2014 Abdul Chaudhry
24
+
25
+ Permission is hereby granted, free of charge, to any person obtaining
26
+ a copy of this software and associated documentation files (the
27
+ 'Software'), to deal in the Software without restriction, including
28
+ without limitation the rights to use, copy, modify, merge, publish,
29
+ distribute, sublicense, and/or sell copies of the Software, and to
30
+ permit persons to whom the Software is furnished to do so, subject to
31
+ the following conditions:
32
+
33
+ The above copyright notice and this permission notice shall be
34
+ included in all copies or substantial portions of the Software.
35
+
36
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
37
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
38
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
39
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
40
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
41
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
42
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ # -*- ruby -*-
2
+
3
+ require "rubygems"
4
+ require "hoe"
5
+
6
+ HOE = Hoe.spec "mapcode" do
7
+ developer('Abdul Chaudhry', 'abdollar@yahoo.com')
8
+ self.urls = ['http://example.com']
9
+ self.readme_file = 'README.md'
10
+ self.history_file = 'CHANGELOG.rdoc'
11
+ self.extra_rdoc_files = ["ext/mapcode/mapcode.c"]
12
+ self.extra_dev_deps << ['rake-compiler', '>= 0']
13
+ self.spec_extras = { :extensions => ["ext/mapcode/extconf.rb"] }
14
+ end
15
+
16
+ require "rake/extensiontask"
17
+
18
+ Rake::ExtensionTask.new(HOE.name, HOE.spec) do |ext|
19
+ ext.lib_dir = File.join('lib', 'mapcode')
20
+ end
21
+
22
+ Rake::Task[:test].prerequisites << :compile
23
+
24
+ # vim: syntax=ruby
@@ -0,0 +1,2 @@
1
+ require 'mkmf'
2
+ create_makefile('mapcode/mapcode')
@@ -0,0 +1,33 @@
1
+ #include <stdio.h>
2
+ #include <ruby.h>
3
+
4
+ VALUE cMapcode;
5
+
6
+ static VALUE latlong2mapcode(VALUE klass, VALUE lat, VALUE lon)
7
+ {
8
+ double latitude = NUM2DBL(lat);
9
+ double longitude = NUM2DBL(lon);
10
+ char *r[64];
11
+ int nrresults = coord2mc(r, latitude, longitude, 0);
12
+ if (nrresults < 2) {
13
+ rb_raise(rb_eStandardError, "Expected a valid lat long");
14
+ return Qnil;
15
+ }
16
+ char res[64];
17
+ sprintf(res, "%s@%s", r[0], r[1]);
18
+ return rb_str_new2(res);
19
+ }
20
+
21
+ /*
22
+ * call-seq:
23
+ * Mapcode.new.mapcode(required, required) -> string
24
+ *
25
+ * Call +mapcode
26
+ * returns the mapcode as a string given a lat and long as float
27
+ */
28
+ void Init_mapcode()
29
+ {
30
+ cMapcode = rb_define_class_under(rb_cObject, "Mapcode", rb_cObject);
31
+ rb_define_method(cMapcode, "mapcode", latlong2mapcode, 2);
32
+ }
33
+
data/lib/mapcode.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'mapcode/mapcode'
2
+
3
+ class Mapcode
4
+ VERSION = "1.0.0"
5
+ end
@@ -0,0 +1,27 @@
1
+ require "test/unit"
2
+ require "mapcode"
3
+
4
+ class TestMapcode < Test::Unit::TestCase
5
+ def test_basic
6
+ assert_equal Mapcode::VERSION, '1.0.0'
7
+ end
8
+
9
+ def test_latlong
10
+ assert_equal Mapcode.new.mapcode(37.445474475283376, -122.16181335628585), "9Z.YVD3@US-CA"
11
+ assert_equal Mapcode.new.mapcode(37.2841, -122.1432), "FH.95R9@US-CA"
12
+ end
13
+
14
+ def test_badlatlong
15
+ exception = assert_raise(StandardError) {
16
+ Mapcode.new.mapcode(0.00, 0.00)
17
+ }
18
+ assert_equal("Expected a valid lat long", exception.message)
19
+ end
20
+
21
+ def test_invalidParams
22
+ exception = assert_raise(TypeError) {
23
+ Mapcode.new.mapcode('0.00', '0.00')
24
+ }
25
+ assert_equal("no implicit conversion to float from string", exception.message)
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mapcode
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Abdul Chaudhry
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rdoc
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake-compiler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: hoe
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.12'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.12'
55
+ description: ''
56
+ email:
57
+ - abdollar@yahoo.com
58
+ executables: []
59
+ extensions:
60
+ - ext/mapcode/extconf.rb
61
+ extra_rdoc_files:
62
+ - History.txt
63
+ - Manifest.txt
64
+ - README.md
65
+ - ext/mapcode/mapcode.c
66
+ files:
67
+ - ".autotest"
68
+ - ".gemtest"
69
+ - History.txt
70
+ - Manifest.txt
71
+ - README.md
72
+ - Rakefile
73
+ - ext/mapcode/extconf.rb
74
+ - ext/mapcode/mapcode.c
75
+ - lib/mapcode.rb
76
+ - test/test_mapcode.rb
77
+ homepage: http://example.com
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options:
83
+ - "--main"
84
+ - README.md
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.2.2
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: ''
103
+ test_files:
104
+ - test/test_mapcode.rb