editor-open 0.1.1.0 → 0.2.0.0
raw patch · 5 files changed
+142/−5 lines, 5 filesdep +editor-opennew-component:exe:editor-open-test_yaml_filePVP ok
version bump matches the API change (PVP)
Dependencies added: editor-open
API changes (from Hackage documentation)
+ Text.Editor: wrapStr :: ByteString -> String
Files
- editor-open.cabal +16/−2
- res/bug-schema.json +43/−0
- res/bug-schema.yaml +33/−0
- src/Text/Editor.hs +13/−3
- tests/test_yaml_file.hs +37/−0
editor-open.cabal view
@@ -1,5 +1,5 @@ name: editor-open-version: 0.1.1.0+version: 0.2.0.0 synopsis: Open the user's $EDITOR for text input. description: You know when you run @git commit@, and an editor pops open so you can enter a@@ -19,6 +19,9 @@ bug-reports: https://notabug.org/pharpend/editor-open/issues/new extra-source-files: README.md+data-files:+ res/*.json+ res/*.yaml library -- other-modules: @@ -38,6 +41,17 @@ exposed-modules: Text.Editor +executable editor-open-test_yaml_file+ hs-source-dirs: tests/+ default-language: Haskell2010+ build-depends:+ base ==4.8.*+ , bytestring+ , editor-open+ main-is: test_yaml_file.hs+ -- other-modules: + -- other-extensions: + source-repository head type: git location: https://notabug.org/pharpend/editor-open.git@@ -45,4 +59,4 @@ source-repository this type: git location: https://notabug.org/pharpend/editor-open.git- tag: 0.1.1.0+ tag: 0.2.0.0
+ res/bug-schema.json view
@@ -0,0 +1,43 @@+{+ "name": "bug",+ "type": "object",+ "properties": {+ "bug-creation-date": {+ "required": true,+ "type": "string",+ "description": "The ISO 8601 date at which the bug was created."+ },+ "bug-comments": {+ "items": {+ "type": "object"+ },+ "type": "array",+ "description": "Comments on the bug. Each item should fit the comment schema."+ },+ "bug-id": {+ "required": true,+ "type": "string",+ "description": "Unique identifier for this bug. Should be a whirlpool hash of the title concat the time at which it was created."+ },+ "bug-description": {+ "required": false,+ "type": "string",+ "description": "An optional description of the bug."+ },+ "bug-open": {+ "required": true,+ "type": "boolean",+ "description": "Whether or not the bug is open"+ },+ "bug-reporter": {+ "required": false,+ "type": "object",+ "description": "The person who reported the bug. Object should fit the person schema."+ },+ "bug-title": {+ "required": true,+ "type": "string",+ "description": "The title of the bug."+ }+ }+}
+ res/bug-schema.yaml view
@@ -0,0 +1,33 @@+name: bug+type: object+properties:+ bug-creation-date:+ required: true+ type: string+ description: The ISO 8601 date at which the bug was created.+ bug-comments:+ items:+ type: object+ type: array+ description: Comments on the bug. Each item should fit the comment schema.+ bug-id:+ required: true+ type: string+ description: Unique identifier for this bug. Should be a whirlpool hash of the+ title concat the time at which it was created.+ bug-description:+ required: false+ type: string+ description: An optional description of the bug.+ bug-open:+ required: true+ type: boolean+ description: Whether or not the bug is open+ bug-reporter:+ required: false+ type: object+ description: The person who reported the bug. Object should fit the person schema.+ bug-title:+ required: true+ type: string+ description: The title of the bug.
src/Text/Editor.hs view
@@ -29,6 +29,7 @@ import qualified Data.ByteString as B import Data.ByteString (ByteString)+import Data.ByteString.Char8 (unpack) import Data.Monoid import System.IO import System.IO.Temp@@ -37,6 +38,15 @@ -- == Porcelain functions = +-- |If you don't want to use ByteString, use this function.+-- +-- >>> :t runUserEditorDWIM plainTemplate mempty+-- ByteString+-- >>> :t wrapStr <$> runUserEditorDWIM plainTemplate mempty+-- String+wrapStr :: ByteString -> String+wrapStr = unpack+ -- |This is most likely the function you want to use. It takes a file -- type template as an argument, along with what you want displayed -- when the user opens the editor. It then runs the editor, and@@ -209,9 +219,9 @@ hSetBinaryMode hdl True hSetBuffering hdl NoBuffering B.hPut hdl initialContents- callProcess editorName [filePath]- B.hGetContents hdl-+ hClose hdl+ waitForProcess =<< spawnProcess editorName [filePath]+ B.readFile filePath -- |This uses 'getEnv' from "System.Posix" to attempt to -- get the user's @$EDITOR@ variable.
+ tests/test_yaml_file.hs view
@@ -0,0 +1,37 @@+-- Copyright 2015 Peter Harpending+-- +-- Licensed 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.+++-- | +-- Module : Main+-- Description : Test of editor-open+-- Copyright : Copyright 2015 Peter Harpending+-- License : Apache-2.0+-- Maintainer : Peter Harpending <peter@harpending.org>+-- Stability : experimental+-- Portability : POSIX+-- ++module Main where++import qualified Data.ByteString as B+import Paths_editor_open+import System.IO+import Text.Editor++main :: IO ()+main =+ getDataFileName "res/bug-schema.yaml" >>=+ runUserEditorDWIMFile yamlTemplate >>=+ B.hPut stdout