Skip to content

Commit

Permalink
[knf] Added helper 'Q'
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Oct 28, 2024
1 parent a9aa5cb commit 486707d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

### [13.9.2](https://kaos.sh/ek/13.9.2)

- `[knf]` Added helper `Q`

### [13.9.1](https://kaos.sh/ek/13.9.1)

- `[errors]` Fixed bug with extra newline character at the end of `Error` output
Expand Down
3 changes: 3 additions & 0 deletions knf/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ func ExampleGlobal() {
// Read string value
GetS("main:string")

// Use helper Q to create full property name
GetS(Q("main", "string"))

// Read integer value
GetI("main:int")

Expand Down
6 changes: 6 additions & 0 deletions knf/knf.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,12 @@ func Validate(validators Validators) errors.Errors {
return global.Validate(validators)
}

// Q is a helper to create a valid full property name (section + delimiter
// + property name)
func Q(section, prop string) string {
return section + _SYMBOL_DELIMITER + prop
}

// ////////////////////////////////////////////////////////////////////////////////// //

// Add adds given validators and returns new slice
Expand Down
4 changes: 4 additions & 0 deletions knf/knf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,10 @@ func (s *KNFSuite) TestKNFParserExceptions(c *check.C) {
c.Assert(err.Error(), check.Equals, "Error at line 3: Unknown property {abcd:test}")
}

func (s *KNFSuite) TestHelpers(c *check.C) {
c.Assert(Q("section", "prop"), check.Equals, "section:prop")
}

// ////////////////////////////////////////////////////////////////////////////////// //

func (s *KNFSuite) BenchmarkBasic(c *check.C) {
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ package ek
// ////////////////////////////////////////////////////////////////////////////////// //

// VERSION is current ek package version
const VERSION = "13.9.1"
const VERSION = "13.9.2"

0 comments on commit 486707d

Please sign in to comment.