vfrmap 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a8e0b3bafa076ce9864972cc9667e8ad4f69607e74337e0ea1085fc5c556fd5b
4
+ data.tar.gz: 7ec65f8e5b3b70cbc1e0cecc191175847573824c95adf4f17e5128257241aeb5
5
+ SHA512:
6
+ metadata.gz: 882b94b82459a029078e939783b2b813cba974d75a14b5c9fe5be65084d70fe077fb2dc24e9c7330f402bfde5172034520e653c9e6855f63c02f1915186c850e
7
+ data.tar.gz: e995347810d89c27885851d3cc2f8774fc7e062afd4949d747b63000682998b7f0425f0c6488ca70c9305c626fbbd7445cd50ec3a04986bd69f3fd97a447be20
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .rspec_status
10
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,9 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.5
5
+ - 2.3.0
6
+ - 2.4.0
7
+ - 2.5.0
8
+
9
+ before_install: gem install bundler -v 1.16.0
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ gemspec
@@ -0,0 +1,91 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ vfrmap (1.0.0)
5
+ addressable (~> 2.5)
6
+ airports (~> 1.0)
7
+ geo_coord (~> 0.1)
8
+ padrino-helpers (~> 0.14)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ addressable (2.5.2)
14
+ public_suffix (>= 2.0.2, < 4.0)
15
+ airports (1.0.0)
16
+ coderay (1.1.2)
17
+ concurrent-ruby (1.0.5)
18
+ diff-lcs (1.3)
19
+ ffi (1.9.23)
20
+ formatador (0.2.5)
21
+ geo_coord (0.1.0)
22
+ guard (2.14.2)
23
+ formatador (>= 0.2.4)
24
+ listen (>= 2.7, < 4.0)
25
+ lumberjack (>= 1.0.12, < 2.0)
26
+ nenv (~> 0.1)
27
+ notiffany (~> 0.0)
28
+ pry (>= 0.9.12)
29
+ shellany (~> 0.0)
30
+ thor (>= 0.18.1)
31
+ guard-compat (1.2.1)
32
+ guard-rspec (4.7.3)
33
+ guard (~> 2.1)
34
+ guard-compat (~> 1.1)
35
+ rspec (>= 2.99.0, < 4.0)
36
+ i18n (0.9.5)
37
+ concurrent-ruby (~> 1.0)
38
+ listen (3.1.5)
39
+ rb-fsevent (~> 0.9, >= 0.9.4)
40
+ rb-inotify (~> 0.9, >= 0.9.7)
41
+ ruby_dep (~> 1.2)
42
+ lumberjack (1.0.12)
43
+ method_source (0.9.0)
44
+ nenv (0.3.0)
45
+ notiffany (0.1.1)
46
+ nenv (~> 0.1)
47
+ shellany (~> 0.0)
48
+ padrino-helpers (0.14.3)
49
+ i18n (~> 0.6, >= 0.6.7)
50
+ padrino-support (= 0.14.3)
51
+ tilt (>= 1.4.1, < 3)
52
+ padrino-support (0.14.3)
53
+ pry (0.11.3)
54
+ coderay (~> 1.1.0)
55
+ method_source (~> 0.9.0)
56
+ public_suffix (3.0.2)
57
+ rake (10.5.0)
58
+ rb-fsevent (0.10.3)
59
+ rb-inotify (0.9.10)
60
+ ffi (>= 0.5.0, < 2)
61
+ rspec (3.7.0)
62
+ rspec-core (~> 3.7.0)
63
+ rspec-expectations (~> 3.7.0)
64
+ rspec-mocks (~> 3.7.0)
65
+ rspec-core (3.7.1)
66
+ rspec-support (~> 3.7.0)
67
+ rspec-expectations (3.7.0)
68
+ diff-lcs (>= 1.2.0, < 2.0)
69
+ rspec-support (~> 3.7.0)
70
+ rspec-mocks (3.7.0)
71
+ diff-lcs (>= 1.2.0, < 2.0)
72
+ rspec-support (~> 3.7.0)
73
+ rspec-support (3.7.1)
74
+ ruby_dep (1.5.0)
75
+ shellany (0.0.1)
76
+ thor (0.20.0)
77
+ tilt (2.0.8)
78
+
79
+ PLATFORMS
80
+ ruby
81
+
82
+ DEPENDENCIES
83
+ bundler (~> 1.16)
84
+ guard-rspec (~> 4.3)
85
+ pry (~> 0.11)
86
+ rake (~> 10.0)
87
+ rspec (~> 3.0)
88
+ vfrmap!
89
+
90
+ BUNDLED WITH
91
+ 1.16.0
@@ -0,0 +1,70 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+
43
+ # Rails files
44
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
45
+ dsl.watch_spec_files_for(rails.app_files)
46
+ dsl.watch_spec_files_for(rails.views)
47
+
48
+ watch(rails.controllers) do |m|
49
+ [
50
+ rspec.spec.call("routing/#{m[1]}_routing"),
51
+ rspec.spec.call("controllers/#{m[1]}_controller"),
52
+ rspec.spec.call("acceptance/#{m[1]}")
53
+ ]
54
+ end
55
+
56
+ # Rails config changes
57
+ watch(rails.spec_helper) { rspec.spec_dir }
58
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60
+
61
+ # Capybara features specs
62
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
63
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
64
+
65
+ # Turnip features and steps
66
+ watch(%r{^spec/acceptance/(.+)\.feature$})
67
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
69
+ end
70
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Ryan Burnette
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ # Vfrmap
2
+
3
+ An implementation of the [VFRMAP API](http://vfrmap.com/map_api.html) in Ruby.
4
+
5
+ ## Installation
6
+
7
+ ```ruby
8
+ # Gemfile
9
+ gem 'vfrmap'
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ```ruby
15
+ require 'vfrmap'
16
+ Vfrmap.new([location],[options])
17
+ ```
18
+
19
+ - `location` Coordinates that can be parsed by
20
+ [Geo::Coord](https://github.com/zverok/geo_coord) or a 3-letter IATA airport
21
+ code.
22
+ - `options` See [DEFAULTS](#) constant.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,85 @@
1
+ require 'vfrmap/version'
2
+ require 'vfrmap/location'
3
+ require 'uri'
4
+ require 'addressable/uri'
5
+ require 'padrino-helpers'
6
+ require 'open-uri'
7
+ require 'base64'
8
+
9
+ class Vfrmap
10
+ include Padrino::Helpers::TagHelpers
11
+
12
+ DEFAULT_OPTIONS = {
13
+ type: 'vfrc',
14
+ zoom: 10,
15
+ width: 350,
16
+ height: 350,
17
+ class: nil,
18
+ alt: nil
19
+ }
20
+
21
+ attr_accessor :options
22
+
23
+ def initialize(location_string,options={})
24
+ @location = Location.factory(location_string)
25
+ raise 'Invalid location' unless @location
26
+ @options = DEFAULT_OPTIONS.merge(options)
27
+ end
28
+
29
+ def uri
30
+ URI::HTTP
31
+ .build(host: 'vfrmap.com', path: '/api', query: query_params)
32
+ .to_s
33
+ end
34
+ alias_method :src, :uri
35
+
36
+ def to_html
37
+ tag(:img, src: src, class: @options[:class], alt: @options[:alt])
38
+ end
39
+
40
+ def to_jpg
41
+ open(uri).read
42
+ end
43
+
44
+ def to_base64_jpg
45
+ Base64.encode64(to_jpg)
46
+ end
47
+
48
+ private
49
+
50
+ def location
51
+ @location
52
+ end
53
+
54
+ def latitude
55
+ case
56
+ when @location.is_a?(Geo::Coord)
57
+ (@location.to_h[:lat]*10000000).round / 10000000.0
58
+ when @location.is_a?(Airports::Airport)
59
+ @location.latitude.to_f
60
+ end
61
+ end
62
+
63
+ def longitude
64
+ case
65
+ when @location.is_a?(Geo::Coord)
66
+ (@location.to_h[:lng]*10000000).round / 10000000.0
67
+ when @location.is_a?(Airports::Airport)
68
+ @location.longitude.to_f
69
+ end
70
+ end
71
+
72
+ def query_params
73
+ uri = Addressable::URI.new
74
+ uri.query_values = {
75
+ req: 'map',
76
+ type: @options[:type],
77
+ lat: latitude,
78
+ lon: longitude,
79
+ zoom: @options[:zoom],
80
+ width: @options[:width],
81
+ height: @options[:height]
82
+ }
83
+ uri.query
84
+ end
85
+ end
@@ -0,0 +1,22 @@
1
+ require 'geo/coord'
2
+ require 'airports'
3
+
4
+ class Vfrmap::Location
5
+ def self.factory(location_string)
6
+ coordinates = try_coordinates(location_string)
7
+ return coordinates if coordinates
8
+
9
+ airport = try_airport(location_string)
10
+ return airport if airport
11
+ end
12
+
13
+ private
14
+
15
+ def self.try_coordinates(location_string)
16
+ Geo::Coord.parse(location_string)
17
+ end
18
+
19
+ def self.try_airport(location_string)
20
+ Airports.find_by_iata_code(location_string.upcase)
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ class Vfrmap
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,33 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "vfrmap/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "vfrmap"
7
+ spec.version = Vfrmap::VERSION
8
+ spec.authors = ["Ryan Burnette"]
9
+ spec.email = ["ryan.burnette@gmail.com"]
10
+ spec.summary = "An implementation of the [VFRMAP API](http://vfrmap.com/map_api.html) in Ruby."
11
+ spec.homepage = "https://github.com/ryanburnette/vfrmap"
12
+ spec.license = "MIT"
13
+
14
+ spec.required_ruby_version = ">= 2.2.5"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.16"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+ spec.add_development_dependency "guard-rspec", "~> 4.3"
27
+ spec.add_development_dependency "pry", "~> 0.11"
28
+
29
+ spec.add_dependency "padrino-helpers", "~> 0.14"
30
+ spec.add_dependency "geo_coord", "~> 0.1"
31
+ spec.add_dependency "airports", "~> 1.0"
32
+ spec.add_dependency "addressable", "~> 2.5"
33
+ end
metadata ADDED
@@ -0,0 +1,184 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vfrmap
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Burnette
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-03-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.11'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.11'
83
+ - !ruby/object:Gem::Dependency
84
+ name: padrino-helpers
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.14'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.14'
97
+ - !ruby/object:Gem::Dependency
98
+ name: geo_coord
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.1'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: airports
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: addressable
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.5'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '2.5'
139
+ description:
140
+ email:
141
+ - ryan.burnette@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".rspec"
148
+ - ".travis.yml"
149
+ - Gemfile
150
+ - Gemfile.lock
151
+ - Guardfile
152
+ - LICENSE.txt
153
+ - README.md
154
+ - Rakefile
155
+ - lib/vfrmap.rb
156
+ - lib/vfrmap/location.rb
157
+ - lib/vfrmap/version.rb
158
+ - vfrmap.gemspec
159
+ homepage: https://github.com/ryanburnette/vfrmap
160
+ licenses:
161
+ - MIT
162
+ metadata: {}
163
+ post_install_message:
164
+ rdoc_options: []
165
+ require_paths:
166
+ - lib
167
+ required_ruby_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: 2.2.5
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ requirements: []
178
+ rubyforge_project:
179
+ rubygems_version: 2.7.4
180
+ signing_key:
181
+ specification_version: 4
182
+ summary: An implementation of the [VFRMAP API](http://vfrmap.com/map_api.html) in
183
+ Ruby.
184
+ test_files: []