lit-cli 0.6.0 → 0.6.1
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 +4 -4
- data/lib/config.rb +6 -6
- data/lib/lit_pry.rb +77 -51
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39a417c815a30ecdf0e99aaa9aa47d22b4def3f2d891f6da1911414a7187a86b
|
4
|
+
data.tar.gz: 5bb7af898274544027202aedb33d9428401044867ad0693ae6314b1c361c9418
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b45c6ae31e1db4cf3ac3fd338e8a11df273618cd8aa8b7d870d3764c9ae86b472b5823504fec11956c33fcc7fe0ca044db544e6c872f167a9db7bbfeaf881b5
|
7
|
+
data.tar.gz: 47a8560f08cbd269877dcd1a6bd14b718a684b190991b80b439602fe766b15f84bc1c44826aafed8416277e2fb425f66d35d447f32676cacdc8d9ef4fa31a8a0
|
data/lib/config.rb
CHANGED
@@ -33,12 +33,12 @@ module LitCLI
|
|
33
33
|
def initialize()
|
34
34
|
|
35
35
|
@statuses = {
|
36
|
-
:info => { icon: "ℹ", color: :blue },
|
37
|
-
:pass => { icon: "✔", color: :green },
|
38
|
-
:warn => { icon: "⚠", color: :yellow },
|
39
|
-
:fail => { icon: "⨯", color: :red },
|
40
|
-
:error => { icon: "!", color: :red },
|
41
|
-
:debug => { icon: "?", color: :purple },
|
36
|
+
:info => { icon: "ℹ", color: :blue, styles: [:upcase] },
|
37
|
+
:pass => { icon: "✔", color: :green, styles: [:upcase] },
|
38
|
+
:warn => { icon: "⚠", color: :yellow, styles: [:upcase] },
|
39
|
+
:fail => { icon: "⨯", color: :red, styles: [:upcase] },
|
40
|
+
:error => { icon: "!", color: :red, styles: [:upcase] },
|
41
|
+
:debug => { icon: "?", color: :purple, styles: [:upcase] },
|
42
42
|
}
|
43
43
|
|
44
44
|
@types = nil
|
data/lib/lit_pry.rb
CHANGED
@@ -1,70 +1,96 @@
|
|
1
1
|
# Only override kernel methods when Lit's @step flag is true.
|
2
2
|
if ENV['LIT_FLAGS'] && ENV['LIT_FLAGS'].include?('step')
|
3
|
+
require 'set'
|
4
|
+
|
5
|
+
# TODO: Investigate RubyGems `require` before overriding.
|
6
|
+
# SEE: https://github.com/ruby/ruby/blob/v2_6_3/lib/rubygems/core_ext/kernel_require.rb
|
7
|
+
|
3
8
|
module Kernel
|
4
9
|
|
5
|
-
|
6
|
-
filename = relative_path
|
10
|
+
@@lit_processed_paths = Set.new
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
absolute_path.pop
|
12
|
+
def require_relative relative_path, current_directory = nil
|
13
|
+
return false if relative_path.nil?
|
11
14
|
|
12
|
-
#
|
13
|
-
if relative_path.start_with?('
|
14
|
-
|
15
|
-
|
15
|
+
# Handle absolute path.
|
16
|
+
if relative_path.start_with?('/') && File.exist?(relative_path)
|
17
|
+
absolute_path = relative_path.split('/')
|
18
|
+
file_name = absolute_path.pop
|
19
|
+
# Handle relative path.
|
20
|
+
else
|
21
|
+
# Get directory of the file that called this file.
|
22
|
+
if current_directory.nil?
|
23
|
+
absolute_path = caller_locations.first.absolute_path.split('/')
|
24
|
+
absolute_path.pop
|
25
|
+
else
|
26
|
+
absolute_path = current_directory.split('/')
|
27
|
+
end
|
16
28
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
29
|
+
# When path is current directory.
|
30
|
+
if relative_path.start_with?('./')
|
31
|
+
relative_path.delete_prefix! './'
|
32
|
+
end
|
33
|
+
|
34
|
+
# When path is parent directory.
|
35
|
+
while relative_path.start_with?('../')
|
36
|
+
relative_path.delete_prefix! '../'
|
37
|
+
absolute_path.pop
|
38
|
+
end
|
39
|
+
|
40
|
+
# When path contains child directories.
|
41
|
+
if relative_path.split('/').count > 1
|
42
|
+
# Add child directories to absolute path and remove from relative path.
|
43
|
+
child_path = relative_path.split('/')
|
44
|
+
relative_path = child_path.pop
|
45
|
+
child_path.each do |dir|
|
46
|
+
absolute_path << dir
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
file_name = relative_path
|
21
51
|
end
|
22
52
|
|
23
53
|
# Append default extension.
|
24
|
-
unless
|
25
|
-
|
54
|
+
unless file_name.end_with? '.rb'
|
55
|
+
file_name << '.rb'
|
26
56
|
end
|
27
57
|
|
28
|
-
|
58
|
+
file_path = File.join(absolute_path.join('/'), file_name)
|
59
|
+
|
60
|
+
unless @@lit_processed_paths.include? file_path
|
61
|
+
@@lit_processed_paths.add file_path
|
62
|
+
|
63
|
+
new_lines = ''
|
64
|
+
File.foreach(file_path) do |line|
|
65
|
+
|
66
|
+
# Pass current directory into the next file's requires.
|
67
|
+
if line.strip.start_with? 'require_relative '
|
68
|
+
line = line.strip + ", '#{absolute_path.join('/')}'\n"
|
69
|
+
new_lines << line
|
70
|
+
else
|
71
|
+
new_lines << line
|
72
|
+
end
|
29
73
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
new_lines << "binding.pry if LitCLI.is_prying?\n"
|
36
|
-
new_lines << "@@is_prying = false\n"
|
74
|
+
# Add pry binding beneath each lit message.
|
75
|
+
if line.strip.start_with? 'lit "'
|
76
|
+
new_lines << "binding.pry if LitCLI.is_prying?\n"
|
77
|
+
new_lines << "@@is_prying = false\n"
|
78
|
+
end
|
37
79
|
end
|
38
|
-
end
|
39
80
|
|
40
|
-
|
81
|
+
eval(new_lines, get_binding(__dir__ = absolute_path), file_path)
|
82
|
+
return true
|
83
|
+
# Path has already been required.
|
84
|
+
else
|
85
|
+
return false
|
86
|
+
end
|
41
87
|
end
|
42
88
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
# #p __dir__
|
50
|
-
# #p File.dirname(File.realpath(__FILE__))
|
51
|
-
# #p File.realpath(__FILE__)
|
52
|
-
#
|
53
|
-
# # Split client-side and server-side code.
|
54
|
-
# new_lines = []
|
55
|
-
# binding_line = "binding.pry if LitCLI.is_prying?"
|
56
|
-
#
|
57
|
-
# # Add pry binding beneath each lit message.
|
58
|
-
# p path
|
59
|
-
# File.foreach(path) do |line|
|
60
|
-
# new_lines << line
|
61
|
-
# if line.strip.start_with? 'lit "'
|
62
|
-
# new_lines << binding_line
|
63
|
-
# end
|
64
|
-
# end
|
65
|
-
#
|
66
|
-
# eval(new_lines.join)
|
67
|
-
# end
|
68
|
-
|
89
|
+
def get_binding(__dir__)
|
90
|
+
# Don't go to this binding when Pry session activated.
|
91
|
+
# The variables have already been evaluated by eval(). NEEDS CONFIRMATION.
|
92
|
+
# Setting file_path in eval() negates this fix but will keep just in case.
|
93
|
+
return binding unless LitCLI.is_prying?
|
94
|
+
end
|
69
95
|
end
|
70
96
|
end
|