Class: Steep::Project::Options

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

Constant Summary collapse

PathOptions =
_ = Struct.new(:core_root, :stdlib_root, :repo_paths, keyword_init: true) do
  # @implements PathOptions

  def customized_stdlib?
    stdlib_root != nil
  end

  def customized_core?
    core_root != nil
  end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions

Returns a new instance of Options.



20
21
22
23
# File 'lib/steep/project/options.rb', line 20

def initialize
  @paths = PathOptions.new(repo_paths: [])
  @libraries = []
end

Instance Attribute Details

#collection_config_pathObject

Returns the value of attribute collection_config_path.



18
19
20
# File 'lib/steep/project/options.rb', line 18

def collection_config_path
  @collection_config_path
end

#librariesObject (readonly)

Returns the value of attribute libraries.



16
17
18
# File 'lib/steep/project/options.rb', line 16

def libraries
  @libraries
end

#pathsObject

Returns the value of attribute paths.



17
18
19
# File 'lib/steep/project/options.rb', line 17

def paths
  @paths
end

Instance Method Details

#collection_lockObject



53
54
55
56
57
58
59
60
# File 'lib/steep/project/options.rb', line 53

def collection_lock
  case config = load_collection_lock()
  when RBS::Collection::Config::Lockfile
    config
  else
    nil
  end
end

#collection_lock_pathObject



25
26
27
28
29
# File 'lib/steep/project/options.rb', line 25

def collection_lock_path
  if collection_config_path
    RBS::Collection::Config.to_lockfile_path(collection_config_path)
  end
end

#load_collection_lock(force: false) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/steep/project/options.rb', line 31

def load_collection_lock(force: false)
  @collection_lock = nil if force
  @collection_lock ||=
    if collection_config_path && collection_lock_path
      case
      when !collection_config_path.file?
        collection_config_path
      when !collection_lock_path.file?
        collection_lock_path
      else
        begin
          content = YAML.load_file(collection_lock_path)
          lock_file = RBS::Collection::Config::Lockfile.from_lockfile(lockfile_path: collection_lock_path, data: content)
          lock_file.check_rbs_availability!
          lock_file
        rescue YAML::SyntaxError, RBS::Collection::Config::CollectionNotAvailable => exn
          exn
        end
      end
    end
end