immosquare-cleaner 0.1.98 → 0.1.99
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/bin/immosquare-cleaner +29 -2
- data/lib/immosquare-cleaner/version.rb +1 -1
- data/linters/rubocop-3.4.1.yml +4 -4
- data/linters/rubocop-4.0.0.yml +4 -4
- data/linters/rubocop-4.0.1.yml +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ae82690134b5edc536e8d6e8a0b77540c20508fe8a6f920101da4c8e13e87c76
|
|
4
|
+
data.tar.gz: d00dd9e2f86c5e48a6a3fe671c1c100b062262944bd583b2f761ffd6bcda1ae2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 81437203bdc18095da71e6bd498c5a9e2aeba2e4b4ab5cc2df0599beba257246bf6872e02e822fe47505569d74cac469bc48e7d55f07550d17d8f9c04ce395fb
|
|
7
|
+
data.tar.gz: f9d969bd127a229097d177cc7e602d5958b7166bda3811e2e1e53b8ed11a08d60d09d164149f567a779bd6eaa9f3678429813e819fb4c76ca6c0b4f0ea3411d5
|
data/bin/immosquare-cleaner
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "immosquare-cleaner"
|
|
4
4
|
require "optparse"
|
|
5
|
+
require "digest"
|
|
5
6
|
|
|
6
7
|
##============================================================##
|
|
7
8
|
## Prevent "invalid byte sequence in US-ASCII" error on some files (eg: yaml)
|
|
@@ -27,7 +28,9 @@ options = {}
|
|
|
27
28
|
##============================================================##
|
|
28
29
|
OptionParser.new do |parser|
|
|
29
30
|
parser.banner = "Usage: immosquare-cleaner [options] file"
|
|
30
|
-
|
|
31
|
+
parser.on("-p", "--prevent-concurrent-write", "Prevent concurrent write") do
|
|
32
|
+
options[:prevent_concurrent_write] = true
|
|
33
|
+
end
|
|
31
34
|
parser.on("-h", "--help", "Prints this help") do
|
|
32
35
|
puts(parser)
|
|
33
36
|
exit
|
|
@@ -70,4 +73,28 @@ end
|
|
|
70
73
|
## We can now call the clean method, passing the file absolute path and options
|
|
71
74
|
##============================================================##
|
|
72
75
|
file_path = File.expand_path(file_path)
|
|
73
|
-
|
|
76
|
+
if options[:prevent_concurrent_write]
|
|
77
|
+
##============================================================##
|
|
78
|
+
## concurrent write detection
|
|
79
|
+
## wait 2s for the ide to do a pre-processing, then 3 cases :
|
|
80
|
+
## - if the original file changed during the clean, give up
|
|
81
|
+
## - if the cleaned file has the same checksum, do nothing
|
|
82
|
+
## - else, erase the original file with the cleaned one
|
|
83
|
+
##============================================================##
|
|
84
|
+
sleep(2)
|
|
85
|
+
before = Digest::MD5.file(file_path)
|
|
86
|
+
temp_path = "/tmp/#{file_path}"
|
|
87
|
+
FileUtils.mkdir_p(File.dirname(temp_path))
|
|
88
|
+
FileUtils.copy(file_path, temp_path)
|
|
89
|
+
ImmosquareCleaner.clean(temp_path, **options)
|
|
90
|
+
if Digest::MD5.file(file_path) != before
|
|
91
|
+
puts("Original file has changed, giving up cleaning.")
|
|
92
|
+
elsif Digest::MD5.file(temp_path) == before
|
|
93
|
+
puts("Cleaner had nothing to do, moving on.")
|
|
94
|
+
else
|
|
95
|
+
puts("Overwriting original file with cleaned version.")
|
|
96
|
+
FileUtils.move(temp_path, file_path)
|
|
97
|
+
end
|
|
98
|
+
else
|
|
99
|
+
ImmosquareCleaner.clean(file_path, **options)
|
|
100
|
+
end
|
data/linters/rubocop-3.4.1.yml
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
require:
|
|
3
|
-
- rubocop/cop/style/method_call_with_args_parentheses_override
|
|
4
|
-
- rubocop/cop/custom_cops/style/comment_normalization
|
|
5
|
-
- rubocop/cop/custom_cops/style/font_awesome_normalization
|
|
6
|
-
- rubocop/cop/custom_cops/style/align_assignments
|
|
3
|
+
- /Users/olivier/Sites/gems/immosquare-cleaner/linters/rubocop/cop/style/method_call_with_args_parentheses_override
|
|
4
|
+
- /Users/olivier/Sites/gems/immosquare-cleaner/linters/rubocop/cop/custom_cops/style/comment_normalization
|
|
5
|
+
- /Users/olivier/Sites/gems/immosquare-cleaner/linters/rubocop/cop/custom_cops/style/font_awesome_normalization
|
|
6
|
+
- /Users/olivier/Sites/gems/immosquare-cleaner/linters/rubocop/cop/custom_cops/style/align_assignments
|
|
7
7
|
AllCops:
|
|
8
8
|
NewCops: enable
|
|
9
9
|
EnabledByDefault: false
|
data/linters/rubocop-4.0.0.yml
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
require:
|
|
3
|
-
- rubocop/cop/style/method_call_with_args_parentheses_override
|
|
4
|
-
- rubocop/cop/custom_cops/style/comment_normalization
|
|
5
|
-
- rubocop/cop/custom_cops/style/font_awesome_normalization
|
|
6
|
-
- rubocop/cop/custom_cops/style/align_assignments
|
|
3
|
+
- /Users/olivier/Sites/gems/immosquare-cleaner/linters/rubocop/cop/style/method_call_with_args_parentheses_override
|
|
4
|
+
- /Users/olivier/Sites/gems/immosquare-cleaner/linters/rubocop/cop/custom_cops/style/comment_normalization
|
|
5
|
+
- /Users/olivier/Sites/gems/immosquare-cleaner/linters/rubocop/cop/custom_cops/style/font_awesome_normalization
|
|
6
|
+
- /Users/olivier/Sites/gems/immosquare-cleaner/linters/rubocop/cop/custom_cops/style/align_assignments
|
|
7
7
|
AllCops:
|
|
8
8
|
NewCops: enable
|
|
9
9
|
EnabledByDefault: false
|
data/linters/rubocop-4.0.1.yml
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
require:
|
|
3
|
-
- rubocop/cop/style/method_call_with_args_parentheses_override
|
|
4
|
-
- rubocop/cop/custom_cops/style/comment_normalization
|
|
5
|
-
- rubocop/cop/custom_cops/style/font_awesome_normalization
|
|
6
|
-
- rubocop/cop/custom_cops/style/align_assignments
|
|
3
|
+
- /Users/olivier/Sites/gems/immosquare-cleaner/linters/rubocop/cop/style/method_call_with_args_parentheses_override
|
|
4
|
+
- /Users/olivier/Sites/gems/immosquare-cleaner/linters/rubocop/cop/custom_cops/style/comment_normalization
|
|
5
|
+
- /Users/olivier/Sites/gems/immosquare-cleaner/linters/rubocop/cop/custom_cops/style/font_awesome_normalization
|
|
6
|
+
- /Users/olivier/Sites/gems/immosquare-cleaner/linters/rubocop/cop/custom_cops/style/align_assignments
|
|
7
7
|
AllCops:
|
|
8
8
|
NewCops: enable
|
|
9
9
|
EnabledByDefault: false
|