Class: Hashira::Project
- Inherits:
-
Object
- Object
- Hashira::Project
- Defined in:
- lib/hashira/project.rb
Constant Summary collapse
- ROOT_PACKAGE =
"(root)"
Instance Method Summary collapse
- #directories ⇒ Object
- #files ⇒ Object
-
#initialize(requested) ⇒ Project
constructor
A new instance of Project.
- #label ⇒ Object
- #package(path) ⇒ Object
- #rails? ⇒ Boolean
- #relative(path) ⇒ Object
- #root ⇒ Object
Constructor Details
#initialize(requested) ⇒ Project
Returns a new instance of Project.
6 7 8 |
# File 'lib/hashira/project.rb', line 6 def initialize(requested) @requested = requested end |
Instance Method Details
#directories ⇒ Object
10 |
# File 'lib/hashira/project.rb', line 10 def directories = @_directories ||= resolved |
#files ⇒ Object
14 |
# File 'lib/hashira/project.rb', line 14 def files = directories.flat_map { Dir["#{it}/**/*.rb"] }.sort |
#label ⇒ Object
24 |
# File 'lib/hashira/project.rb', line 24 def label = directories.join(", ") |
#package(path) ⇒ Object
16 17 18 19 20 |
# File 'lib/hashira/project.rb', line 16 def package(path) first, rest = relative(path).delete_suffix(".rb").split("/", 2) return ROOT_PACKAGE unless rest || folder?(path, first) contested.include?(first) ? "#{parent(path)}/#{first}" : first end |
#rails? ⇒ Boolean
12 |
# File 'lib/hashira/project.rb', line 12 def rails? = directories.any? { config?(File.(it)) } |
#relative(path) ⇒ Object
22 |
# File 'lib/hashira/project.rb', line 22 def relative(path) = path.delete_prefix("#{parent(path)}/") |
#root ⇒ Object
26 |
# File 'lib/hashira/project.rb', line 26 def root = ROOT_PACKAGE |