notams 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in notams.gemspec
4
+ gemspec
@@ -0,0 +1,8 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2 do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Svilen Vassilev
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ # Notams [![Build Status](https://secure.travis-ci.org/tarakanbg/notams.png)](http://travis-ci.org/tarakanbg/notams)
2
+
3
+ A ruby gem for retrieving the currently active NOTAMs for an airport or a region.
4
+ Supports multiple airports/regions in one request. Pulls data from [FAA](http://www.faa.gov/) website.
5
+ Depends on `nokogiri` for the heavy lifting.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'notams'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install notams
20
+
21
+ ## Usage
22
+
23
+ The `.notams` method can be applied to any string (or variable containing a string), representing a valid
24
+ ICAO code of an airport or FIR, or a comma-separated list of airports/regions. It will return an array,
25
+ containing all the **currently active** NOTAMs for your selection. You can loop through the array to display or
26
+ parse individual notams.
27
+
28
+ ```ruby
29
+ icao = "lowi"
30
+ icao.notams # => returns an array containing all NOTAMs for Innsbruck airport
31
+
32
+ "lowi".notams # => same as above
33
+
34
+ icao = "lqsa,lqsb"
35
+ icao.notams # => returns an array containing all NOTAMs for Sarajevo Airport and Bosnia and Herzegovina FIR
36
+ ```
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork it
41
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
42
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
43
+ 4. Push to the branch (`git push origin my-new-feature`)
44
+ 5. Create new Pull Request
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
@@ -0,0 +1,25 @@
1
+ require "notams/version"
2
+ require 'nokogiri'
3
+ require 'open-uri'
4
+
5
+
6
+ class String
7
+ def notams
8
+ Notams.notams(self)
9
+ end
10
+ end
11
+
12
+ module Notams
13
+ def self.notams(icao)
14
+ notams = []
15
+ get_raw_page(icao).css("pre").each {|n| notams << n.text }
16
+ return notams
17
+ end
18
+
19
+ private
20
+
21
+ def self.get_raw_page(icao)
22
+ Nokogiri::HTML(open("https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId=#{icao}&actionType=notamRetrievalByICAOs"))
23
+ end
24
+
25
+ end
@@ -0,0 +1,3 @@
1
+ module Notams
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/notams/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Svilen Vassilev"]
6
+ gem.email = ["svilen@rubystudio.net"]
7
+ gem.description = %q{Retrieves the currently active NOTAMs for an airport or a region. Supports multiple airports/regions in one request. Pulls data from FAA website.}
8
+ gem.summary = %q{Retrieves the currently active NOTAMs for an airport or a region}
9
+ gem.homepage = "https://github.com/tarakanbg/notams"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "notams"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Notams::VERSION
17
+
18
+ gem.add_development_dependency "rspec"
19
+ gem.add_development_dependency "rake"
20
+ gem.add_development_dependency "guard"
21
+ gem.add_development_dependency "libnotify"
22
+ gem.add_development_dependency "guard-rspec"
23
+ gem.add_dependency "nokogiri"
24
+
25
+ end
@@ -0,0 +1,54 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe String do
4
+
5
+ describe "input" do
6
+ it "is a string" do
7
+ input = "lqsa"
8
+ input.class.should eq(String)
9
+ input = "lqsa, lqsb"
10
+ input.class.should eq(String)
11
+ end
12
+ end
13
+
14
+ describe ".notams" do
15
+ it "should return an array" do
16
+ icao = "lqsa"
17
+ icao.notams.class.should eq(Array)
18
+ end
19
+
20
+ it "length should be more than 0" do
21
+ icao = "lqsa"
22
+ icao.notams.length.should be > 0
23
+ end
24
+
25
+ it "array should include strings" do
26
+ icao = "lqsa"
27
+ icao.notams.first.class.should eq(String)
28
+ end
29
+
30
+ it "string should contain icao" do
31
+ icao = "LQSA"
32
+ icao.notams.first.should include icao
33
+ end
34
+
35
+ it "should handle multiple icaos" do
36
+ "lqsa".notams.length.should_not eq("lqsa,lqsb".notams.length)
37
+ end
38
+
39
+ end
40
+
41
+ describe Notams do
42
+
43
+ describe "get_raw_page" do
44
+ it "should execute open uri request via Nokogiri" do
45
+ icao = "lqsa"
46
+ Notams.get_raw_page(icao).class.should eq(Nokogiri::HTML::Document)
47
+ Notams.get_raw_page(icao).css("title").text.should eq("PilotWeb: Results Page ")
48
+ end
49
+ end
50
+
51
+ end
52
+
53
+
54
+ end
@@ -0,0 +1,4 @@
1
+ require 'notams'
2
+
3
+
4
+
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: notams
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Svilen Vassilev
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
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: rake
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: guard
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: libnotify
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
+ - !ruby/object:Gem::Dependency
79
+ name: guard-rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: nokogiri
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: Retrieves the currently active NOTAMs for an airport or a region. Supports
111
+ multiple airports/regions in one request. Pulls data from FAA website.
112
+ email:
113
+ - svilen@rubystudio.net
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .travis.yml
120
+ - Gemfile
121
+ - Guardfile
122
+ - LICENSE
123
+ - README.md
124
+ - Rakefile
125
+ - lib/notams.rb
126
+ - lib/notams/version.rb
127
+ - notams.gemspec
128
+ - spec/notams_spec.rb
129
+ - spec/spec_helper.rb
130
+ homepage: https://github.com/tarakanbg/notams
131
+ licenses: []
132
+ post_install_message:
133
+ rdoc_options: []
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ none: false
144
+ requirements:
145
+ - - ! '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 1.8.24
151
+ signing_key:
152
+ specification_version: 3
153
+ summary: Retrieves the currently active NOTAMs for an airport or a region
154
+ test_files:
155
+ - spec/notams_spec.rb
156
+ - spec/spec_helper.rb