Skip to content

Commit

Permalink
Merge pull request #48 from alces-software/feat/expand-asterisks
Browse files Browse the repository at this point in the history
Expand asterisks in node names
  • Loading branch information
DavidMarchant authored Jan 21, 2019
2 parents 4b41eda + b0a711a commit a30fa6f
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions lib/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,22 @@ def self.expand_node_ranges(nodes)
nodes.delete(node)
end
end
nodes = nodes + new_nodes
nodes.push(*new_nodes)
return expand_asterisks(nodes)
end

def self.expand_asterisks(nodes)
new_nodes = []
nodes.each do |node|
if node.match(/\*/)
node_names = Dir.glob(File.join(YAML_DIR, node)).map { |file|
File.basename(file, '.yaml')
}
new_nodes.push(*node_names)
end
end
nodes.delete_if { |node| node.match(/\*/) }
nodes.push(*new_nodes)
return nodes
end

Expand Down Expand Up @@ -181,7 +196,7 @@ def self.select_nodes(nodes, options, return_missing = false)
node_locations = find_all_nodes
else
if nodes
node_locations.push(*find_nodes(nodes, return_missing = true))
node_locations.push(*find_nodes(nodes, return_missing))
end
if options.group
node_locations.push(*find_nodes_in_groups(options.group.split(',')))
Expand Down Expand Up @@ -243,7 +258,7 @@ def self.find_nodes(nodes, return_missing = false)
if return_missing
$stderr.puts "Creating..."
else
$stderr.puts "Skipping"
$stderr.puts "Skipping."
next
end
end
Expand Down

0 comments on commit a30fa6f

Please sign in to comment.