dry-file 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -31
- data/lib/dry/file/version.rb +1 -1
- data/lib/dry-file.rb +15 -8
- 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: 74088c4434597c52c8be30c0d5376aa1100b9bba9ec23183bca43862a0a6c408
|
4
|
+
data.tar.gz: f30ffba2614d78f565164644b8cb8e111e678adadfceced1d42c74f271112aa6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b83e595eef237ac929dc1afc4be2049a9c98c97f16373e36cec599c2929429a8953a9f9998dbe106cb7cdf3af3c3399d0e8327258936c3f603764d00c732a4cc
|
7
|
+
data.tar.gz: 36a6cfbebe9ef56c25e70574ceb3ef04865d5cc6c8f5003e5e79c78a6db245ec190b52cfaa36e88f4d7d4532ec79e7eb554cba0d4b135153d2d651f21ce05282
|
data/README.md
CHANGED
@@ -1,35 +1,9 @@
|
|
1
|
-
|
1
|
+
Purpose:
|
2
2
|
|
3
|
-
|
3
|
+
Remove duplicate URLs from a file, where the URLs only differ in the value of the params
|
4
4
|
|
5
|
-
|
5
|
+
Usage:
|
6
6
|
|
7
|
-
|
7
|
+
dry 40 $domain/scan/gf/xss.txt # creates dry-xss.txt
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'dry-file'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle install
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install dry-file
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dry-file.
|
9
|
+
This gem has been deprecated since gh/tomnomnom/qsreplace does the same job more efficiently.
|
data/lib/dry/file/version.rb
CHANGED
data/lib/dry-file.rb
CHANGED
@@ -9,12 +9,19 @@ module Dry
|
|
9
9
|
# === Usage
|
10
10
|
# dry 40 test/data/sqli.txt
|
11
11
|
# === Params
|
12
|
-
# max_chars: minimum number of different characters to keep a line
|
13
|
-
# file: input file
|
14
|
-
|
12
|
+
# max_chars: minimum number of different characters to keep a line.
|
13
|
+
# file: input file.
|
14
|
+
# options: '-i' replace file in-place.
|
15
|
+
def run(max_chars, file, *options)
|
15
16
|
max_chars = max_chars.to_i
|
16
17
|
previous_line = ''
|
17
|
-
file_out =
|
18
|
+
file_out = if options.include?('-i')
|
19
|
+
File.basename(file)
|
20
|
+
else
|
21
|
+
"dry-#{File.basename(file)}"
|
22
|
+
end
|
23
|
+
|
24
|
+
temp_file = Tempfile.new(File.basename(file))
|
18
25
|
|
19
26
|
File.open(file).each_line do |l|
|
20
27
|
# We compare the line size as well as the line similarity. We could have
|
@@ -23,16 +30,16 @@ module Dry
|
|
23
30
|
# similarity comparison, but i think using +max_chars+ for both
|
24
31
|
# comparisons is also OK, the results seem pretty good.
|
25
32
|
if (previous_line.size - l.size).abs > max_chars || diff_size(previous_line, l) > max_chars
|
26
|
-
|
33
|
+
temp_file.write l
|
27
34
|
previous_line = l
|
28
35
|
end
|
29
36
|
end
|
30
|
-
|
31
|
-
FileUtils.mv(
|
37
|
+
temp_file.close
|
38
|
+
FileUtils.mv(temp_file.path, File.join(File.dirname(file), file_out))
|
32
39
|
end
|
33
40
|
|
34
41
|
# Returns the number of differing characters between two lines.
|
35
42
|
def diff_size(line_1, line_2)
|
36
|
-
|
43
|
+
line_1.chars.each_with_index.filter_map{|c,i| line_1[i] != line_2[i]}.size
|
37
44
|
end
|
38
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-file
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Romero
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Removes almost identical lines based on a similarity parameter.
|
14
14
|
email:
|