ruby_json_parser 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +35 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE +21 -0
- data/README.md +143 -0
- data/Rakefile +12 -0
- data/lib/ruby_json_parser/ast.rb +312 -0
- data/lib/ruby_json_parser/evaluator.rb +81 -0
- data/lib/ruby_json_parser/lexer.rb +358 -0
- data/lib/ruby_json_parser/parser.rb +205 -0
- data/lib/ruby_json_parser/result.rb +43 -0
- data/lib/ruby_json_parser/token.rb +171 -0
- data/lib/ruby_json_parser/version.rb +6 -0
- data/lib/ruby_json_parser.rb +77 -0
- data/sorbet/config +4 -0
- data/sorbet/rbi/annotations/.gitattributes +1 -0
- data/sorbet/rbi/annotations/minitest.rbi +119 -0
- data/sorbet/rbi/annotations/rainbow.rbi +269 -0
- data/sorbet/rbi/gems/.gitattributes +1 -0
- data/sorbet/rbi/gems/ast@2.4.2.rbi +585 -0
- data/sorbet/rbi/gems/erubi@1.13.0.rbi +150 -0
- data/sorbet/rbi/gems/json@2.7.2.rbi +1562 -0
- data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +14238 -0
- data/sorbet/rbi/gems/minitest@5.24.1.rbi +1563 -0
- data/sorbet/rbi/gems/netrc@0.11.0.rbi +159 -0
- data/sorbet/rbi/gems/parallel@1.25.1.rbi +287 -0
- data/sorbet/rbi/gems/parser@3.3.4.0.rbi +5519 -0
- data/sorbet/rbi/gems/prism@0.30.0.rbi +39212 -0
- data/sorbet/rbi/gems/racc@1.8.0.rbi +162 -0
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +403 -0
- data/sorbet/rbi/gems/rake@13.2.1.rbi +3028 -0
- data/sorbet/rbi/gems/rbi@0.1.13.rbi +3078 -0
- data/sorbet/rbi/gems/regexp_parser@2.9.2.rbi +3772 -0
- data/sorbet/rbi/gems/rexml@3.3.1.rbi +4813 -0
- data/sorbet/rbi/gems/rubocop-ast@1.31.3.rbi +7015 -0
- data/sorbet/rbi/gems/rubocop@1.65.0.rbi +58191 -0
- data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1318 -0
- data/sorbet/rbi/gems/spoom@1.3.3.rbi +4926 -0
- data/sorbet/rbi/gems/strscan@3.1.0.rbi +9 -0
- data/sorbet/rbi/gems/tapioca@0.15.1.rbi +3566 -0
- data/sorbet/rbi/gems/thor@1.3.1.rbi +4352 -0
- data/sorbet/rbi/gems/unicode-display_width@2.5.0.rbi +66 -0
- data/sorbet/rbi/gems/yard-sorbet@0.9.0.rbi +435 -0
- data/sorbet/rbi/gems/yard@0.9.36.rbi +18221 -0
- data/sorbet/tapioca/config.yml +13 -0
- data/sorbet/tapioca/require.rb +4 -0
- metadata +105 -0
@@ -0,0 +1,171 @@
|
|
1
|
+
# typed: strong
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'set'
|
5
|
+
|
6
|
+
class RubyJsonParser
|
7
|
+
# Represents a single token (word) produced by the lexer.
|
8
|
+
class Token
|
9
|
+
extend T::Sig
|
10
|
+
|
11
|
+
class << self
|
12
|
+
extend T::Sig
|
13
|
+
|
14
|
+
# Converts a token type into a human-readable string.
|
15
|
+
sig { params(type: Symbol).returns(String) }
|
16
|
+
def type_to_string(type)
|
17
|
+
case type
|
18
|
+
when NONE
|
19
|
+
'NONE'
|
20
|
+
when END_OF_FILE
|
21
|
+
'END_OF_FILE'
|
22
|
+
when ERROR
|
23
|
+
'ERROR'
|
24
|
+
when LBRACKET
|
25
|
+
'['
|
26
|
+
when RBRACKET
|
27
|
+
']'
|
28
|
+
when LBRACE
|
29
|
+
'{'
|
30
|
+
when RBRACE
|
31
|
+
'}'
|
32
|
+
when COMMA
|
33
|
+
','
|
34
|
+
when COLON
|
35
|
+
':'
|
36
|
+
when DOT
|
37
|
+
'.'
|
38
|
+
when NUMBER
|
39
|
+
'NUMBER'
|
40
|
+
when STRING
|
41
|
+
'STRING'
|
42
|
+
when false
|
43
|
+
'false'
|
44
|
+
when true
|
45
|
+
'true'
|
46
|
+
when NULL
|
47
|
+
'null'
|
48
|
+
else
|
49
|
+
'<invalid>'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
sig { returns(Symbol) }
|
55
|
+
attr_reader :type
|
56
|
+
|
57
|
+
sig { returns(T.nilable(String)) }
|
58
|
+
attr_reader :value
|
59
|
+
|
60
|
+
sig { params(type: Symbol, value: T.nilable(String)).void }
|
61
|
+
def initialize(type, value = nil)
|
62
|
+
@type = type
|
63
|
+
@value = value
|
64
|
+
end
|
65
|
+
|
66
|
+
sig { params(other: Object).returns(T::Boolean) }
|
67
|
+
def ==(other)
|
68
|
+
return false unless other.is_a?(Token)
|
69
|
+
|
70
|
+
type == other.type && value == other.value
|
71
|
+
end
|
72
|
+
|
73
|
+
sig { returns(String) }
|
74
|
+
def inspect
|
75
|
+
return "Token(#{type.inspect})" if value.nil?
|
76
|
+
|
77
|
+
"Token(#{type.inspect}, #{value.inspect})"
|
78
|
+
end
|
79
|
+
|
80
|
+
# Converts a token into a human-readable string.
|
81
|
+
sig { returns(String) }
|
82
|
+
def to_s
|
83
|
+
case type
|
84
|
+
when NONE
|
85
|
+
'NONE'
|
86
|
+
when END_OF_FILE
|
87
|
+
'END_OF_FILE'
|
88
|
+
when ERROR
|
89
|
+
"<error: #{value}>"
|
90
|
+
when LBRACKET
|
91
|
+
'['
|
92
|
+
when RBRACKET
|
93
|
+
']'
|
94
|
+
when LBRACE
|
95
|
+
'{'
|
96
|
+
when RBRACE
|
97
|
+
'}'
|
98
|
+
when COMMA
|
99
|
+
','
|
100
|
+
when COLON
|
101
|
+
':'
|
102
|
+
when DOT
|
103
|
+
'.'
|
104
|
+
when NUMBER
|
105
|
+
value.to_s
|
106
|
+
when STRING
|
107
|
+
T.cast(value.inspect, String)
|
108
|
+
when false
|
109
|
+
'false'
|
110
|
+
when true
|
111
|
+
'true'
|
112
|
+
when NULL
|
113
|
+
'null'
|
114
|
+
else
|
115
|
+
'<invalid>'
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# String containing all valid decimal digits
|
120
|
+
DIGITS = '0123456789'
|
121
|
+
# String containing all valid hexadecimal digits
|
122
|
+
HEX_DIGITS = '0123456789abcdefABCDEF'
|
123
|
+
|
124
|
+
# Set of all JSON keywords
|
125
|
+
KEYWORDS = T.let(
|
126
|
+
Set[
|
127
|
+
'false',
|
128
|
+
'true',
|
129
|
+
'null',
|
130
|
+
],
|
131
|
+
T::Set[String],
|
132
|
+
)
|
133
|
+
|
134
|
+
|
135
|
+
# List of all token types
|
136
|
+
# ------------------------
|
137
|
+
|
138
|
+
# Represents no token, a placeholder
|
139
|
+
NONE = :none
|
140
|
+
# Signifies that the entire string/file has been processed,
|
141
|
+
# there will be no more tokens
|
142
|
+
END_OF_FILE = :end_of_file
|
143
|
+
# Holds an error message, means that the string/file could not be
|
144
|
+
# successfully processed
|
145
|
+
ERROR = :error
|
146
|
+
# Left bracket `[`
|
147
|
+
LBRACKET = :lbracket
|
148
|
+
# Right bracket `]`
|
149
|
+
RBRACKET = :rbracket
|
150
|
+
# Right brace `{`
|
151
|
+
LBRACE = :lbrace
|
152
|
+
# Left brace `}`
|
153
|
+
RBRACE = :rbrace
|
154
|
+
# Comma `,`
|
155
|
+
COMMA = :comma
|
156
|
+
# Colon `:`
|
157
|
+
COLON = :colon
|
158
|
+
# Dot `.`
|
159
|
+
DOT = :dot
|
160
|
+
# Number literal eg. `123`
|
161
|
+
NUMBER = :number
|
162
|
+
# String literal eg. `"foo"`
|
163
|
+
STRING = :string
|
164
|
+
# False literal `false`
|
165
|
+
FALSE = :false
|
166
|
+
# True literal `true`
|
167
|
+
TRUE = :true
|
168
|
+
# Null literal `null`
|
169
|
+
NULL = :null
|
170
|
+
end
|
171
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# typed: strong
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'sorbet-runtime'
|
5
|
+
|
6
|
+
require_relative 'ruby_json_parser/version'
|
7
|
+
require_relative 'ruby_json_parser/token'
|
8
|
+
require_relative 'ruby_json_parser/lexer'
|
9
|
+
require_relative 'ruby_json_parser/ast'
|
10
|
+
require_relative 'ruby_json_parser/result'
|
11
|
+
require_relative 'ruby_json_parser/parser'
|
12
|
+
require_relative 'ruby_json_parser/evaluator'
|
13
|
+
|
14
|
+
# Implements a JSON lexer, parser and evaluator in pure Ruby.
|
15
|
+
# Built for educational purposes.
|
16
|
+
class RubyJsonParser
|
17
|
+
extend T::Sig
|
18
|
+
|
19
|
+
# JSON syntax error
|
20
|
+
class SyntaxError < StandardError
|
21
|
+
extend T::Sig
|
22
|
+
|
23
|
+
sig { returns(T::Array[String]) }
|
24
|
+
attr_reader :errors
|
25
|
+
|
26
|
+
sig { params(errors: T::Array[String]).void }
|
27
|
+
def initialize(errors)
|
28
|
+
@errors = errors
|
29
|
+
end
|
30
|
+
|
31
|
+
sig { returns(String) }
|
32
|
+
def message
|
33
|
+
@errors.join('; ')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class << self
|
38
|
+
extend T::Sig
|
39
|
+
|
40
|
+
# Tokenize the JSON source string.
|
41
|
+
# Carries out lexical analysis and returns
|
42
|
+
# an array of tokens (words).
|
43
|
+
sig do
|
44
|
+
params(
|
45
|
+
source: String,
|
46
|
+
).returns(T::Array[Token])
|
47
|
+
end
|
48
|
+
def lex(source)
|
49
|
+
Lexer.lex(source)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Parse the JSON source.
|
53
|
+
# Returns an AST (Abstract Syntax Tree) and a list of errors.
|
54
|
+
sig do
|
55
|
+
params(
|
56
|
+
source: String,
|
57
|
+
).returns(Result)
|
58
|
+
end
|
59
|
+
def parse(source)
|
60
|
+
Parser.parse(source)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Evaluate the JSON source string.
|
64
|
+
# Parses the string and interprets it
|
65
|
+
# converting the AST into builtin Ruby data structures.
|
66
|
+
sig do
|
67
|
+
params(
|
68
|
+
source: String,
|
69
|
+
).returns(Object)
|
70
|
+
end
|
71
|
+
def eval(source)
|
72
|
+
Evaluator.eval(source)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
end
|
data/sorbet/config
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
**/*.rbi linguist-vendored=true
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This file was pulled from a central RBI files repository.
|
5
|
+
# Please run `bin/tapioca annotations` to update it.
|
6
|
+
|
7
|
+
module Minitest::Assertions
|
8
|
+
sig { params(test: T.anything, msg: T.anything).returns(TrueClass) }
|
9
|
+
def assert(test, msg = nil); end
|
10
|
+
|
11
|
+
sig { params(obj: T.anything, msg: T.anything).returns(TrueClass) }
|
12
|
+
def assert_empty(obj, msg = nil); end
|
13
|
+
|
14
|
+
sig { params(exp: T.anything, act: T.anything, msg: T.anything).returns(TrueClass) }
|
15
|
+
def assert_equal(exp, act, msg = nil); end
|
16
|
+
|
17
|
+
sig { params(exp: T.anything, act: T.anything, delta: Numeric, msg: T.anything).returns(TrueClass) }
|
18
|
+
def assert_in_delta(exp, act, delta = T.unsafe(nil), msg = nil); end
|
19
|
+
|
20
|
+
sig { params(a: T.anything, b: T.anything, epsilon: Numeric, msg: T.anything).returns(TrueClass) }
|
21
|
+
def assert_in_epsilon(a, b, epsilon = T.unsafe(nil), msg = nil); end
|
22
|
+
|
23
|
+
sig { params(collection: T.anything, obj: T.anything, msg: T.anything).returns(TrueClass) }
|
24
|
+
def assert_includes(collection, obj, msg = nil); end
|
25
|
+
|
26
|
+
sig { params(cls: T.anything, obj: T.anything, msg: T.anything).returns(TrueClass) }
|
27
|
+
def assert_instance_of(cls, obj, msg = nil); end
|
28
|
+
|
29
|
+
sig { params(cls: T.anything, obj: T.anything, msg: T.anything).returns(TrueClass) }
|
30
|
+
def assert_kind_of(cls, obj, msg = nil); end
|
31
|
+
|
32
|
+
sig { params(matcher: T.any(String, Regexp), obj: T.anything, msg: T.anything).returns(MatchData) }
|
33
|
+
def assert_match(matcher, obj, msg = nil); end
|
34
|
+
|
35
|
+
sig { params(obj: T.anything, msg: T.anything).returns(TrueClass) }
|
36
|
+
def assert_nil(obj, msg = nil); end
|
37
|
+
|
38
|
+
sig { params(o1: T.anything, op: T.any(Symbol, String), o2: T.anything, msg: T.anything).returns(TrueClass) }
|
39
|
+
def assert_operator(o1, op, o2 = T.unsafe(nil), msg = nil); end
|
40
|
+
|
41
|
+
sig { params(stdout: T.nilable(T.any(String, Regexp)), stderr: T.nilable(T.any(String, Regexp)), block: T.proc.void).returns(T::Boolean) }
|
42
|
+
def assert_output(stdout = nil, stderr = nil, &block); end
|
43
|
+
|
44
|
+
sig { params(path: T.any(String, Pathname), msg: T.anything).returns(TrueClass) }
|
45
|
+
def assert_path_exists(path, msg = nil); end
|
46
|
+
|
47
|
+
sig { params(block: T.proc.void).returns(TrueClass) }
|
48
|
+
def assert_pattern(&block); end
|
49
|
+
|
50
|
+
sig { params(o1: T.anything, op: T.any(String, Symbol), msg: T.anything).returns(TrueClass) }
|
51
|
+
def assert_predicate(o1, op, msg = nil); end
|
52
|
+
|
53
|
+
sig { params(exp: NilClass, block: T.proc.void).returns(StandardError) }
|
54
|
+
sig { type_parameters(:T).params(exp: T.any(T::Class[T.type_parameter(:T)], Regexp, String), block: T.proc.void).returns(T.type_parameter(:T)) }
|
55
|
+
def assert_raises(*exp, &block); end
|
56
|
+
|
57
|
+
sig { params(obj: T.anything, meth: T.any(String, Symbol), msg: T.anything, include_all: T::Boolean).returns(TrueClass) }
|
58
|
+
def assert_respond_to(obj, meth, msg = nil, include_all: false); end
|
59
|
+
|
60
|
+
sig { params(exp: T.anything, act: T.anything, msg: T.anything).returns(TrueClass) }
|
61
|
+
def assert_same(exp, act, msg = nil); end
|
62
|
+
|
63
|
+
sig { params(send_ary: T::Array[T.anything], m: T.anything).returns(T::Boolean) }
|
64
|
+
def assert_send(send_ary, m = nil); end
|
65
|
+
|
66
|
+
sig { params(block: T.proc.void).returns(T::Boolean) }
|
67
|
+
def assert_silent(&block); end
|
68
|
+
|
69
|
+
sig { params(sym: Symbol, msg: T.anything, block: T.proc.void).returns(T.anything) }
|
70
|
+
def assert_throws(sym, msg = nil, &block); end
|
71
|
+
|
72
|
+
sig { params(test: T.anything, msg: T.anything).returns(TrueClass) }
|
73
|
+
def refute(test, msg = nil); end
|
74
|
+
|
75
|
+
sig { params(obj: T.anything, msg: T.anything).returns(TrueClass) }
|
76
|
+
def refute_empty(obj, msg = nil); end
|
77
|
+
|
78
|
+
sig { params(exp: T.anything, act: T.anything, msg: T.anything).returns(TrueClass) }
|
79
|
+
def refute_equal(exp, act, msg = nil); end
|
80
|
+
|
81
|
+
sig { params(exp: T.anything, act: T.anything, delta: Numeric, msg: T.anything).returns(TrueClass) }
|
82
|
+
def refute_in_delta(exp, act, delta = T.unsafe(nil), msg = nil); end
|
83
|
+
|
84
|
+
sig { params(a: T.anything, b: T.anything, epsilon: Numeric, msg: T.anything).returns(TrueClass) }
|
85
|
+
def refute_in_epsilon(a, b, epsilon = T.unsafe(nil), msg = nil); end
|
86
|
+
|
87
|
+
sig { params(collection: T.anything, obj: T.anything, msg: T.anything).returns(TrueClass) }
|
88
|
+
def refute_includes(collection, obj, msg = nil); end
|
89
|
+
|
90
|
+
sig { params(cls: T.anything, obj: T.anything, msg: T.anything).returns(TrueClass) }
|
91
|
+
def refute_instance_of(cls, obj, msg = nil); end
|
92
|
+
|
93
|
+
sig { params(cls: T.anything, obj: T.anything, msg: T.anything).returns(TrueClass) }
|
94
|
+
def refute_kind_of(cls, obj, msg = nil); end
|
95
|
+
|
96
|
+
sig { params(matcher: T.any(String, Regexp), obj: T.anything, msg: T.anything).returns(TrueClass) }
|
97
|
+
def refute_match(matcher, obj, msg = nil); end
|
98
|
+
|
99
|
+
sig { params(obj: T.anything, msg: T.anything).returns(TrueClass) }
|
100
|
+
def refute_nil(obj, msg = nil); end
|
101
|
+
|
102
|
+
sig { params(block: T.proc.void).returns(TrueClass) }
|
103
|
+
def refute_pattern(&block); end
|
104
|
+
|
105
|
+
sig { params(o1: T.anything, op: T.any(Symbol, String), o2: T.anything, msg: T.anything).returns(TrueClass) }
|
106
|
+
def refute_operator(o1, op, o2 = T.unsafe(nil), msg = nil); end
|
107
|
+
|
108
|
+
sig { params(path: T.any(String, Pathname), msg: T.anything).returns(TrueClass) }
|
109
|
+
def refute_path_exists(path, msg = nil); end
|
110
|
+
|
111
|
+
sig { params(o1: T.anything, op: T.any(String, Symbol), msg: T.anything).returns(TrueClass) }
|
112
|
+
def refute_predicate(o1, op, msg = nil); end
|
113
|
+
|
114
|
+
sig { params(obj: T.anything, meth: T.any(String, Symbol), msg: T.anything, include_all: T::Boolean).returns(TrueClass) }
|
115
|
+
def refute_respond_to(obj, meth, msg = nil, include_all: false); end
|
116
|
+
|
117
|
+
sig { params(exp: T.anything, act: T.anything, msg: T.anything).returns(TrueClass) }
|
118
|
+
def refute_same(exp, act, msg = nil); end
|
119
|
+
end
|
@@ -0,0 +1,269 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This file was pulled from a central RBI files repository.
|
5
|
+
# Please run `bin/tapioca annotations` to update it.
|
6
|
+
|
7
|
+
module Rainbow
|
8
|
+
# @shim: https://github.com/sickill/rainbow/blob/master/lib/rainbow.rb#L10-L12
|
9
|
+
sig { returns(T::Boolean) }
|
10
|
+
attr_accessor :enabled
|
11
|
+
|
12
|
+
class Color
|
13
|
+
sig { returns(Symbol) }
|
14
|
+
attr_reader :ground
|
15
|
+
|
16
|
+
sig { params(ground: Symbol, values: T.any([Integer], [Integer, Integer, Integer])).returns(Color) }
|
17
|
+
def self.build(ground, values); end
|
18
|
+
|
19
|
+
sig { params(hex: String).returns([Integer, Integer, Integer]) }
|
20
|
+
def self.parse_hex_color(hex); end
|
21
|
+
|
22
|
+
class Indexed < Rainbow::Color
|
23
|
+
sig { returns(Integer) }
|
24
|
+
attr_reader :num
|
25
|
+
|
26
|
+
sig { params(ground: Symbol, num: Integer).void }
|
27
|
+
def initialize(ground, num); end
|
28
|
+
|
29
|
+
sig { returns(T::Array[Integer]) }
|
30
|
+
def codes; end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Named < Rainbow::Color::Indexed
|
34
|
+
NAMES = T.let(nil, T::Hash[Symbol, Integer])
|
35
|
+
|
36
|
+
sig { params(ground: Symbol, name: Symbol).void }
|
37
|
+
def initialize(ground, name); end
|
38
|
+
|
39
|
+
sig { returns(T::Array[Symbol]) }
|
40
|
+
def self.color_names; end
|
41
|
+
|
42
|
+
sig { returns(String) }
|
43
|
+
def self.valid_names; end
|
44
|
+
end
|
45
|
+
|
46
|
+
class RGB < Rainbow::Color::Indexed
|
47
|
+
sig { returns(Integer) }
|
48
|
+
attr_reader :r, :g, :b
|
49
|
+
|
50
|
+
sig { params(ground: Symbol, values: Integer).void }
|
51
|
+
def initialize(ground, *values); end
|
52
|
+
|
53
|
+
sig { returns(T::Array[Integer]) }
|
54
|
+
def codes; end
|
55
|
+
|
56
|
+
sig { params(value: Numeric).returns(Integer) }
|
57
|
+
def self.to_ansi_domain(value); end
|
58
|
+
end
|
59
|
+
|
60
|
+
class X11Named < Rainbow::Color::RGB
|
61
|
+
include Rainbow::X11ColorNames
|
62
|
+
|
63
|
+
sig { params(ground: Symbol, name: Symbol).void }
|
64
|
+
def initialize(ground, name); end
|
65
|
+
|
66
|
+
sig { returns(T::Array[Symbol]) }
|
67
|
+
def self.color_names; end
|
68
|
+
|
69
|
+
sig { returns(String) }
|
70
|
+
def self.valid_names; end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
sig { returns(Wrapper) }
|
75
|
+
def self.global; end
|
76
|
+
|
77
|
+
sig { returns(T::Boolean) }
|
78
|
+
def self.enabled; end
|
79
|
+
|
80
|
+
sig { params(value: T::Boolean).returns(T::Boolean) }
|
81
|
+
def self.enabled=(value); end
|
82
|
+
|
83
|
+
sig { params(string: String).returns(String) }
|
84
|
+
def self.uncolor(string); end
|
85
|
+
|
86
|
+
class NullPresenter < String
|
87
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(NullPresenter) }
|
88
|
+
def color(*values); end
|
89
|
+
|
90
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(NullPresenter) }
|
91
|
+
def foreground(*values); end
|
92
|
+
|
93
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(NullPresenter) }
|
94
|
+
def fg(*values); end
|
95
|
+
|
96
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(NullPresenter) }
|
97
|
+
def background(*values); end
|
98
|
+
|
99
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(NullPresenter) }
|
100
|
+
def bg(*values); end
|
101
|
+
|
102
|
+
sig { returns(NullPresenter) }
|
103
|
+
def reset; end
|
104
|
+
|
105
|
+
sig { returns(NullPresenter) }
|
106
|
+
def bright; end
|
107
|
+
|
108
|
+
sig { returns(NullPresenter) }
|
109
|
+
def faint; end
|
110
|
+
|
111
|
+
sig { returns(NullPresenter) }
|
112
|
+
def italic; end
|
113
|
+
|
114
|
+
sig { returns(NullPresenter) }
|
115
|
+
def underline; end
|
116
|
+
|
117
|
+
sig { returns(NullPresenter) }
|
118
|
+
def blink; end
|
119
|
+
|
120
|
+
sig { returns(NullPresenter) }
|
121
|
+
def inverse; end
|
122
|
+
|
123
|
+
sig { returns(NullPresenter) }
|
124
|
+
def hide; end
|
125
|
+
|
126
|
+
sig { returns(NullPresenter) }
|
127
|
+
def cross_out; end
|
128
|
+
|
129
|
+
sig { returns(NullPresenter) }
|
130
|
+
def black; end
|
131
|
+
|
132
|
+
sig { returns(NullPresenter) }
|
133
|
+
def red; end
|
134
|
+
|
135
|
+
sig { returns(NullPresenter) }
|
136
|
+
def green; end
|
137
|
+
|
138
|
+
sig { returns(NullPresenter) }
|
139
|
+
def yellow; end
|
140
|
+
|
141
|
+
sig { returns(NullPresenter) }
|
142
|
+
def blue; end
|
143
|
+
|
144
|
+
sig { returns(NullPresenter) }
|
145
|
+
def magenta; end
|
146
|
+
|
147
|
+
sig { returns(NullPresenter) }
|
148
|
+
def cyan; end
|
149
|
+
|
150
|
+
sig { returns(NullPresenter) }
|
151
|
+
def white; end
|
152
|
+
|
153
|
+
sig { returns(NullPresenter) }
|
154
|
+
def bold; end
|
155
|
+
|
156
|
+
sig { returns(NullPresenter) }
|
157
|
+
def dark; end
|
158
|
+
|
159
|
+
sig { returns(NullPresenter) }
|
160
|
+
def strike; end
|
161
|
+
end
|
162
|
+
|
163
|
+
class Presenter < String
|
164
|
+
TERM_EFFECTS = T.let(nil, T::Hash[Symbol, Integer])
|
165
|
+
|
166
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(Presenter) }
|
167
|
+
def color(*values); end
|
168
|
+
|
169
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(Presenter) }
|
170
|
+
def foreground(*values); end
|
171
|
+
|
172
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(Presenter) }
|
173
|
+
def fg(*values); end
|
174
|
+
|
175
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(Presenter) }
|
176
|
+
def background(*values); end
|
177
|
+
|
178
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(Presenter) }
|
179
|
+
def bg(*values); end
|
180
|
+
|
181
|
+
sig { returns(Presenter) }
|
182
|
+
def reset; end
|
183
|
+
|
184
|
+
sig { returns(Presenter) }
|
185
|
+
def bright; end
|
186
|
+
|
187
|
+
sig { returns(Presenter) }
|
188
|
+
def faint; end
|
189
|
+
|
190
|
+
sig { returns(Presenter) }
|
191
|
+
def italic; end
|
192
|
+
|
193
|
+
sig { returns(Presenter) }
|
194
|
+
def underline; end
|
195
|
+
|
196
|
+
sig { returns(Presenter) }
|
197
|
+
def blink; end
|
198
|
+
|
199
|
+
sig { returns(Presenter) }
|
200
|
+
def inverse; end
|
201
|
+
|
202
|
+
sig { returns(Presenter) }
|
203
|
+
def hide; end
|
204
|
+
|
205
|
+
sig { returns(Presenter) }
|
206
|
+
def cross_out; end
|
207
|
+
|
208
|
+
sig { returns(Presenter) }
|
209
|
+
def black; end
|
210
|
+
|
211
|
+
sig { returns(Presenter) }
|
212
|
+
def red; end
|
213
|
+
|
214
|
+
sig { returns(Presenter) }
|
215
|
+
def green; end
|
216
|
+
|
217
|
+
sig { returns(Presenter) }
|
218
|
+
def yellow; end
|
219
|
+
|
220
|
+
sig { returns(Presenter) }
|
221
|
+
def blue; end
|
222
|
+
|
223
|
+
sig { returns(Presenter) }
|
224
|
+
def magenta; end
|
225
|
+
|
226
|
+
sig { returns(Presenter) }
|
227
|
+
def cyan; end
|
228
|
+
|
229
|
+
sig { returns(Presenter) }
|
230
|
+
def white; end
|
231
|
+
|
232
|
+
sig { returns(Presenter) }
|
233
|
+
def bold; end
|
234
|
+
|
235
|
+
sig { returns(Presenter) }
|
236
|
+
def dark; end
|
237
|
+
|
238
|
+
sig { returns(Presenter) }
|
239
|
+
def strike; end
|
240
|
+
end
|
241
|
+
|
242
|
+
class StringUtils
|
243
|
+
sig { params(string: String, codes: T::Array[Integer]).returns(String) }
|
244
|
+
def self.wrap_with_sgr(string, codes); end
|
245
|
+
|
246
|
+
sig { params(string: String).returns(String) }
|
247
|
+
def self.uncolor(string); end
|
248
|
+
end
|
249
|
+
|
250
|
+
VERSION = T.let(nil, String)
|
251
|
+
|
252
|
+
class Wrapper
|
253
|
+
sig { returns(T::Boolean) }
|
254
|
+
attr_accessor :enabled
|
255
|
+
|
256
|
+
sig { params(enabled: T::Boolean).void }
|
257
|
+
def initialize(enabled = true); end
|
258
|
+
|
259
|
+
sig { params(string: String).returns(T.any(Rainbow::Presenter, Rainbow::NullPresenter)) }
|
260
|
+
def wrap(string); end
|
261
|
+
end
|
262
|
+
|
263
|
+
module X11ColorNames
|
264
|
+
NAMES = T.let(nil, T::Hash[Symbol, [Integer, Integer, Integer]])
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
sig { params(string: String).returns(Rainbow::Presenter) }
|
269
|
+
def Rainbow(string); end
|
@@ -0,0 +1 @@
|
|
1
|
+
**/*.rbi linguist-generated=true
|