Class: Steep::Project::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/steep/project/target.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, options:, source_pattern:, inline_source_pattern:, signature_pattern:, code_diagnostics_config:, project:, unreferenced:, implicitly_returns_nil:) ⇒ Target

Returns a new instance of Target.



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/steep/project/target.rb', line 16

def initialize(name:, options:, source_pattern:, inline_source_pattern:, signature_pattern:, code_diagnostics_config:, project:, unreferenced:, implicitly_returns_nil:)
  @name = name
  @target_options = options
  @source_pattern = source_pattern
  @inline_source_pattern = inline_source_pattern
  @signature_pattern = signature_pattern
  @code_diagnostics_config = code_diagnostics_config
  @project = project
  @unreferenced = unreferenced
  @groups = []
  @implicitly_returns_nil = implicitly_returns_nil
end

Instance Attribute Details

#code_diagnostics_configObject (readonly)

Returns the value of attribute code_diagnostics_config.



10
11
12
# File 'lib/steep/project/target.rb', line 10

def code_diagnostics_config
  @code_diagnostics_config
end

#groupsObject (readonly)

Returns the value of attribute groups.



13
14
15
# File 'lib/steep/project/target.rb', line 13

def groups
  @groups
end

#implicitly_returns_nilObject (readonly)

Returns the value of attribute implicitly_returns_nil.



14
15
16
# File 'lib/steep/project/target.rb', line 14

def implicitly_returns_nil
  @implicitly_returns_nil
end

#inline_source_patternObject (readonly)

Returns the value of attribute inline_source_pattern.



9
10
11
# File 'lib/steep/project/target.rb', line 9

def inline_source_pattern
  @inline_source_pattern
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/steep/project/target.rb', line 4

def name
  @name
end

#projectObject (readonly)

Returns the value of attribute project.



11
12
13
# File 'lib/steep/project/target.rb', line 11

def project
  @project
end

#signature_patternObject (readonly)

Returns the value of attribute signature_pattern.



8
9
10
# File 'lib/steep/project/target.rb', line 8

def signature_pattern
  @signature_pattern
end

#source_patternObject (readonly)

Returns the value of attribute source_pattern.



7
8
9
# File 'lib/steep/project/target.rb', line 7

def source_pattern
  @source_pattern
end

#target_optionsObject (readonly)

Returns the value of attribute target_options.



5
6
7
# File 'lib/steep/project/target.rb', line 5

def target_options
  @target_options
end

#unreferencedObject (readonly)

Returns the value of attribute unreferenced.



12
13
14
# File 'lib/steep/project/target.rb', line 12

def unreferenced
  @unreferenced
end

Class Method Details

.construct_env_loader(options:, project:) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/steep/project/target.rb', line 73

def self.construct_env_loader(options:, project:)
  repo = RBS::Repository.new(no_stdlib: options.paths.customized_stdlib?)

  if options.paths.stdlib_root
    repo.add(project.absolute_path(options.paths.stdlib_root))
  end

  options.paths.repo_paths.each do |path|
    repo.add(project.absolute_path(path))
  end

  core_root_path =
    if options.paths.customized_core?
      if options.paths.core_root
        project.absolute_path(options.paths.core_root)
      end
    else
      RBS::EnvironmentLoader::DEFAULT_CORE_ROOT
    end

  loader = RBS::EnvironmentLoader.new(core_root: core_root_path, repository: repo)

  options.libraries.each do |lib|
    name, version = lib.split(/:/, 2)
    name or raise
    loader.add(library: name, version: version)
  end
  loader.add_collection(options.collection_lock) if options.collection_lock

  loader
end

Instance Method Details

#new_env_loaderObject



69
70
71
# File 'lib/steep/project/target.rb', line 69

def new_env_loader()
  Target.construct_env_loader(options: options, project: project)
end

#optionsObject



29
30
31
# File 'lib/steep/project/target.rb', line 29

def options
  target_options || project.global_options
end

#possible_inline_source_file?(path) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
60
61
62
63
64
65
66
67
# File 'lib/steep/project/target.rb', line 57

def possible_inline_source_file?(path)
  if group = groups.find { _1.possible_inline_source_file?(path) }
    return group
  end

  if inline_source_pattern =~ path
    return self
  end

  nil
end

#possible_signature_file?(path) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
51
52
53
54
55
# File 'lib/steep/project/target.rb', line 45

def possible_signature_file?(path)
  if target = groups.find { _1.possible_signature_file?(path) }
    return target
  end

  if signature_pattern =~ path
    return self
  end

  nil
end

#possible_source_file?(path) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
39
40
41
42
43
# File 'lib/steep/project/target.rb', line 33

def possible_source_file?(path)
  if target = groups.find { _1.possible_source_file?(path) }
    return target
  end

  if source_pattern =~ path && inline_source_pattern !~ path
    return self
  end

  nil
end