yoga 0.4.1 → 0.4.2

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
  SHA1:
3
- metadata.gz: 03845e88ffb4574489a6881d994554233bffe779
4
- data.tar.gz: 1217f182ff6402b7df6f5997f7f24dca773e39d2
3
+ metadata.gz: d47b133334a8a84e8376462babbbe7ead6a966bd
4
+ data.tar.gz: d2b5d18e263caf245c93677658dadb1c5c66f36b
5
5
  SHA512:
6
- metadata.gz: 14e9209587fc857be6637316ae9e3cdfe08022b61d5326987b2d7f7a3e2ba18b2c20e2bc8277097f7f35dfa38742813378b2acb02114c7afb9780afdea4e3343
7
- data.tar.gz: 84892e0eca95a1d0b56f64ccab0bb1b6c532f3775185e31b89b54f21386c0803873e872361abf66d6d425c8383d6423eacfa4790618b4e576e71859c2c1f5643
6
+ metadata.gz: fd9eb5267207071585e630dcf03186a0e7f8ac748b578fc207330a2560544f649573d7ebe299fe4820ec53a473e01fc2980048b9484979fb9cb5781b2576fb32
7
+ data.tar.gz: 14c809c089f72ddfd86d64dad0d4834d6d7faabfe0386efcc487550c0c4615cb81ee5c6cd1bced90b92bf462a6182a040737d81567079b64d602116ffb91d57b
data/.rubocop.yml CHANGED
@@ -37,4 +37,6 @@ Style/IndentArray:
37
37
  Style/Alias:
38
38
  EnforcedStyle: prefer_alias_method
39
39
  Style/ParallelAssignment:
40
- Enabled: false
40
+ Enabled: false
41
+ Style/NumericPredicate:
42
+ Enabled: false
@@ -173,8 +173,8 @@ module Yoga
173
173
  # @return [::Array] The collected nodes from the yielding process.
174
174
  def collect(ending, join = nil)
175
175
  children = []
176
- join = Utils.flatten_into_set([join]) if join
177
- ending = Utils.flatten_into_set([ending]) if ending
176
+ join = Utils.flatten_into_set(join) if join
177
+ ending = Utils.flatten_into_set(ending) if ending
178
178
 
179
179
  return [] if (ending && peek?(ending)) || (!ending && !join)
180
180
 
@@ -196,9 +196,8 @@ module Yoga
196
196
  #
197
197
  # @param tokens [<::Symbol>] The possible kinds.
198
198
  # @return [::Boolean]
199
- def peek?(*tokens)
200
- tokens = Utils.flatten_into_set(tokens)
201
- tokens.include?(peek.kind)
199
+ def peek?(tokens)
200
+ Utils.flatten_into_set(tokens).include?(peek.kind)
202
201
  end
203
202
 
204
203
  # Peeks out to a specific point in the future to match. This is an
@@ -210,8 +209,7 @@ module Yoga
210
209
  # @param tokens [<::Symbol>] The kinds of tokens to check for.
211
210
  # @return [::Boolean]
212
211
  def peek_out?(to, tokens)
213
- tokens = Utils.flatten_into_set([tokens])
214
- tokens.include?(peek_out(to).kind)
212
+ Utils.flatten_into_set(tokens).include?(peek_out(to).kind)
215
213
  end
216
214
 
217
215
  # Shifts to the next token, and returns the old token.
@@ -229,10 +227,10 @@ module Yoga
229
227
  #
230
228
  # @param tokens [<::Symbol>] The expected tokens.
231
229
  # @return [Yoga::Token]
232
- def expect(*tokens)
230
+ def expect(tokens)
233
231
  tokens = Utils.flatten_into_set(tokens)
234
- return shift if peek?(*tokens)
235
- error(tokens.flatten)
232
+ return shift if peek?(tokens)
233
+ error(tokens)
236
234
  end
237
235
 
238
236
  # Retrieves the first set for the given node name.
data/lib/yoga/scanner.rb CHANGED
@@ -171,8 +171,8 @@ module Yoga
171
171
  def update_line_information
172
172
  return unless (lines = @scanner[0].scan(LINE)).any?
173
173
  @line += lines.size
174
- @last_line_at =
175
- @scanner.string.rindex(LINE, @scanner.charpos) + 1
174
+ line_index = @scanner.string.rindex(LINE, @scanner.charpos)
175
+ @last_line_at = line_index < 0 ? 0 : line_index + 1
176
176
  end
177
177
  end
178
178
  end
data/lib/yoga/utils.rb CHANGED
@@ -15,22 +15,11 @@ module Yoga
15
15
  # The array to flatten into a set.
16
16
  # @return [::Set<Yoga::Token>]
17
17
  def flatten_into_set(tokens)
18
- flatten_into_array(tokens).to_set
19
- end
20
-
21
- # Takes an array of tokens or a set/array of tokens and turns it into a
22
- # single array.
23
- #
24
- # @param tokens [<Yoga::Token>, ::Set<Yoga::Token>, ::Enumerable]
25
- # The array to flatten into a set.
26
- # @return [<Yoga::Token>]
27
- def flatten_into_array(tokens)
28
- tokens.flat_map do |part|
29
- if part.is_a?(::Enumerable)
30
- flatten_into_array(part)
31
- else
32
- part
33
- end
18
+ case tokens
19
+ when ::Set then tokens
20
+ when ::Array then ::Set.new(tokens)
21
+ else
22
+ ::Set.new(tokens.to_a)
34
23
  end
35
24
  end
36
25
  end
data/lib/yoga/version.rb CHANGED
@@ -5,5 +5,5 @@ module Yoga
5
5
  # The version of the module.
6
6
  #
7
7
  # @return [::String]
8
- VERSION = "0.4.1"
8
+ VERSION = "0.4.2"
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yoga
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Rodi