Method: VMC::Cli::ManifestHelper#each_app

Defined in:
lib/cli/manifest_helper.rb

#each_app(panic = true) ⇒ Object

take a block and call it once for each app to push/update. with @application and @app_info set appropriately



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/cli/manifest_helper.rb', line 18

def each_app(panic=true)
  if @manifest and all_apps = @manifest["applications"]
    where = File.expand_path(@path)
    single = false

    all_apps.each do |path, info|
      app = File.expand_path("../" + path, manifest_file)
      if where.start_with?(app)
        @application = app
        @app_info = info
        yield info["name"]
        single = true
        break
      end
    end

    unless single
      if where == File.expand_path("../", manifest_file)
        ordered_by_deps(all_apps).each do |path, info|
          app = File.expand_path("../" + path, manifest_file)
          @application = app
          @app_info = info
          yield info["name"]
        end
      else
        err "Path '#{@path}' is not known to manifest '#{manifest_file}'."
      end
    end
  else
    @application = @path
    @app_info = @manifest
    if @app_info
      yield @app_info["name"]
    elsif panic
      err "No applications."
    end
  end

  nil
ensure
  @application = nil
  @app_info = nil
end