| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| MkGitignores | 
 | 
 | 1.5;1.5 | ||||
| MkGitignores$AjcClosure1 | 
 | 
 | 1.5;1.5 | ||||
| MkGitignores$AjcClosure3 | 
 | 
 | 1.5;1.5 | ||||
| MkGitignores$AjcClosure5 | 
 | 
 | 1.5;1.5 | 
| 1 | 2 |  /** | 
| 2 |   * Copyright (c) 2013-2017, jcabi.com | |
| 3 |   * All rights reserved. | |
| 4 |   * | |
| 5 |   * Redistribution and use in source and binary forms, with or without | |
| 6 |   * modification, are permitted provided that the following conditions | |
| 7 |   * are met: 1) Redistributions of source code must retain the above | |
| 8 |   * copyright notice, this list of conditions and the following | |
| 9 |   * disclaimer. 2) Redistributions in binary form must reproduce the above | |
| 10 |   * copyright notice, this list of conditions and the following | |
| 11 |   * disclaimer in the documentation and/or other materials provided | |
| 12 |   * with the distribution. 3) Neither the name of the jcabi.com nor | |
| 13 |   * the names of its contributors may be used to endorse or promote | |
| 14 |   * products derived from this software without specific prior written | |
| 15 |   * permission. | |
| 16 |   * | |
| 17 |   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 18 |   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT | |
| 19 |   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
| 20 |   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
| 21 |   * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
| 22 |   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 23 |   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| 24 |   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 25 |   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
| 26 |   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 27 |   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
| 28 |   * OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 |   */ | |
| 30 |  package com.jcabi.github.mock; | |
| 31 | ||
| 32 |  import com.jcabi.aspects.Immutable; | |
| 33 |  import com.jcabi.aspects.Loggable; | |
| 34 |  import com.jcabi.github.Github; | |
| 35 |  import com.jcabi.github.Gitignores; | |
| 36 |  import java.io.IOException; | |
| 37 |  import java.util.Collections; | |
| 38 |  import java.util.Map; | |
| 39 |  import lombok.EqualsAndHashCode; | |
| 40 |  import lombok.ToString; | |
| 41 | ||
| 42 |  /** | |
| 43 |   * Mock Gitignore. | |
| 44 |   * @author Paul Polishchuk (ppol@ua.fm) | |
| 45 |   * @version $Id: f9a50f8f20f25ecd1eccd1a4628b406b50b59406 $ | |
| 46 |   * @since 0.8 | |
| 47 |   */ | |
| 48 | @Immutable | |
| 49 | @Loggable(Loggable.DEBUG) | |
| 50 | 0 |  @ToString | 
| 51 | 0 |  @EqualsAndHashCode(of = { "ghub" }) | 
| 52 |  @SuppressWarnings("PMD.UseConcurrentHashMap") | |
| 53 | final class MkGitignores implements Gitignores { | |
| 54 | ||
| 55 |      /** | |
| 56 |       * The gitignore templates. | |
| 57 |       */ | |
| 58 | 2 | private static final Map<String, String> GITIGNORES = | 
| 59 | 1 | Collections.singletonMap( | 
| 60 |              "Java", | |
| 61 |              "*.class\n\n# Package Files #\n*.jar\n*.war\n*.ear\n" | |
| 62 | ); | |
| 63 | ||
| 64 |      /** | |
| 65 |       * Github. | |
| 66 |       */ | |
| 67 | private final transient MkGithub ghub; | |
| 68 | ||
| 69 |      /** | |
| 70 |       * Public ctor. | |
| 71 |       * @param github The github | |
| 72 |       */ | |
| 73 | 2 |      MkGitignores(final MkGithub github) { | 
| 74 | 2 |          this.ghub = github; | 
| 75 | 2 | } | 
| 76 | ||
| 77 | @Override | |
| 78 |      public Github github() { | |
| 79 | 0 |          return this.ghub; | 
| 80 | } | |
| 81 | ||
| 82 | @Override | |
| 83 | public Iterable<String> iterate() throws IOException { | |
| 84 | 2 |          return GITIGNORES.keySet(); | 
| 85 | } | |
| 86 | ||
| 87 | @Override | |
| 88 |      public String template( | |
| 89 | final String name) throws IOException { | |
| 90 | 2 |          final String template = GITIGNORES.get(name); | 
| 91 | 1 |          if (template == null) { | 
| 92 | 0 |              throw new IllegalArgumentException("Template not found."); | 
| 93 | } | |
| 94 | 1 |          return template; | 
| 95 | } | |
| 96 | } |