Skip to content
Haskell library to parse a subset of Ruby objects serialised with Marshal.dump
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
src/Data/Ruby
test
.ghci
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
Setup.hs
example.bin
ruby-marshal.cabal
stack-7.10.yaml
stack-7.8.yaml
stack-8.0.yaml
stack-8.4.yaml
stack.yaml
upload-docs

README.md

ruby-marshal

Build Status

Haskell library to parse a subset of Ruby objects serialised with Marshal.dump.

Supported Types

  • NilClass
  • TrueClass | FalseClass
  • Array
  • Fixnum
  • Float
  • Hash
  • String
  • Symbol

If you would like to add support for another type, please feel free to create an issue or open a pull request using the guidelines below.

Usage

Example

{-# LANGUAGE OverloadedStrings #-}

module Main where

import Data.Ruby.Marshal
import Data.ByteString  (ByteString)
import System.Directory (getCurrentDirectory)

import qualified Data.ByteString as BS
import qualified Data.Map.Strict as DM

lookupUserID :: (ByteString, RubyStringEncoding)
             -> RubyObject
             -> Maybe (ByteString, RubyStringEncoding)
lookupUserID key hash = fromRuby hash >>= \cookie -> DM.lookup key cookie

main :: IO ()
main = do
  dir <- getCurrentDirectory
  rbs <- BS.readFile (mconcat [dir, "/test/bin/railsCookie.bin"])
  print $
    case decode rbs of
      Just cookie -> lookupUserID ("user_id", UTF_8) cookie
      Nothing     -> Nothing

Contributing

  1. Fork it.
  2. Create your feature branch (git checkout -b my-new-feature).
  3. Commit your changes (git commit -am 'Add some feature').
  4. Push to the branch (git push origin my-new-feature).
  5. Create new Pull Request.

Contributors

Similar Libraries

You can’t perform that action at this time.