diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e5d8fd..c27bfd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Change Log All notable changes to this project will be documented in this file. +## [1.2.1] - 2021-02-12 +Wrap querying features from the `query` namespace in the `email` namespace. + ## [1.2.0] - 2021-02-12 Add `query` namespace, that can be used to extract file names or find an attachment by name. diff --git a/README.md b/README.md index 8a30e1b..41b500b 100644 --- a/README.md +++ b/README.md @@ -30,13 +30,13 @@ email/pdf? email/xml? ``` -There is also a `query` namespace that can be used to extract file names or find an attachment by name: +There are also querying helpers, that can be used to extract file names or find an attachment by name: ``` clojure -(query/filenames content-types) ;; pass in the result from the email/content-types function -(query/filename content-type) ;; pass in one item from the seq of email/content-types result +(email/filenames content-types) ;; pass in the result from the email/content-types function +(email/filename content-type) ;; pass in one item from the seq of email/content-types result -(query/find-in content-types "my-filename.csv") +(email/find-in content-types "my-filename.csv") ``` Example output from the `email/content-types` function: diff --git a/project.clj b/project.clj index eb45a29..3da9036 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject email-attachments "1.2.0" +(defproject email-attachments "1.2.1" :description "makes extracting email attachments simple" :url "https://github.com/DavidVujic/email-attachments" :license {:name "The MIT License (MIT)" diff --git a/src/email_attachments/email.clj b/src/email_attachments/email.clj index f4a5360..9a32233 100644 --- a/src/email_attachments/email.clj +++ b/src/email_attachments/email.clj @@ -1,6 +1,7 @@ (ns email-attachments.email (:require [clojure.string :as str] - [email-attachments.message :as message])) + [email-attachments.message :as message] + [email-attachments.query :as query])) (defn- content-type? [m type] (-> m @@ -38,3 +39,12 @@ (->> email-input-stream message/stream->mime-message message/body)) + +(defn filename [message-map] + (query/filename message-map)) + +(defn filenames [content-types] + (query/filenames content-types)) + +(defn find-in [content-types filename] + (query/find-in content-types filename)) diff --git a/test/email_attachments/email_test.clj b/test/email_attachments/email_test.clj index 6549f3d..0af32c4 100644 --- a/test/email_attachments/email_test.clj +++ b/test/email_attachments/email_test.clj @@ -1,7 +1,6 @@ (ns email-attachments.email-test (:require [clojure.java.io :as io] - [email-attachments.email :as email] - [email-attachments.query :as query])) + [email-attachments.email :as email])) (comment (->> "emails/example2.eml" @@ -20,13 +19,13 @@ io/input-stream email/content-types first - query/filename)) + email/filename)) (comment (->> "emails/example2.eml" io/input-stream email/content-types - query/filenames)) + email/filenames)) (comment (def content-types (->> "emails/example4.eml" @@ -34,4 +33,4 @@ email/content-types)) (def filename "email-exempel.csv") - (query/find-in content-types filename)) + (email/find-in content-types filename))