-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd283c2
commit c3c51a0
Showing
10 changed files
with
271 additions
and
13 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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= | ||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= | ||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
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 |
---|---|---|
|
@@ -9,4 +9,3 @@ func NewConfiguration(packages ...string) Configuration { | |
packages: packages, | ||
} | ||
} | ||
|
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,40 @@ | ||
package scraper | ||
|
||
import ( | ||
"github.com/krzysztofreczek/go-structurizr/pkg/model" | ||
"github.com/krzysztofreczek/go-structurizr/pkg/yaml" | ||
) | ||
|
||
func toScraperConfig(c yaml.Config) Configuration { | ||
return NewConfiguration(c.Configuration.Packages...) | ||
} | ||
|
||
func toScraperRules(c yaml.Config) ([]Rule, error) { | ||
rules := make([]Rule, len(c.Rules)) | ||
for i, r := range c.Rules { | ||
r := r | ||
rule, err := NewRule(). | ||
WithNameRegexp(r.NameRegexp). | ||
WithPkgRegexps(r.PackageRegexps...). | ||
WithApplyFunc( | ||
func() model.Info { | ||
info := make([]string, len(r.Component.Tags)+2) | ||
info[0] = r.Component.Description | ||
info[1] = r.Component.Technology | ||
|
||
idx := 2 | ||
for _, t := range r.Component.Tags { | ||
info[idx] = t | ||
idx++ | ||
} | ||
|
||
return model.ComponentInfo(info...) | ||
}, | ||
).Build() | ||
if err != nil { | ||
return nil, err | ||
} | ||
rules[i] = rule | ||
} | ||
return rules, nil | ||
} |
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,62 @@ | ||
package view | ||
|
||
import ( | ||
"encoding/hex" | ||
"image/color" | ||
"log" | ||
|
||
"github.com/krzysztofreczek/go-structurizr/pkg/yaml" | ||
) | ||
|
||
func toView(c yaml.Config) (View, error) { | ||
v := NewView().WithTitle(c.View.Title) | ||
|
||
if c.View.LineColor != "" { | ||
col, err := decodeHexColor(c.View.LineColor) | ||
if err != nil { | ||
return View{}, err | ||
} | ||
v.WithLineColor(col) | ||
} | ||
|
||
for _, s := range c.View.Styles { | ||
style := NewComponentStyle(s.ID) | ||
|
||
if s.BackgroundColor != "" { | ||
col, err := decodeHexColor(s.BackgroundColor) | ||
if err != nil { | ||
return View{}, err | ||
} | ||
style.WithBackgroundColor(col) | ||
} | ||
|
||
if s.FontColor != "" { | ||
col, err := decodeHexColor(s.FontColor) | ||
if err != nil { | ||
return View{}, err | ||
} | ||
style.WithFontColor(col) | ||
} | ||
|
||
if s.BorderColor != "" { | ||
col, err := decodeHexColor(s.BorderColor) | ||
if err != nil { | ||
return View{}, err | ||
} | ||
style.WithBorderColor(col) | ||
} | ||
|
||
v.WithComponentStyle(style.Build()) | ||
} | ||
|
||
return v.Build(), nil | ||
} | ||
|
||
func decodeHexColor(s string) (color.Color, error) { | ||
b, err := hex.DecodeString(s) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
return color.RGBA{R: b[0], G: b[1], B: b[2], A: 255}, nil | ||
} |
Oops, something went wrong.