Class: Tapioca::SorbetConfig
- Inherits:
-
Object
- Object
- Tapioca::SorbetConfig
- Extended by:
- T::Sig
- Defined in:
- lib/tapioca/sorbet_config_parser.rb
Instance Attribute Summary collapse
-
#ignore ⇒ Object
readonly
Returns the value of attribute ignore.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ SorbetConfig
constructor
A new instance of SorbetConfig.
Constructor Details
#initialize ⇒ SorbetConfig
Returns a new instance of SorbetConfig.
12 13 14 15 |
# File 'lib/tapioca/sorbet_config_parser.rb', line 12 def initialize @paths = T.let([], T::Array[String]) @ignore = T.let([], T::Array[String]) end |
Instance Attribute Details
#ignore ⇒ Object (readonly)
Returns the value of attribute ignore.
9 10 11 |
# File 'lib/tapioca/sorbet_config_parser.rb', line 9 def ignore @ignore end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
9 10 11 |
# File 'lib/tapioca/sorbet_config_parser.rb', line 9 def paths @paths end |
Class Method Details
.parse_file(sorbet_config_path) ⇒ Object
21 22 23 |
# File 'lib/tapioca/sorbet_config_parser.rb', line 21 def parse_file(sorbet_config_path) parse_string(File.read(sorbet_config_path)) end |
.parse_string(sorbet_config) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/tapioca/sorbet_config_parser.rb', line 26 def parse_string(sorbet_config) config = SorbetConfig.new ignore = T.let(false, T::Boolean) skip = T.let(false, T::Boolean) sorbet_config.each_line do |line| line = line.strip case line when /^--ignore$/ ignore = true next when /^--ignore=/ config.ignore << parse_option(line) next when /^--file$/ next when /^--file=/ config.paths << parse_option(line) next when /^--dir$/ next when /^--dir=/ config.paths << parse_option(line) next when /^--.*=/ next when /^--/ skip = true when /^-.*=?/ next else if ignore config.ignore << line ignore = false elsif skip skip = false else config.paths << line end end end config end |