ix-cli 0.0.24 → 0.0.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ix-hls +27 -2
- data/bin/ix-json-to-csv +1 -1
- data/bin/ix-linkify +51 -9
- data/bin/ix-pad-char +63 -0
- data/bin/ix-string-to-json +13 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b90eae0cfdfe4e66f3d4f00aa6b43cfc79604b298f84b9c8925c28465dce2da
|
4
|
+
data.tar.gz: 10ce8d8b34502871e1f6996e186969fbfff1e90f8ecd9d65e38987e5ce772921
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf573b716a598513a1c7f8e79ef287997094ec29aeb88cd316f035e35cd67492a0953b617606b414ffde36af62ddec4de6c6b2b027ea91881527fa164b4ea8e0
|
7
|
+
data.tar.gz: 15152f3b4cd5616439218df39bbd4a3a89533b028b70ddf51b6ca415dd7d331dddcc92c2f28293845d01b82375a467d3180d94364eb3aa2b724fea0de40d581b
|
data/bin/ix-hls
CHANGED
@@ -10,6 +10,29 @@
|
|
10
10
|
|
11
11
|
require 'isna'
|
12
12
|
|
13
|
+
require 'optparse'
|
14
|
+
|
15
|
+
options = {}
|
16
|
+
options[:delimiter] = ':'
|
17
|
+
|
18
|
+
OptionParser.new do |opts|
|
19
|
+
|
20
|
+
opts.banner = "Usage: #{$0} [OPTIONS]"
|
21
|
+
|
22
|
+
opts.on('-d', '--delimiter [STRING]', 'Delimiter.') do |value|
|
23
|
+
options[:delimiter] = value
|
24
|
+
end
|
25
|
+
|
26
|
+
end.parse!
|
27
|
+
|
28
|
+
required_options = [:delimiter]
|
29
|
+
required_options.each do |option|
|
30
|
+
unless options[option]
|
31
|
+
$stderr.puts "Can not run #{option.to_s} was not given."
|
32
|
+
exit 1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
13
36
|
abort 'No pattern given' if ARGV[0].nil?
|
14
37
|
|
15
38
|
trap('SIGINT') { }
|
@@ -17,9 +40,11 @@ trap('SIGINT') { }
|
|
17
40
|
$stdout.sync = true
|
18
41
|
|
19
42
|
STDIN.each_line do |line|
|
43
|
+
line.chomp!
|
20
44
|
ARGV.each do |arg|
|
21
|
-
chunks = arg.split(
|
22
|
-
|
45
|
+
chunks = arg.split(options[:delimiter])
|
46
|
+
line.gsub!(/(#{chunks[0]})/i) { |x| $1.to_ansi.send(chunks[1].to_sym).to_s }
|
23
47
|
end
|
48
|
+
puts line
|
24
49
|
end
|
25
50
|
|
data/bin/ix-json-to-csv
CHANGED
data/bin/ix-linkify
CHANGED
@@ -3,6 +3,28 @@
|
|
3
3
|
require 'net/http'
|
4
4
|
require 'nokogiri'
|
5
5
|
require 'open-uri'
|
6
|
+
require 'optparse'
|
7
|
+
|
8
|
+
options = {}
|
9
|
+
options[:output] = 'text'
|
10
|
+
|
11
|
+
OptionParser.new do |opts|
|
12
|
+
|
13
|
+
opts.banner = "Usage: #{$0} [OPTIONS]"
|
14
|
+
|
15
|
+
opts.on('-o', '--output [STRING]', 'Output.') do |value|
|
16
|
+
options[:output] = value
|
17
|
+
end
|
18
|
+
|
19
|
+
end.parse!
|
20
|
+
|
21
|
+
required_options = [:output]
|
22
|
+
required_options.each do |option|
|
23
|
+
unless options[option]
|
24
|
+
$stderr.puts "Can not run #{option.to_s} was not given."
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
end
|
6
28
|
|
7
29
|
class Mock
|
8
30
|
attr_accessor :title
|
@@ -10,13 +32,19 @@ end
|
|
10
32
|
|
11
33
|
counter = 0
|
12
34
|
|
35
|
+
if options[:output] == 'html'
|
36
|
+
puts "<ol>"
|
37
|
+
end
|
38
|
+
|
13
39
|
STDIN.each_line do |line|
|
14
40
|
next if line.chomp == ''
|
15
41
|
counter += 1
|
16
42
|
url = line.chomp
|
17
43
|
begin
|
18
|
-
|
44
|
+
data = Net::HTTP.get(URI.parse(url))
|
45
|
+
doc = Nokogiri::HTML(data)
|
19
46
|
rescue => e
|
47
|
+
$stderr.puts e.message
|
20
48
|
doc = Mock.new
|
21
49
|
doc.title = url
|
22
50
|
end
|
@@ -24,12 +52,26 @@ STDIN.each_line do |line|
|
|
24
52
|
doc = Mock.new
|
25
53
|
doc.title = url
|
26
54
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
55
|
+
if options[:output] == 'text'
|
56
|
+
template = "%s - %s\n%s\n\n"
|
57
|
+
title = doc.title
|
58
|
+
title.chomp!
|
59
|
+
title.gsub!(/\n/, '')
|
60
|
+
title.gsub!(/^\s+/, '')
|
61
|
+
title.gsub!(/\s+$/, '')
|
62
|
+
bindings = [counter, title, url]
|
63
|
+
puts template % bindings
|
64
|
+
elsif options[:output] == 'html'
|
65
|
+
title = doc.title
|
66
|
+
title.chomp!
|
67
|
+
title.gsub!(/\n/, '')
|
68
|
+
title.gsub!(/^\s+/, '')
|
69
|
+
title.gsub!(/\s+$/, '')
|
70
|
+
# bindings = [counter, title, url, url]
|
71
|
+
puts "<li><a href='#{url}'>#{title}</a></li>"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
if options[:output] == 'html'
|
76
|
+
puts "</ol>"
|
35
77
|
end
|
data/bin/ix-pad-char
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
options = {}
|
6
|
+
options[:pad] = 4
|
7
|
+
options[:fill] = '─'
|
8
|
+
options[:char] = '['
|
9
|
+
|
10
|
+
OptionParser.new do |opts|
|
11
|
+
|
12
|
+
opts.banner = "Usage: #{$0} [OPTIONS]"
|
13
|
+
|
14
|
+
opts.on('-c', '--char [STRING]', 'Char to use as padding target.') do |value|
|
15
|
+
options[:char] = value
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on('-f', '--fill [STRING]', 'Char to use as filling.') do |value|
|
19
|
+
options[:fill] = value
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.on('-p', '--pad [NUMBER]', 'Padd to add to the fill.') do |value|
|
23
|
+
options[:pad] = value.to_i
|
24
|
+
end
|
25
|
+
|
26
|
+
end.parse!
|
27
|
+
|
28
|
+
required_options = [:char, :pad, :fill]
|
29
|
+
required_options.each do |option|
|
30
|
+
unless options[option]
|
31
|
+
$stderr.puts "Can not run #{option.to_s} was not given."
|
32
|
+
exit 1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
items = []
|
37
|
+
|
38
|
+
STDIN.each_line do |line|
|
39
|
+
items << line.chomp
|
40
|
+
end
|
41
|
+
|
42
|
+
max_index_of_char = items.map { |item| item.index(options[:char]) }.max
|
43
|
+
char = options[:char]
|
44
|
+
|
45
|
+
if char == ' '
|
46
|
+
char = '\s'
|
47
|
+
end
|
48
|
+
|
49
|
+
if char == '['
|
50
|
+
char = '\['
|
51
|
+
end
|
52
|
+
|
53
|
+
REGEX = Regexp.new("^([^#{char}]+)(#{char})(.*$)")
|
54
|
+
|
55
|
+
# puts "Max index of char: #{max_index_of_char}"
|
56
|
+
|
57
|
+
items.each do |item|
|
58
|
+
next unless REGEX.match(item)
|
59
|
+
item.gsub(REGEX) do |match|
|
60
|
+
puts "#{($1) + ($2).rjust((max_index_of_char) - $1.size + options[:pad], options[:fill])}#{$3}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ix-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuyoshi Tlacaelel
|
@@ -207,6 +207,7 @@ executables:
|
|
207
207
|
- ix-occurrence
|
208
208
|
- ix-open
|
209
209
|
- ix-pad
|
210
|
+
- ix-pad-char
|
210
211
|
- ix-parse
|
211
212
|
- ix-pass
|
212
213
|
- ix-path
|
@@ -278,6 +279,7 @@ executables:
|
|
278
279
|
- ix-stream
|
279
280
|
- ix-string-similarity
|
280
281
|
- ix-string-similarity2
|
282
|
+
- ix-string-to-json
|
281
283
|
- ix-strip
|
282
284
|
- ix-substract
|
283
285
|
- ix-success
|
@@ -513,6 +515,7 @@ files:
|
|
513
515
|
- bin/ix-occurrence
|
514
516
|
- bin/ix-open
|
515
517
|
- bin/ix-pad
|
518
|
+
- bin/ix-pad-char
|
516
519
|
- bin/ix-parse
|
517
520
|
- bin/ix-pass
|
518
521
|
- bin/ix-path
|
@@ -584,6 +587,7 @@ files:
|
|
584
587
|
- bin/ix-stream
|
585
588
|
- bin/ix-string-similarity
|
586
589
|
- bin/ix-string-similarity2
|
590
|
+
- bin/ix-string-to-json
|
587
591
|
- bin/ix-strip
|
588
592
|
- bin/ix-substract
|
589
593
|
- bin/ix-success
|