Method: AppDeploy.each

Defined in:
lib/app-deploy/utils.rb

.each(*with) ⇒ Object



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
61
62
# File 'lib/app-deploy/utils.rb', line 35

def each *with
  # yield common gem first, github gem last
  with = [:gem, :github] if with.empty?
  cwd = Dir.pwd

  # github's gem would be in @github and @gem,
  # so call uniq to ensure it wouldn't get called twice.
  with.map{ |kind| AppDeploy.send(kind) }.flatten.uniq.each{ |opts|
    puts

    if opts[:github_project]
      if File.directory?(opts[:git_path])
        begin
          Dir.chdir(opts[:git_path])
          yield(opts)
        rescue RuntimeError => e
          puts e
        ensure
          Dir.chdir(cwd)
        end
      else
        puts "Skip #{opts[:github_project]}, because it was not found"
      end
    else # it's a plain gem
      yield(opts)
    end
  }
end