searchlink 2.3.59 → 2.3.60

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afaa2c476c0dea9ca4af8d6049a6235c3aabf265fc512f61ec091343f0913cfa
4
- data.tar.gz: 94d56d4f5af396e1fc71e564c35d25bbaee4540a039e73030f3623e32a03d9cf
3
+ metadata.gz: 90196cb473d5230cce634897bd0b7e59a5d7d2a6966480cef6c4cced7503f73c
4
+ data.tar.gz: a719aa259b7d20a45e6453d6f4edd2784c0d6f6f386cf9709ca191e3700cc8ec
5
5
  SHA512:
6
- metadata.gz: 70f776838f8735da2c152ead9d4178efa82d6c072ea2207bd0608bc116d84f30daa7170675412ec0e65611f5278bbd6eb8bec25324603a98fdaaae2941ab6894
7
- data.tar.gz: f6d8d843f6e141caf38b1e1ac45fa7d244d19e01584d04f9fdee9f2b8dc9fe9ebf44a6a88bdbcc6403b9c5b8f09d6c526e8eb89780114e2f7a33de0515a981a5
6
+ metadata.gz: 2463f6f2745687aee721ed1055049b3ff459b6e7f763460c549ed2fc4ea5a2fc7eaad1e1ffe251a1e232a7ed599cc6f8835da316d0eba7a9b74f561511a51f89
7
+ data.tar.gz: d5b691776856fb06312ec6edbfcacdb5cd60de9c336c9cc691262de0e5a72f2f79c82f1f44cbc1942e3eca016a046b57f34e3b3b93414166943589576803cef2
data/bin/searchlink CHANGED
@@ -31,13 +31,13 @@ if !ARGV.empty?
31
31
  puts
32
32
  sl.help_cli
33
33
  $stdout.puts 'See https://github.com/ttscoff/searchlink/wiki for help'
34
- Process.exit
34
+ Process.exit 0
35
35
  when /^(--?)?v(er(s(ion)?)?)?$/
36
36
  print SL.version_check
37
- Process.exit
37
+ Process.exit 0
38
38
  when /^--?(stdout)$/
39
39
  overwrite = false
40
- when /^--?no[\-_]backup$/
40
+ when /^--?no[-_]backup$/
41
41
  backup = false
42
42
  else
43
43
  files.push(arg)
@@ -47,6 +47,7 @@ if !ARGV.empty?
47
47
  files.each do |file|
48
48
  if File.exist?(file) && `file -b "#{file}"|grep -c text`.to_i.positive?
49
49
  input = RUBY_VERSION.to_f > 1.9 ? IO.read(file).force_encoding('utf-8') : IO.read(file)
50
+ input.scrub!
50
51
 
51
52
  backup_file = "#{file}.bak"
52
53
  backup_file = "#{file}.bak 1" if File.exist?(backup_file)
@@ -72,7 +73,7 @@ if !ARGV.empty?
72
73
  end
73
74
  else
74
75
  input = RUBY_VERSION.to_f > 1.9 ? $stdin.read.force_encoding('utf-8').encode : $stdin.read
75
-
76
+ input.scrub!
76
77
  sl.parse(input)
77
78
  output = SL.output&.join('')
78
79
 
@@ -1,7 +1,29 @@
1
1
  # Array helpers
2
2
  class ::Array
3
- # Finds the longest element in a given array.
3
+ # Finds the longest element in an array of strings
4
+ #
5
+ # @return [String] first element among longest elements
4
6
  def longest_element
5
- group_by(&:size).max.last[0]
7
+ longest_elements[0]
8
+ end
9
+ # Finds the longest elements and returns an Array
10
+ #
11
+ # @return [Array] array of longest elements
12
+ def longest_elements
13
+ group_by(&:size).max.last
14
+ end
15
+
16
+ # Finds the shortest element in an array of strings
17
+ #
18
+ # @return [String] first element among shortest elements
19
+ def shortest_element
20
+ shortest_elements[0]
21
+ end
22
+
23
+ # Finds the shortest elements in an array of strings
24
+ #
25
+ # @return [Array] array of shortest elements
26
+ def shortest_elements
27
+ group_by(&:size).min.last
6
28
  end
7
29
  end
@@ -1,5 +1,15 @@
1
1
  # String helpers
2
2
  class ::String
3
+ # Scrub invalid characters from string
4
+ def scrub
5
+ encode('utf-16', invalid: :replace).encode('utf-8')
6
+ end
7
+
8
+ # @see #scrub
9
+ def scrub!
10
+ replace scrub
11
+ end
12
+
3
13
  # URL Encode string
4
14
  #
5
15
  # @return [String] url encoded string
@@ -1,5 +1,5 @@
1
1
  module SL
2
- VERSION = '2.3.59'
2
+ VERSION = '2.3.60'
3
3
  end
4
4
 
5
5
  module SL
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchlink
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.59
4
+ version: 2.3.60
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra