notams 0.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -1
- data/CONTRIBUTING.md +8 -0
- data/Guardfile +1 -4
- data/LICENSE +1 -1
- data/README.md +28 -4
- data/lib/notams.rb +2 -69
- data/lib/notams/notam.rb +33 -0
- data/lib/notams/notam_fetcher.rb +41 -0
- data/lib/notams/version.rb +1 -1
- data/notams.gemspec +1 -1
- data/spec/notams_spec.rb +0 -1
- metadata +8 -5
data/.travis.yml
CHANGED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
## Contributing to "notams"
|
2
|
+
|
3
|
+
1. Fork it
|
4
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
5
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
6
|
+
4. Make sure all tests pass!
|
7
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
8
|
+
6. Create new Pull Request
|
data/Guardfile
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
# More info at https://github.com/guard/guard#readme
|
3
|
-
|
4
|
-
guard 'rspec', :version => 2 do
|
1
|
+
guard 'rspec' do
|
5
2
|
watch(%r{^spec/.+_spec\.rb$})
|
6
3
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
4
|
watch('spec/spec_helper.rb') { "spec" }
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -4,9 +4,15 @@ A ruby gem for retrieving the currently active NOTAMs for an airport or a region
|
|
4
4
|
Supports multiple airports/regions in one request. Pulls data from
|
5
5
|
[FAA](http://www.faa.gov/) website. Depends on `nokogiri` for the heavy lifting.
|
6
6
|
|
7
|
-
[![Build Status](https://secure.travis-ci.org/tarakanbg/notams.png)](http://travis-ci.org/tarakanbg/notams)
|
8
|
-
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/tarakanbg/notams)
|
7
|
+
[![Build Status](https://secure.travis-ci.org/tarakanbg/notams.png?branch=master)](http://travis-ci.org/tarakanbg/notams)
|
9
8
|
[![Gemnasium](https://gemnasium.com/tarakanbg/notams.png?travis)](https://gemnasium.com/tarakanbg/notams)
|
9
|
+
[![Gem Version](https://badge.fury.io/rb/notams.png)](http://badge.fury.io/rb/notams)
|
10
|
+
[![Code Climate](https://codeclimate.com/github/tarakanbg/notams.png)](https://codeclimate.com/github/tarakanbg/notams)
|
11
|
+
|
12
|
+
## Requirements
|
13
|
+
|
14
|
+
[Ruby 1.9.3](http://www.ruby-lang.org/en/downloads/) or higher | **Supports Ruby 2.0!**
|
15
|
+
|
10
16
|
|
11
17
|
## Installation
|
12
18
|
|
@@ -107,7 +113,13 @@ end
|
|
107
113
|
|
108
114
|
## Changelog
|
109
115
|
|
110
|
-
### v. 0.
|
116
|
+
### v. 0.2.0 27 February 2013
|
117
|
+
|
118
|
+
* Ruby 2.0 support
|
119
|
+
* dependencies update
|
120
|
+
* classes refactored
|
121
|
+
|
122
|
+
### v. 0.1.0 28 July 2012
|
111
123
|
|
112
124
|
* added optional arguments customization to the `.notams` method (see [Advanced Usage](#advanced-usage))
|
113
125
|
* code refactored into classes for flexibility
|
@@ -118,6 +130,18 @@ end
|
|
118
130
|
1. Fork it
|
119
131
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
120
132
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
121
|
-
4. Make sure all tests
|
133
|
+
4. Make sure all tests pass!
|
122
134
|
5. Push to the branch (`git push origin my-new-feature`)
|
123
135
|
6. Create new Pull Request
|
136
|
+
|
137
|
+
|
138
|
+
## Credits
|
139
|
+
|
140
|
+
Copyright © 2013 [Svilen Vassilev](http://svilen.rubystudio.net)
|
141
|
+
|
142
|
+
*If you find my work useful or time-saving, you can endorse it or buy me a cup of coffee:*
|
143
|
+
|
144
|
+
[![endorse](http://api.coderwall.com/svilenv/endorsecount.png)](http://coderwall.com/svilenv)
|
145
|
+
[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5FR7AQA4PLD8A)
|
146
|
+
|
147
|
+
Released under the [MIT LICENSE](https://github.com/tarakanbg/notams/blob/master/LICENSE)
|
data/lib/notams.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
%w{notams/version notams/notam_fetcher notams/notam}.each { |lib| require lib }
|
2
2
|
|
3
3
|
class String
|
4
4
|
def notams(args={})
|
@@ -7,76 +7,9 @@ class String
|
|
7
7
|
end
|
8
8
|
|
9
9
|
module Notams
|
10
|
+
|
10
11
|
def self.notams(icao, args)
|
11
12
|
NotamFetcher.new(icao, args).fetch
|
12
13
|
end
|
13
14
|
|
14
|
-
class NotamFetcher
|
15
|
-
require 'nokogiri'
|
16
|
-
require 'open-uri'
|
17
|
-
|
18
|
-
attr_accessor :icao, :obj_list, :notams, :string_notams
|
19
|
-
|
20
|
-
def initialize(icao, args = nil)
|
21
|
-
@icao = icao
|
22
|
-
process_arguments(args) if args.class == Hash
|
23
|
-
@notams = []; @string_notams = []
|
24
|
-
notams_object_list
|
25
|
-
notams_string_list
|
26
|
-
end
|
27
|
-
|
28
|
-
def raw_list
|
29
|
-
Nokogiri::HTML(open("https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId=#{@icao}&actionType=notamRetrievalByICAOs"))
|
30
|
-
end
|
31
|
-
|
32
|
-
def fetch
|
33
|
-
@obj_list == true ? @notams : @string_notams
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def notams_string_list
|
39
|
-
@notams.each {|n| @string_notams << n.to_s}
|
40
|
-
end
|
41
|
-
|
42
|
-
def notams_object_list
|
43
|
-
raw_list.css("pre").each {|n| @notams << Notam.new(n.text)}
|
44
|
-
end
|
45
|
-
|
46
|
-
def process_arguments(args)
|
47
|
-
args[:objects] == true ? @obj_list = true : @obj_list = false
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
class Notam
|
53
|
-
|
54
|
-
attr_accessor :raw, :message, :icao
|
55
|
-
|
56
|
-
def initialize(text)
|
57
|
-
@raw = text
|
58
|
-
@message = get_message
|
59
|
-
@icao = get_icao
|
60
|
-
end
|
61
|
-
|
62
|
-
def to_s
|
63
|
-
@raw
|
64
|
-
end
|
65
|
-
|
66
|
-
private
|
67
|
-
|
68
|
-
def get_message
|
69
|
-
starts = @raw.index('E)') + 3
|
70
|
-
@raw.index('F)') ? ends = @raw.index('F)') : ends = @raw.length
|
71
|
-
@raw[starts..ends]
|
72
|
-
end
|
73
|
-
|
74
|
-
def get_icao
|
75
|
-
starts = @raw.index('A)') + 3
|
76
|
-
ends = @raw.index('B)') - 2
|
77
|
-
@raw[starts..ends]
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
15
|
end
|
data/lib/notams/notam.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module Notams
|
2
|
+
|
3
|
+
class Notam
|
4
|
+
|
5
|
+
attr_accessor :raw, :message, :icao
|
6
|
+
|
7
|
+
def initialize(text)
|
8
|
+
@raw = text
|
9
|
+
@message = get_message
|
10
|
+
@icao = get_icao
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_s
|
14
|
+
@raw
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def get_message
|
20
|
+
starts = @raw.index('E)') + 3
|
21
|
+
@raw.index('F)') ? ends = @raw.index('F)') : ends = @raw.length
|
22
|
+
@raw[starts..ends]
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_icao
|
26
|
+
starts = @raw.index('A)') + 3
|
27
|
+
ends = @raw.index('B)') - 2
|
28
|
+
@raw[starts..ends]
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Notams
|
2
|
+
|
3
|
+
class NotamFetcher
|
4
|
+
require 'nokogiri'
|
5
|
+
require 'open-uri'
|
6
|
+
|
7
|
+
attr_accessor :icao, :obj_list, :notams, :string_notams
|
8
|
+
|
9
|
+
def initialize(icao, args = nil)
|
10
|
+
@icao = icao
|
11
|
+
process_arguments(args) if args.class == Hash
|
12
|
+
@notams = []; @string_notams = []
|
13
|
+
notams_object_list
|
14
|
+
notams_string_list
|
15
|
+
end
|
16
|
+
|
17
|
+
def raw_list
|
18
|
+
Nokogiri::HTML(open("https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId=#{@icao}&actionType=notamRetrievalByICAOs"))
|
19
|
+
end
|
20
|
+
|
21
|
+
def fetch
|
22
|
+
@obj_list == true ? @notams : @string_notams
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def notams_string_list
|
28
|
+
@notams.each {|n| @string_notams << n.to_s}
|
29
|
+
end
|
30
|
+
|
31
|
+
def notams_object_list
|
32
|
+
raw_list.css("pre").each {|n| @notams << Notam.new(n.text)}
|
33
|
+
end
|
34
|
+
|
35
|
+
def process_arguments(args)
|
36
|
+
args[:objects] == true ? @obj_list = true : @obj_list = false
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/lib/notams/version.rb
CHANGED
data/notams.gemspec
CHANGED
@@ -20,6 +20,6 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_development_dependency "guard"
|
21
21
|
gem.add_development_dependency "libnotify"
|
22
22
|
gem.add_development_dependency "guard-rspec"
|
23
|
-
gem.add_dependency "nokogiri", "~> 1.5.
|
23
|
+
gem.add_dependency "nokogiri", "~> 1.5.6"
|
24
24
|
|
25
25
|
end
|
data/spec/notams_spec.rb
CHANGED
@@ -54,7 +54,6 @@ describe String do
|
|
54
54
|
icao = "lqsa"
|
55
55
|
Notams::NotamFetcher.new(icao, :objects => true).fetch.first.message.should eq(icao.notams(:objects => true).first.message)
|
56
56
|
icao.notams(:objects => true).first.message.class.should eq(String)
|
57
|
-
# "lqsb".notams(:objects => true).first.message.should eq("moo")
|
58
57
|
end
|
59
58
|
|
60
59
|
it "should properly return the notam object icao" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notams
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
requirements:
|
99
99
|
- - ~>
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: 1.5.
|
101
|
+
version: 1.5.6
|
102
102
|
type: :runtime
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -106,7 +106,7 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 1.5.
|
109
|
+
version: 1.5.6
|
110
110
|
description: Retrieves the currently active NOTAMs for an airport or a region. Supports
|
111
111
|
multiple airports/regions in one request. Pulls data from FAA website.
|
112
112
|
email:
|
@@ -117,12 +117,15 @@ extra_rdoc_files: []
|
|
117
117
|
files:
|
118
118
|
- .gitignore
|
119
119
|
- .travis.yml
|
120
|
+
- CONTRIBUTING.md
|
120
121
|
- Gemfile
|
121
122
|
- Guardfile
|
122
123
|
- LICENSE
|
123
124
|
- README.md
|
124
125
|
- Rakefile
|
125
126
|
- lib/notams.rb
|
127
|
+
- lib/notams/notam.rb
|
128
|
+
- lib/notams/notam_fetcher.rb
|
126
129
|
- lib/notams/version.rb
|
127
130
|
- notams.gemspec
|
128
131
|
- spec/notams_spec.rb
|
@@ -147,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
150
|
version: '0'
|
148
151
|
requirements: []
|
149
152
|
rubyforge_project:
|
150
|
-
rubygems_version: 1.8.
|
153
|
+
rubygems_version: 1.8.25
|
151
154
|
signing_key:
|
152
155
|
specification_version: 3
|
153
156
|
summary: Retrieves the currently active NOTAMs for an airport or a region
|