Class: Solargraph::Repo
- Inherits:
-
Object
- Object
- Solargraph::Repo
- Defined in:
- lib/solargraph/repo.rb
Overview
A repository for the gems available in the specified directory. If the directory has a Gemfile, Repo will use its gem definitions. Otherwise it uses the system gems.
Instance Attribute Summary collapse
- #directory ⇒ String? readonly
Instance Method Summary collapse
-
#bundled ⇒ Array<Solargraph::Metagem>
Metagems from the directory's bundle definition, or an empty array if a bundle definition does not exist.
-
#bundled? ⇒ Boolean
(also: #bundle?)
True if the directory has a bundle definition.
-
#find_by_group(group) ⇒ Array<Metagem>
Get an array of metagems by its bundle group name.
-
#find_by_name(name) ⇒ Metagem?
Find a metagem by name from the directory's bundle definition or the system gems.
-
#find_by_path(path) ⇒ Metagem?
Find a metagem by path from the directory's bundle definition or the system gems.
-
#initialize(directory) ⇒ Repo
constructor
A new instance of Repo.
Constructor Details
#initialize(directory) ⇒ Repo
Returns a new instance of Repo.
16 17 18 19 |
# File 'lib/solargraph/repo.rb', line 16 def initialize directory @directory = File.(directory) if directory build_from_directory end |
Instance Attribute Details
#directory ⇒ String? (readonly)
13 14 15 |
# File 'lib/solargraph/repo.rb', line 13 def directory @directory end |
Instance Method Details
#bundled ⇒ Array<Solargraph::Metagem>
Metagems from the directory's bundle definition, or an empty array if a bundle definition does not exist.
68 69 70 |
# File 'lib/solargraph/repo.rb', line 68 def bundled @metagems || [] end |
#bundled? ⇒ Boolean Also known as: bundle?
If Solargraph itself is running in this directory's bundled
environment, bundled? is false.
True if the directory has a bundle definition.
59 60 61 |
# File 'lib/solargraph/repo.rb', line 59 def bundled? !!@metagems end |
#find_by_group(group) ⇒ Array<Metagem>
Get an array of metagems by its bundle group name. Returns an empty array if the repo isn't bundled or the group doesn't exist.
48 49 50 51 52 |
# File 'lib/solargraph/repo.rb', line 48 def find_by_group group return system_find_by_group(group) unless bundled? bundled_group_map[group] || [] end |
#find_by_name(name) ⇒ Metagem?
Find a metagem by name from the directory's bundle definition or the system gems.
37 38 39 40 41 |
# File 'lib/solargraph/repo.rb', line 37 def find_by_name name return system_find_by_name(name) unless bundled? [name] end |
#find_by_path(path) ⇒ Metagem?
Find a metagem by path from the directory's bundle definition or the system gems.
26 27 28 29 30 |
# File 'lib/solargraph/repo.rb', line 26 def find_by_path path return system_find_by_path(path) unless bundled? [path] end |