vatbook 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
@@ -3,6 +3,6 @@
3
3
  1. Fork it
4
4
  2. Create your feature branch (`git checkout -b my-new-feature`)
5
5
  3. Commit your changes (`git commit -am 'Added some feature'`)
6
- 4. Make sure all tests are passing!
6
+ 4. Make sure all tests pass!
7
7
  5. Push to the branch (`git push origin my-new-feature`)
8
8
  6. Create new Pull Request
data/Guardfile CHANGED
@@ -1,4 +1,4 @@
1
- guard 'rspec', :version => 2 do
1
+ guard 'rspec' do
2
2
  watch(%r{^spec/.+_spec\.rb$})
3
3
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
4
  watch('spec/spec_helper.rb') { "spec" }
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Svilen Vassilev
1
+ Copyright (c) 2013 Svilen Vassilev
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -6,8 +6,9 @@ objects, exposing a rich set of attributes. Supports excluding enroute pilot boo
6
6
  Supports pulling pilot and atc bookings separately or as a combined hash.
7
7
 
8
8
  [![Build Status](https://secure.travis-ci.org/tarakanbg/vatbook.png?branch=master)](http://travis-ci.org/tarakanbg/vatbook)
9
- [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/tarakanbg/vatbook)
10
- <!-- [![Gemnasium](https://gemnasium.com/tarakanbg/vatbook.png?travis)](https://gemnasium.com/tarakanbg/vatbook) -->
9
+ [![Gemnasium](https://gemnasium.com/tarakanbg/vatbook.png?travis)](https://gemnasium.com/tarakanbg/vatbook)
10
+ [![Gem Version](https://badge.fury.io/rb/vatbook.png)](http://badge.fury.io/rb/vatbook)
11
+ [![Code Climate](https://codeclimate.com/github/tarakanbg/vatbook.png)](https://codeclimate.com/github/tarakanbg/vatbook)
11
12
 
12
13
 
13
14
  ## Installation
@@ -118,6 +119,12 @@ airports. Example:
118
119
 
119
120
  ## Changelog
120
121
 
122
+ ### v. 0.2 - 28 February 2013
123
+
124
+ * Ruby 2.0 support
125
+ * dependencies update
126
+ * classes refactored
127
+
121
128
  ### v. 0.1 - 22 October 2012
122
129
 
123
130
  * Initial release
@@ -133,11 +140,11 @@ airports. Example:
133
140
 
134
141
  ## Credits
135
142
 
136
- Copyright © 2012 [Svilen Vassilev](http://about.me/svilen)
143
+ Copyright © 2013 [Svilen Vassilev](http://svilen.rubystudio.net)
137
144
 
138
- *If you find my work useful or time-saving, you can endorse it or buy me a beer:*
145
+ *If you find my work useful or time-saving, you can endorse it or buy me a cup of coffee:*
139
146
 
140
- [![endorse](http://api.coderwall.com/svilenv/endorse.png)](http://coderwall.com/svilenv)
147
+ [![endorse](http://api.coderwall.com/svilenv/endorsecount.png)](http://coderwall.com/svilenv)
141
148
  [![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)
142
149
 
143
- Released under the [MIT LICENSE](https://github.com/tarakanbg/vatbook/blob/master/LICENSE.txt)
150
+ Released under the [MIT LICENSE](https://github.com/tarakanbg/vatbook/blob/master/LICENSE)
@@ -1,4 +1,4 @@
1
- require "vatbook/version"
1
+ %w{vatbook/version vatbook/book_fetcher vatbook/booking}.each { |lib| require lib }
2
2
 
3
3
  class String
4
4
  def vatbook(args={})
@@ -7,113 +7,9 @@ class String
7
7
  end
8
8
 
9
9
  module Vatbook
10
+
10
11
  def self.bookings(fir, args)
11
12
  BookFetcher.new(fir, args).fetch
12
13
  end
13
14
 
14
- class BookFetcher
15
- require 'nokogiri'
16
- require 'open-uri'
17
-
18
- attr_accessor :fir, :atc_bookings, :pilot_bookings, :enroute, :doc
19
-
20
- def initialize(fir, args = nil)
21
- @fir = fir.upcase
22
- @enroute = true
23
- process_arguments(args) if args.class == Hash
24
- @atc_bookings = []; @pilot_bookings = [];
25
- @doc = raw_list
26
- atcs
27
- pilots
28
- end
29
-
30
- def raw_list
31
- Nokogiri::XML(open("http://vatbook.euroutepro.com/xml2.php?fir=#{@fir}"))
32
- end
33
-
34
- def fetch
35
- {:atc => atc_bookings, :pilots => pilot_bookings}
36
- end
37
-
38
- def atc_bookings
39
- @atc_bookings
40
- end
41
-
42
- def pilot_bookings
43
- @pilot_bookings
44
- end
45
-
46
- def atcs_count
47
- @doc.css("atcs booking").count
48
- end
49
-
50
- def pilots_count
51
- @doc.css("pilots booking").count
52
- end
53
-
54
- private
55
-
56
- def atcs
57
- @doc.css("atcs booking").each do |booking|
58
- @atc_bookings << Booking.new(booking, role = "atc", @fir)
59
- end
60
- end
61
-
62
- def pilots
63
- @doc.css("pilots booking").each do |booking|
64
- if @enroute == false
65
- bk = Booking.new(booking, role = "pilot", @fir)
66
- if bk.enroute == false
67
- @pilot_bookings << bk
68
- end
69
- else
70
- @pilot_bookings << Booking.new(booking, role = "pilot", @fir)
71
- end
72
- end
73
- end
74
-
75
- def process_arguments(args)
76
- args[:enroute] == false ? @enroute = false : @enroute = true
77
- end
78
-
79
- end
80
-
81
- class Booking
82
- require 'nokogiri'
83
-
84
- attr_accessor :role, :callsign, :name, :cid, :start, :end, :dep, :arr
85
- attr_accessor :aircraft, :route, :enroute, :fir
86
-
87
-
88
- def initialize(booking, role, fir)
89
- @fir = fir
90
- @role = role
91
- @callsign = booking.children.css("callsign").first.children.to_s
92
- @name = booking.children.css("name").first.children.to_s
93
- @role == "atc" ? @cid = booking.children.css("cid").first.children.to_s : @cid = booking.children.css("pid").first.children.to_s
94
- if @role == "atc"
95
- @start = booking.children.css("time_start").first.children.to_s
96
- @end = booking.children.css("time_end").first.children.to_s
97
- elsif @role == "pilot"
98
- @dep = booking.children.css("dep").first.children.to_s
99
- @arr = booking.children.css("arr").first.children.to_s
100
- @route = booking.children.css("route").first.children.to_s.gsub(/[\n]/, ' ').strip
101
- @start = booking.children.css("from").first.children.to_s
102
- @end = booking.children.css("to").first.children.to_s
103
- @aircraft = booking.children.css("actype").first.children.to_s
104
- check_enroute
105
- end
106
- end
107
-
108
- private
109
- def check_enroute
110
- if @fir[0..1] == @dep[0..1] or @fir[0..1] == @arr[0..1]
111
- @enroute = false
112
- else
113
- @enroute = true
114
- end
115
- end
116
-
117
- end
118
-
119
- end
15
+ end
@@ -0,0 +1,70 @@
1
+ module Vatbook
2
+
3
+ class BookFetcher
4
+ require 'nokogiri'
5
+ require 'open-uri'
6
+
7
+ attr_accessor :fir, :atc_bookings, :pilot_bookings, :enroute, :doc
8
+
9
+ def initialize(fir, args = nil)
10
+ @fir = fir.upcase
11
+ @enroute = true
12
+ process_arguments(args) if args.class == Hash
13
+ @atc_bookings = []; @pilot_bookings = [];
14
+ @doc = raw_list
15
+ atcs
16
+ pilots
17
+ end
18
+
19
+ def raw_list
20
+ Nokogiri::XML(open("http://vatbook.euroutepro.com/xml2.php?fir=#{@fir}"))
21
+ end
22
+
23
+ def fetch
24
+ {:atc => atc_bookings, :pilots => pilot_bookings}
25
+ end
26
+
27
+ def atc_bookings
28
+ @atc_bookings
29
+ end
30
+
31
+ def pilot_bookings
32
+ @pilot_bookings
33
+ end
34
+
35
+ def atcs_count
36
+ @doc.css("atcs booking").count
37
+ end
38
+
39
+ def pilots_count
40
+ @doc.css("pilots booking").count
41
+ end
42
+
43
+ private
44
+
45
+ def atcs
46
+ @doc.css("atcs booking").each do |booking|
47
+ @atc_bookings << Booking.new(booking, role = "atc", @fir)
48
+ end
49
+ end
50
+
51
+ def pilots
52
+ @doc.css("pilots booking").each do |booking|
53
+ if @enroute == false
54
+ bk = Booking.new(booking, role = "pilot", @fir)
55
+ if bk.enroute == false
56
+ @pilot_bookings << bk
57
+ end
58
+ else
59
+ @pilot_bookings << Booking.new(booking, role = "pilot", @fir)
60
+ end
61
+ end
62
+ end
63
+
64
+ def process_arguments(args)
65
+ args[:enroute] == false ? @enroute = false : @enroute = true
66
+ end
67
+
68
+ end
69
+
70
+ end
@@ -0,0 +1,41 @@
1
+ module Vatbook
2
+
3
+ class Booking
4
+ require 'nokogiri'
5
+
6
+ attr_accessor :role, :callsign, :name, :cid, :start, :end, :dep, :arr
7
+ attr_accessor :aircraft, :route, :enroute, :fir
8
+
9
+ def initialize(booking, role, fir)
10
+ @fir = fir
11
+ @role = role
12
+ @callsign = booking.children.css("callsign").first.children.to_s
13
+ @name = booking.children.css("name").first.children.to_s
14
+ @role == "atc" ? @cid = booking.children.css("cid").first.children.to_s : @cid = booking.children.css("pid").first.children.to_s
15
+ if @role == "atc"
16
+ @start = booking.children.css("time_start").first.children.to_s
17
+ @end = booking.children.css("time_end").first.children.to_s
18
+ elsif @role == "pilot"
19
+ @dep = booking.children.css("dep").first.children.to_s
20
+ @arr = booking.children.css("arr").first.children.to_s
21
+ @route = booking.children.css("route").first.children.to_s.gsub(/[\n]/, ' ').strip
22
+ @start = booking.children.css("from").first.children.to_s
23
+ @end = booking.children.css("to").first.children.to_s
24
+ @aircraft = booking.children.css("actype").first.children.to_s
25
+ check_enroute
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def check_enroute
32
+ if @fir[0..1] == @dep[0..1] or @fir[0..1] == @arr[0..1]
33
+ @enroute = false
34
+ else
35
+ @enroute = true
36
+ end
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -1,3 +1,3 @@
1
1
  module Vatbook
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -22,5 +22,5 @@ Gem::Specification.new do |gem|
22
22
  gem.add_development_dependency "guard"
23
23
  gem.add_development_dependency "libnotify"
24
24
  gem.add_development_dependency "guard-rspec"
25
- gem.add_dependency "nokogiri", "~> 1.5.5"
25
+ gem.add_dependency "nokogiri", "~> 1.5.6"
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vatbook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
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: 2012-10-22 00:00:00.000000000 Z
12
+ date: 2013-02-28 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.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.5
109
+ version: 1.5.6
110
110
  description: Ruby API to the Vatbook service for reading and parsing Vatsim pilot
111
111
  and ATC bookings. Booking query requests are made by FIR and individual bookings
112
112
  are returned as objects, exposing a rich set of attributes. Support for excluding
@@ -119,6 +119,7 @@ extensions: []
119
119
  extra_rdoc_files: []
120
120
  files:
121
121
  - .gitignore
122
+ - .travis.yml
122
123
  - CONTRIBUTING.md
123
124
  - Gemfile
124
125
  - Guardfile
@@ -126,6 +127,8 @@ files:
126
127
  - README.md
127
128
  - Rakefile
128
129
  - lib/vatbook.rb
130
+ - lib/vatbook/book_fetcher.rb
131
+ - lib/vatbook/booking.rb
129
132
  - lib/vatbook/version.rb
130
133
  - spec/spec_helper.rb
131
134
  - spec/vatbook_spec.rb
@@ -151,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
154
  version: '0'
152
155
  requirements: []
153
156
  rubyforge_project:
154
- rubygems_version: 1.8.24
157
+ rubygems_version: 1.8.25
155
158
  signing_key:
156
159
  specification_version: 3
157
160
  summary: Ruby API to the Vatbook service for reading Vatsim pilot and ATC bookings