You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@creadur.apache.org by rd...@apache.org on 2012/11/29 20:55:51 UTC

svn commit: r1415343 - in /creadur/whisker/trunk/apache-whisker-app/src: main/java/org/apache/creadur/whisker/app/ test/java/org/apache/creadur/whisker/app/

Author: rdonkin
Date: Thu Nov 29 19:55:50 2012
New Revision: 1415343

URL: http://svn.apache.org/viewvc?rev=1415343&view=rev
Log:
Configuration for source URLs in LICENSE files (or not)

Added:
    creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/LicenseConfiguration.java   (with props)
    creadur/whisker/trunk/apache-whisker-app/src/test/java/org/apache/creadur/whisker/app/TestWhisker.java   (with props)
Modified:
    creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/ConfigurationBuilder.java
    creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/Whisker.java

Modified: creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/ConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/ConfigurationBuilder.java?rev=1415343&r1=1415342&r2=1415343&view=diff
==============================================================================
--- creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/ConfigurationBuilder.java (original)
+++ creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/ConfigurationBuilder.java Thu Nov 29 19:55:50 2012
@@ -71,4 +71,14 @@ public class ConfigurationBuilder {
         return this;
     }
 
+    /**
+     * Adjusts the configuration.
+     * @param licenseConfiguration not null
+     * @return this builder, not null
+     */
+    public ConfigurationBuilder with(final LicenseConfiguration licenseConfiguration) {
+        includeSourceUrlsInLicense = licenseConfiguration.includeSourceUrlsInLicense();
+        return this;
+    }
+
 }

Added: creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/LicenseConfiguration.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/LicenseConfiguration.java?rev=1415343&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/LicenseConfiguration.java (added)
+++ creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/LicenseConfiguration.java Thu Nov 29 19:55:50 2012
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.creadur.whisker.app;
+
+/**
+ * Enumerates
+ */
+public enum LicenseConfiguration {
+    /** Include source URLs in the LICENSE (as well as the NOTICE) */
+    INCLUDE_SOURCE_URLS,
+    /** The essentials only. */
+    MINIMAL;
+
+    /**
+     * Default to include source URLs.
+     */
+    public static LicenseConfiguration DEFAULT_LICENSE_CONFIGURATION = INCLUDE_SOURCE_URLS;
+
+    /**
+     * Replaces null with DEFAULT_LICENSE_CONFIGURATION.
+     * @param configuration possibly null
+     * @return not null
+     */
+    public static LicenseConfiguration notNull(final LicenseConfiguration configuration) {
+        final LicenseConfiguration result;
+        if (configuration == null) {
+            result = DEFAULT_LICENSE_CONFIGURATION;
+        } else {
+            result = configuration;
+        }
+        return result;
+    }
+
+    /**
+     * Should source URLs be included in the LICENSE?
+     * @return true when source URLs should be included,
+     * false otherwise
+     */
+    public boolean includeSourceUrlsInLicense() {
+        return this == INCLUDE_SOURCE_URLS;
+    }
+}

Propchange: creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/LicenseConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/Whisker.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/Whisker.java?rev=1415343&r1=1415342&r2=1415343&view=diff
==============================================================================
--- creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/Whisker.java (original)
+++ creadur/whisker/trunk/apache-whisker-app/src/main/java/org/apache/creadur/whisker/app/Whisker.java Thu Nov 29 19:55:50 2012
@@ -18,6 +18,7 @@
  */
 package org.apache.creadur.whisker.app;
 
+import static org.apache.creadur.whisker.app.LicenseConfiguration.*;
 import static org.apache.creadur.whisker.app.ConfigurationBuilder.*;
 
 import java.io.IOException;
@@ -46,6 +47,26 @@ public class Whisker {
     private ResultWriterFactory writerFactory;
     /** Pluggable templating. */
     private AbstractEngine engine;
+    /** Configuration options for license rendering */
+    private LicenseConfiguration licenseConfiguration = DEFAULT_LICENSE_CONFIGURATION;
+
+    /**
+     * Gets the configuration options for license rendering.
+     * @return not null
+     */
+    public LicenseConfiguration getLicenseConfiguration() {
+        return licenseConfiguration;
+    }
+
+    /**
+     * Sets the configuration options for license rendering.
+     * @param licenseConfiguration not null
+     * @return this, not null
+     */
+    public Whisker setLicenseConfiguration(final LicenseConfiguration licenseConfiguration) {
+        this.licenseConfiguration = notNull(licenseConfiguration);
+        return this;
+    }
 
     /**
      * Gets the factory that builds product {@link Writer}s.
@@ -169,8 +190,8 @@ public class Whisker {
      * Builds a populated configuration.
      * @return not null
      */
-    private Configuration configuration() {
-        return aConfiguration().build();
+    public Configuration configuration() {
+        return aConfiguration().with(licenseConfiguration).build();
     }
 
     /**

Added: creadur/whisker/trunk/apache-whisker-app/src/test/java/org/apache/creadur/whisker/app/TestWhisker.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-app/src/test/java/org/apache/creadur/whisker/app/TestWhisker.java?rev=1415343&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-app/src/test/java/org/apache/creadur/whisker/app/TestWhisker.java (added)
+++ creadur/whisker/trunk/apache-whisker-app/src/test/java/org/apache/creadur/whisker/app/TestWhisker.java Thu Nov 29 19:55:50 2012
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.creadur.whisker.app;
+
+import junit.framework.TestCase;
+
+public class TestWhisker extends TestCase {
+
+    Whisker subject;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        subject = new Whisker();
+    }
+
+    public void testSetNullLicenseConfiguration() {
+        assertEquals(
+                subject.setLicenseConfiguration(null).getLicenseConfiguration(),
+                LicenseConfiguration.DEFAULT_LICENSE_CONFIGURATION);
+    }
+
+    public void testMinimalLicenseConfigurationConfiguresNoSourceUrls() {
+        assertFalse(
+                subject
+                    .setLicenseConfiguration(LicenseConfiguration.MINIMAL)
+                    .configuration().includeSourceURLsInLicense());
+    }
+
+    public void testIncludeSourceUrlsLicenseConfigurationConfiguresNoSourceUrls() {
+        assertTrue(
+                subject
+                    .setLicenseConfiguration(LicenseConfiguration.INCLUDE_SOURCE_URLS)
+                    .configuration().includeSourceURLsInLicense());
+    }
+
+}

Propchange: creadur/whisker/trunk/apache-whisker-app/src/test/java/org/apache/creadur/whisker/app/TestWhisker.java
------------------------------------------------------------------------------
    svn:eol-style = native