Class: Hashira::Project

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

Constant Summary collapse

ROOT_PACKAGE =
"(root)"

Instance Method Summary collapse

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

#directoriesObject



10
# File 'lib/hashira/project.rb', line 10

def directories = @_directories ||= resolved

#filesObject



14
# File 'lib/hashira/project.rb', line 14

def files = directories.flat_map { Dir["#{it}/**/*.rb"] }.sort

#labelObject



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

Returns:

  • (Boolean)


12
# File 'lib/hashira/project.rb', line 12

def rails? = directories.any? { config?(File.expand_path(it)) }

#relative(path) ⇒ Object



22
# File 'lib/hashira/project.rb', line 22

def relative(path) = path.delete_prefix("#{parent(path)}/")

#rootObject



26
# File 'lib/hashira/project.rb', line 26

def root = ROOT_PACKAGE