compose 0.1.5 → 0.1.6

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: d36eebaf01309fb4c0762dcbc6665e48704c47efdcc53d705a959eca780cbc2f
4
- data.tar.gz: d109de09f9b08947aa5b17a3f67ce4e050854cc123a69d4ae95c791586e0e719
3
+ metadata.gz: '0181e80bc473a0e67c074cc18b299be97ecad391875a7578780a3f8a93286cdc'
4
+ data.tar.gz: a4d171f396fd690387c122958565eb047efd3b0ef11c99acd6fc6e557a78f1e4
5
5
  SHA512:
6
- metadata.gz: 657a0b56b8e25976c901be35c47d531947f524eef84e2696d9ebd0cdea8468b19ec1517b3eca803d49d4dac88e4a37b819695d3a8226bb323171fdeff8d38dd8
7
- data.tar.gz: 72e63f67707c80f0287d5faab11e611e08f4910640e02be9c570738a11bfa939f4adba9c64a2ecd1cf9684c06fcdd5327f181fd1ebce40d2e1bde61ceee8c70e
6
+ metadata.gz: 172b6babed118da8b989bffb8dad311eef02a27c21200df782fccf29783d929559ca44e98023c4ac2e3607e1ece53a36e7490834c9fc09aaffe82aaf8dfc94ec
7
+ data.tar.gz: 89b5cd472edfe13a5007e753d23bca1be694ae056314f71376f442af323de21e1bdcf395c0560445534172c22a7304185df21d0b1835c7e65f05c26c325bf050
@@ -7,6 +7,8 @@ Facts:
7
7
  2. Leave toLine empty for additions.
8
8
  3. Make sure the code snippet in the edit is complete. Feel free to make multiple edits, avoid repeating existing code if you can.
9
9
  4. Ensure the line numbers are accurate. Feel free to repeat existing code from previous or after lines to be sure.
10
+ 5. When adding new code to the end of a file, make sure to repeat the last
11
+ line of the file in the edit before adding a new line.
10
12
 
11
13
  ```json
12
14
  {
@@ -10,7 +10,10 @@ Verify this change:
10
10
  {{CHANGE}}
11
11
  ```
12
12
 
13
- and make sure it's needed and it's only replacing the correct lines, or adding the code to the correct place. Feel free to change additions to replacements or vice versa, or skip edits if they're not needed.
13
+ and make sure it's needed and it's only replacing the correct lines, or adding
14
+ the code to the correct place. Feel free to change additions to replacements
15
+ or vice versa, fix atLine, fromLineNumber, toLineNumber if they would produce
16
+ duplicated code lines, `or skip edits if they're not needed.
14
17
  Return only the fixed change object following this JSON spec:
15
18
 
16
19
  ```json
@@ -86,7 +86,7 @@ module Compose
86
86
 
87
87
  case edit[:change][:type]
88
88
  when 'addition'
89
- new_content.insert(edit[:change][:atLine] - 1, edit[:code])
89
+ new_content.insert(edit[:change][:atLine] - 1, edit[:code].split("\n").map { |line| line + "\n" })
90
90
  when 'replacement'
91
91
  new_content[edit[:change][:fromLineNumber] - 1..edit[:change][:toLineNumber] - 1] = edit[:code].split("\n").map { |line| line + "\n" }
92
92
  end
@@ -109,7 +109,7 @@ module Compose
109
109
  case edit[:change][:type]
110
110
  when 'addition'
111
111
  adjusted_line = edit[:change][:atLine] + line_offset
112
- content.insert(adjusted_line - 1, edit[:code])
112
+ content.insert(adjusted_line - 1, edit[:code].split("\n").map { |line| line + "\n" })
113
113
  line_offset += edit[:code].count("\n") + 1
114
114
  when 'replacement'
115
115
  from_line = edit[:change][:fromLineNumber] + line_offset
@@ -121,6 +121,8 @@ module Compose
121
121
  end
122
122
  end
123
123
 
124
+ content = content.flatten
125
+
124
126
  FileUtils.mkdir_p(File.dirname(filename))
125
127
  File.write(filename, content.join)
126
128
  puts "Applied changes to #{filename}".green
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Compose
4
- VERSION = '0.1.5'
4
+ VERSION = '0.1.6'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dreaming Tulpa