fsorg 0.2.2 → 0.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 +4 -4
- data/lib/fsorg.rb +12 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1ce86ca67be5d602db8974b0741160b2b3c5d9c2036af4c335c565de0729529
|
4
|
+
data.tar.gz: f305cfa72e0b889ceca6dda5e6046d82aabf37ed2049657c97f7c5e2654281da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '080d45289d3ddcab4f72b467cd40f5958c0dc94983f84738498201f62eec41ff98438e7019e8c3389efc030176f21a9fe757a96a7f95598927063602ab285535'
|
7
|
+
data.tar.gz: 8cf2527ec7f16ac0bf2cd63d5d2ad4c241a783f5135d911320cbce438728cac46214c4529133581739bd4e67269ba6ff1e2b74f5dafdbd833750af7e08f7bf9f
|
data/lib/fsorg.rb
CHANGED
@@ -132,7 +132,7 @@ class Fsorg
|
|
132
132
|
filepath = @document_path.parent.join(line.sub /^INCLUDE /, "")
|
133
133
|
included_raw = File.new(filepath).read.strip
|
134
134
|
included_fsorg = Fsorg.new(@root_directory, @data, included_raw, filepath)
|
135
|
-
included_fsorg.preprocess
|
135
|
+
included_fsorg.preprocess
|
136
136
|
@data = included_fsorg.data.merge @data
|
137
137
|
output += included_fsorg.document.lines(chomp: true)
|
138
138
|
else
|
@@ -145,7 +145,6 @@ class Fsorg
|
|
145
145
|
|
146
146
|
def store_writes
|
147
147
|
output = []
|
148
|
-
|
149
148
|
|
150
149
|
@document = output.join "\n"
|
151
150
|
end
|
@@ -392,7 +391,7 @@ class Fsorg
|
|
392
391
|
puts "#{indentation}> ".cyan.bold + dest.relative_path_from(@root_directory).to_s + (future_file[:permissions] ? " mode #{future_file[:permissions]}".yellow : "")
|
393
392
|
end
|
394
393
|
unless dry_run
|
395
|
-
dest.write deindent replace_data future_file[:content]
|
394
|
+
dest.write ensure_final_newline deindent replace_data future_file[:content]
|
396
395
|
# Not using dest.chmod as the syntax for permissions is more than just integers,
|
397
396
|
# and matches in fact the exact syntax of chmod's argument, per the manpage, chmod(1) (line "Each MODE is of the form…")
|
398
397
|
`chmod #{future_file[:permissions]} #{dest}` if future_file[:permissions]
|
@@ -400,9 +399,9 @@ class Fsorg
|
|
400
399
|
end
|
401
400
|
|
402
401
|
def replace_data(content)
|
403
|
-
content.gsub /\{\{(?<variable>[^}]+?)\}\}/ do |interpolation|
|
402
|
+
content.gsub /\{\{(?<variable>[^}]+?)\}\}/ do |interpolation|
|
404
403
|
variable = interpolation[2..-3]
|
405
|
-
@data[variable.to_sym]
|
404
|
+
@data[variable.to_sym]
|
406
405
|
end
|
407
406
|
end
|
408
407
|
|
@@ -452,6 +451,14 @@ def deindent(text)
|
|
452
451
|
end.join "\n"
|
453
452
|
end
|
454
453
|
|
454
|
+
def ensure_final_newline(text)
|
455
|
+
unless text.end_with? "\n"
|
456
|
+
text + "\n"
|
457
|
+
else
|
458
|
+
text
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
455
462
|
def capture_output
|
456
463
|
old_stdout = $stdout
|
457
464
|
old_stderr = $stderr
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fsorg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ewen Le Bihan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|