Skip to content

Commit

Permalink
feat: non-standard pert
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Aug 27, 2019
1 parent 5794663 commit 6aac67a
Show file tree
Hide file tree
Showing 13 changed files with 176 additions and 500 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ web/pertify/examples/
*~
*#
.#*
covrage.txt
coverage.txt

# Vendors
node_modules/
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ netlify: _netlify_deps lambda-build install
.PHONY: sam-local
sam-local: lambda-build
@echo ""
@echo "Open: http://localhost:3000/pertify/index.html"
@echo "Open: http://localhost:8080/pertify/index.html"
@echo ""
sam local start-api --static-dir=web
sam local start-api --host=0.0.0.0 --port=8080 --static-dir=web

.PHONY: netlify
netlify: _netlify-deps lambda-build

.PHONY: _netlify-deps
_netlify_deps:
Expand Down
50 changes: 38 additions & 12 deletions attr.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,52 @@ func (a Attrs) GetTitle() string {
return ""
}

func (a Attrs) SetPertEstimates(opt, real, pess float64) Attrs {
a["pert"] = &PertAttrs{
Optimistic: opt,
Realistic: real,
Pessimistic: pess,
func (a Attrs) getOrCreatePert() *PertAttrs {
if _, ok := a["pert"]; !ok {
a["pert"] = &PertAttrs{}
}
return a["pert"].(*PertAttrs)
}

func (a Attrs) SetPertEstimates(opt, real, pess float64) Attrs {
pert := a.getOrCreatePert()
pert.Optimistic = opt
pert.Realistic = real
pert.Pessimistic = pess
pert.IsAction = true
pert.IsState = false
return a
}

func (a Attrs) SetPertUntitledState() Attrs {
a["pert"] = &PertAttrs{
IsUntitledState: true,
}
func (a Attrs) SetPertState() Attrs {
pert := a.getOrCreatePert()
pert.IsAction = false
pert.IsState = true
return a
}

func (a Attrs) SetPertAction() Attrs {
pert := a.getOrCreatePert()
pert.IsAction = true
pert.IsState = false
return a
}

func (a Attrs) SetPertUntitled() Attrs {
pert := a.getOrCreatePert()
pert.IsUntitled = true
return a
}

func (a Attrs) SetPertZeroTimeActivity() Attrs {
a["pert"] = &PertAttrs{
IsZeroTimeActivity: true,
}
pert := a.getOrCreatePert()
pert.IsZeroTimeActivity = true
return a
}

func (a Attrs) SetPertNonStandardGraph() Attrs {
pert := a.getOrCreatePert()
pert.IsNonStandardGraph = true
return a
}

Expand Down
3 changes: 1 addition & 2 deletions cmd/pertify/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ module moul.io/cmd/pertify

go 1.12

require moul.io/graphman v1.0.0

require (
github.com/pkg/errors v0.8.1
gopkg.in/urfave/cli.v2 v2.0.0-20180128182452-d3ae77c26ac8
gopkg.in/yaml.v3 v3.0.0-20190705120443-117fdf03f45f
moul.io/graphman v1.0.0
moul.io/graphman/viz v0.0.0
)

Expand Down
7 changes: 4 additions & 3 deletions cmd/pertify/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func main() {
&cli.BoolFlag{Name: "vertical", Usage: "displaying steps from top to bottom"},
&cli.BoolFlag{Name: "with-details", Usage: "Show pert numbers"},
&cli.BoolFlag{Name: "no-simplify", Usage: "Don't simplify the graph"},
&cli.BoolFlag{Name: "standard-pert", Usage: "Use edges for actions instead of vertices"},
&cli.BoolFlag{Name: "debug", Aliases: []string{"D"}, Usage: "verbose mode"},
},
Action: graph,
Expand All @@ -42,9 +43,9 @@ func graph(c *cli.Context) error {
return errors.Wrap(err, "failed to parse yaml file")
}

if c.Bool("no-simplify") {
config.Opts.NoSimplify = true
}
config.Opts.NoSimplify = c.Bool("no-simplify")
config.Opts.StandardPert = c.Bool("standard-pert")

graph := graphman.FromPertConfig(config)
if c.Bool("debug") {
log.Println(graph)
Expand Down
Loading

0 comments on commit 6aac67a

Please sign in to comment.