mt_line_eraser 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mt_line_eraser.rb +14 -5
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33b4fb6b9757c1025faa5e7ec5bf8f1c348cb34b66385aa571acf2c2a0314790
|
4
|
+
data.tar.gz: da67dbd17f47c644375933b530fae6a26ef0d3fb0e8db602028c514b3aef5bda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ae32b032cb0b3150fd194d1c2fda2e9b73141879f9e484478928597fc4e079fb2ab69fba2ca142189acfce800d42f2b7d7e6d46223ae070efabdfe5c37d791c
|
7
|
+
data.tar.gz: 3f497309990760ef4cf78c42144b96bbeb341364abc7e8a447196662218ca672c763188baeb40613902ac5008049249ef4d3734bb1a663925a654d2a16aaeedb
|
data/lib/mt_line_eraser.rb
CHANGED
@@ -1,15 +1,24 @@
|
|
1
1
|
class MtLineEraser
|
2
2
|
class << self
|
3
|
-
def erase_in(
|
4
|
-
return "Invalid File path" unless File.exists?(
|
5
|
-
|
6
|
-
|
3
|
+
def erase_in(file_or_dir_path)
|
4
|
+
return "Invalid File path" unless File.exists?(file_or_dir_path)
|
5
|
+
files_to_be_processed = File.file?(file_or_dir_path) ? file_or_dir_path
|
6
|
+
: Dir["#{file_or_dir_path}/**/*.*"]
|
7
|
+
files_to_be_processed.each do |_file|
|
8
|
+
erase_empty_lines_in_file(_file)
|
9
|
+
p "Erased all the empty lines from #{_file}"
|
10
|
+
end
|
11
|
+
return nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def erase_empty_lines_in_file(file_path)
|
15
|
+
original_file = File.open(file_path, 'r')
|
16
|
+
clone_file = File.open(file_path + '.clone', 'w')
|
7
17
|
original_file.readlines.each do |line|
|
8
18
|
clone_file.write(line) if line.gsub(/^[\s|\n]*/, '') != ''
|
9
19
|
end
|
10
20
|
[original_file, clone_file].map{|_file| _file.close}
|
11
21
|
File.rename(clone_file, original_file)
|
12
|
-
"Erased all the empty lines from #{file_name_with_path}"
|
13
22
|
end
|
14
23
|
end
|
15
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mt_line_eraser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Subash R
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Erase the empty lines in a specified file
|
14
14
|
email:
|
@@ -22,6 +22,7 @@ homepage: https://github.com/subashravichandran/mt_line_eraser
|
|
22
22
|
licenses:
|
23
23
|
- MIT
|
24
24
|
metadata:
|
25
|
+
source_code_uri: https://github.com/subashravichandran/mt_line_eraser/blob/main/lib/mt_line_eraser.rb
|
25
26
|
homepage_uri: https://github.com/subashravichandran/mt_line_eraser
|
26
27
|
post_install_message:
|
27
28
|
rdoc_options: []
|