Class: Hashira::Project
- Inherits:
-
Object
- Object
- Hashira::Project
- Defined in:
- lib/hashira/project.rb
Constant Summary collapse
- ROOT_PACKAGE =
"(root)"
Instance Attribute Summary collapse
-
#boundaries ⇒ Object
readonly
Returns the value of attribute boundaries.
Instance Method Summary collapse
- #directories ⇒ Object
- #files ⇒ Object
-
#initialize(requested, boundaries: []) ⇒ Project
constructor
A new instance of Project.
- #label ⇒ Object
- #package(path) ⇒ Object
- #rails? ⇒ Boolean
- #relative(path) ⇒ Object
- #root ⇒ Object
Constructor Details
#initialize(requested, boundaries: []) ⇒ Project
Returns a new instance of Project.
6 7 8 9 |
# File 'lib/hashira/project.rb', line 6 def initialize(requested, boundaries: []) @requested = requested @boundaries = boundaries end |
Instance Attribute Details
#boundaries ⇒ Object (readonly)
Returns the value of attribute boundaries.
11 12 13 |
# File 'lib/hashira/project.rb', line 11 def boundaries @boundaries end |
Instance Method Details
#directories ⇒ Object
13 |
# File 'lib/hashira/project.rb', line 13 def directories = @_directories ||= resolved |
#files ⇒ Object
17 |
# File 'lib/hashira/project.rb', line 17 def files = directories.flat_map { Dir["#{it}/**/*.rb"] }.sort |
#label ⇒ Object
27 |
# File 'lib/hashira/project.rb', line 27 def label = directories.join(", ") |
#package(path) ⇒ Object
19 20 21 22 23 |
# File 'lib/hashira/project.rb', line 19 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
15 |
# File 'lib/hashira/project.rb', line 15 def rails? = directories.any? { config?(File.(it)) } |
#relative(path) ⇒ Object
25 |
# File 'lib/hashira/project.rb', line 25 def relative(path) = path.delete_prefix("#{parent(path)}/") |
#root ⇒ Object
29 |
# File 'lib/hashira/project.rb', line 29 def root = ROOT_PACKAGE |