Class: Docker::Template::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/docker/template/parser.rb

Constant Summary collapse

SLASH_REGEXP =
/\//.freeze
SPLIT_REGEXP =
/:|\//.freeze
COLON_REGEXP =
/:/.freeze

Instance Method Summary collapse

Constructor Details

#initialize(argv = [].freeze) ⇒ Parser

Returns a new instance of Parser.



12
13
14
# File 'lib/docker/template/parser.rb', line 12

def initialize(argv = [].freeze)
  @argv = argv.freeze
end

Instance Method Details

#allObject

Return ARGV if you send us a list of repos you wish to build, otherwise we get the children of the repo folder and ship that off so you can build every repo, I don’t know if you want that.



20
21
22
23
24
25
26
27
# File 'lib/docker/template/parser.rb', line 20

def all
  return @argv unless @argv.empty?
  Template.repos_root.children.map do |path|
    path.basename.to_s
  end
rescue Errno::ENOENT
  raise Error::RepoNotFound
end

#parse(as: :repos, out: Set.new) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/docker/template/parser.rb', line 31

def parse(as: :repos, out: Set.new)
  all.each do |val|
    hash = build_repo_hash(val)
    raise Docker::Template::Error::BadRepoName, val if hash.empty?
    out += as == :repos ? Repo.new(hash).to_repos : [hash]
  end
  out
end