oppen 0.9.2 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fdf36c265fd8c6c3d7335fe79b016ac1e6d8014a23f1b027fc4d956d05b442ab
4
- data.tar.gz: d75772336cb34c8af929e95d5c4520f0388718739f7d6df722496f6f2f96a82a
3
+ metadata.gz: 5a2178222eed2a9789223d62624ee4d5b468ec35dbd65c602bfdea24e5e08c77
4
+ data.tar.gz: 3ef37f2ad458bac064f77e7a37959fac18f33fc2d31dfc9ddbf4a4b88f527270
5
5
  SHA512:
6
- metadata.gz: 1d745467bc343f1262dbf36f1206a1a37336840014b6785badab602712fe167457b45598b4d2f10e4d438cb49935472c8fe9aea1e21109f349c6f52524831e8e
7
- data.tar.gz: ad6279e7c29f9b6764fd19ddcdfc8fe006272eb481632d0a3f4f7fa9aad7a5b873e624ea5e829b89ee97401c474779034cfa956ff202e438a27afa22e6bd9151
6
+ metadata.gz: 3a83e465f4279d02b9689d58f4023c61287b5f2ba03a0f209fcfdedc55e8451e05802fa61e01c0f1c898afb3e5577b0321fd60002a1c08924130991e9769a490
7
+ data.tar.gz: 11d507ea9e4f5e6b5c0fe258c478b47243fd04c1a348bd935ce4404cd56d005776f161f11d52d93326ca1ecf5739bbbed2f360d397c37a5e497ec1b1ed103bcd
@@ -246,7 +246,9 @@ module Oppen
246
246
  #
247
247
  # @return [Nil]
248
248
  def indent(amount)
249
- write genspace.call(amount)
249
+ raise ArgumentError 'Indenting using negative amount' if amount.negative?
250
+
251
+ write genspace.call(amount) if amount.positive?
250
252
  end
251
253
  end
252
254
  end
data/lib/oppen/version.rb CHANGED
@@ -5,5 +5,5 @@ module Oppen
5
5
  # Oppen version
6
6
  #
7
7
  # @return [String] current version
8
- VERSION = '0.9.2' # managed by release.sh
8
+ VERSION = '0.9.4' # managed by release.sh
9
9
  end
data/lib/wadler/print.rb CHANGED
@@ -35,6 +35,10 @@ module Oppen
35
35
 
36
36
  # @return [String]
37
37
  def output
38
+ if !tokens.first.is_a? Token::Begin
39
+ tokens.unshift Oppen.begin_consistent(offset: 0)
40
+ tokens << Oppen.end
41
+ end
38
42
  if !tokens.last.is_a? Oppen::Token::EOF
39
43
  tokens << Oppen.eof
40
44
  end
@@ -128,5 +132,72 @@ module Oppen
128
132
  def break(line_continuation: '')
129
133
  tokens << Oppen.line_break(line_continuation:, offset: current_indent)
130
134
  end
135
+
136
+ # @!group Helpers
137
+
138
+ # Set a base indenetaion level to the printer.
139
+ #
140
+ # @param indent [Integer]
141
+ #
142
+ # @return [Nil]
143
+ def base_indent(indent = 0)
144
+ @current_indent = indent if !indent.nil?
145
+ end
146
+
147
+ # Open a consistent group.
148
+ #
149
+ # @param indent [Integer]
150
+ #
151
+ # @return [Nil]
152
+ def group_open(indent: 0)
153
+ tokens << Oppen.begin_consistent(offset: indent)
154
+ end
155
+
156
+ # Close a group.
157
+ #
158
+ # @return [Nil]
159
+ def group_close(_)
160
+ tokens << Oppen.end
161
+ end
162
+
163
+ # Open a consistent group with indent.
164
+ #
165
+ # @param indent [Integer]
166
+ #
167
+ # @return [Nil]
168
+ def indent_open(indent)
169
+ @current_indent += indent
170
+ group_open
171
+ end
172
+
173
+ # Close a group with indent.
174
+ #
175
+ # @param indent [Integer]
176
+ #
177
+ # @return [Nil]
178
+ def indent_close(group, indent)
179
+ @current_indent -= indent
180
+ group_close(group)
181
+ end
182
+
183
+ # Open a nest by indent.
184
+ #
185
+ # @param indent [Integer]
186
+ #
187
+ # @return [Nil]
188
+ def nest_open(indent)
189
+ @current_indent += indent
190
+ end
191
+
192
+ # Close a nest by indent.
193
+ #
194
+ # @param indent [Integer]
195
+ #
196
+ # @return [Nil]
197
+ def nest_close(indent)
198
+ @current_indent -= indent
199
+ end
200
+
201
+ # @!endgroup
131
202
  end
132
203
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oppen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amine Mike El Maalouf <amine.el-maalouf@epita.fr>