Merge pull request #426 from davemachado/master

Add new format validation check and update logic
This commit is contained in:
Dave Machado 2017-07-29 13:16:08 -04:00 committed by GitHub
commit 0e00123f51
2 changed files with 99 additions and 58 deletions

View file

@ -175,7 +175,7 @@ API | Description | Auth | HTTPS | Link |
| Hipster Ipsum | Generates Hipster Ipsum text | No | No | [Go!](http://hipsterjesus.com/) | | Hipster Ipsum | Generates Hipster Ipsum text | No | No | [Go!](http://hipsterjesus.com/) |
| IPify | A simple IP Address API | No | Yes | [Go!](https://www.ipify.org/) | | IPify | A simple IP Address API | No | Yes | [Go!](https://www.ipify.org/) |
| JSON 2 JSONP | Convert JSON to JSONP (on-the-fly) for easy cross-domain data requests using client-side JavaScript | No | Yes | [Go!](https://json2jsonp.com/) | | JSON 2 JSONP | Convert JSON to JSONP (on-the-fly) for easy cross-domain data requests using client-side JavaScript | No | Yes | [Go!](https://json2jsonp.com/) |
| JSONbin.io | Free JSON storage service. Ideal for small scale Web apps, Websites and Mobile apps. | No | Yes | [Go!](https://jsonbin.io) | | JSONbin.io | Free JSON storage service. Ideal for small scale Web apps, Websites and Mobile apps | No | Yes | [Go!](https://jsonbin.io) |
| JSONPlaceholder | Fake data for testing and prototyping | No | No | [Go!](http://jsonplaceholder.typicode.com/) | | JSONPlaceholder | Fake data for testing and prototyping | No | No | [Go!](http://jsonplaceholder.typicode.com/) |
| Judge0 API | Compile and run source code | No | Yes | [Go!](https://api.judge0.com/) | | Judge0 API | Compile and run source code | No | Yes | [Go!](https://api.judge0.com/) |
| Kairos | Face Recognition and Emotion Analysis | `apiKey` | Yes | [Go!](https://www.kairos.com/features) | | Kairos | Face Recognition and Emotion Analysis | `apiKey` | Yes | [Go!](https://www.kairos.com/features) |
@ -244,7 +244,7 @@ API | Description | Auth | HTTPS | Link |
| Whitepages Pro | Phone reputation to detect spammy phones | `apiKey` | Yes | [Go!](https://pro.whitepages.com/developer/documentation/phone-reputation-api/) | | Whitepages Pro | Phone reputation to detect spammy phones | `apiKey` | Yes | [Go!](https://pro.whitepages.com/developer/documentation/phone-reputation-api/) |
| Whitepages Pro | Get an owners name, address, demographics based on the phone number | `apiKey` | Yes | [Go!](https://pro.whitepages.com/developer/documentation/reverse-phone-api/) | | Whitepages Pro | Get an owners name, address, demographics based on the phone number | `apiKey` | Yes | [Go!](https://pro.whitepages.com/developer/documentation/reverse-phone-api/) |
| Whitepages Pro | Phone number validation, line_type, carrier append | `apiKey` | Yes | [Go!](https://pro.whitepages.com/developer/documentation/phone-intelligence-api/) | | Whitepages Pro | Phone number validation, line_type, carrier append | `apiKey` | Yes | [Go!](https://pro.whitepages.com/developer/documentation/phone-intelligence-api/) |
| Whitepages Pro| Get normalized physical address, residents, address type, and validity. | `apiKey` | Yes | [Go!](https://pro.whitepages.com/developer/documentation/reverse-address-api/) | | Whitepages Pro | Get normalized physical address, residents, address type, and validity | `apiKey` | Yes | [Go!](https://pro.whitepages.com/developer/documentation/reverse-address-api/) |
### Games & Comics ### Games & Comics
API | Description | Auth | HTTPS | Link | API | Description | Auth | HTTPS | Link |
@ -274,7 +274,7 @@ API | Description | Auth | HTTPS | Link |
### Geocoding ### Geocoding
API | Description | Auth | HTTPS | Link | API | Description | Auth | HTTPS | Link |
|---|---|---|---|---| |---|---|---|---|---|
| adresse.data.gouv.fr | Address database of France. geocoding and reverse. | No | Yes | [Go!](https://adresse.data.gouv.fr) | | adresse.data.gouv.fr | Address database of France, geocoding, and reverse | No | Yes | [Go!](https://adresse.data.gouv.fr) |
| Bing Maps | Create/customize digital maps based on Bing Maps data | `apiKey` | Yes | [Go!](https://www.microsoft.com/maps/) | | Bing Maps | Create/customize digital maps based on Bing Maps data | `apiKey` | Yes | [Go!](https://www.microsoft.com/maps/) |
| Geocode.xyz | Provides worldwide forward/reverse geocoding, batch geocoding and geoparsing | No | Yes | [Go!](https://geocode.xyz/) | | Geocode.xyz | Provides worldwide forward/reverse geocoding, batch geocoding and geoparsing | No | Yes | [Go!](https://geocode.xyz/) |
| GeoNames | Place names and other geographical data | No | No | [Go!](http://www.geonames.org/export/web-services.html) | | GeoNames | Place names and other geographical data | No | No | [Go!](http://www.geonames.org/export/web-services.html) |
@ -366,7 +366,7 @@ API | Description | Auth | HTTPS | Link |
| chucknorris.io | JSON API for hand curated Chuck Norris jokes | No | Yes | [Go!](https://api.chucknorris.io) | | chucknorris.io | JSON API for hand curated Chuck Norris jokes | No | Yes | [Go!](https://api.chucknorris.io) |
| Forismatic | Inspirational Quotes | No | No | [Go!](http://forismatic.com/en/api/) | | Forismatic | Inspirational Quotes | No | No | [Go!](http://forismatic.com/en/api/) |
| icanhazdadjoke | The largest selection of dad jokes on the internet | No | Yes | [Go!](https://icanhazdadjoke.com/api) | | icanhazdadjoke | The largest selection of dad jokes on the internet | No | Yes | [Go!](https://icanhazdadjoke.com/api) |
| Medium | Community of readers and writers offering unique perspectives on ideas. | `OAuth` | Yes | [Go!](https://github.com/Medium/medium-api-docs) | | Medium | Community of readers and writers offering unique perspectives on ideas | `OAuth` | Yes | [Go!](https://github.com/Medium/medium-api-docs) |
| Quotes on Design | Inspirational Quotes | No | Yes | [Go!](https://quotesondesign.com/api-v4-0/) | | Quotes on Design | Inspirational Quotes | No | Yes | [Go!](https://quotesondesign.com/api-v4-0/) |
| Traitify | Assess, collect, and analyze Personality | No | Yes | [Go!](https://app.traitify.com/developer) | | Traitify | Assess, collect, and analyze Personality | No | Yes | [Go!](https://app.traitify.com/developer) |
| tronalddump.io | Api & web archive for the things Donald Trump has said | No | Yes | [Go!](https://www.tronalddump.io) | | tronalddump.io | Api & web archive for the things Donald Trump has said | No | Yes | [Go!](https://www.tronalddump.io) |
@ -393,7 +393,7 @@ API | Description | Auth | HTTPS | Link |
| Minor Planet Center | Asterank.com Information | No | No | [Go!](http://www.asterank.com/mpc) | | Minor Planet Center | Asterank.com Information | No | No | [Go!](http://www.asterank.com/mpc) |
| NASA | NASA data, including imagery | No | Yes | [Go!](https://api.nasa.gov) | | NASA | NASA data, including imagery | No | Yes | [Go!](https://api.nasa.gov) |
| Open Notify | ISS astronauts, current location, etc | No | No | [Go!](http://open-notify.org/Open-Notify-API/) | | Open Notify | ISS astronauts, current location, etc | No | No | [Go!](http://open-notify.org/Open-Notify-API/) |
| Sunrise and Sunset | Sunset and sunrise times for a given latitude and longitude. | No | Yes | [Go!](https://sunrise-sunset.org/api) | | Sunrise and Sunset | Sunset and sunrise times for a given latitude and longitude | No | Yes | [Go!](https://sunrise-sunset.org/api) |
| USGS Earthquake Hazards Program | Earthquakes data real-time | No | Yes | [Go!](https://earthquake.usgs.gov/fdsnws/event/1/) | | USGS Earthquake Hazards Program | Earthquakes data real-time | No | Yes | [Go!](https://earthquake.usgs.gov/fdsnws/event/1/) |
| USGS Water Services | Water quality and level info for rivers and lakes | No | Yes | [Go!](https://waterservices.usgs.gov/) | | USGS Water Services | Water quality and level info for rivers and lakes | No | Yes | [Go!](https://waterservices.usgs.gov/) |
| World Bank | World Data | No | No | [Go!](https://datahelpdesk.worldbank.org/knowledgebase/topics/125589) | | World Bank | World Data | No | No | [Go!](https://datahelpdesk.worldbank.org/knowledgebase/topics/125589) |
@ -436,7 +436,7 @@ API | Description | Auth | HTTPS | Link |
### Sports & Fitness ### Sports & Fitness
API | Description | Auth | HTTPS | Link | API | Description | Auth | HTTPS | Link |
|---|---|---|---|---| |---|---|---|---|---|
| Cartola FC | The Cartola FC API serves to check the partial points of your team. | No | Yes | [Go!](https://github.com/wgenial/cartrolandofc) | | Cartola FC | The Cartola FC API serves to check the partial points of your team | No | Yes | [Go!](https://github.com/wgenial/cartrolandofc) |
| City Bikes | City Bikes around the world | No | No | [Go!](http://api.citybik.es/v2/) | | City Bikes | City Bikes around the world | No | No | [Go!](http://api.citybik.es/v2/) |
| Ergast F1 | F1 data from the beginning of the world championships in 1950 | No | No | [Go!](http://ergast.com/mrd/) | | Ergast F1 | F1 data from the beginning of the world championships in 1950 | No | No | [Go!](http://ergast.com/mrd/) |
| Fitbit | Fitbit Information | `OAuth` | Yes | [Go!](https://dev.fitbit.com/) | | Fitbit | Fitbit Information | `OAuth` | Yes | [Go!](https://dev.fitbit.com/) |
@ -469,7 +469,7 @@ API | Description | Auth | HTTPS | Link |
| Schiphol Airport | Schiphol | `apiKey` | Yes | [Go!](https://developer.schiphol.nl/) | | Schiphol Airport | Schiphol | `apiKey` | Yes | [Go!](https://developer.schiphol.nl/) |
| TransitLand | Transit Aggregation | No | Yes | [Go!](https://transit.land/documentation/datastore/api-endpoints.html) | | TransitLand | Transit Aggregation | No | Yes | [Go!](https://transit.land/documentation/datastore/api-endpoints.html) |
| Transport for Atlanta, US | Marta | No | No | [Go!](http://www.itsmarta.com/app-developer-resources.aspx) | | Transport for Atlanta, US | Marta | No | No | [Go!](http://www.itsmarta.com/app-developer-resources.aspx) |
| Transport for Auckland, New Zealand | Auckland Transport API | No | Yes | [Go!](https://api.at.govt.nz/) | | Transport for Auckland, New Zealand | Auckland Transport | No | Yes | [Go!](https://api.at.govt.nz/) |
| Transport for Belgium | Belgian transport API | No | Yes | [Go!](https://hello.irail.be/api/) | | Transport for Belgium | Belgian transport API | No | Yes | [Go!](https://hello.irail.be/api/) |
| Transport for Berlin, Germany | Third-party VBB API | No | Yes | [Go!](https://github.com/derhuerst/vbb-rest/blob/master/docs/index.md) | | Transport for Berlin, Germany | Third-party VBB API | No | Yes | [Go!](https://github.com/derhuerst/vbb-rest/blob/master/docs/index.md) |
| Transport for Boston, US | MBTA API | No | No | [Go!](http://realtime.mbta.com/Portal/Home/Documents) | | Transport for Boston, US | MBTA API | No | No | [Go!](http://realtime.mbta.com/Portal/Home/Documents) |
@ -528,7 +528,7 @@ API | Description | Auth | HTTPS | Link |
| TMDb | Community-based movie data | `apiKey` | Yes | [Go!](https://www.themoviedb.org/documentation/api) | | TMDb | Community-based movie data | `apiKey` | Yes | [Go!](https://www.themoviedb.org/documentation/api) |
| TVMaze | TV Show Data | No | No | [Go!](http://www.tvmaze.com/api) | | TVMaze | TV Show Data | No | No | [Go!](http://www.tvmaze.com/api) |
| Vimeo | Vimeo Developer API | `OAuth` | Yes | [Go!](https://developer.vimeo.com/) | | Vimeo | Vimeo Developer API | `OAuth` | Yes | [Go!](https://developer.vimeo.com/) |
| YouTube | Add YouTube functionality to your sites and apps. | `OAuth` | Yes | [Go!](https://developers.google.com/youtube/) | | YouTube | Add YouTube functionality to your sites and apps | `OAuth` | Yes | [Go!](https://developers.google.com/youtube/) |
### Weather ### Weather
API | Description | Auth | HTTPS | Link | API | Description | Auth | HTTPS | Link |

View file

@ -1,45 +1,86 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
auth_keys = ['apiKey', 'OAuth', 'X-Mashape-Key', 'No'] auth_keys = ['apiKey', 'OAuth', 'X-Mashape-Key', 'No']
punctuation = ['.', '?', '!']
https_keys = ['Yes', 'No'] https_keys = ['Yes', 'No']
args = ARGV
filename = args[0] INDEX_TITLE = 1
fail_flag = false INDEX_DESCRIPTION = 2
INDEX_AUTH = 3
INDEX_HTTPS = 4
INDEX_LINK = 5
filename = ARGV[0]
$errors = []
def add_error(line_num, val_index, message)
case val_index
when INDEX_TITLE
segment = "Title"
when INDEX_DESCRIPTION
segment = "Description"
when INDEX_AUTH
segment = "Auth"
when INDEX_HTTPS
segment = "HTTPS"
when INDEX_LINK
segment = "Link"
end
$errors.push("(L%03d) %-14.14s #{message}" % [line_num, segment])
end
File.foreach(filename).with_index do | line, line_num | File.foreach(filename).with_index do | line, line_num |
line_num += 1 line_num += 1
if line.start_with?('|')
# Skip table schema lines # Skip non-markdown table lines and table schema lines
if line.eql? "|---|---|---|---|---|\n" if !line.start_with?('|') || line.eql?("|---|---|---|---|---|\n")
next next
end end
values = line.split("|") values = line.split("|")
# Check Description to make sure first character is capitalized
desc_val = values[2].lstrip.chop ################### GLOBAL ###################
values.each.with_index do |val, val_index|
msg = ""
case val_index
when INDEX_TITLE..INDEX_LINK
# every line segment should start and end with exactly 1 space
if val[/\A */].size != 1 || val[/ *\z/].size != 1
add_error(line_num, val_index, "string should start and end with exactly 1 space")
end
end
end
################# DESCRIPTION ################
# First character should be capitalized
desc_val = values[INDEX_DESCRIPTION].lstrip.chop
if !/[[:upper:]]/.match(desc_val[0]) if !/[[:upper:]]/.match(desc_val[0])
puts "(#{line_num}) Invalid Description (first char not uppercase): #{desc_val}" add_error(line_num, INDEX_DESCRIPTION, "first char not uppercase")
fail_flag = true
end end
# Check Auth values to conform to valid options only # value should not be punctuated
auth_val = values[3].lstrip.chop.tr('``', '') last_char = desc_val[desc_val.length-1]
if punctuation.include?(last_char)
add_error(line_num, INDEX_DESCRIPTION, "description should not end with \"#{last_char}\"")
end
#################### AUTH ####################
# Values should conform to valid options only
auth_val = values[INDEX_AUTH].lstrip.chop.tr('``', '')
if !auth_keys.include?(auth_val) if !auth_keys.include?(auth_val)
puts "(#{line_num}) Invalid Auth (not a valid option): #{auth_val}" add_error(line_num, INDEX_AUTH, "not a valid option: #{auth_val}")
fail_flag = true
end end
# Check HTTPS Support values to be either "Yes" or "No" #################### HTTPS ###################
https_val = values[4].lstrip.chop # Values should be either "Yes" or "No"
https_val = values[INDEX_HTTPS].lstrip.chop
if !https_keys.include?(https_val) if !https_keys.include?(https_val)
puts "(#{line_num}) Invalid HTTPS: (must use \"Yes\" or \"No\"): #{https_val}" add_error(line_num, INDEX_HTTPS, "must use \"Yes\" or \"No\": #{https_val}")
fail_flag = true
end end
# Check Link to ensure url is wrapped in "[Go!]" view #################### LINK ####################
link_val = values[5].lstrip.chop # Url should be wrapped in "[Go!]" view
link_val = values[INDEX_LINK].lstrip.chop
if !link_val.start_with?("[Go!](") || !link_val.end_with?(')') if !link_val.start_with?("[Go!](") || !link_val.end_with?(')')
puts "(#{line_num}) Invalid Link: (format should be \"[Go!](<LINK>)\"): #{link_val}" add_error(line_num, INDEX_LINK, "format should be \"[Go!](<LINK>)\": #{link_val}")
fail_flag = true
end end
end end
$errors.each do | e |
puts e
end end
if fail_flag exit($errors.length)
exit(1)
else
exit(0)
end