rufo 0.5.0 → 0.5.1

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: dc9f1ff616a0e805085d05d0f2fcb92bd8c1b0887e5aedaff75a94a33ee3b0a7
4
- data.tar.gz: 9525bb1291e062e4822105b95cce321b89ef06013a05bc5c444be04ddf1ae24e
3
+ metadata.gz: 35513ffcbf662415975c643eb3dff524ef01b969b64505f221ee2bee96390492
4
+ data.tar.gz: f23d854af35a0ffbe302537d9d2483ef6f0500dfa9428babe66bca83a4bb81c0
5
5
  SHA512:
6
- metadata.gz: 5de0e49f1d959f51383602712f54c3c9e1dc947583f99c074c0524989ec8b2971158187b08d5c0bd85fdd982f0db327d2246ed4bfab0f37f9b76b2581dd0d5d2
7
- data.tar.gz: 7ea03c65b2744b23fadc20ebd5021ec964997755d6d299ab92cdb5f31a1eaa07df00f53a72bcdbda38370a3918d7f2f3d9d0f489c51007ae0a920fe1b8b8c460
6
+ metadata.gz: 51922a71d81402c5d56ff33cd6c1290fa917607b2a1dd934630098061942cef54f394552fa8975949137f02e824663563a2bdebdcfcf4e89a5239c02c0810e43
7
+ data.tar.gz: b93dd700b63aa8fa8a9d3444b9cec9b996e9d031f474cab5c45a26d8768f991b89baf819be42483362c61bcfd7dedac955fd8ec1f82270f76a0db55faae31413
@@ -10,6 +10,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
10
10
 
11
11
  ### Added
12
12
 
13
+ ## [0.5.1] - 2019-02-13
14
+
15
+ ### Fixed
16
+
17
+ - Fix bug: Rufo crashes on nested empty hash literal (issue [152](https://github.com/ruby-formatter/rufo/issues/152))
18
+ - Handle case where rufo would change formatting if run multiple times for hashes in some cases.
19
+
13
20
  ## [0.5.0] - 2019-02-09
14
21
 
15
22
  ### Added
@@ -2306,6 +2306,7 @@ class Rufo::Formatter
2306
2306
 
2307
2307
  check :on_lbrace
2308
2308
  write "{"
2309
+ brace_position = @output.length - 1
2309
2310
  write " " if need_space
2310
2311
  next_token
2311
2312
 
@@ -2314,6 +2315,13 @@ class Rufo::Formatter
2314
2315
  push_hash(node) do
2315
2316
  visit_literal_elements(elements[1], inside_hash: true, token_column: token_column)
2316
2317
  end
2318
+ char_after_brace = @output[brace_position + 1]
2319
+ # Check that need_space is set correctly.
2320
+ if !need_space && !["\n", " "].include?(char_after_brace)
2321
+ need_space = true
2322
+ # Add a space in the missing position.
2323
+ @output.insert(brace_position + 1, " ")
2324
+ end
2317
2325
  else
2318
2326
  skip_space_or_newline
2319
2327
  end
@@ -3844,8 +3852,8 @@ class Rufo::Formatter
3844
3852
  if beginning
3845
3853
  node_line(node[1], beginning: beginning)
3846
3854
  else
3847
- if node.last == [:string_literal, [:string_content]]
3848
- # there's no line number for [:string_literal, [:string_content]]
3855
+ if node.last == [:string_literal, [:string_content]] || node.last == [:hash, nil]
3856
+ # there's no line number for [:string_literal, [:string_content]] or [:hash, nil]
3849
3857
  node_line(node[1], beginning: beginning)
3850
3858
  else
3851
3859
  node_line(node.last, beginning: beginning)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rufo
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ary Borenszweig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-09 00:00:00.000000000 Z
11
+ date: 2019-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler