bsflow 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 457b3db7aef819c0684ec2ed6b74e6e4f3586f2072da8ca8e855c25dc7e86790
4
- data.tar.gz: 2fa0aeccb978acc29aac5c7c5b0fc599abd01e3033eb1241600d18afdef58c4e
3
+ metadata.gz: 6787213121edc5fc781e1a234343ddf26eb337b28c7085d8349b0c056118a58a
4
+ data.tar.gz: f81bc9bb45ebdc770950b1f6d54e39a490c45342552d84df0b21f1ed7d8ad927
5
5
  SHA512:
6
- metadata.gz: cb427d952b5e8d27aa30daba5e5c0ddd7ef9e9b5f0c5c72f1d12e7ae5525c01d1cfaccc9ab213a65bc7c152dcde97c973d8b70f4c32b61eedcfac96f23ba5f3a
7
- data.tar.gz: 70bf14e6fed64895ab7bde2326626d72a436019a7f35472c1976227fe95124c91edbcf42c3f93741fea593c4572b45536c4922e71b3b9d2c0d65e3865cdedca6
6
+ metadata.gz: 1445972cb93c36c99a547aca6a0aa1ff3ee000fbab77842eaa9461ae0c381efbde28507663f9c21a97a7a1579e3b4ff14c237051516e00ee94bbc9317d055a75
7
+ data.tar.gz: f30828ff0362ce63b34cac3e6e79f1cc5716be2adc47cb0341561d383e9746bf298b67449cb22db0de88f302252ec5a5bb7cc24b1989b34fcfb272d9090d4eb0
data/README.md CHANGED
@@ -88,6 +88,117 @@ Paramaters:
88
88
  - **_procs_** - an array of procs or objects responding on `.call` message. The first **_proc_** takes the "main" input of the class (any number of arguments). The result is passed to the next **_proc_** as input. The output of the last **_proc_** is the output of `.call` method of **Pipeline** class.
89
89
 
90
90
 
91
+ ### Class BSFlow::StdoutAdapter
92
+
93
+ It allows to "connect" standard output stream to an object that expects `#call` mathod.
94
+
95
+ Source code:
96
+
97
+ ```ruby
98
+ module BSFlow
99
+ class StdoutAdapter
100
+ def initialize(stdout:)
101
+ @stdout = stdout
102
+ end
103
+
104
+ def call(string)
105
+ @stdout.puts(string)
106
+ end
107
+ end
108
+ end
109
+ ```
110
+
111
+ #### Require
112
+
113
+ ```ruby
114
+ require "bsflow/stdout_adapter"
115
+ ```
116
+
117
+ #### Constructor
118
+
119
+ ```ruby
120
+ BSFlow:StdoutAdapter.new(procs: procs) # => new_adapter
121
+ ```
122
+
123
+ Paramaters:
124
+
125
+ - **_stdout_** - an object that respond to `.#puts` message with one argument.
126
+
127
+
128
+ ### Class BSFlow::StdinAdapter
129
+
130
+ It allows to "connect" standard input stream to an object that expects `#call` mathod.
131
+
132
+ Source code:
133
+
134
+ ```ruby
135
+ module BSFlow
136
+ class StdinAdapter
137
+ def initialize(stdin:)
138
+ @stdin = stdin
139
+ end
140
+
141
+ def call()
142
+ @stdin.gets.chomp
143
+ end
144
+ end
145
+ end
146
+ ```
147
+
148
+ #### Require
149
+
150
+ ```ruby
151
+ require "bsflow/stdin_adapter"
152
+ ```
153
+
154
+ #### Constructor
155
+
156
+ ```ruby
157
+ BSFlow:StdinAdapter.new(stdin: stdin) # => new_adapter
158
+ ```
159
+
160
+ Paramaters:
161
+
162
+ - **_stdin_** - an object that respond to `.#gets` message. The chomped output of this object is the output of `.call` method of **StdinAdapter** class.
163
+
164
+
165
+ ### Class BSFlow::SquareBracketsAdapter
166
+
167
+ It passes a value to **_[]_** method of a hash or any objects that response to [] method.
168
+
169
+ Source code:
170
+
171
+ ```ruby
172
+ module BSFlow
173
+ class SquareBracketsAdapter
174
+ def initialize(map:)
175
+ @map = map
176
+ end
177
+
178
+ def call(symbol)
179
+ @map[symbol]
180
+ end
181
+ end
182
+ end
183
+ ```
184
+
185
+ #### Require
186
+
187
+ ```ruby
188
+ require "bsflow/square_brackets_adapter"
189
+ ```
190
+
191
+ #### Constructor
192
+
193
+ ```ruby
194
+ BSFlow:SquareBracketsAdapter.new(map: map) # => new_square_brackets_adapter
195
+ ```
196
+
197
+ Paramaters:
198
+
199
+ - **_map_** - an object that respond to `.#[]` message. It takes the "main" input of the class (one argument). The output of this object is the output of `.call` method of **SquareBracketsAdapter** class.
200
+
201
+
91
202
  ### Class BSFlow::FirstArg
92
203
 
93
204
  It just returns first pased argument and ignores the rest. Used to reduce number of arguments.
@@ -0,0 +1,11 @@
1
+ module BSFlow
2
+ class SquareBracketsAdapter
3
+ def initialize(map:)
4
+ @map = map
5
+ end
6
+
7
+ def call(symbol)
8
+ @map[symbol]
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module BSFlow
2
+ class StdinAdapter
3
+ def initialize(stdin:)
4
+ @stdin = stdin
5
+ end
6
+
7
+ def call()
8
+ @stdin.gets.chomp
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module BSFlow
2
+ class StdoutAdapter
3
+ def initialize(stdout:)
4
+ @stdout = stdout
5
+ end
6
+
7
+ def call(string)
8
+ @stdout.puts(string)
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module BSFlow
2
- VERSION = "2.2.0"
2
+ VERSION = "2.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bsflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartłomiej Sielski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-23 00:00:00.000000000 Z
11
+ date: 2018-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,6 +78,9 @@ files:
78
78
  - lib/bsflow/pass.rb
79
79
  - lib/bsflow/pipeline.rb
80
80
  - lib/bsflow/self.rb
81
+ - lib/bsflow/square_brackets_adapter.rb
82
+ - lib/bsflow/stdin_adapter.rb
83
+ - lib/bsflow/stdout_adapter.rb
81
84
  - lib/bsflow/true.rb
82
85
  - lib/bsflow/until_true_loop.rb
83
86
  - lib/bsflow/version.rb