New Upstream Snapshot - typesafe-config-clojure

Ready changes

Summary

Merged new upstream version: 0.2.0+git20220708.1.01dc399 (was: 0.1.5).

Resulting package

Built on 2023-01-19T15:30 (took 3m57s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots libtypesafe-config-clojure

Diff

diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index f466d77..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-*jar
-.lein-deps-sum
-.lein-failures
-.lein-repl-history
-/classes/
-/lib/
-/targets/
-pom.xml
-target/
diff --git a/.travis.yml b/.travis.yml
index 3652432..e6baf61 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,9 +1,14 @@
 language: clojure
-lein: lein2
+lein: 2.9.1
+
 jdk:
-  - oraclejdk7
-  - openjdk7
-script: ./ext/travisci/test.sh
+  - openjdk8
+  - openjdk11
+script: lein test
+
 notifications:
   email: false
 
+cache:
+  directories:
+    - $HOME/.m2
diff --git a/CODEOWNERS b/CODEOWNERS
new file mode 100644
index 0000000..97c7df0
--- /dev/null
+++ b/CODEOWNERS
@@ -0,0 +1 @@
+* @puppetlabs/dumpling
diff --git a/README.md b/README.md
index fe37daa..b100c53 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,3 @@ A thin clojure wrapper around the [Typesafe Config](https://github.com/typesafeh
 Add the following dependency to your `project.clj` file:
 
 [![Clojars Project](http://clojars.org/puppetlabs/typesafe-config/latest-version.svg)](http://clojars.org/puppetlabs/typesafe-config)
-
-## Support
-
-Please log tickets and issues at our [Jira Tracker](https://tickets.puppetlabs.com/issues/?jql=project%20%3D%20Trapperkeeper).
diff --git a/debian/changelog b/debian/changelog
index aa8ce94..31f573a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,9 +1,12 @@
-typesafe-config-clojure (0.1.5-2) UNRELEASED; urgency=normal
+typesafe-config-clojure (0.2.0+git20220708.1.01dc399-1) UNRELEASED; urgency=normal
 
   [ Louis-Philippe Véronneau ]
   * d/control: Migrate to the Clojure Team.
 
- -- Louis-Philippe Véronneau <pollo@debian.org>  Sat, 08 Jan 2022 17:54:19 -0500
+  [ Debian Janitor ]
+  * New upstream snapshot.
+
+ -- Louis-Philippe Véronneau <pollo@debian.org>  Thu, 19 Jan 2023 15:27:47 -0000
 
 typesafe-config-clojure (0.1.5-1) unstable; urgency=medium
 
diff --git a/ext/travisci/test.sh b/ext/travisci/test.sh
deleted file mode 100755
index db011da..0000000
--- a/ext/travisci/test.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-lein2 test
diff --git a/project.clj b/project.clj
index c20b8ce..d1b3727 100644
--- a/project.clj
+++ b/project.clj
@@ -1,4 +1,4 @@
-(defproject puppetlabs/typesafe-config "0.1.5"
+(defproject puppetlabs/typesafe-config "0.2.1-SNAPSHOT"
   :description "Thin Clojure wrapper around Typesafe Config library"
   :license {:name "Apache License, Version 2.0"
             :url "http://www.apache.org/licenses/LICENSE-2.0.html"}
@@ -8,8 +8,8 @@
   ;; requires lein 2.2.0+.
   :pedantic? :abort
 
-  :dependencies [[org.clojure/clojure "1.5.1"]
-                 [com.typesafe/config "1.2.0"]]
+  :dependencies [[org.clojure/clojure "1.8.0"]
+                 [com.typesafe/config "1.4.1"]]
 
   :plugins [[lein-release "1.0.5"]]
 
@@ -20,4 +20,4 @@
                                      :username :env/clojars_jenkins_username
                                      :password :env/clojars_jenkins_password
                                      :sign-releases false}]
-                        ["snapshots" "http://nexus.delivery.puppetlabs.net/content/repositories/snapshots/"]])
+                        ["snapshots" "https://artifactory.delivery.puppetlabs.net/artifactory/clojure-snapshots__local/"]])
diff --git a/src/puppetlabs/config/typesafe.clj b/src/puppetlabs/config/typesafe.clj
index d7da46e..db7f4f4 100644
--- a/src/puppetlabs/config/typesafe.clj
+++ b/src/puppetlabs/config/typesafe.clj
@@ -1,8 +1,9 @@
 (ns puppetlabs.config.typesafe
   (:import (java.util Map List)
            (com.typesafe.config ConfigFactory ConfigParseOptions ConfigSyntax
-                                Config))
-  (:require [clojure.java.io :as io]))
+                                Config ConfigValueFactory))
+  (:require [clojure.java.io :as io]
+            [clojure.walk :as walk]))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Private
@@ -12,7 +13,7 @@
 (defn strip-quotes
   "Given a string read from a config file, check to see if it begins and ends with
   double-quotes, and if so, remove them."
-  [s]
+  [^String s]
   {:pre [(string? s)]
    :post [(string? %)
           (not (and (.startsWith % "\"")
@@ -45,7 +46,7 @@
 (defn nested-java-map->map
   "Given a (potentially nested) java Map object read from a config file,
   convert it (potentially recursively) to a clojure map with keywordized keys."
-  [m]
+  [^Map m]
   {:pre [(instance? Map m)]
    :post [(map? %)
           (every? keyword? (keys %))]}
@@ -77,7 +78,7 @@
 
 (defn config->map
   "Converts an instance of `Config` to a more user-friendly clojure map"
-  [config]
+  [^Config config]
   {:pre [(instance? Config config)]
    :post [(map? %)]}
   (-> config
@@ -91,7 +92,8 @@
 
 (defn config-file->map
   "Given the path to a configuration file (of type .conf, .json, or .properties),
-  parse the file and return a clojure map representation of the data."
+  parse the file and return a clojure map representation of the data.
+  Returns empty map for non-existing file."
   [file-path]
   {:pre [(string? file-path)]
    :post [(map? %)]}
@@ -122,3 +124,12 @@
          (ConfigFactory/parseReader parse-options)
          config->map))))
 
+(defn map->string
+  "Serialize the clojure data structure `m` to string using the
+  typesafe config format. `m` is typically the result of a
+  `config-file->map` or `reader-map` with some modifications."
+  [m]
+  (-> m
+      walk/stringify-keys
+      ConfigValueFactory/fromAnyRef
+      .render))
diff --git a/test/puppetlabs/config/typesafe_test.clj b/test/puppetlabs/config/typesafe_test.clj
index 1eea68c..502e677 100644
--- a/test/puppetlabs/config/typesafe_test.clj
+++ b/test/puppetlabs/config/typesafe_test.clj
@@ -1,5 +1,5 @@
 (ns puppetlabs.config.typesafe_test
-  (:import (java.io FileInputStream))
+  (:import (java.io FileInputStream StringReader))
   (:require [puppetlabs.config.typesafe :as ts]
             [clojure.test :refer :all]))
 
@@ -33,8 +33,20 @@
     (let [cfg (ts/config-file->map (str test-files-dir "substitution.conf"))]
       (is (= {:top {:henry "text"
                     :bob "text"}}
+             cfg))))
+  (testing "returns empty result for non-existing file"
+    (let [cfg (ts/config-file->map (str test-files-dir "non-existing-file.conf"))]
+      (is (= {}
              cfg)))))
 
+(defn round-trip-config
+  "Converts cfg (clojure representation of a config) to a string, then
+  back to clojure data structures"
+  [cfg]
+  (-> cfg
+      ts/map->string
+      StringReader.
+      ts/reader->map))
 
 (deftest reader->map-test
   (testing "can parse .properties stream with nested data structures"
@@ -45,7 +57,8 @@
                     :baz "bazbaz"
                     :bam 42
                     :bap {:boozle "boozleboozle"}}}
-             cfg))))
+             cfg))
+      (is (= cfg (round-trip-config cfg)))))
   (testing "can parse .json stream with nested data structures"
     (let [cfg (ts/reader->map
                 (FileInputStream. (str test-files-dir "config.json"))
@@ -55,7 +68,8 @@
                     :bam 42
                     :bap {:boozle "boozleboozle"
                           :bip [1 2 {:hi "there"} 3]}}}
-             cfg))))
+             cfg))
+      (is (= cfg (round-trip-config cfg)))))
   (testing "can parse .conf stream with nested data structures"
     (let [cfg (ts/reader->map
                 (FileInputStream. (str test-files-dir "config.conf"))
@@ -65,13 +79,13 @@
                     :bam 42
                     :bap {:boozle "boozleboozle"
                           :bip [1 2 {:hi "there"} 3]}}}
-             cfg))))
+             cfg))
+      (is (= cfg (round-trip-config cfg)))))
   (testing "can parse .conf file with substitution variables"
     (let [cfg (ts/reader->map
                 (FileInputStream. (str test-files-dir "substitution.conf"))
                 :conf)]
       (is (= {:top {:henry "text"
                     :bob "text"}}
-             cfg)))))
-
-
+             cfg))
+      (is (= cfg (round-trip-config cfg))))))

Debdiff

[The following lists of changes regard files as different if they have different names, permissions or owners.]

Files in second set of .debs but not in first

-rw-r--r--  root/root   /usr/share/java/clj-typesafe-config-0.2.0+git20220708.1.01dc399.jar
lrwxrwxrwx  root/root   /usr/share/java/clj-typesafe-config.jar -> clj-typesafe-config-0.2.0+git20220708.1.01dc399.jar

Files in first set of .debs but not in second

-rw-r--r--  root/root   /usr/share/java/clj-typesafe-config-0.1.5.jar
lrwxrwxrwx  root/root   /usr/share/java/clj-typesafe-config.jar -> clj-typesafe-config-0.1.5.jar

No differences were encountered in the control files

More details

Full run details