Skip to content

Commit

Permalink
Merge pull request jasperes#8 from burberius/bugfix/convert-multi-das…
Browse files Browse the repository at this point in the history
…hs-and-dots
  • Loading branch information
jasperes authored Jul 16, 2018
2 parents 7244c7b + f2265f8 commit 6289721
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions test/file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@ more_tests:
hash2: "a #hash"
hash3: "#hi"
comment_in_string: "a string..." #a comment
a-multi-dash-property: result-is=OK
a.multi.dot.property: result.is=OK
a-property-that-has-quite-a-number-of-dashes: result-is=OK
a-property-that-has-dashes.and.dots: result-is.absolutely=fine.and-perfect
4 changes: 4 additions & 0 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ test_list "${complex_test_simple_obj_a_list[*]}" &&
[ "$more_tests_double_quotes_hash2" = "\"a #hash\"" ] &&
[ "$more_tests_double_quotes_hash3" = "\"#hi\"" ] &&
[ "$more_tests_double_quotes_comment_in_string" = "\"a string...\"" ] &&
[ "$more_tests_a_multi_dash_property" = "result-is=OK" ] &&
[ "$more_tests_a_multi_dot_property" = "result.is=OK" ] &&
[ "$more_tests_a_property_that_has_quite_a_number_of_dashes" = "result-is=OK" ] &&
[ "$more_tests_a_property_that_has_dashes_and_dots" = "result-is.absolutely=fine.and-perfect" ] &&

# Output result
echo "Tests ok!" && exit 0 || echo "Error on execute tests!" && exit 1
12 changes: 9 additions & 3 deletions yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ function parse_yaml() {
}
}' |

sed -e 's/_=/+=/g' \
-e '/\..*=/s|\.|_|' \
-e '/\-.*=/s|\-|_|'
sed -e 's/_=/+=/g' |
awk 'BEGIN {
FS="=";
OFS="="
}
/(-|\.).*=/ {
gsub("-|\\.", "_", $1)
}
{ print }'

) < "$yaml_file"
}
Expand Down

0 comments on commit 6289721

Please sign in to comment.