* Fixing ruby script with wrong File.exists #1

Merged
Basti merged 1 commit from adding-dependencies into main 2024-03-20 09:59:06 +01:00
10 changed files with 1935 additions and 1 deletions

1711
.devcontainer/advanced/.p10k.zsh Executable file

File diff suppressed because it is too large Load diff

56
.devcontainer/advanced/.zshrc Executable file
View file

@ -0,0 +1,56 @@
# shellcheck disable=2148
# shellcheck disable=2154
# shellcheck disable=1090
# shellcheck disable=2312
[[ "${TERM_PROGRAM}" == "vscode" ]] && . "$(code --locate-shell-integration-path zsh)"
source ~/powerlevel10k/powerlevel10k.zsh-theme
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
export ZSH=${HOME}/.oh-my-zsh
# shellcheck disable=2034
plugins=(
git
zsh-syntax-highlighting
fasd
zsh-autosuggestions
colored-man-pages
)
alias tf='terraform'
alias tfa="terraform apply"
alias tfi="terraform init"
alias tfr="terraform refresh"
alias tfip="terraform init && terraform plan"
alias tfia="terraform init && terraform apply"
alias tfp="terraform plan"
alias tfo="terraform output"
alias tfiru="terraform init --upgrade=true -reconfigure"
alias tfirup="terraform init --upgrade=true -reconfigure && terraform plan"
alias tfd="terraform destroy"
alias tfsl="terraform state list"
tfgrep() {
grep --include="*.tf" -rl "$1" .
}
tfat() {
terraform apply --target "$1"
}
# shellcheck disable=2312
eval "$(fasd --init auto)"
alias fzf="fzf --bind 'ctrl-a:select-all+accept' -m"
# shellcheck disable=1091
source "${ZSH}/oh-my-zsh.sh"
export DISABLE_AUTO_UPDATE=true
export DISABLE_UPDATE_PROMPT=true
if [ -z "$SSH_AUTH_SOCK" ]; then
# Check for a currently running instance of the agent
RUNNING_AGENT="`ps -ax | grep 'ssh-agent -s' | grep -v grep | wc -l | tr -d '[:space:]'`"
if [ "$RUNNING_AGENT" = "0" ]; then
# Launch a new instance of the agent
ssh-agent -s &> $HOME/.ssh/ssh-agent
fi
eval `cat $HOME/.ssh/ssh-agent`
fi

View file

@ -0,0 +1,57 @@
{
"image": "mcr.microsoft.com/devcontainers/universal:2",
"features": {
"ghcr.io/devcontainers/features/python:1": {
"version": "3.12"
},
"ghcr.io/devcontainers-contrib/features/zsh-plugins": {
"omzPlugins": [
"https://github.com/zsh-users/zsh-autosuggestions",
"https://github.com/zsh-users/zsh-syntax-highlighting.git"
]
},
"ghcr.io/devcontainers/features/ruby:1": {},
"ghcr.io/prulloac/devcontainer-features/latex:1": {},
"ghcr.io/devcontainers-contrib/features/tldr:2": {},
"ghcr.io/devcontainers-contrib/features/yamllint:2": {},
"ghcr.io/devcontainers-contrib/features/markdownlint-cli2:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"charliermarsh.ruff",
"DavidAnson.vscode-markdownlint",
"EditorConfig.EditorConfig",
"GitHub.copilot",
"ms-azuretools.vscode-docker",
"ms-python.black-formatter",
"ms-python.python",
"ms-vsliveshare.vsliveshare",
"oderwat.indent-rainbow",
"redhat.vscode-yaml",
"samuelcolvin.jinjahtml",
"timonwong.shellcheck",
"wholroyd.jinja"
],
"settings": {
"terminal.integrated.defaultProfile.linux": "zsh",
"terminal.integrated.scrollback": 10000,
"prettier.requireConfig": true,
"terminal.integrated.fontFamily": "MesloLGS NF",
"editor.formatOnSave": true,
"cSpell.language": "en-GB",
"shellcheck.customArgs": [
"-x"
]
}
}
},
"mounts": [
"source=${localWorkspaceFolder}/.devcontainer/advanced/.p10k.zsh,target=/home/codespace/.p10k.zsh,type=bind,consistency=cached",
"source=${localWorkspaceFolder}/.devcontainer/advanced/.zshrc,target=/home/codespace/.zshrc,type=bind,consistency=cached",
"source=${localWorkspaceFolder}/.devcontainer/advanced/post-create.sh,target=/home/codespace/post-create.sh,type=bind,consistency=cached",
"source=${localWorkspaceFolder}/.devcontainer/advanced/post-start.sh,target=/home/codespace/post-start.sh,type=bind,consistency=cached"
],
"postCreateCommand": "chmod +x /home/codespace/post-create.sh && /home/codespace/post-create.sh",
"postStartCommand": "chmod +x /home/codespace/post-create.sh && /home/codespace/post-create.sh"
}

View file

@ -0,0 +1,39 @@
# Advanced Devcontainer Configuration
This folder contains opinionated advanced configuration options for the devcontainer. If you just want to edit a config and don't care about the details, you can use the [essential configuration options](../../essential/) instead.
## Why does this exist?
There are a few goals for this configuration:
### Make it as close to the pipeline environment as possible
This ensures that the same versions of tools are used in the devcontainer as in the pipeline.
### Allow for caching
Terraform and terraform plugins are cached across projects on the local machine. This means that if you switch between projects, you don't have to download the same terraform version and plugins again.
### Make development easier
We don't want to have to install all tools and dependencies on our local machine. Instead we want to open a devcontainer and have everything ready to go. This includes linting, formatting and various plugins for vscode.
### Make the devcontainer nice to use
This is more related to personal preference regarding the shell and vscode. The basic linux devcontainer shell is not very nice to use so zsh, oh-my-zsh and the powerlevel10k theme are used to make it nicer.
## Included Tools
- Installs various vscode extensions like linting, formatting, git, etc.
- Configures the zsh shell with oh-my-zsh and the powerlevel10k theme
## Usage
### VSCode
- Open the project in vscode and click on the button in the bottom left corner.
- Select `Reopen in Container`
- Choose `advanced`
- Wait for the devcontainer to build.
- After the build is finished for the first time, make sure to open a new terminal in vscode to make sure all nix tools are available.
- After that you can use the terminal and vscode as usual.

View file

@ -0,0 +1,23 @@
#!/usr/bin/env bash
sudo apt-get update
sudo apt-get install fasd fontconfig -y
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
sudo mkdir -p /usr/share/fonts/MesloLGS_NF
sudo wget -q -O /usr/share/fonts/MesloLGS_NF/MesloLGS_NF_Regular.ttf https://github.com/romkatv/dotfiles-public/raw/master/.local/share/fonts/NerdFonts/MesloLGS%20NF%20Regular.ttf
sudo wget -q -O /usr/share/fonts/MesloLGS_NF/MesloLGS_NF_Bold.ttf https://github.com/romkatv/dotfiles-public/raw/master/.local/share/fonts/NerdFonts/MesloLGS%20NF%20Bold.ttf
sudo wget -q -O /usr/share/fonts/MesloLGS_NF/MesloLGS_NF_Italic.ttf https://github.com/romkatv/dotfiles-public/raw/master/.local/share/fonts/NerdFonts/MesloLGS%20NF%20Italic.ttf
sudo wget -q -O /usr/share/fonts/MesloLGS_NF/MesloLGS_NF_Bold_Italic.ttf https://github.com/romkatv/dotfiles-public/raw/master/.local/share/fonts/NerdFonts/MesloLGS%20NF%20Bold%20Italic.ttf
fc-cache -fv
# find . -type f -name "requirements.txt" -exec pip3 install -r {} \;
python3 -m pip install --upgrade pip
# python3 -m pip install -r scripts/requirements.txt
bundle install
./install_tex_packages.sh

View file

@ -0,0 +1,7 @@
#!/usr/bin/env bash
# git submodule update --init --recursive
echo "Starting post-start.sh"
echo "This is a placeholder script. You can add commands to this file to install dependencies, etc."
echo "In case VS Code opened a terminal with missing plugins, close it and open a new one."

5
Gemfile Normal file
View file

@ -0,0 +1,5 @@
source 'https://rubygems.org'
gem 'cmxl', '~> 1.5.0'
gem 'roo', '~> 2.10.0'
gem 'humanize', '~> 2.5.1'

View file

@ -36,7 +36,7 @@ def get_payments_from_member_id(mitgliedsnummer)
filename = ARGV[0] filename = ARGV[0]
# check if the filename is valid or not presented # check if the filename is valid or not presented
if filename.nil? || !File.exists?(filename) if filename.nil? || !File.exist?(filename)
puts "Enter the filename of the MT940 statement to parse" puts "Enter the filename of the MT940 statement to parse"
filename = gets.chomp filename = gets.chomp
end end

17
install_tex_packages.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/bash
tlmgr update --self
tlmgr update --all
tlmgr install koma-script
tlmgr install german
tlmgr install eurosym
tlmgr install pdfpages
tlmgr install nopageno
tlmgr install makecell
tlmgr install csvsimple
tlmgr install pgf
tlmgr install psnfss
tlmgr install pdflscape
tlmgr install collection-fontsrecommended
tlmgr install collection-fontsextra
updmap-sys

View file

@ -12,6 +12,22 @@ This script creates automatic donation reciepts from an MT940 file exported in t
You need LaTex and Ruby installed You need LaTex and Ruby installed
### LaTex Dependencies
All required packages are listed in `install_tex_packages.sh`. Run the following command to install them:
```bash
./install_tex_packages.sh
```
### Ruby Dependencies
All required gems are listed in the `Gemfile`. Run the following command to install them:
```bash
bundle install
```
## Usage ## Usage
`./beitragsquittung.rb <MT940 file> <Excel file> <member id>` `./beitragsquittung.rb <MT940 file> <Excel file> <member id>`
@ -19,6 +35,9 @@ You need LaTex and Ruby installed
The member ID is optional. If not provided, all members are processed. The member ID is optional. If not provided, all members are processed.
The time range is used from the MT940 file. The time range is used from the MT940 file.
MT940 file: The file exported from the online banking transaction history.
Excel file: The file containing the member data.
Member ID: The ID of the member for which the reciept should be created.
## License ## License