-
-
Save anonymous/37638fee29789d0d40ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@projects_directory = "projects" | |
# Structure inside "projects" at the moment is: | |
# projects | |
# -> proj1 | |
# --> folder1 | |
# --> folder2 | |
# -> proj2 | |
# --> folder1 | |
# | |
# Return an Array with all the projects path. | |
def all_projects_paths | |
Dir.glob("#{@projects_directory}/*").select {|f| File.directory? f} | |
end | |
# Return an Array with all projects components paths. | |
def all_components_path(component = "*") | |
all_projects_path.map do |project| | |
#File.join(project, component) | |
# Same with this instead: | |
Dir.glob("#{@projects_directory}/*/#{component}").select {|f| File.directory? f} | |
# If I use `puts` in either option, it will print correct results, but duplicated | |
end | |
end | |
all_components_path("folder1") | |
# Returns a two-dimensional array: | |
# [["projects/proj1/folder1", "projects/proj2/folder1"], ["projects/proj1/folder1", "projects/proj2/folder1"]] | |
# Instead of an uni-dimensional array: | |
# ["projects/proj1/folder1", "projects/proj2/folder1"] | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment