-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix all rubocop warnings and add extensive cooments to the code
- Loading branch information
Showing
11 changed files
with
284 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,4 @@ jobs: | |
bundle install | ||
- name: Run RSpec tests | ||
run: bundle exec rake spec | ||
run: bundle exec rake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,4 @@ | ||
AllCops: | ||
TargetRubyVersion: 2.7 | ||
|
||
Style/StringLiterals: | ||
Enabled: true | ||
EnforcedStyle: double_quotes | ||
|
||
Style/StringLiteralsInInterpolation: | ||
Enabled: true | ||
EnforcedStyle: double_quotes | ||
|
||
Layout/LineLength: | ||
Max: 120 | ||
|
||
Layout/EndOfLine: | ||
Enabled: False | ||
TargetRubyVersion: 3.2 | ||
NewCops: enable | ||
SuggestExtensions: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
source "https://rubygems.org" | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in flight_radar.gemspec | ||
gemspec | ||
|
||
gem 'rake' | ||
gem 'rspec' | ||
gem 'rubocop' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "flight_radar" | ||
spec.version = "0.2.0" | ||
spec.authors = ["Jakub Polak"] | ||
spec.email = ["[email protected]"] | ||
spec.name = 'flight_radar' | ||
spec.version = '0.2.0' | ||
spec.authors = ['Jakub Polak'] | ||
spec.email = ['[email protected]'] | ||
|
||
spec.summary = "Ruby gem for fetching aircraft data from Flightradar24" | ||
spec.description = "To use this API see more information at: https://www.flightradar24.com/terms-and-conditions" | ||
spec.homepage = "https://github.com/kupolak/flight_radar" | ||
spec.license = "MIT" | ||
spec.required_ruby_version = ">= 2.7.0" | ||
spec.summary = 'Ruby gem for fetching aircraft data from Flightradar24' | ||
spec.description = 'To use this API see more information at: https://www.flightradar24.com/terms-and-conditions' | ||
spec.homepage = 'https://github.com/kupolak/flight_radar' | ||
spec.license = 'MIT' | ||
spec.required_ruby_version = '>= 3.2.0' | ||
|
||
spec.metadata["homepage_uri"] = spec.homepage | ||
spec.metadata["source_code_uri"] = "https://github.com/kupolak/flight_radar" | ||
spec.metadata["changelog_uri"] = "https://github.com/kupolak/flight_radar/blob/main/CHANGELOG.md" | ||
spec.metadata['homepage_uri'] = spec.homepage | ||
spec.metadata['source_code_uri'] = 'https://github.com/kupolak/flight_radar' | ||
spec.metadata['changelog_uri'] = 'https://github.com/kupolak/flight_radar/blob/main/CHANGELOG.md' | ||
|
||
# Specify which files should be added to the gem when it is released. | ||
# The `git ls-files -z` loads the files in the RubyGem that have been added into git. | ||
spec.files = Dir.chdir(File.expand_path(__dir__)) do | ||
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) } | ||
end | ||
spec.bindir = "exe" | ||
spec.bindir = 'exe' | ||
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } | ||
spec.require_paths = ["lib"] | ||
spec.require_paths = ['lib'] | ||
|
||
spec.add_dependency "httparty", "~> 0.21.0" | ||
spec.add_dependency 'httparty', '~> 0.21.0' | ||
|
||
spec.add_development_dependency "rake", "~>13.1.0" | ||
spec.add_development_dependency "rspec", "~>3.12.0" | ||
spec.add_development_dependency "rubocop", "~>1.59.0" | ||
spec.metadata['rubygems_mfa_required'] = 'true' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,65 @@ | ||
# frozen_string_literal: true | ||
|
||
# The `Core` module contains constants related to FlightRadar API endpoints, | ||
# URLs for various data sources, and headers used in HTTP requests. | ||
module Core | ||
API_FLIGHT_RADAR_BASE_URL = "https://api.flightradar24.com/common/v1" | ||
CDN_FLIGHT_RADAR_BASE_URL = "https://cdn.flightradar24.com" | ||
FLIGHT_RADAR_BASE_URL = "https://www.flightradar24.com" | ||
DATA_LIVE_BASE_URL = "https://data-live.flightradar24.com" | ||
DATA_CLOUD_BASE_URL = "https://data-cloud.flightradar24.com" | ||
API_FLIGHT_RADAR_BASE_URL = 'https://api.flightradar24.com/common/v1' | ||
CDN_FLIGHT_RADAR_BASE_URL = 'https://cdn.flightradar24.com' | ||
FLIGHT_RADAR_BASE_URL = 'https://www.flightradar24.com' | ||
DATA_LIVE_BASE_URL = 'https://data-live.flightradar24.com' | ||
DATA_CLOUD_BASE_URL = 'https://data-cloud.flightradar24.com' | ||
|
||
# User login URL. | ||
USER_LOGIN_URL = "#{FLIGHT_RADAR_BASE_URL}/user/login" | ||
USER_LOGOUT_URL = "#{FLIGHT_RADAR_BASE_URL}/user/logout" | ||
USER_LOGIN_URL = "#{FLIGHT_RADAR_BASE_URL}/user/login".freeze | ||
USER_LOGOUT_URL = "#{FLIGHT_RADAR_BASE_URL}/user/logout".freeze | ||
|
||
# Most tracked data URL | ||
MOST_TRACKED_URL = "#{FLIGHT_RADAR_BASE_URL}/flights/most-tracked" | ||
MOST_TRACKED_URL = "#{FLIGHT_RADAR_BASE_URL}/flights/most-tracked".freeze | ||
|
||
# Search data URL | ||
SEARCH_DATA_URL = "#{FLIGHT_RADAR_BASE_URL}/v1/search/web/find?query={}&limit=50" | ||
SEARCH_DATA_URL = "#{FLIGHT_RADAR_BASE_URL}/v1/search/web/find?query={}&limit=50".freeze | ||
|
||
# Flights data URLs. | ||
REAL_TIME_FLIGHT_TRACKER_DATA_URL = "#{DATA_CLOUD_BASE_URL}/zones/fcgi/feed.js" | ||
FLIGHT_DATA_URL = "#{DATA_LIVE_BASE_URL}/clickhandler/?flight={}" | ||
REAL_TIME_FLIGHT_TRACKER_DATA_URL = "#{DATA_CLOUD_BASE_URL}/zones/fcgi/feed.js".freeze | ||
FLIGHT_DATA_URL = "#{DATA_LIVE_BASE_URL}/clickhandler/?flight={}".freeze | ||
|
||
# Airports data URLs. | ||
API_AIRPORT_DATA_URL = "#{API_FLIGHT_RADAR_BASE_URL}/airport.json" | ||
AIRPORT_DATA_URL = "#{FLIGHT_RADAR_BASE_URL}/airports/traffic-stats/?airport=" | ||
AIRPORTS_DATA_URL = "#{FLIGHT_RADAR_BASE_URL}/_json/airports.php" | ||
API_AIRPORT_DATA_URL = "#{API_FLIGHT_RADAR_BASE_URL}/airport.json".freeze | ||
AIRPORT_DATA_URL = "#{FLIGHT_RADAR_BASE_URL}/airports/traffic-stats/?airport=".freeze | ||
AIRPORTS_DATA_URL = "#{FLIGHT_RADAR_BASE_URL}/_json/airports.php".freeze | ||
|
||
# Airlines data URL. | ||
AIRLINES_DATA_URL = "#{FLIGHT_RADAR_BASE_URL}/_json/airlines.php" | ||
AIRLINES_DATA_URL = "#{FLIGHT_RADAR_BASE_URL}/_json/airlines.php".freeze | ||
|
||
# Zones data URL. | ||
ZONES_DATA_URL = "#{FLIGHT_RADAR_BASE_URL}/js/zones.js.php" | ||
ZONES_DATA_URL = "#{FLIGHT_RADAR_BASE_URL}/js/zones.js.php".freeze | ||
|
||
# Country flag image URL. | ||
COUNTRY_FLAG_URL = "#{FLIGHT_RADAR_BASE_URL}/static/images/data/flags-small/" | ||
COUNTRY_FLAG_URL = "#{FLIGHT_RADAR_BASE_URL}/static/images/data/flags-small/".freeze | ||
|
||
# Airline logo image URL. | ||
AIRLINE_LOGO_URL = "#{CDN_FLIGHT_RADAR_BASE_URL}/assets/airlines/logotypes/" | ||
ALTERNATIVE_AIRLINE_LOGO_URL = "#{FLIGHT_RADAR_BASE_URL}/static/images/data/operators/" | ||
AIRLINE_LOGO_URL = "#{CDN_FLIGHT_RADAR_BASE_URL}/assets/airlines/logotypes/".freeze | ||
ALTERNATIVE_AIRLINE_LOGO_URL = "#{FLIGHT_RADAR_BASE_URL}/static/images/data/operators/".freeze | ||
|
||
# rubocop:disable Style/MutableConstant | ||
HEADERS = { | ||
"accept-encoding": "gzip, br", | ||
"accept-language": "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7", | ||
"cache-control": "max-age=0", | ||
"origin": "#{FLIGHT_RADAR_BASE_URL}", | ||
"referer": "#{FLIGHT_RADAR_BASE_URL}/", | ||
"sec-fetch-dest": "empty", | ||
"sec-fetch-mode": "cors", | ||
"sec-fetch-site": "same-site", | ||
"user-agent": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" | ||
'accept-encoding': 'gzip, br', | ||
'accept-language': 'pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7', | ||
'cache-control': 'max-age=0', | ||
origin: FLIGHT_RADAR_BASE_URL.to_s, | ||
referer: "#{FLIGHT_RADAR_BASE_URL}/", | ||
'sec-fetch-dest': 'empty', | ||
'sec-fetch-mode': 'cors', | ||
'sec-fetch-site': 'same-site', | ||
'user-agent': 'Mozilla/5.0 (Windows NT 6.1) | ||
AppleWebKit/537.36 (KHTML, like Gecko) | ||
Chrome/87.0.4280.88 Safari/537.36' | ||
} | ||
# rubocop:enable Style/MutableConstant | ||
|
||
JSON_HEADERS = HEADERS | ||
JSON_HEADERS["accept"] = "application/json" | ||
JSON_HEADERS['accept'] = 'application/json' | ||
|
||
IMAGE_HEADERS = HEADERS | ||
IMAGE_HEADERS["accept"] = "image/gif, image/jpg, image/jpeg, image/png" | ||
IMAGE_HEADERS['accept'] = 'image/gif, image/jpg, image/jpeg, image/png' | ||
end |
Oops, something went wrong.