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:, signature_pattern:, code_diagnostics_config:, project:, unreferenced:, implicitly_returns_nil:) ⇒ Target

Returns a new instance of Target.



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

def initialize(name:, options:, source_pattern:, signature_pattern:, code_diagnostics_config:, project:, unreferenced:, implicitly_returns_nil:)
  @name = name
  @target_options = options
  @source_pattern = 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.



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

def code_diagnostics_config
  @code_diagnostics_config
end

#groupsObject (readonly)

Returns the value of attribute groups.



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

def groups
  @groups
end

#implicitly_returns_nilObject (readonly)

Returns the value of attribute implicitly_returns_nil.



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

def implicitly_returns_nil
  @implicitly_returns_nil
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.



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

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.



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

def unreferenced
  @unreferenced
end

Class Method Details

.construct_env_loader(options:, project:) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/steep/project/target.rb', line 59

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



55
56
57
# File 'lib/steep/project/target.rb', line 55

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

#optionsObject



27
28
29
# File 'lib/steep/project/target.rb', line 27

def options
  target_options || project.global_options
end

#possible_signature_file?(path) ⇒ Boolean

Returns:

  • (Boolean)


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

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)


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

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

  if source_pattern =~ path
    return self
  end

  nil
end