mt_line_eraser 0.0.4 → 0.0.5

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mt_line_eraser.rb +12 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33b4fb6b9757c1025faa5e7ec5bf8f1c348cb34b66385aa571acf2c2a0314790
4
- data.tar.gz: da67dbd17f47c644375933b530fae6a26ef0d3fb0e8db602028c514b3aef5bda
3
+ metadata.gz: ea0af945ccd7b5483604b3ad540e3232cd583d3dd096bdb15fe7a26fcc72a38d
4
+ data.tar.gz: 376b197a78ccf94b4890794025d06b7b78bab11b28959f92518963572a127d33
5
5
  SHA512:
6
- metadata.gz: 5ae32b032cb0b3150fd194d1c2fda2e9b73141879f9e484478928597fc4e079fb2ab69fba2ca142189acfce800d42f2b7d7e6d46223ae070efabdfe5c37d791c
7
- data.tar.gz: 3f497309990760ef4cf78c42144b96bbeb341364abc7e8a447196662218ca672c763188baeb40613902ac5008049249ef4d3734bb1a663925a654d2a16aaeedb
6
+ metadata.gz: 9a5f9a65ae9fb1d4d419945f8c8f3d44696711c901f905d11ff007dd4f21462d6ba2b06218a950ebd042616060504e713271001e9cc7fcd375b678932cdee161
7
+ data.tar.gz: 44b439f11e1d3b0dbcb7ea766f26e9fa2cb22ae26f8ce4f5891dbfc0f805f1d231e6b9f9d162a5c5fa02f802cc54ed616c3e3e252bf5b904dcb03861ee5a01f9
@@ -1,23 +1,29 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class MtLineEraser
2
4
  class << self
3
5
  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}/**/*.*"]
6
+ return 'Invalid File path' unless File.exist?(file_or_dir_path)
7
+
8
+ files_to_be_processed = if File.file?(file_or_dir_path)
9
+ [file_or_dir_path]
10
+ else
11
+ Dir["#{file_or_dir_path}/**/*.*"]
12
+ end
7
13
  files_to_be_processed.each do |_file|
8
14
  erase_empty_lines_in_file(_file)
9
15
  p "Erased all the empty lines from #{_file}"
10
16
  end
11
- return nil
17
+ nil
12
18
  end
13
19
 
14
20
  def erase_empty_lines_in_file(file_path)
15
21
  original_file = File.open(file_path, 'r')
16
- clone_file = File.open(file_path + '.clone', 'w')
22
+ clone_file = File.open("#{file_path}.clone", 'w')
17
23
  original_file.readlines.each do |line|
18
24
  clone_file.write(line) if line.gsub(/^[\s|\n]*/, '') != ''
19
25
  end
20
- [original_file, clone_file].map{|_file| _file.close}
26
+ [original_file, clone_file].map(&:close)
21
27
  File.rename(clone_file, original_file)
22
28
  end
23
29
  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
4
+ version: 0.0.5
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-13 00:00:00.000000000 Z
11
+ date: 2022-12-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Erase the empty lines in a specified file
14
14
  email: