EMMA Coverage Report (generated Wed Jun 22 19:47:49 EDT 2011)
[all classes][org.jclouds.scriptbuilder.domain]

COVERAGE SUMMARY FOR SOURCE FILE [PipeHttpResponseTo.java]

nameclass, %method, %block, %line, %
PipeHttpResponseTo.java100% (2/2)100% (4/4)100% (69/69)100% (6/6)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PipeHttpResponseTo100% (1/1)100% (2/2)100% (51/51)100% (4/4)
PipeHttpResponseTo (Statement, String, URI, Multimap): void 100% (1/1)100% (39/39)100% (2/2)
render (OsFamily): String 100% (1/1)100% (12/12)100% (2/2)
     
class PipeHttpResponseTo$1100% (1/1)100% (2/2)100% (18/18)100% (2/2)
PipeHttpResponseTo$1 (): void 100% (1/1)100% (3/3)100% (1/1)
apply (Map$Entry): String 100% (1/1)100% (15/15)100% (1/1)

1/**
2 *
3 * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4 *
5 * ====================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ====================================================================
18 */
19package org.jclouds.scriptbuilder.domain;
20 
21import static com.google.common.base.Preconditions.checkArgument;
22 
23import java.net.URI;
24import java.util.Map.Entry;
25 
26import com.google.common.base.Function;
27import com.google.common.base.Joiner;
28import com.google.common.collect.Iterables;
29import com.google.common.collect.Multimap;
30 
31/**
32 * Pipes the content of the http response to a shell command that accepts input from stdin
33 * 
34 * @author Adrian Cole
35 */
36public class PipeHttpResponseTo extends InterpretableStatement {
37   /**
38    * 
39    * @param toExec
40    *           what to invoke
41    * @param method
42    *           http method: ex GET
43    * @param endpoint
44    *           uri corresponding to the request
45    * @param headers
46    *           request headers to send
47    */
48   public PipeHttpResponseTo(Statement toExec, String method, URI endpoint, Multimap<String, String> headers) {
49      super(String.format("curl -X %s -s --retry 20 %s %s |(%s)\n", method, Joiner.on(' ').join(
50               Iterables.transform(headers.entries(), new Function<Entry<String, String>, String>() {
51 
52                  @Override
53                  public String apply(Entry<String, String> from) {
54                     return String.format("-H \"%s: %s\"", from.getKey(), from.getValue());
55                  }
56 
57               })), endpoint.toASCIIString(), toExec.render(OsFamily.UNIX)));
58   }
59 
60   public String render(OsFamily family) {
61      checkArgument(family != OsFamily.WINDOWS, "windows not supported");
62      return super.render(family);
63   }
64}

[all classes][org.jclouds.scriptbuilder.domain]
EMMA 2.0.5312 (C) Vladimir Roubtsov