bblib 1.0.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +502 -8
- data/lib/bblib.rb +1 -28
- data/lib/bblib/all.rb +5 -0
- data/lib/{time → bblib/classes}/cron.rb +0 -0
- data/lib/{string → bblib/classes}/fuzzy_matcher.rb +0 -0
- data/lib/bblib/cli.rb +3 -0
- data/lib/bblib/cli/color.rb +51 -0
- data/lib/bblib/cli/exceptions/invalid_argument.rb +5 -0
- data/lib/bblib/cli/exceptions/missing_argument.rb +5 -0
- data/lib/bblib/cli/exceptions/missing_required_argument.rb +5 -0
- data/lib/bblib/cli/exceptions/opts_parser.rb +9 -0
- data/lib/bblib/cli/option.rb +116 -0
- data/lib/bblib/cli/options/basic_option.rb +19 -0
- data/lib/bblib/cli/options/bool.rb +19 -0
- data/lib/bblib/cli/options/command.rb +11 -0
- data/lib/bblib/cli/options/date.rb +14 -0
- data/lib/bblib/cli/options/float.rb +14 -0
- data/lib/bblib/cli/options/integer.rb +14 -0
- data/lib/bblib/cli/options/json.rb +16 -0
- data/lib/bblib/cli/options/regexp.rb +17 -0
- data/lib/bblib/cli/options/string.rb +13 -0
- data/lib/bblib/cli/options/symbol.rb +13 -0
- data/lib/bblib/cli/options/time.rb +14 -0
- data/lib/bblib/cli/options/toggle.rb +27 -0
- data/lib/bblib/cli/options/untoggle.rb +18 -0
- data/lib/bblib/cli/opts_parser.rb +65 -0
- data/lib/bblib/core.rb +37 -0
- data/lib/{hash → bblib/core/classes}/hash_struct.rb +9 -2
- data/lib/bblib/core/classes/splitter.rb +101 -0
- data/lib/{time → bblib/core/classes}/task_timer.rb +0 -0
- data/lib/{hash → bblib/core/classes}/tree_hash.rb +22 -22
- data/lib/bblib/core/exceptions/abstract.rb +3 -0
- data/lib/bblib/core/exceptions/exception.rb +5 -0
- data/lib/{hash_path → bblib/core/hash_path}/hash_path.rb +0 -2
- data/lib/{hash_path → bblib/core/hash_path}/part.rb +0 -0
- data/lib/{mixins → bblib/core/mixins}/attrs.rb +17 -7
- data/lib/{mixins → bblib/core/mixins}/bbmixins.rb +1 -0
- data/lib/{mixins → bblib/core/mixins}/bridge.rb +0 -0
- data/lib/bblib/core/mixins/delegator.rb +90 -0
- data/lib/{class → bblib/core/mixins}/effortless.rb +0 -0
- data/lib/{mixins → bblib/core/mixins}/family_tree.rb +1 -1
- data/lib/{mixins → bblib/core/mixins}/hooks.rb +0 -0
- data/lib/{mixins → bblib/core/mixins}/logger.rb +0 -0
- data/lib/{mixins → bblib/core/mixins}/prototype.rb +0 -0
- data/lib/{mixins → bblib/core/mixins}/serializer.rb +0 -0
- data/lib/{mixins → bblib/core/mixins}/simple_init.rb +41 -3
- data/lib/{mixins → bblib/core/mixins}/type_init.rb +0 -0
- data/lib/{array/bbarray.rb → bblib/core/util/array.rb} +0 -0
- data/lib/{string → bblib/core/util}/cases.rb +0 -0
- data/lib/{file/bbfile.rb → bblib/core/util/file.rb} +31 -7
- data/lib/{hash/bbhash.rb → bblib/core/util/hash.rb} +0 -3
- data/lib/{logging/bblogging.rb → bblib/core/util/logging.rb} +11 -2
- data/lib/{string → bblib/core/util}/matching.rb +0 -0
- data/lib/{number/bbnumber.rb → bblib/core/util/number.rb} +0 -0
- data/lib/{object/bbobject.rb → bblib/core/util/object.rb} +2 -0
- data/lib/{opal/bbopal.rb → bblib/core/util/opal.rb} +0 -0
- data/lib/{os/bbos.rb → bblib/core/util/os.rb} +0 -0
- data/lib/{string → bblib/core/util}/pluralization.rb +0 -0
- data/lib/{string → bblib/core/util}/regexp.rb +0 -0
- data/lib/{string → bblib/core/util}/roman.rb +0 -0
- data/lib/{string/bbstring.rb → bblib/core/util/string.rb} +18 -24
- data/lib/{time/bbtime.rb → bblib/core/util/time.rb} +1 -5
- data/lib/bblib/cron.rb +2 -0
- data/lib/bblib/fuzzy_matcher.rb +2 -0
- data/lib/bblib/html.rb +4 -0
- data/lib/{html → bblib/html}/builder.rb +0 -0
- data/lib/{html → bblib/html}/tag.rb +0 -0
- data/lib/{html → bblib/html}/tag_set.rb +0 -0
- data/lib/bblib/system.rb +3 -0
- data/lib/bblib/system/command.rb +7 -0
- data/lib/bblib/system/system.rb +39 -0
- data/lib/bblib/version.rb +1 -1
- metadata +71 -44
- data/lib/error/abstract.rb +0 -3
- data/lib/hash_path/path_hash.rb +0 -84
- data/lib/hash_path/proc.rb +0 -93
- data/lib/hash_path/processors.rb +0 -239
- data/lib/html/bbhtml.rb +0 -3
- data/lib/system/bbsystem.rb +0 -42
data/lib/html/bbhtml.rb
DELETED
data/lib/system/bbsystem.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
module BBLib
|
2
|
-
# A string representation of the command line that evoked this ruby instance (platform agnostic)
|
3
|
-
def self.cmd_line(*args, include_args: true, include_ruby: true, prefix: nil, suffix: nil)
|
4
|
-
args = ARGV if args.empty?
|
5
|
-
include_ruby = false if special_program?
|
6
|
-
"#{prefix}#{include_ruby ? Command.quote(Gem.ruby) : nil} #{Command.quote($PROGRAM_NAME)}" \
|
7
|
-
" #{include_args ? args.map { |a| Command.quote(a) }.join(' ') : nil}#{suffix}"
|
8
|
-
.strip
|
9
|
-
end
|
10
|
-
|
11
|
-
# EXPERIMENTAL: Reloads the original file that was called
|
12
|
-
# Use at your own risk, this could cause some weird issues
|
13
|
-
def self.reload(include_args: true)
|
14
|
-
return false if special_program?
|
15
|
-
load cmd_line(*args, include_ruby: false, include_args: include_args)
|
16
|
-
end
|
17
|
-
|
18
|
-
# EXPERIMENTAL: Restart the ruby process that is currently running.
|
19
|
-
# Use at your own risk
|
20
|
-
def self.restart(*args, include_args: true, stay_alive: 1)
|
21
|
-
exit(0)
|
22
|
-
rescue SystemExit
|
23
|
-
opts = BBLib::OS.windows? ? { new_pgroup: true } : { pgroup: true }
|
24
|
-
pid = spawn(cmd_line(*args, include_args: include_args, prefix: (BBLib::OS.windows? ? 'start ' : nil)), **opts)
|
25
|
-
Process.detach(pid)
|
26
|
-
sleep(stay_alive)
|
27
|
-
exit(0) if special_program?
|
28
|
-
end
|
29
|
-
|
30
|
-
SPECIAL_PROGRAMS = ['pry', 'irb.cmd', 'irb'].freeze
|
31
|
-
|
32
|
-
def self.special_program?
|
33
|
-
SPECIAL_PROGRAMS.include?($PROGRAM_NAME)
|
34
|
-
end
|
35
|
-
|
36
|
-
module Command
|
37
|
-
def self.quote(arg)
|
38
|
-
arg =~ /\s+/ ? "\"#{arg}\"" : arg.to_s
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|