-
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.
add functional option pattern; testing first draft
- Loading branch information
Showing
9 changed files
with
205 additions
and
113 deletions.
There are no files selected for viewing
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
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 @@ | ||
package gobpmn_builder |
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 |
---|---|---|
@@ -1,10 +1,20 @@ | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/deemount/gobpmnCounter v0.0.0-20240312102840-227373d7f040 h1:vMsKGBWBsdy2UEDaOO+yCG4RLjYVyoLNARopS8o1/XM= | ||
github.com/deemount/gobpmnCounter v0.0.0-20240312102840-227373d7f040/go.mod h1:gtlVIb4tlWVLxCZmme7ORdXFpbeVajRXKCI4KtaQ0l0= | ||
github.com/deemount/gobpmnModels v0.0.0-20240315195348-76e2d8110fe8 h1:GIBwEU2hQIfXphDxI6Anv3dwO4Iorp6EFMRgTFIZ3Co= | ||
github.com/deemount/gobpmnModels v0.0.0-20240315195348-76e2d8110fe8/go.mod h1:bv2zkkqCzzaGV5gYP3gDQfMXuqjxMBjSl9GjHFo2mY8= | ||
github.com/deemount/gobpmnReflection v0.0.0-20240312080001-0601dc0824b6 h1:ZRHog+R0LurHMet3bliWHEUDM4z6mTe7j/eVGocMyrs= | ||
github.com/deemount/gobpmnReflection v0.0.0-20240312080001-0601dc0824b6/go.mod h1:j8WCmdzEkTq/FVsWJAdoPtjTiRryLZp/WjOLcIqtt5c= | ||
github.com/deemount/gobpmnModels v0.0.0-20240316085912-7831ff39ffa4 h1:xAqg4ZIeMDxME0O8O4UpwpcS3AeXB+3IspauNX2G2AA= | ||
github.com/deemount/gobpmnModels v0.0.0-20240316085912-7831ff39ffa4/go.mod h1:bv2zkkqCzzaGV5gYP3gDQfMXuqjxMBjSl9GjHFo2mY8= | ||
github.com/deemount/gobpmnReflection v0.0.0-20240315112013-036495e4c08d h1:yQY4ikw/HuvVlPu3hGc0X8gntQnSbLqMnUw/nHRRCKU= | ||
github.com/deemount/gobpmnReflection v0.0.0-20240315112013-036495e4c08d/go.mod h1:j8WCmdzEkTq/FVsWJAdoPtjTiRryLZp/WjOLcIqtt5c= | ||
github.com/deemount/gobpmnTypes v0.0.0-20240315111519-43046016ad9f h1:0gux6KtY8XgrN/L9tiZ7B+wx3th7x4hBYu1+wtUkHYY= | ||
github.com/deemount/gobpmnTypes v0.0.0-20240315111519-43046016ad9f/go.mod h1:Dw7Jo8/vr0DzNHNMnbwQu0JSMWm2klNdo00rcxHCzJs= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= | ||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= | ||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= | ||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
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 |
---|---|---|
@@ -1,12 +1,52 @@ | ||
package gobpmn_builder | ||
|
||
import "github.com/deemount/gobpmnModels/pkg/core" | ||
|
||
// Options | ||
type Options struct { | ||
Counter int | ||
CurrentFile string | ||
ModelType string | ||
Def *core.Definitions | ||
Repo core.DefinitionsRepository | ||
import ( | ||
"log" | ||
"os" | ||
|
||
"github.com/deemount/gobpmnModels/pkg/core" | ||
) | ||
|
||
/* | ||
Functional Options Pattern Type and Functions for the Builder | ||
*/ | ||
|
||
// Option ... | ||
type Option = func(bldr *Builder) | ||
|
||
// WithPath ... | ||
func WithPath(FilePathBPMN, FilePathJSON string) Option { | ||
return func(bldr *Builder) { | ||
bldr.FilePathBPMN = FilePathBPMN | ||
bldr.FilePathJSON = FilePathJSON | ||
} | ||
} | ||
|
||
// WithCounter ... | ||
func WithCounter(filePath string) Option { | ||
return func(bldr *Builder) { | ||
// reading the directory with the path to the specified files | ||
files, err := os.ReadDir(filePath) | ||
if err != nil { | ||
log.Panic(err) | ||
} | ||
// set number and count up for each created file | ||
if len(files) == 0 { | ||
bldr.Counter = 1 | ||
} else { | ||
bldr.Counter += 1 | ||
} | ||
} | ||
} | ||
|
||
func WithCurrentFile(filenamePrefix string) Option { | ||
return func(bldr *Builder) { | ||
bldr.FilenamePrefix = filenamePrefix | ||
} | ||
} | ||
|
||
func WithDefinitions(Repo core.DefinitionsRepository) Option { | ||
return func(bldr *Builder) { | ||
bldr.Repo = Repo | ||
} | ||
} |
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
Oops, something went wrong.