immosquare-cleaner 0.1.0 → 0.1.4

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: 99d7d3985550b02c0e29de7fe0934b9b3190f82961570d671fbc45a4fdfe8f17
4
- data.tar.gz: 655b87bc65f6b485050f8ee616ecb8601d8b130d619bdfe9856ce3b8a8d5c280
3
+ metadata.gz: e341bf1067e21b5e4389372799dd8b1c0a3d7def5c9519b979a482be2d03c0f3
4
+ data.tar.gz: b315cff9a2a3f3a8d9d60db7b496b54c1cded48ddd9740b5c944f883da507903
5
5
  SHA512:
6
- metadata.gz: 8e01de397011a5a527e8fcd3f931ca4b66b7d3851d52315f10a58e7d18b8da79c8d82f71cddc19f2af7933916bf91e2464751196ee6880e2f8590611c485a623
7
- data.tar.gz: 41b6a114cb2c420227afe547b3cccfb6f350afb19c8202a4ce7453348a4438b45ffbebcb0fcf11e934845324b87a72e1d141ab5e8a4861df1479c1349df51518
6
+ metadata.gz: b25f01dfba4c066a21021fb5c72f7449eefbb0b5831b910e347494435bcb197dad37c6ec02ec6bfc1d38ac18bb80a38f1257c70be3e44ade9c60702218e5a451
7
+ data.tar.gz: 6d3945a01c4480d90b58f711e30763cdb5ee90c37e994bfad538644e4872c3e7ad9c98cc5b6bc269d8feee2deec794c5f57f96ac1c23c62e9cd3f6f20474e262
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "immosquare_cleaner"
3
+ require "immosquare-cleaner"
4
4
  require "optparse"
5
5
 
6
6
  options = {}
@@ -1,4 +1,4 @@
1
- module ImmosquareYaml
1
+ module ImmosquareCleaner
2
2
  class Railtie < Rails::Railtie
3
3
 
4
4
  rake_tasks do
@@ -1,3 +1,3 @@
1
1
  module ImmosquareCleaner
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.1.4".freeze
3
3
  end
@@ -1,7 +1,13 @@
1
- require "immosquare-yaml"
1
+ require "English"
2
2
  require_relative "immosquare-cleaner/configuration"
3
- require_relative "immosquare-yaml/railtie" if defined?(Rails)
4
-
3
+ require_relative "immosquare-cleaner/railtie" if defined?(Rails)
4
+
5
+ ##===========================================================================##
6
+ ## Importing the 'English' library allows us to use more human-readable
7
+ ## global variables, such as $INPUT_RECORD_SEPARATOR instead of $/,
8
+ ## which enhances code clarity and makes it easier to understand
9
+ ## the purpose of these variables in our code.
10
+ ##===========================================================================##
5
11
  module ImmosquareCleaner
6
12
  class << self
7
13
 
@@ -44,7 +50,7 @@ module ImmosquareCleaner
44
50
  ##============================================================##
45
51
  if file_path.end_with?(".html.erb")
46
52
  cmd << [true, "bundle exec htmlbeautifier #{file_path} #{ImmosquareCleaner.configuration.htmlbeautifier_options || "--keep-blank-lines 4"}"]
47
- cmd << [true, "bundle exec erblint -c #{gem_root}/linters/erb-lint.yml #{file_path} #{ImmosquareCleaner.configuration.erblint_options || "--autocorrect"}"]
53
+ cmd << [true, "bundle exec erblint --config #{gem_root}/linters/erb-lint.yml #{file_path} #{ImmosquareCleaner.configuration.erblint_options || "--autocorrect"}"]
48
54
  elsif file_path.end_with?(".rb", ".rake", "Gemfile", "Rakefile", ".axlsx", ".gemspec", ".ru", ".podspec", ".jbuilder", ".rabl", ".thor", "config.ru", "Berksfile", "Capfile", "Guardfile", "Podfile", "Thorfile", "Vagrantfile") || File.open(file_path, &:gets)&.include?(SHEBANG)
49
55
  cmd << [true, "bundle exec rubocop -c #{gem_root}/linters/rubocop.yml #{file_path} #{ImmosquareCleaner.configuration.rubocop_options || "--autocorrect-all"}"]
50
56
  elsif file_path =~ %r{locales/.*\.yml$}
@@ -72,7 +78,7 @@ module ImmosquareCleaner
72
78
  end if !cmd.empty?
73
79
  rescue StandardError => e
74
80
  puts(e.message)
75
- false
81
+ puts(e.backtrace)
76
82
  end
77
83
  end
78
84
 
@@ -105,21 +111,23 @@ module ImmosquareCleaner
105
111
  ## The total number of lines in the normalized file.
106
112
  ##===========================================================================##
107
113
  def normalize_last_line(file_path)
114
+ end_of_line = $INPUT_RECORD_SEPARATOR
108
115
  ##============================================================##
109
116
  ## Read all lines from the file
110
117
  ## https://gist.github.com/guilhermesimoes/d69e547884e556c3dc95
111
118
  ##============================================================##
112
119
  content = File.read(file_path)
113
120
 
121
+
114
122
  ##===========================================================================##
115
123
  ## Remove all trailing empty lines at the end of the file
116
- content.gsub!(/#{Regexp.escape($INPUT_RECORD_SEPARATOR)}+\z/, "")
117
124
  ##===========================================================================##
125
+ content.gsub!(/#{Regexp.escape(end_of_line)}+\z/, "")
118
126
 
119
127
  ##===========================================================================##
120
- ## Append a newline at the end to maintain the file structure
121
- ###===========================================================================##
122
- content += $INPUT_RECORD_SEPARATOR
128
+ ## Append an EOL at the end to maintain the file structure
129
+ ##===========================================================================##
130
+ content << end_of_line
123
131
 
124
132
  ##===========================================================================##
125
133
  ## Write the modified lines back to the file
@@ -4,7 +4,14 @@ namespace :immosquare_cleaner do
4
4
  ##============================================================##
5
5
  desc "Clean translation files in rails app"
6
6
  task :clean => :environment do
7
- Dir.glob("#{Rails.root}/*").each do |file|
7
+ file_paths = Dir.glob("#{Rails.root}/**/*").reject do |file_path|
8
+ test1 = file_path.gsub("#{Rails.root}/", "")
9
+ File.directory?(file_path) ||
10
+ test1.start_with?("node_modules", "tmp", "public", "log", "app/assets/builds", "app/assets/fonts", "app/assets/images") ||
11
+ file_path.end_with?(".lock", ".lockb")
12
+ end
13
+ file_paths.each do |file|
14
+ puts file
8
15
  ImmosquareCleaner.clean(file)
9
16
  end
10
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: immosquare-cleaner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - IMMO SQUARE
@@ -77,10 +77,10 @@ extensions: []
77
77
  extra_rdoc_files: []
78
78
  files:
79
79
  - bin/immosquare-cleaner
80
+ - lib/immosquare-cleaner.rb
80
81
  - lib/immosquare-cleaner/configuration.rb
81
82
  - lib/immosquare-cleaner/railtie.rb
82
83
  - lib/immosquare-cleaner/version.rb
83
- - lib/immosquare_cleaner.rb
84
84
  - lib/tasks/immosquare-cleaner.rake
85
85
  - linters/erb-lint.yml
86
86
  - linters/prettier.yml