quick_and_ruby 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/.reek.yml +7 -0
- data/.rubocop.yml +34 -0
- data/README.md +45 -22
- data/Rakefile +10 -1
- data/bin/cat.rb +4 -0
- data/bin/datetime +6 -0
- data/bin/distinguished_name +34 -0
- data/bin/jb +17 -0
- data/bin/json2yaml +20 -0
- data/bin/yaml2json +20 -0
- data/bin/yb +17 -0
- data/lib/quick_and_ruby/data/browser.rb +68 -0
- data/lib/quick_and_ruby/data/context.rb +81 -0
- data/lib/quick_and_ruby/data.rb +10 -0
- data/lib/quick_and_ruby/date/date_time_args.rb +79 -0
- data/lib/quick_and_ruby/date/date_time_cli.rb +44 -0
- data/lib/quick_and_ruby/date.rb +11 -0
- data/lib/quick_and_ruby/distinguished_name.rb +59 -0
- data/lib/quick_and_ruby/proxy/arg_parser.rb +2 -1
- data/lib/quick_and_ruby/version.rb +1 -1
- data/man/distinguished_name.1.ronn +26 -0
- data/quick_and_ruby.gemspec +21 -10
- metadata +148 -24
- data/Gemfile.lock +0 -53
- /data/{exe → bin}/proxy +0 -0
- /data/{bin → scripts}/console +0 -0
- /data/{bin → scripts}/setup +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c0817c5dc3e4a34622553992b9ff3158e437d9df32915d2cf4307fceb841229
|
4
|
+
data.tar.gz: 7c7bc9b6cda4974e464f8232616da0f58064b53ce494436ce3242991ec03ae54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c4fe131c66dcbc054838b5b7f84f983656d188158f7b2552a0d6791f28851d91e400ef7fab68425cec1a64030f35ca025c95df555c12860ab6e1a449bb3ddb9
|
7
|
+
data.tar.gz: 12c49deb386a0241060d6e01e5f5d4df0317c1d0c3eae65f9f56065c41d9939cbd1273c962de7ab7c424cb82053f719c47f16ccc333463d366d8237a1b1c9374
|
data/.gitignore
CHANGED
data/.reek.yml
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rake
|
3
|
+
- rubocop-rspec
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
NewCops: enable
|
7
|
+
TargetRubyVersion: 2.7
|
8
|
+
|
9
|
+
Layout/LineLength:
|
10
|
+
Max: 100
|
11
|
+
|
12
|
+
Metrics/BlockLength:
|
13
|
+
Exclude:
|
14
|
+
- quick_and_ruby.gemspec
|
15
|
+
- spec/**/*.rb
|
16
|
+
|
17
|
+
Metrics/MethodLength:
|
18
|
+
Max: 25
|
19
|
+
|
20
|
+
# Style/StringLiterals:
|
21
|
+
# Enabled: true
|
22
|
+
# EnforcedStyle: double_quotes
|
23
|
+
|
24
|
+
Style/Documentation:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Style/StringLiteralsInInterpolation:
|
28
|
+
Enabled: true
|
29
|
+
EnforcedStyle: double_quotes
|
30
|
+
|
31
|
+
# RSpec
|
32
|
+
|
33
|
+
RSpec/MultipleExpectations:
|
34
|
+
Max: 2
|
data/README.md
CHANGED
@@ -1,43 +1,66 @@
|
|
1
1
|
# QuickAndRuby
|
2
2
|
|
3
|
-
|
3
|
+
Gem to group utilities in ruby.
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
5
|
+
## install
|
10
6
|
|
11
7
|
```ruby
|
12
|
-
gem
|
8
|
+
gem install quick_and_ruby
|
13
9
|
```
|
14
10
|
|
15
|
-
|
11
|
+
## bins
|
12
|
+
|
13
|
+
### proxy
|
14
|
+
|
15
|
+
### datetime
|
16
16
|
|
17
|
-
|
17
|
+
Used to manipulate date:
|
18
|
+
- allow to compute all increment between 2 dates.
|
19
|
+
- allow to compute a date starting form another/now.
|
18
20
|
|
19
|
-
|
21
|
+
Usage:
|
22
|
+
``` shell
|
23
|
+
datetime -o <offset> -i <incr> -f "<format>" <from>|now <to>|now
|
20
24
|
|
21
|
-
|
25
|
+
datetime -o <offset> -i <incr> -f "<format>" <from>|now
|
26
|
+
```
|
27
|
+
|
28
|
+
### yaml2json
|
22
29
|
|
23
|
-
|
30
|
+
Convert yaml formated string, file or stdin to json format.
|
24
31
|
|
25
|
-
|
32
|
+
usage:
|
26
33
|
|
27
|
-
|
34
|
+
``` shell
|
35
|
+
yaml2json file.json
|
36
|
+
# ... generates file.json
|
28
37
|
|
29
|
-
|
38
|
+
yaml2json 'msg: test'
|
39
|
+
# {
|
40
|
+
# "msg": "test"
|
41
|
+
# }
|
30
42
|
|
31
|
-
|
43
|
+
echo 'msg: test' | yaml2json
|
44
|
+
# {
|
45
|
+
# "msg": "test"
|
46
|
+
# }
|
47
|
+
```
|
32
48
|
|
33
|
-
|
49
|
+
### json2yaml
|
34
50
|
|
35
|
-
|
51
|
+
Convert json formated string, file or stdin to yaml format.
|
36
52
|
|
37
|
-
|
53
|
+
usage:
|
38
54
|
|
39
|
-
|
55
|
+
``` shell
|
56
|
+
json2yaml file.json
|
57
|
+
# ... generates file.yaml
|
40
58
|
|
41
|
-
|
59
|
+
json2yaml '{"msg": "test"}'
|
60
|
+
# ---
|
61
|
+
# msg: test
|
42
62
|
|
43
|
-
|
63
|
+
echo '{"msg": "test"}' | json2yaml
|
64
|
+
# ---
|
65
|
+
# msg: test
|
66
|
+
```
|
data/Rakefile
CHANGED
@@ -1,6 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/gem_tasks'
|
4
|
+
|
2
5
|
require 'rspec/core/rake_task'
|
3
6
|
|
4
7
|
RSpec::Core::RakeTask.new(:spec)
|
5
8
|
|
6
|
-
|
9
|
+
require 'rubocop/rake_task'
|
10
|
+
|
11
|
+
RuboCop::RakeTask.new
|
12
|
+
|
13
|
+
require 'bump/tasks'
|
14
|
+
|
15
|
+
task default: %i[spec rubocop]
|
data/bin/cat.rb
ADDED
data/bin/datetime
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'optparse'
|
5
|
+
require 'quick_and_ruby/distinguished_name'
|
6
|
+
|
7
|
+
argv = ARGV.clone
|
8
|
+
|
9
|
+
options = {}
|
10
|
+
option_parser = OptionParser.new do |opts|
|
11
|
+
executable_name = File.basename($PROGRAM_NAME)
|
12
|
+
opts.banner = "Format Distinguished Name.\n" \
|
13
|
+
"\n" \
|
14
|
+
"Usage: #{executable_name} [options] distinguished_name"
|
15
|
+
|
16
|
+
opts.on('-r', '--reverse', 'Reverse Distinguished Name') do |reverse|
|
17
|
+
options[:reverse] = reverse
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
option_parser.parse!(argv)
|
22
|
+
if argv.empty?
|
23
|
+
STDERR.puts 'error: you must supply a distinguished_name'
|
24
|
+
STDERR.puts
|
25
|
+
STDERR.puts option_parser.help
|
26
|
+
exit 2
|
27
|
+
else
|
28
|
+
distinguished_name = argv.clone.join(" ")
|
29
|
+
end
|
30
|
+
|
31
|
+
dn = QuickAndRuby::DistinguishedName.from_string(distinguished_name)
|
32
|
+
dn = dn.reverse if options[:reverse]
|
33
|
+
|
34
|
+
puts dn.to_s
|
data/bin/jb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'optparse'
|
5
|
+
require 'quick_and_ruby/data'
|
6
|
+
|
7
|
+
option_parser = OptionParser.new do |opts|
|
8
|
+
executable_name = File.basename($PROGRAM_NAME)
|
9
|
+
opts.banner = "Interactively browse a JSON file\n" \
|
10
|
+
"\n" \
|
11
|
+
"Usage: #{executable_name} [json_file]"
|
12
|
+
end
|
13
|
+
option_parser.parse!
|
14
|
+
|
15
|
+
json_context = QuickAndRuby::Data::Context.from_json(ARGF.read)
|
16
|
+
browser = QuickAndRuby::Data::Browser.new(json_context)
|
17
|
+
browser.main
|
data/bin/json2yaml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'json'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
def json2yaml(str)
|
8
|
+
YAML.dump(JSON.parse(str))
|
9
|
+
end
|
10
|
+
|
11
|
+
from = ARGV[0]
|
12
|
+
if from && File.exist?(from)
|
13
|
+
to = ARGV[1] || "#{from.chomp(".json")}.yaml"
|
14
|
+
|
15
|
+
File.write(to, json2yaml(File.read(from)))
|
16
|
+
elsif from
|
17
|
+
puts json2yaml(from)
|
18
|
+
elsif !$stdin.tty? && !$stdin.closed?
|
19
|
+
puts json2yaml($stdin.read)
|
20
|
+
end
|
data/bin/yaml2json
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'json'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
def yaml2json(str)
|
8
|
+
JSON.pretty_generate(YAML.safe_load(str))
|
9
|
+
end
|
10
|
+
|
11
|
+
from = ARGV[0]
|
12
|
+
if from && File.exist?(from)
|
13
|
+
to = ARGV[1] || "#{from.chomp(".yaml").chomp(".yml")}.json"
|
14
|
+
|
15
|
+
File.write(to, yaml2json(File.read(from)))
|
16
|
+
elsif from
|
17
|
+
puts yaml2json(from)
|
18
|
+
elsif !$stdin.tty? && !$stdin.closed?
|
19
|
+
puts yaml2json($stdin.read)
|
20
|
+
end
|
data/bin/yb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'optparse'
|
5
|
+
require 'quick_and_ruby/data'
|
6
|
+
|
7
|
+
option_parser = OptionParser.new do |opts|
|
8
|
+
executable_name = File.basename($PROGRAM_NAME)
|
9
|
+
opts.banner = "Interactively browse a Yaml file\n" \
|
10
|
+
"\n" \
|
11
|
+
"Usage: #{executable_name} [yaml_file]"
|
12
|
+
end
|
13
|
+
option_parser.parse!
|
14
|
+
|
15
|
+
yaml_context = QuickAndRuby::Data::Context.from_yaml(ARGF.read)
|
16
|
+
browser = QuickAndRuby::Data::Browser.new(yaml_context)
|
17
|
+
browser.main
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'reline'
|
4
|
+
|
5
|
+
module QuickAndRuby
|
6
|
+
module Data
|
7
|
+
class Browser
|
8
|
+
attr_reader :root_context
|
9
|
+
|
10
|
+
def initialize(root_context)
|
11
|
+
@root_context = root_context
|
12
|
+
end
|
13
|
+
|
14
|
+
def main
|
15
|
+
command = nil
|
16
|
+
current_context = root_context
|
17
|
+
|
18
|
+
Reline.completion_proc = lambda { |input|
|
19
|
+
current_context.completions(input)
|
20
|
+
}
|
21
|
+
|
22
|
+
while command != 'exit'
|
23
|
+
command = Reline.readline("#{current_context.pwd}> ", true)
|
24
|
+
break if command.nil?
|
25
|
+
|
26
|
+
current_context = execute_command(command.strip, current_context)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def execute_command(command, context)
|
33
|
+
case command
|
34
|
+
when /^ls$/
|
35
|
+
puts context
|
36
|
+
when /^cd (.*$)/
|
37
|
+
new_context = context.cd(::Regexp.last_match(1))
|
38
|
+
if new_context.nil?
|
39
|
+
puts "No such key #{::Regexp.last_match(1)}"
|
40
|
+
else
|
41
|
+
context = new_context
|
42
|
+
end
|
43
|
+
when /^cat (.*)$/
|
44
|
+
item = context.cat(::Regexp.last_match(1))
|
45
|
+
if item.nil?
|
46
|
+
puts "No such item #{::Regexp.last_match(1)}"
|
47
|
+
else
|
48
|
+
puts item.inspect
|
49
|
+
end
|
50
|
+
when /^pwd$/
|
51
|
+
puts context.pwd
|
52
|
+
when /^help$/
|
53
|
+
puts 'cat <item> - print the contents of <item> in the current context'
|
54
|
+
puts 'cd <item> - change context to the context of <item>'
|
55
|
+
puts 'cd .. - change up one level'
|
56
|
+
puts 'ls - list available items in the current context'
|
57
|
+
puts 'pwd - print context path'
|
58
|
+
end
|
59
|
+
context
|
60
|
+
end
|
61
|
+
|
62
|
+
def complete_command(input, context)
|
63
|
+
require 'byebug'
|
64
|
+
byebug
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module QuickAndRuby
|
7
|
+
module Data
|
8
|
+
class Context
|
9
|
+
attr_reader :here, :id, :parent
|
10
|
+
|
11
|
+
def initialize(here, id: nil, parent: nil)
|
12
|
+
@here = here
|
13
|
+
@id = id
|
14
|
+
@parent = parent
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
if here.is_a? Array
|
19
|
+
indices = []
|
20
|
+
here.each_index { |i| indices << i }
|
21
|
+
indices.join(' ')
|
22
|
+
elsif here.is_a? Hash
|
23
|
+
here.keys.join(' ')
|
24
|
+
else
|
25
|
+
here.to_s
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def pwd
|
30
|
+
pwd_parts = []
|
31
|
+
pwd_cur = self
|
32
|
+
while pwd_cur
|
33
|
+
pwd_parts.unshift pwd_cur.id if pwd_cur.id
|
34
|
+
pwd_cur = pwd_cur.parent
|
35
|
+
end
|
36
|
+
"/" + pwd_parts.join('/')
|
37
|
+
end
|
38
|
+
|
39
|
+
def cat(path)
|
40
|
+
item_at(path)
|
41
|
+
end
|
42
|
+
|
43
|
+
def cd(path)
|
44
|
+
if path == '..'
|
45
|
+
parent
|
46
|
+
else
|
47
|
+
item = item_at(path)
|
48
|
+
if item.nil?
|
49
|
+
nil
|
50
|
+
else
|
51
|
+
Context.new(item, id: path, parent: self)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def completions(input)
|
57
|
+
to_s.split(/\s+/).grep(/^#{input}/)
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def item_at(path)
|
63
|
+
if path == '..'
|
64
|
+
parent.here
|
65
|
+
elsif here.is_a? Array
|
66
|
+
here[path.to_i]
|
67
|
+
elsif here.is_a? Hash
|
68
|
+
here[path]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.from_yaml(yaml_data)
|
73
|
+
new(YAML.parse(yaml_data))
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.from_json(json_data)
|
77
|
+
new(JSON.parse(json_data))
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
require 'quick_and_ruby/version'
|
7
|
+
|
8
|
+
module QuickAndRuby
|
9
|
+
module Date
|
10
|
+
# argv parser for datetime utility
|
11
|
+
# parsing example:
|
12
|
+
# - datetime -z <zone> -i <incr> -f "<format>" <from>|now <to>|now
|
13
|
+
# - datetime -z <zone> -i <incr> -f "<format>" <from>|now
|
14
|
+
class DateTimeArgs
|
15
|
+
DEFAULT_FORMAT = '%Y-%m-%dT%H:%M:%S.%3NZ'
|
16
|
+
DEFAULT_INCR = '1d'
|
17
|
+
DEFAULT_ZONE = DateTime.now.zone
|
18
|
+
|
19
|
+
attr_reader :date_begin, :date_end, :incr, :format, :zone
|
20
|
+
|
21
|
+
def initialize(date_begin: DateTime.now, date_end: nil,
|
22
|
+
incr: DEFAULT_INCR,
|
23
|
+
format: DEFAULT_FORMAT,
|
24
|
+
zone: DEFAULT_ZONE)
|
25
|
+
@date_begin = date_begin
|
26
|
+
@date_end = date_end
|
27
|
+
@incr = incr
|
28
|
+
@format = format
|
29
|
+
@zone = zone
|
30
|
+
end
|
31
|
+
|
32
|
+
def want_range?
|
33
|
+
date_begin && date_end
|
34
|
+
end
|
35
|
+
|
36
|
+
def want_incr?
|
37
|
+
date_begin && !date_end
|
38
|
+
end
|
39
|
+
|
40
|
+
class << self
|
41
|
+
def load(argv = ARGV)
|
42
|
+
options = new
|
43
|
+
parser(options).parse!(argv.clone)
|
44
|
+
puts options
|
45
|
+
options
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def parser(options)
|
51
|
+
@parser ||= OptionParser.new do |opts|
|
52
|
+
opts.banner = 'Usage: daterange [options] time-begin time-end'
|
53
|
+
opts.on_tail('-h', '--help', 'Show this message') do
|
54
|
+
puts opts
|
55
|
+
exit
|
56
|
+
end
|
57
|
+
|
58
|
+
opts.on_tail('--version', 'Show version') do
|
59
|
+
puts ::QuickAndRuby::VERSION
|
60
|
+
exit
|
61
|
+
end
|
62
|
+
|
63
|
+
opts.on_tail('-f', '--format=FORMAT', 'FORMAT for printing date') do |format|
|
64
|
+
options.format = format
|
65
|
+
end
|
66
|
+
|
67
|
+
opts.on_tail('-i', '--incr=INCR', 'Increment by INCR') do |incr|
|
68
|
+
options.incr = incr
|
69
|
+
end
|
70
|
+
|
71
|
+
opts.on_tail('-z', '--zone=ZONE', 'Timezone ZONE') do |zone|
|
72
|
+
options.zone = zone
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'date_time_args'
|
4
|
+
|
5
|
+
module QuickAndRuby
|
6
|
+
module Date
|
7
|
+
# cli / main class for datetime utility
|
8
|
+
# usage example:
|
9
|
+
# - datetime -z <zone> -i <incr> -f "<format>" <from>|now <to>|now
|
10
|
+
# - datetime -z <zone> -i <incr> -f "<format>" <from>|now
|
11
|
+
class DateTimeCli
|
12
|
+
def initialize(argv = ARGV, args_loader = QuickAndRuby::Date::DateTimeArgs)
|
13
|
+
@argv = argv || []
|
14
|
+
@args_loader = args_loader
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
run_range if args.want_range?
|
19
|
+
run_incr if args.want_incr?
|
20
|
+
end
|
21
|
+
|
22
|
+
def run_range
|
23
|
+
puts :RUN_RANGE
|
24
|
+
time_cursor = args.date_begin
|
25
|
+
while time_cursor <= args.date_end
|
26
|
+
puts time_cursor.strftime(args.format)
|
27
|
+
time_cursor.increment(**args.incr)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def run_incr
|
32
|
+
puts :RUN_INCR
|
33
|
+
end
|
34
|
+
|
35
|
+
def args
|
36
|
+
@args ||= args_loader.load(argv)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
attr_reader :argv, :args_loader
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module QuickAndRuby
|
4
|
+
class DistinguishedName
|
5
|
+
attr_reader :attributes
|
6
|
+
|
7
|
+
def initialize(attributes = [])
|
8
|
+
@attributes = attributes
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
attributes.map(&:to_s).join(',')
|
13
|
+
end
|
14
|
+
|
15
|
+
def size
|
16
|
+
@attributes.size
|
17
|
+
end
|
18
|
+
alias length size
|
19
|
+
|
20
|
+
def reverse
|
21
|
+
self.class.new(attributes.reverse)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.from_string(dn_str)
|
25
|
+
attributes = dn_str.split(/(?<!\\),/).map do |dn_component|
|
26
|
+
unless (match = /^([^=]+)=(.*)$/.match(dn_component.strip))
|
27
|
+
raise "#{dn_component} is not a valid DistinguishedName component"
|
28
|
+
end
|
29
|
+
|
30
|
+
Attribute.new(*match.captures)
|
31
|
+
end
|
32
|
+
|
33
|
+
new(attributes)
|
34
|
+
end
|
35
|
+
|
36
|
+
class Attribute
|
37
|
+
# DC domainComponent
|
38
|
+
# CN commonName
|
39
|
+
# OU organizationalUnitName
|
40
|
+
# O organizationName
|
41
|
+
# STREET streetAddress
|
42
|
+
# L localityName
|
43
|
+
# ST stateOrProvinceName
|
44
|
+
# C countryName
|
45
|
+
# UID userid
|
46
|
+
|
47
|
+
attr_reader :attribute, :value
|
48
|
+
|
49
|
+
def initialize(attribute, value)
|
50
|
+
@attribute = attribute
|
51
|
+
@value = value
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_s
|
55
|
+
"#{attribute}=#{value}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
distinguished_name(1) -- utility to manipulate DN formated string
|
2
|
+
=================================================================
|
3
|
+
|
4
|
+
## SYNOPSIS
|
5
|
+
|
6
|
+
`distinguished_name` <dn>
|
7
|
+
`distinguished_name` `-r`|`--reverse` <dn>
|
8
|
+
|
9
|
+
## DESCRIPTION
|
10
|
+
|
11
|
+
**distinguished_name** is a simple command-line tool for modifying a dn string.
|
12
|
+
|
13
|
+
## FILES
|
14
|
+
|
15
|
+
No files are used for the moment.
|
16
|
+
|
17
|
+
## OPTIONS
|
18
|
+
|
19
|
+
* `-r`, `--reverse`:
|
20
|
+
Do a reverse of each attribute in the distinguished name (dn).
|
21
|
+
|
22
|
+
## EXAMPLES
|
23
|
+
|
24
|
+
Print in reverse order the dn:
|
25
|
+
|
26
|
+
$ distinguished_name --reverse "C=CountryCode, ST=State, CN=CommonName"
|
data/quick_and_ruby.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'quick_and_ruby/version'
|
@@ -10,20 +12,24 @@ Gem::Specification.new do |spec|
|
|
10
12
|
|
11
13
|
spec.summary = 'Quick and Ruby utilities.'
|
12
14
|
spec.description = 'Set of small and standalone utilities in Ruby.'
|
13
|
-
spec.homepage = 'https://github.com/ttych/
|
15
|
+
spec.homepage = 'https://github.com/ttych/quick_and_ruby'
|
14
16
|
spec.license = 'MIT'
|
15
17
|
|
18
|
+
spec.required_ruby_version = '> 2.7'
|
19
|
+
|
16
20
|
if spec.respond_to?(:metadata)
|
17
21
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
22
|
|
19
23
|
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
-
spec.metadata['source_code_uri'] =
|
21
|
-
spec.metadata['changelog_uri'] =
|
24
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
25
|
+
spec.metadata['changelog_uri'] = "#{spec.homepage}/CHANGELOG.md"
|
22
26
|
else
|
23
27
|
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
24
|
-
|
28
|
+
'public gem pushes.'
|
25
29
|
end
|
26
30
|
|
31
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
32
|
+
|
27
33
|
# Specify which files should be added to the gem when it is released.
|
28
34
|
# The `git ls-files -z` loads the files in the RubyGem
|
29
35
|
# that have been added into git.
|
@@ -32,12 +38,17 @@ Gem::Specification.new do |spec|
|
|
32
38
|
f.match(%r{^(test|spec|features)/})
|
33
39
|
end
|
34
40
|
end
|
35
|
-
spec.bindir = '
|
36
|
-
spec.executables = spec.files.grep(%r{
|
41
|
+
spec.bindir = 'bin'
|
42
|
+
spec.executables = spec.files.grep(%r{^#{spec.bindir}/}) { |f| File.basename(f) }
|
37
43
|
spec.require_paths = ['lib']
|
38
44
|
|
39
|
-
spec.add_development_dependency '
|
40
|
-
spec.add_development_dependency '
|
41
|
-
spec.add_development_dependency '
|
42
|
-
spec.add_development_dependency '
|
45
|
+
spec.add_development_dependency 'bump', '~> 0.10.0'
|
46
|
+
spec.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.31'
|
47
|
+
spec.add_development_dependency 'byebug', '~> 11.1', '>= 11.1.3'
|
48
|
+
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
|
49
|
+
spec.add_development_dependency 'reek', '~> 6.0', '>= 6.0.6'
|
50
|
+
spec.add_development_dependency 'rspec', '~> 3.10'
|
51
|
+
spec.add_development_dependency 'rubocop', '~> 1.22', '>= 1.22.3'
|
52
|
+
spec.add_development_dependency 'rubocop-rake', '~> 0.6.0'
|
53
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.6'
|
43
54
|
end
|
metadata
CHANGED
@@ -1,122 +1,246 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quick_and_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ttych
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bump
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.10.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.10.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
33
|
+
version: '2.2'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 2.2.31
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.2'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.2.31
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: byebug
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '11.1'
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 11.1.3
|
20
57
|
type: :development
|
21
58
|
prerelease: false
|
22
59
|
version_requirements: !ruby/object:Gem::Requirement
|
23
60
|
requirements:
|
24
61
|
- - "~>"
|
25
62
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
63
|
+
version: '11.1'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 11.1.3
|
27
67
|
- !ruby/object:Gem::Dependency
|
28
68
|
name: rake
|
29
69
|
requirement: !ruby/object:Gem::Requirement
|
30
70
|
requirements:
|
31
71
|
- - "~>"
|
32
72
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
73
|
+
version: '13.0'
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 13.0.6
|
34
77
|
type: :development
|
35
78
|
prerelease: false
|
36
79
|
version_requirements: !ruby/object:Gem::Requirement
|
37
80
|
requirements:
|
38
81
|
- - "~>"
|
39
82
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
83
|
+
version: '13.0'
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 13.0.6
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: reek
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - "~>"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '6.0'
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 6.0.6
|
97
|
+
type: :development
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '6.0'
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 6.0.6
|
41
107
|
- !ruby/object:Gem::Dependency
|
42
108
|
name: rspec
|
43
109
|
requirement: !ruby/object:Gem::Requirement
|
44
110
|
requirements:
|
45
111
|
- - "~>"
|
46
112
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
113
|
+
version: '3.10'
|
48
114
|
type: :development
|
49
115
|
prerelease: false
|
50
116
|
version_requirements: !ruby/object:Gem::Requirement
|
51
117
|
requirements:
|
52
118
|
- - "~>"
|
53
119
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
120
|
+
version: '3.10'
|
55
121
|
- !ruby/object:Gem::Dependency
|
56
122
|
name: rubocop
|
57
123
|
requirement: !ruby/object:Gem::Requirement
|
58
124
|
requirements:
|
59
125
|
- - "~>"
|
60
126
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
127
|
+
version: '1.22'
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 1.22.3
|
62
131
|
type: :development
|
63
132
|
prerelease: false
|
64
133
|
version_requirements: !ruby/object:Gem::Requirement
|
65
134
|
requirements:
|
66
135
|
- - "~>"
|
67
136
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
137
|
+
version: '1.22'
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: 1.22.3
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: rubocop-rake
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - "~>"
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: 0.6.0
|
148
|
+
type: :development
|
149
|
+
prerelease: false
|
150
|
+
version_requirements: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - "~>"
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: 0.6.0
|
155
|
+
- !ruby/object:Gem::Dependency
|
156
|
+
name: rubocop-rspec
|
157
|
+
requirement: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - "~>"
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '2.6'
|
162
|
+
type: :development
|
163
|
+
prerelease: false
|
164
|
+
version_requirements: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - "~>"
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '2.6'
|
69
169
|
description: Set of small and standalone utilities in Ruby.
|
70
170
|
email:
|
71
171
|
- thomas.tych@gmail.com
|
72
172
|
executables:
|
173
|
+
- cat.rb
|
174
|
+
- datetime
|
175
|
+
- distinguished_name
|
176
|
+
- jb
|
177
|
+
- json2yaml
|
73
178
|
- proxy
|
179
|
+
- yaml2json
|
180
|
+
- yb
|
74
181
|
extensions: []
|
75
182
|
extra_rdoc_files: []
|
76
183
|
files:
|
77
184
|
- ".gitignore"
|
185
|
+
- ".reek.yml"
|
78
186
|
- ".rspec"
|
187
|
+
- ".rubocop.yml"
|
79
188
|
- ".travis.yml"
|
80
189
|
- CODE_OF_CONDUCT.md
|
81
190
|
- Gemfile
|
82
|
-
- Gemfile.lock
|
83
191
|
- LICENSE.txt
|
84
192
|
- README.md
|
85
193
|
- Rakefile
|
86
|
-
- bin/
|
87
|
-
- bin/
|
88
|
-
-
|
194
|
+
- bin/cat.rb
|
195
|
+
- bin/datetime
|
196
|
+
- bin/distinguished_name
|
197
|
+
- bin/jb
|
198
|
+
- bin/json2yaml
|
199
|
+
- bin/proxy
|
200
|
+
- bin/yaml2json
|
201
|
+
- bin/yb
|
89
202
|
- lib/quick_and_ruby.rb
|
203
|
+
- lib/quick_and_ruby/data.rb
|
204
|
+
- lib/quick_and_ruby/data/browser.rb
|
205
|
+
- lib/quick_and_ruby/data/context.rb
|
206
|
+
- lib/quick_and_ruby/date.rb
|
207
|
+
- lib/quick_and_ruby/date/date_time_args.rb
|
208
|
+
- lib/quick_and_ruby/date/date_time_cli.rb
|
209
|
+
- lib/quick_and_ruby/distinguished_name.rb
|
90
210
|
- lib/quick_and_ruby/proxy/arg_parser.rb
|
91
211
|
- lib/quick_and_ruby/proxy/env_parser.rb
|
92
212
|
- lib/quick_and_ruby/proxy/proxy.rb
|
93
213
|
- lib/quick_and_ruby/version.rb
|
214
|
+
- man/distinguished_name.1.ronn
|
94
215
|
- quick_and_ruby.gemspec
|
95
|
-
|
216
|
+
- scripts/console
|
217
|
+
- scripts/setup
|
218
|
+
homepage: https://github.com/ttych/quick_and_ruby
|
96
219
|
licenses:
|
97
220
|
- MIT
|
98
221
|
metadata:
|
99
222
|
allowed_push_host: https://rubygems.org
|
100
|
-
homepage_uri: https://github.com/ttych/
|
223
|
+
homepage_uri: https://github.com/ttych/quick_and_ruby
|
101
224
|
source_code_uri: https://github.com/ttych/quick_and_ruby
|
102
|
-
changelog_uri: https://github.com/ttych/quick_and_ruby
|
103
|
-
|
225
|
+
changelog_uri: https://github.com/ttych/quick_and_ruby/CHANGELOG.md
|
226
|
+
rubygems_mfa_required: 'true'
|
227
|
+
post_install_message:
|
104
228
|
rdoc_options: []
|
105
229
|
require_paths:
|
106
230
|
- lib
|
107
231
|
required_ruby_version: !ruby/object:Gem::Requirement
|
108
232
|
requirements:
|
109
|
-
- - "
|
233
|
+
- - ">"
|
110
234
|
- !ruby/object:Gem::Version
|
111
|
-
version: '
|
235
|
+
version: '2.7'
|
112
236
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
237
|
requirements:
|
114
238
|
- - ">="
|
115
239
|
- !ruby/object:Gem::Version
|
116
240
|
version: '0'
|
117
241
|
requirements: []
|
118
|
-
rubygems_version: 3.
|
119
|
-
signing_key:
|
242
|
+
rubygems_version: 3.1.6
|
243
|
+
signing_key:
|
120
244
|
specification_version: 4
|
121
245
|
summary: Quick and Ruby utilities.
|
122
246
|
test_files: []
|
data/Gemfile.lock
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
quick_and_ruby (0.2.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
ast (2.4.0)
|
10
|
-
diff-lcs (1.3)
|
11
|
-
jaro_winkler (1.5.2)
|
12
|
-
parallel (1.17.0)
|
13
|
-
parser (2.6.2.0)
|
14
|
-
ast (~> 2.4.0)
|
15
|
-
psych (3.1.0)
|
16
|
-
rainbow (3.0.0)
|
17
|
-
rake (10.5.0)
|
18
|
-
rspec (3.8.0)
|
19
|
-
rspec-core (~> 3.8.0)
|
20
|
-
rspec-expectations (~> 3.8.0)
|
21
|
-
rspec-mocks (~> 3.8.0)
|
22
|
-
rspec-core (3.8.0)
|
23
|
-
rspec-support (~> 3.8.0)
|
24
|
-
rspec-expectations (3.8.2)
|
25
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
-
rspec-support (~> 3.8.0)
|
27
|
-
rspec-mocks (3.8.0)
|
28
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
-
rspec-support (~> 3.8.0)
|
30
|
-
rspec-support (3.8.0)
|
31
|
-
rubocop (0.66.0)
|
32
|
-
jaro_winkler (~> 1.5.1)
|
33
|
-
parallel (~> 1.10)
|
34
|
-
parser (>= 2.5, != 2.5.1.1)
|
35
|
-
psych (>= 3.1.0)
|
36
|
-
rainbow (>= 2.2.2, < 4.0)
|
37
|
-
ruby-progressbar (~> 1.7)
|
38
|
-
unicode-display_width (>= 1.4.0, < 1.6)
|
39
|
-
ruby-progressbar (1.10.0)
|
40
|
-
unicode-display_width (1.5.0)
|
41
|
-
|
42
|
-
PLATFORMS
|
43
|
-
ruby
|
44
|
-
|
45
|
-
DEPENDENCIES
|
46
|
-
bundler (~> 2.0)
|
47
|
-
quick_and_ruby!
|
48
|
-
rake (~> 10.0)
|
49
|
-
rspec (~> 3.0)
|
50
|
-
rubocop (~> 0.66.0)
|
51
|
-
|
52
|
-
BUNDLED WITH
|
53
|
-
2.0.1
|
/data/{exe → bin}/proxy
RENAMED
File without changes
|
/data/{bin → scripts}/console
RENAMED
File without changes
|
/data/{bin → scripts}/setup
RENAMED
File without changes
|