summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorv0d1ch <>2017-08-12 21:03:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2017-08-12 21:03:00 (GMT)
commitd4fb7725a805f519e4390faa3eb6a5c40d5d49d4 (patch)
tree4e6640c8e019f39bcdb4a340faf295d09624373f
parent84f27ba5ea7b6298760720e0bd94cbda783c9228 (diff)
version 0.1.0.1HEAD0.1.0.1master
-rw-r--r--LICENSE4
-rw-r--r--nmis-parser.cabal4
-rw-r--r--nmis-parser.cabal~40
-rw-r--r--src/Text/Internal/.DS_Store (renamed from .DS_Store)bin6148 -> 6148 bytes
-rw-r--r--src/Text/Internal/._.DS_Store (renamed from ._.DS_Store)bin120 -> 120 bytes
-rw-r--r--src/Text/Internal/Helper.hs~84
-rw-r--r--src/Text/Internal/NmisTypes.hs~36
7 files changed, 44 insertions, 124 deletions
diff --git a/LICENSE b/LICENSE
index 6a042c2..844078b 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright Author name here (c) 2017
+Copyright Sasa Bogicevic (c) 2017
All rights reserved.
@@ -27,4 +27,4 @@ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/nmis-parser.cabal b/nmis-parser.cabal
index a2af7b1..861598f 100644
--- a/nmis-parser.cabal
+++ b/nmis-parser.cabal
@@ -1,5 +1,5 @@
name: nmis-parser
-version: 0.1.0.0
+version: 0.1.0.1
synopsis: NMIS file parser
homepage: https://github.com/v0d1ch/nmis-parser#readme
license: BSD3
@@ -22,7 +22,7 @@ library
, Text.Internal.NmisTypes
build-depends: base >= 4.7 && < 5
, containers
- , megaparsec
+ , megaparsec < 5.3.2
default-language: Haskell2010
diff --git a/nmis-parser.cabal~ b/nmis-parser.cabal~
new file mode 100644
index 0000000..f370d9c
--- /dev/null
+++ b/nmis-parser.cabal~
@@ -0,0 +1,40 @@
+name: nmis-parser
+version: 0.1.0.0
+synopsis: NMIS file parser
+homepage: https://github.com/v0d1ch/nmis-parser#readme
+license: BSD3
+license-file: LICENSE
+author: Sasa Bogicevic
+maintainer: brutallesale@gmail.com
+copyright: 2017 Sasa Bogicevic
+category: Text, Parsers
+build-type: Simple
+extra-source-files: README.md
+cabal-version: >=1.10
+
+description:
+ Parser for __NMIS__ (Network Management Information System) files to record type. Main module to use is __Text.Nmis__ and __parseNmis__ function
+
+library
+ hs-source-dirs: src
+ exposed-modules: Text.Nmis
+ , Text.Internal.Helper
+ , Text.Internal.NmisTypes
+ build-depends: base >= 4.7 && < 5
+ , containers
+ , megaparsec < 5.3.2
+ default-language: Haskell2010
+
+
+test-suite nmis-test
+ type: exitcode-stdio-1.0
+ hs-source-dirs: test
+ main-is: Spec.hs
+ build-depends: base
+ , Nmis
+ ghc-options: -threaded -rtsopts -with-rtsopts=-N
+ default-language: Haskell2010
+
+source-repository head
+ type: git
+ location: https://github.com/v0d1ch/nmis-parser
diff --git a/.DS_Store b/src/Text/Internal/.DS_Store
index 06a26f3..5008ddf 100644
--- a/.DS_Store
+++ b/src/Text/Internal/.DS_Store
Binary files differ
diff --git a/._.DS_Store b/src/Text/Internal/._.DS_Store
index 09fa6bd..09fa6bd 100644
--- a/._.DS_Store
+++ b/src/Text/Internal/._.DS_Store
Binary files differ
diff --git a/src/Text/Internal/Helper.hs~ b/src/Text/Internal/Helper.hs~
deleted file mode 100644
index c0eebc9..0000000
--- a/src/Text/Internal/Helper.hs~
+++ /dev/null
@@ -1,84 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
--- | This helper module contains functions to parse nmis file.
--- It uses megapasec library
-module Helper where
-
-import Control.Applicative (empty)
-import Control.Monad (void)
-import Prelude hiding (until)
-import Text.Megaparsec
-import qualified Text.Megaparsec.Lexer as L
-import Text.Megaparsec.String
-
--- | space consumer - consume space and comments
-spaceConsumer :: Parser ()
-spaceConsumer = L.space (void spaceChar) lineCmnt blockCmnt
- where
- lineCmnt = L.skipLineComment "#"
- blockCmnt = L.skipBlockComment "/*" "*/"
--- | hashbang line comment
-lineComment :: Parser ()
-lineComment = L.skipLineComment "#"
-
--- | space consumer no 2
-scn :: Parser ()
-scn = L.space (void spaceChar) lineComment empty
-
--- | lexeme
-lexeme :: Parser a -> Parser a
-lexeme = L.lexeme spaceConsumer
-
--- | symbol
-symbol :: String -> Parser String
-symbol = L.symbol scn
-
--- | arrow - parse haskell constraint like arrow sign
-parrow :: Parser String
-parrow = lexeme $ string " => "
-
--- | equals - parse equals sign
-pequals :: Parser String
-pequals = lexeme $ string " = "
-
--- | parse all between parens
-parens :: Parser a -> Parser a
-parens = between (string "(") (string ")")
-
--- | parse all between braces
-braces :: Parser a -> Parser a
-braces = between (string "{") (string "}")
-
--- | parse until string passed as function parameter
-until :: String -> Parsec Dec String String
-until s = anyChar `manyTill` string s
-
--- | parse until newline character
-untilEol :: Parsec Dec String String
-untilEol = anyChar `someTill` newline
-
--- | parse until newline character
-phash :: Parser String
-phash = lexeme $ string' "%hash" >> pequals
-
--- | parse quoted string with optional space in front of it
-pQuotedStr :: Parser String
-pQuotedStr = do
- _ <- optional space
- string' "'" >> until "'"
-
--- | parse 'undef' literal
-pUndefined :: Parser String
-pUndefined = do
- _ <- optional space
- string' "undef"
-
--- | combined parser for single record
-pOpt :: Parser (String, String)
-pOpt = do
- _ <- space
- key <- pQuotedStr
- _ <- space >> string "=>" >> space
- value <- try (pQuotedStr <|> pUndefined <|> many numberChar)
- _ <- optional $ string' ","
- _ <- newline
- return (key, value)
diff --git a/src/Text/Internal/NmisTypes.hs~ b/src/Text/Internal/NmisTypes.hs~
deleted file mode 100644
index 31136c9..0000000
--- a/src/Text/Internal/NmisTypes.hs~
+++ /dev/null
@@ -1,36 +0,0 @@
-module NmisTypes where
-
--- | Main type that containes all parsed data
-data Nmis = Nmis
- { customer :: Maybe String
- , groups :: Maybe String
- , active :: Maybe String
- , advancedOptions :: Maybe String
- , authKey :: Maybe String
- , authPassword :: Maybe String
- , authProtocol :: Maybe String
- , businessService :: Maybe String
- , calls :: Maybe String
- , cbqos :: Maybe String
- , collect :: Maybe String
- , community :: Maybe String
- , depend :: Maybe String
- , display_name :: Maybe String
- , group :: Maybe String
- , host :: Maybe String
- , location :: Maybe String
- , model :: Maybe String
- , name :: Maybe String
- , netType :: Maybe String
- , ping :: Maybe String
- , port :: Maybe String
- , rancid :: Maybe String
- , roleType :: Maybe String
- , serviceStatus :: Maybe String
- , services :: Maybe String
- , threshold :: Maybe String
- , timezone :: Maybe Integer
- , uuid :: Maybe String
- , version :: Maybe String
- , webserver :: Maybe String
- } deriving (Show)