Skip to content

Commit

Permalink
change "ReplaceFunction.replace" to "ReplaceFunction.config"
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusfpleite committed Aug 4, 2024
1 parent 0600cc3 commit a3ee6f1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions preview/src/ReviewConfig.elm
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ configAuthFrontend =
Install.rule "ConfigAuthFrontend"
[ Import.qualified "Frontend" [ "MagicLink.Types", "Auth.Common", "MagicLink.Frontend", "MagicLink.Auth", "Pages.SignIn", "Pages.Home", "Pages.Admin", "Pages.TermsOfService", "Pages.Notes" ]
|> Install.addImport
, ReplaceFunction.replace "Frontend" "tryLoading" tryLoading2
, ReplaceFunction.config "Frontend" "tryLoading" tryLoading2
|> Install.replaceFunction
, ClauseInCase.config "Frontend" "updateFromBackendLoaded" "AuthToFrontend authToFrontendMsg" "MagicLink.Auth.updateFromBackend authToFrontendMsg model.magicLinkModel |> Tuple.mapFirst (\\magicLinkModel -> { model | magicLinkModel = magicLinkModel })"
|> ClauseInCase.withInsertAtBeginning
Expand Down Expand Up @@ -343,9 +343,9 @@ configView =
|> Install.insertClauseInCase
, Import.qualified "View.Main" [ "MagicLink.Helper", "Pages.Counter", "Pages.SignIn", "Pages.Admin", "Pages.TermsOfService", "Pages.Notes", "User" ]
|> Install.addImport
, ReplaceFunction.replace "View.Main" "headerRow" headerRow
, ReplaceFunction.config "View.Main" "headerRow" headerRow
|> Install.replaceFunction
, ReplaceFunction.replace "View.Main" "makeLinks" makeLinks
, ReplaceFunction.config "View.Main" "makeLinks" makeLinks
|> Install.replaceFunction
]

Expand Down
4 changes: 2 additions & 2 deletions src/Install.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Install exposing
, addImport, addElementToList, insertFunction, replaceFunction, insertClauseInCase, insertFieldInTypeAlias, initializer, initializerCmd, subscription, addType, addTypeVariant
)

{-| TODO REPLACEME
{-|
@docs rule
Expand Down Expand Up @@ -94,7 +94,7 @@ insertFunction =
InsertFunction


{-| Replace a function, defined by [`Install.Function.ReplaceFunction.replace`](Install-Function-ReplaceFunction#replace).
{-| Replace a function, defined by [`Install.Function.ReplaceFunction.config`](Install-Function-ReplaceFunction#config).
-}
replaceFunction : Install.Function.ReplaceFunction.Config -> Installation
replaceFunction =
Expand Down
12 changes: 6 additions & 6 deletions src/Install/Function/ReplaceFunction.elm
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module Install.Function.ReplaceFunction exposing (Config, replace)
module Install.Function.ReplaceFunction exposing (Config, config)

{-| Replace a function in a given module with a new implementation.
-- code for ReviewConfig.elm:
rule =
Install.Function.InsertFunction.config
Install.Function.ReplaceFunction.config
"Frontend"
"view"
"""view model =
Html.text "This is a test\""""
|> Install.Function.InsertFunction.makeRule
|> Install.Function.ReplaceFunction.makeRule
Running this rule will replace the function `view` in the module `Frontend` with the provided implementation.
Expand All @@ -22,7 +22,7 @@ The form of the rule is the same for nested modules:
"hoho model = { model | interest = 1.03 * model.interest }"
|> Install.Function.ReplaceFunction.makeRule
@docs Config, replace
@docs Config, config
-}

Expand All @@ -37,8 +37,8 @@ type alias Config =

{-| Initialize the configuration for the rule.
-}
replace : String -> String -> String -> Config
replace hostModuleName functionName functionImplementation =
config : String -> String -> String -> Config
config hostModuleName functionName functionImplementation =
Internal.Config
{ hostModuleName = String.split "." hostModuleName
, functionName = functionName
Expand Down
4 changes: 2 additions & 2 deletions tests/Install/FunctionTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test1 =

rule1 : Installation
rule1 =
ReplaceFunction.replace
ReplaceFunction.config
"Frontend"
"view"
"""view model =
Expand Down Expand Up @@ -130,7 +130,7 @@ makeLinks model route =
rule1b : Installation
rule1b =
ReplaceFunction.replace
ReplaceFunction.config
"View.Main"
"makeLinks"
makeLinks
Expand Down

0 comments on commit a3ee6f1

Please sign in to comment.