Class: RubyLens::Index::Manifest
- Inherits:
-
Object
- Object
- RubyLens::Index::Manifest
- Defined in:
- lib/rubylens/index/manifest.rb
Defined Under Namespace
Classes: DependencySystem, Package
Constant Summary collapse
- GIT_SKIP_REASONS =
DependencyWarning::REASONS
Instance Attribute Summary collapse
-
#dependency_systems ⇒ Object
readonly
Returns the value of attribute dependency_systems.
-
#dependency_warnings ⇒ Object
readonly
Returns the value of attribute dependency_warnings.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#packages ⇒ Object
readonly
Returns the value of attribute packages.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
-
#workspace_files ⇒ Object
readonly
Returns the value of attribute workspace_files.
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(root:, lockfile: nil) ⇒ Manifest
constructor
A new instance of Manifest.
- #package_index_for(path) ⇒ Object
- #relative_workspace_path(path) ⇒ Object
- #workspace_path?(path) ⇒ Boolean
Constructor Details
#initialize(root:, lockfile: nil) ⇒ Manifest
Returns a new instance of Manifest.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rubylens/index/manifest.rb', line 24 def initialize(root:, lockfile: nil) @root = Pathname(root)..realpath @lockfile = Pathname(lockfile || @root.join("Gemfile.lock")). @git_package_source = GitPackageSource.new(lockfile: @lockfile) @warnings = [] @dependency_warnings = [] @packages = [] @dependency_systems = [] @package_roots = [] @package_index_by_file = {} @package_index_cache = {} @relative_workspace_path_cache = {} @workspace_path_cache = {} end |
Instance Attribute Details
#dependency_systems ⇒ Object (readonly)
Returns the value of attribute dependency_systems.
18 19 20 |
# File 'lib/rubylens/index/manifest.rb', line 18 def dependency_systems @dependency_systems end |
#dependency_warnings ⇒ Object (readonly)
Returns the value of attribute dependency_warnings.
18 19 20 |
# File 'lib/rubylens/index/manifest.rb', line 18 def dependency_warnings @dependency_warnings end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
18 19 20 |
# File 'lib/rubylens/index/manifest.rb', line 18 def files @files end |
#packages ⇒ Object (readonly)
Returns the value of attribute packages.
18 19 20 |
# File 'lib/rubylens/index/manifest.rb', line 18 def packages @packages end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
18 19 20 |
# File 'lib/rubylens/index/manifest.rb', line 18 def root @root end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
18 19 20 |
# File 'lib/rubylens/index/manifest.rb', line 18 def warnings @warnings end |
#workspace_files ⇒ Object (readonly)
Returns the value of attribute workspace_files.
18 19 20 |
# File 'lib/rubylens/index/manifest.rb', line 18 def workspace_files @workspace_files end |
Class Method Details
.build(root:, lockfile: nil) ⇒ Object
20 21 22 |
# File 'lib/rubylens/index/manifest.rb', line 20 def self.build(root:, lockfile: nil) new(root: root, lockfile: lockfile).tap(&:build) end |
Instance Method Details
#build ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rubylens/index/manifest.rb', line 39 def build @workspace_files = GitRepository.new(@root).selected_files.freeze @workspace_file_set = @workspace_files.to_set build_packages @package_roots = @packages.each_with_index.map { |package, index| [package.root, index] } .sort_by do |package_root, index| package = @packages.fetch(index) [-package_root.to_s.length, package.name, package.version, index] end build_package_index @files = (@workspace_files + @packages.flat_map(&:files)).uniq.freeze @dependency_warnings.sort_by! { |warning| [warning.fetch("name"), warning.fetch("reason")] } @dependency_warnings.freeze self end |
#package_index_for(path) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rubylens/index/manifest.rb', line 55 def package_index_for(path) path = path.to_s @package_index_by_file.fetch(path) do @package_index_cache.fetch(path) do @package_index_cache[path] = uncached_package_index_for(path) end end rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP nil end |
#relative_workspace_path(path) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/rubylens/index/manifest.rb', line 73 def relative_workspace_path(path) path = path.to_s @relative_workspace_path_cache.fetch(path) do @relative_workspace_path_cache[path] = uncached_relative_workspace_path(path) end end |