Class: RbsGoose::IO::ExampleGroup

Inherits:
Array
  • Object
show all
Defined in:
lib/rbs_goose/io/example_group.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#error_messagesObject

Returns the value of attribute error_messages.



6
7
8
# File 'lib/rbs_goose/io/example_group.rb', line 6

def error_messages
  @error_messages
end

Class Method Details

.default_examplesObject



20
21
22
23
24
25
# File 'lib/rbs_goose/io/example_group.rb', line 20

def default_examples
  example_dir = ::File.join(__dir__.to_s, '../../../examples')
  @default_examples ||= Dir.glob('*', base: example_dir).to_h do |dir|
    [dir.to_sym, load_from(::File.join(example_dir, dir))]
  end
end

.load_from(base_path, code_dir: 'lib', sig_dir: 'sig', refined_dir: 'refined') ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/rbs_goose/io/example_group.rb', line 9

def load_from(base_path, code_dir: 'lib', sig_dir: 'sig', refined_dir: 'refined')
  new.tap do |group|
    Dir.glob('**/*.rb', base: ::File.join(base_path, code_dir)).each do |path|
      group << load_example(base_path, code_dir, path, refined_dir, sig_dir)
    end
    # Read error messages if exists
    error_path = ::File.join(base_path, 'error_messages.txt')
    group.error_messages = ::File.read(error_path).strip if ::File.exist?(error_path)
  end
end

Instance Method Details

#to_refined_rbs_listObject



49
50
51
# File 'lib/rbs_goose/io/example_group.rb', line 49

def to_refined_rbs_list
  map(&:refined_rbs)
end

#to_target_groupObject



43
44
45
46
47
# File 'lib/rbs_goose/io/example_group.rb', line 43

def to_target_group
  TargetGroup.new.tap do |g|
    each { g << _1.typed_ruby }
  end
end