@@ -78,7 +78,7 @@ pipeline to do that like so:
7878flowchart LR
7979 input[String]
8080 subgraph Pipeline
81- pipe1[capitalize ]
81+ pipe1[title ]
8282 pipe2[trim]
8383
8484 pipe1 --> pipe2
@@ -90,14 +90,14 @@ flowchart LR
9090```
9191
9292``` python
93- from pypipeline import Pipeline
93+ from pypipeline.pipeline import Pipeline
9494
9595# Create a new pipeline instance.
9696pipeline = Pipeline()
9797
9898# Send a string through the pipeline.
9999result = pipeline.send(' hello world ' ).through([
100- str .capitalize ,
100+ str .title ,
101101 str .strip
102102]).then_return()
103103
@@ -112,7 +112,7 @@ You don't need to build the pipeline all at once, you can spread it out over a n
112112flowchart LR
113113 input[String]
114114 subgraph Pipeline
115- pipe1[capitalize ]
115+ pipe1[title ]
116116 pipe2[trim]
117117 pipe3[reverse_string]
118118
@@ -126,28 +126,25 @@ flowchart LR
126126```
127127
128128``` python
129- from pypipeline import Pipeline
129+ from pypipeline.pipeline import Pipeline
130130
131131# Create a new pipeline instance.
132132pipeline = Pipeline()
133133
134134# Set the pipes you want to use.
135- pipeline.through([
136- str .capitalize,
137- str .strip
138- ])
135+ pipeline.through([ str .title, str .strip ])
139136
140137# Add another transformation.
141- def reverse_string (s ):
142- return s[:: - 1 ]
138+ def replace (s ):
139+ return s.replace( ' Hello ' , ' Goodbye ' )
143140
144141# Add it to the pipeline.
145- pipeline.pipe(reverse_string )
142+ pipeline.pipe(replace )
146143
147144# Send data through the pipeline.
148145result = pipeline.send(' hello world ' ).then_return()
149146
150- print (result) # Output: 'dlrow olleh '
147+ print (result) # Output: 'Goodbye World '
151148```
152149
153150### Using custom pipes
@@ -172,21 +169,19 @@ flowchart LR
172169```
173170
174171``` python
175- from pypipeline import Pipeline
172+ from pypipeline.pipeline import Pipeline
176173
177174pipeline = Pipeline()
178175
179176def custom_pipe (passable , next_pipe ):
180177 passable = passable.replace(' hello' , ' goodbye' )
181178 return next_pipe(passable)
182179
183- pipeline.through([
184- custom_pipe,
185- str .capitalize
186- ])
180+ pipeline.through([custom_pipe, str .title])
187181
188182result = pipeline.send(' hello world' ).then_return()
189183print (result) # Output: 'Goodbye world'
184+
190185```
191186
192187### Using classes with the ` handle ` method
@@ -201,9 +196,9 @@ optionally implement the `StellarWP\Pipeline\Contracts\Pipe` interface to enforc
201196
202197First class:
203198``` python
204- class CapitalizePipe :
199+ class TitlePipe :
205200 def handle (self , passable , next_pipe ):
206- return next_pipe(passable.capitalize ())
201+ return next_pipe(passable.title ())
207202```
208203
209204Second class:
@@ -219,7 +214,7 @@ class StripPipe:
219214flowchart LR
220215 input[String]
221216 subgraph Pipeline
222- pipe1[CapitalizePipe ::handle]
217+ pipe1[TitlePipe ::handle]
223218 pipe2[StripPipe::handle]
224219
225220 pipe1 --> pipe2
@@ -231,9 +226,9 @@ flowchart LR
231226```
232227
233228``` python
234- from pypipeline import Pipeline
229+ from pypipeline.pipeline import Pipeline
235230
236- pipeline = Pipeline().through([CapitalizePipe (), StripPipe()])
231+ pipeline = Pipeline().through([TitlePipe (), StripPipe()])
237232result = pipeline.send(' hello world ' ).then_return()
238233print (result) # Output: 'Hello world'
239234```
@@ -247,9 +242,9 @@ the alternate method name using the `via()` method.
247242
248243First class:
249244``` python
250- class ReversePipe :
245+ class TitlePipe :
251246 def execute (self , passable , next_pipe ):
252- return next_pipe(passable[:: - 1 ] )
247+ return next_pipe(passable.title() )
253248```
254249
255250Second class:
@@ -277,11 +272,11 @@ flowchart LR
277272```
278273
279274``` python
280- from pypipeline import Pipeline
275+ from pypipeline.pipeline import Pipeline
281276
282277pipeline = Pipeline().via(' execute' ).through([StripPipe(), ReversePipe()])
283278result = pipeline.send(' hello ' ).then_return()
284- print (result) # Output: 'olleh '
279+ print (result) # Output: 'Hello '
285280
286281```
287282
@@ -293,7 +288,7 @@ can do this with a `return` statement!
293288#### Example pipeline
294289
295290``` python
296- from pypipeline import Pipeline
291+ from pypipeline.pipeline import Pipeline
297292
298293def check_content (passable , next_pipe ):
299294 if ' stop' in passable:
@@ -331,7 +326,7 @@ flowchart LR
331326```
332327
333328``` python
334- from pypipeline import Pipeline
329+ from pypipeline.pipeline import Pipeline
335330
336331pipeline = Pipeline().through([str .strip, str .upper])
337332result = pipeline.send(' hello world ' ).then(lambda x : len (x))
@@ -358,7 +353,7 @@ pipeline.pipe( str.strip )
358353# or
359354pipeline.add_pipe( str .strip )
360355# or
361- pipeline.pipe( [ str .capitalize , str .strip ] )
356+ pipeline.pipe( [ str .title , str .strip ] )
362357```
363358
364359### ` send() `
@@ -438,16 +433,16 @@ Aliases: `pipes()`
438433#### Examples
439434``` python
440435# You can provide any number of pipes.
441- pipeline.through([ str .capitalize , str .strip ])
436+ pipeline.through([ str .title , str .strip ])
442437
443438# Using the alias.
444- pipeline.pipes([ str .capitalize , str .strip ])
439+ pipeline.pipes([ str .title , str .strip ])
445440
446441# Pass closures as pipes.
447- pipeline.through([ str .capitalize , lambda passable , next : next_pipe(passable.strip)])
442+ pipeline.through([ str .title , lambda passable , next : next_pipe(passable.strip)])
448443
449444# Pass objects as pipes.
450- pipeline.through([ CapitalizePipe (), StripPipe() ])
445+ pipeline.through([ TitlePipe (), StripPipe() ])
451446```
452447
453448### ` via() `
0 commit comments