Skip to content

A JSON-fetcher for bus departues in bavaria written in D

License

Notifications You must be signed in to change notification settings

fsimphy/bayernfahrplan

Repository files navigation

bayernfahrplan

Build status codecov Join the chat at https://matrix.to/#/#fsi-code:im.f3l.de

A JSON-fetcher for bus departues in bavaria written in D

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system (Raspberry Pi).

Prerequisites

D compiler

Either DMD or LDC is needed to compile the project. Both the latest version of DMD and LDC 1.19.0 are tested in CI, so these are the supported versions. Other recent versions are likely to work, too, but there is no guarantee. Additionally, the packagemanager DUB is needed. Install it via your distribution’s packagemanager if you are running linux or via Homebrew if you are running OS X:

  • Debian based systems:
sudo wget http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list
sudo apt-get update && sudo apt-get -y --allow-unauthenticated install --reinstall d-apt-keyring
sudo apt-get update
# DMD:
sudo apt-get install dmd-compiler
# LDC:
sudo apt-get install ldc
# DUB:
sudo apt-get install dub
  • Arch Linux:
# DMD:
sudo pacman -S dmd
# LDC:
sudo pacman -S ldc
# DUB:
sudo pacman -S dub
  • OS X
# DMD:
brew install dmd
# LDC:
brew install ldc
# DUB:
brew install dub

OpenSSL

The project depens on OpenSSL being available. Both OpenSSL-1.0 and OpenSSL-1.1 are supported. OpenSSL should be available by default on most systems. If it is not available, use your distribution’s packagemanager to install it if you are running linux, or Homebrew if you are running OS X:

  • Debian based systems:
sudo apt-get install openssl
  • Arch Linux:
sudo pacman -S openssl
  • OS X
brew install openssl

Installing

To install the project, you first need to clone the repository:

git clone https://github.com/fsimphy/bayernfahrplan.git

Building the project is done by running the following command inside the project’s root directory:

dub build

To run the project, simply run the following command in the project’s root directory:

dub run [-- options]

If you already built the project, you can also run it directly:

./bayernfahrplan [options]

See configuration for a list of available options.

Configuration

The project can be configured by commandline switches. These are the available options:

Usage: bayernfahrplan [options]

Options:
-f             --file The file that the data is written to.
-s             --stop The bus stop for which to fetch data.
-r --replacement-file The file that contais the direction name replacement info.
-v          --version Display the version of this program.
-h             --help This help information.

The replacement-file file is an optional file used to replace the names of certain bus stops. This is the basic syntax:

"<name>" = "<replacment>"

For example, a replacement-file could look like this:

"Regensburg Wernerwerkstraße" = "Wernerwerkstraße"
"Regensburg Neuprüll" = "Neuprüll"
"Regensburg Klinikum" = "Klinikum"

Running the tests

To run the tests, run the following command in the project’s root directory:

dub test

This runs all available tests.

Deployment

TODO: Update this for newer versions of LDC. LDC (1.22.0) is now available on Arch Linux ARM...

Deploying the project on a Raspberry Pi requires some more work, because DMD is not able to build arm binaries and LDC is not available in the repositories of the major linux distributions for the Raspberry Pi.

We suggest using Arch Linux ARM, but using a different distribution such as Raspbian should also be possible.

Deployment to Arch Linux ARM

First install neccessary dependencies:

sudo pacman -S llvm gcc ncurses zlib

We will install LDC-1.8.0, which depens on libtinfo, which is contained in the ncurses package, but the version (libtinfo.so.6.0) is wrong (LDC needs libtinfo.so.5). It seems as though simply creating a symbolic link does the trick:

sudo ln -s /usr/lib/libtinfo.so /usr/lib/libtinfo.so.5

Be aware that this is quite hacky and might cause problems later on. It might be better to install libtinfo.so.5 manually.

To install LDC-1.8.0 (and DUB), download and extract it in your home folder via the following commands:

wget https://github.com/ldc-developers/ldc/releases/download/v1.8.0/ldc2-1.8.0-linux-armhf.tar.xz
tar xf ldc2-1.8.0-linux-armhf.tar.xz

Then add it to your PATH:

export PATH=~/ldc2-1.8.0-linux-armhf/bin

You might want to add the previous command to your .bashrc (or similar) file so you don't have to retype it every time you want to use DUB or LDC.

Now you can build, run and test the project as explained in the earlier sections.

Built With

  • DUB - Dependency Management
  • requests - HTTP client library

Contributing

Please read CONTRIBUTING.md for details on the process for submitting issues and pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License, see the LICENSE.md file for details.

Acknowledgments

Thanks a lot to the folks at the D Programming Language Forum and especially to ikod, the maintainer of dlang-requests for always helping out with technical questions.

About

A JSON-fetcher for bus departues in bavaria written in D

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages