generated from noi-techpark/java-boilerplate
-
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.
- refactor static configuration - filter parking by origin - add bike parking
- Loading branch information
Showing
16 changed files
with
275 additions
and
84 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file renamed
BIN
+2.51 MB
...tation/240207_PianificazioneSviluppi.docx → ...tation/240521_PianificazioneSviluppi.docx
Binary file not shown.
File renamed without changes.
Binary file not shown.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# SPDX-FileCopyrightText: 2024 NOI Techpark <[email protected]> | ||
# | ||
# SPDX-License-Identifier: CC0-1.0 | ||
|
||
root = "." | ||
testdata_dir = "testdata" | ||
tmp_dir = "tmp" | ||
|
||
[build] | ||
args_bin = [] | ||
bin = "./tmp/main" | ||
cmd = "go build -o ./tmp/main ." | ||
delay = 1000 | ||
exclude_dir = ["assets", "tmp", "vendor", "testdata"] | ||
exclude_file = [] | ||
exclude_regex = ["_test.go"] | ||
exclude_unchanged = false | ||
follow_symlink = false | ||
full_bin = "" | ||
include_dir = [] | ||
include_ext = ["go", "tpl", "tmpl", "html", "yml"] | ||
include_file = ["config/datasets.yml"] | ||
kill_delay = "0s" | ||
log = "build-errors.log" | ||
poll = false | ||
poll_interval = 0 | ||
post_cmd = [] | ||
pre_cmd = [] | ||
rerun = false | ||
rerun_delay = 500 | ||
send_interrupt = false | ||
stop_on_error = false | ||
|
||
[color] | ||
app = "" | ||
build = "yellow" | ||
main = "magenta" | ||
runner = "green" | ||
watcher = "cyan" | ||
|
||
[log] | ||
main_only = false | ||
time = false | ||
|
||
[misc] | ||
clean_on_exit = false | ||
|
||
[proxy] | ||
app_port = 0 | ||
enabled = false | ||
proxy_port = 0 | ||
|
||
[screen] | ||
clear_on_rebuild = false | ||
keep_scroll = true |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# SPDX-FileCopyrightText: 2024 NOI Techpark <[email protected]> | ||
# | ||
# SPDX-License-Identifier: CC0-1.0 | ||
|
||
parking: | ||
origins: | ||
- FBK | ||
- A22 | ||
- Municipality Merano | ||
#- skidata not implemented necessary metadata yet | ||
- FAMAS | ||
- bicincitta |
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 |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# SPDX-FileCopyrightText: 2024 NOI Techpark <[email protected]> | ||
# | ||
# SPDX-License-Identifier: CC0-1.0 | ||
|
||
- origin: BIKE_SHARING_BOLZANO | ||
email: [email protected] | ||
phone: 0471997111 | ||
url: https://opencity.comune.bolzano.it/Servizi/Bike-Sharing-Bici-Bolzano | ||
street: Vicolo Gumer 7 | ||
town: Bolzano | ||
postcode: 39100 | ||
country: Italy | ||
|
||
- origin: BIKE_SHARING_MERANO | ||
email: [email protected] | ||
phone: 0473250111 | ||
url: https://www.comune.merano.bz.it/it/Bikesharing | ||
street: Via Portici 192 | ||
town: Merano | ||
postcode: 39012 | ||
country: Italy | ||
|
||
- origin: BIKE_SHARING_PAPIN | ||
email: [email protected] | ||
phone: 0474913450 | ||
url: https://www.papinsport.com/rent-a-bike/ | ||
street: Via Freising 9 | ||
town: San Candido | ||
postcode: 39038 | ||
country: Italy | ||
|
||
- origin: HAL-API | ||
email: [email protected] | ||
phone: 0471061319 | ||
url: https://www.carsharing.bz.it/it/ | ||
street: Via Beda Weber 1 | ||
town: Bolzano | ||
postcode: 39100 | ||
country: Italy | ||
|
||
- origin: FAMAS | ||
email: [email protected] | ||
phone: 0471997111 | ||
url: https://opencity.comune.bolzano.it/Documenti-e-dati/Documenti-tecnici-di-supporto/Parcheggiare-in-citta | ||
street: Vicolo Gumer 7 | ||
town: Bolzano | ||
postcode: 39100 | ||
country: Italy | ||
|
||
- origin: Municipality Merano | ||
email: [email protected] | ||
phone: 0473250111 | ||
url: https://www.comune.merano.bz.it/it/Parcheggi | ||
street: Via Portici 192 | ||
town: Merano | ||
postcode: 39012 | ||
country: Italy | ||
|
||
- origin: FBK-Trento | ||
email: [email protected] | ||
phone: 0461884111 | ||
url: https://www.comune.trento.it/Citta/Come-orientarsi/Parcheggi | ||
street: Via Belenzani 19 | ||
town: Trento | ||
postcode: 38122 | ||
country: Italy | ||
|
||
- origin: FBK-Rovereto | ||
email: [email protected] | ||
phone: 0464452111 | ||
url: https://www.comune.rovereto.tn.it/Servizi/Sosta-e-parcheggi | ||
street: Piazza Podestà 11 | ||
town: Rovereto | ||
postcode: 38068 | ||
country: Italy | ||
|
||
- origin: A22 | ||
email: [email protected] | ||
phone: 0461212611 | ||
url: https://www.autobrennero.it/it/in-viaggio/sosta-e-servizi/aree-di-servizio/ | ||
street: Via Berlino 10 | ||
town: Trento | ||
postcode: 38121 | ||
country: Italy | ||
|
||
- origin: skidata | ||
email: [email protected] | ||
phone: 0471312888 | ||
url: https://www.sta.bz.it | ||
street: Via dei Conciapelli 60 | ||
town: Bolzano | ||
postcode: 39100 | ||
country: Italy | ||
|
||
- origin: bicincitta | ||
email: [email protected] | ||
phone: 0471312888 | ||
url: https://www.sta.bz.it | ||
street: Via dei Conciapelli 60 | ||
town: Bolzano | ||
postcode: 39100 | ||
country: Italy | ||
|
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// SPDX-FileCopyrightText: 2024 NOI Techpark <[email protected]> | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
package netex | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"path/filepath" | ||
"runtime" | ||
"testing" | ||
|
||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
type Config struct { | ||
operators []operatorCfg | ||
dataset datasetCfg | ||
} | ||
|
||
var Cfg Config | ||
|
||
type datasetCfg struct { | ||
Parking struct { | ||
Origins []string | ||
} | ||
} | ||
|
||
type operatorCfg struct { | ||
Origin string | ||
Email string | ||
Phone string | ||
Url string | ||
Street string | ||
Town string | ||
Postcode string | ||
Country string | ||
} | ||
|
||
func InitConfig() { | ||
Cfg = *ReadConfig() | ||
} | ||
func ReadConfig() *Config { | ||
cfg := Config{} | ||
readYaml(fixRelPath("config", "operators.yml"), &cfg.operators) | ||
readYaml(fixRelPath("config", "datasets.yml"), &cfg.dataset) | ||
return &cfg | ||
} | ||
|
||
func readYaml(path string, o any) { | ||
f, err := os.ReadFile(path) | ||
if err != nil { | ||
log.Panicln("Cannot open config", path, err) | ||
} | ||
|
||
if err := yaml.Unmarshal(f, o); err != nil { | ||
log.Panicln("Cannot unmarshal Operators config", path, err) | ||
} | ||
} | ||
|
||
func fixRelPath(path ...string) string { | ||
cwd, _ := os.Getwd() | ||
// https://stackoverflow.com/questions/31873396/is-it-possible-to-get-the-current-root-of-package-structure-as-a-string-in-golan | ||
// Relative paths are a pain in the butt with unit tests because they always execute from the module they are in | ||
// This is a hack to always start from root folder and compose the full "absolute" path | ||
if testing.Testing() { | ||
_, b, _, _ := runtime.Caller(0) | ||
root := filepath.Join(filepath.Dir(b), "../..") | ||
cwd = filepath.Join(root, "src") | ||
} | ||
|
||
return filepath.Join(append([]string{cwd}, path...)...) | ||
} | ||
|
||
func (c *Config) ParkingOrigins() []string { | ||
return c.dataset.Parking.Origins | ||
} |
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 |
---|---|---|
|
@@ -10,17 +10,9 @@ import ( | |
"gotest.tools/v3/assert" | ||
) | ||
|
||
func TestReadOps(t *testing.T) { | ||
ops := readOps(getCsvPath()) | ||
if len(ops) == 0 { | ||
t.Log("Operators loaded empty") | ||
t.Fail() | ||
} | ||
} | ||
|
||
func TestOpsContent(t *testing.T) { | ||
ops := readOps(getCsvPath()) | ||
mapped := mapByOrigin(ops) | ||
cfg := ReadConfig() | ||
mapped := mapByOrigin(cfg.operators) | ||
|
||
bsb := mapped["BIKE_SHARING_BOLZANO"] | ||
assert.Equal(t, "[email protected]", bsb.Email) | ||
|
Oops, something went wrong.