commit ghc-file-embed for openSUSE:Factory
Hello community,
here is the log from the commit of package ghc-file-embed for openSUSE:Factory checked in at 2016-04-30 23:30:18
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-file-embed (Old)
and /work/SRC/openSUSE:Factory/.ghc-file-embed.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-file-embed"
Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-file-embed/ghc-file-embed.changes 2016-01-28 17:25:30.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.ghc-file-embed.new/ghc-file-embed.changes 2016-04-30 23:30:19.000000000 +0200
@@ -1,0 +2,6 @@
+Tue Apr 26 08:25:43 UTC 2016 - mimi.vx@gmail.com
+
+- update to 0.0.10
+* makeRelativeToProject
+
+-------------------------------------------------------------------
Old:
----
file-embed-0.0.9.1.tar.gz
New:
----
file-embed-0.0.10.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ ghc-file-embed.spec ++++++
--- /var/tmp/diff_new_pack.V9LzF2/_old 2016-04-30 23:30:20.000000000 +0200
+++ /var/tmp/diff_new_pack.V9LzF2/_new 2016-04-30 23:30:20.000000000 +0200
@@ -21,7 +21,7 @@
%bcond_without tests
Name: ghc-file-embed
-Version: 0.0.9.1
+Version: 0.0.10
Release: 0
Summary: Use Template Haskell to embed file contents directly
License: BSD-2-Clause
++++++ file-embed-0.0.9.1.tar.gz -> file-embed-0.0.10.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/file-embed-0.0.9.1/ChangeLog.md new/file-embed-0.0.10/ChangeLog.md
--- old/file-embed-0.0.9.1/ChangeLog.md 2016-01-20 08:30:52.000000000 +0100
+++ new/file-embed-0.0.10/ChangeLog.md 2016-04-21 17:33:11.000000000 +0200
@@ -1,3 +1,7 @@
+## 0.0.10
+
+* `makeRelativeToProject`
+
## 0.0.9
* embedStringFile [#14](https://github.com/snoyberg/file-embed/pull/14)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/file-embed-0.0.9.1/Data/FileEmbed.hs new/file-embed-0.0.10/Data/FileEmbed.hs
--- old/file-embed-0.0.9.1/Data/FileEmbed.hs 2016-01-20 08:30:52.000000000 +0100
+++ new/file-embed-0.0.10/Data/FileEmbed.hs 2016-04-21 17:33:11.000000000 +0200
@@ -35,6 +35,8 @@
, injectFile
, injectWith
, injectFileWith
+ -- * Relative path manipulation
+ , makeRelativeToProject
-- * Internal
, stringToBs
, bsToExp
@@ -50,12 +52,13 @@
#endif
, Q
, runIO
+ , qLocation, loc_filename
#if MIN_VERSION_template_haskell(2,7,0)
, Quasi(qAddDependentFile)
#endif
)
import System.Directory (doesDirectoryExist, doesFileExist,
- getDirectoryContents)
+ getDirectoryContents, canonicalizePath)
import Control.Exception (throw, ErrorCall(..))
import Control.Monad (filterM)
import qualified Data.ByteString as B
@@ -64,7 +67,7 @@
import Control.Applicative ((<$>))
import Data.ByteString.Unsafe (unsafePackAddressLen)
import System.IO.Unsafe (unsafePerformIO)
-import System.FilePath ((>))
+import System.FilePath ((>), takeDirectory, takeExtension)
import Data.String (fromString)
import Prelude as P
@@ -336,3 +339,42 @@
available, you can use the non-@With@ variants.
-}
+
+-- | Take a relative file path and attach it to the root of the current
+-- project.
+--
+-- The idea here is that, when building with Stack, the build will always be
+-- executed with a current working directory of the root of the project (where
+-- your .cabal file is located). However, if you load up multiple projects with
+-- @stack ghci@, the working directory may be something else entirely.
+--
+-- This function looks at the source location of the Haskell file calling it,
+-- finds the first parent directory with a .cabal file, and uses that as the
+-- root directory for fixing the relative path.
+--
+-- @@@
+-- $(makeRelativeToProject "data/foo.txt" >>= fileEmbed)
+-- @@@
+--
+-- @since 0.0.10
+makeRelativeToProject :: FilePath -> Q FilePath
+makeRelativeToProject rel = do
+ loc <- qLocation
+ runIO $ do
+ srcFP <- canonicalizePath $ loc_filename loc
+ mdir <- findProjectDir srcFP
+ case mdir of
+ Nothing -> error $ "Could not find .cabal file for path: " ++ srcFP
+ Just dir -> return $ dir > rel
+ where
+ findProjectDir x = do
+ let dir = takeDirectory x
+ if dir == x
+ then return Nothing
+ else do
+ contents <- getDirectoryContents dir
+ if any isCabalFile contents
+ then return (Just dir)
+ else findProjectDir dir
+
+ isCabalFile fp = takeExtension fp == ".cabal"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/file-embed-0.0.9.1/file-embed.cabal new/file-embed-0.0.10/file-embed.cabal
--- old/file-embed-0.0.9.1/file-embed.cabal 2016-01-20 08:30:52.000000000 +0100
+++ new/file-embed-0.0.10/file-embed.cabal 2016-04-21 17:33:11.000000000 +0200
@@ -1,5 +1,5 @@
name: file-embed
-version: 0.0.9.1
+version: 0.0.10
license: BSD3
license-file: LICENSE
author: Michael Snoyman
participants (1)
-
root@hilbert.suse.de