human_file_size.cr

Human File Size Converter, for JSON & YAML mappings - Crystal-Lang

human_file_size.cr

Build Status serializes and deserializes file sizes (in human readable format), within json or yaml mappings

Installation

Add this to your application's shard.yml:

dependencies:
  human_file_size:
    github: johnjansen/human_file_size.cr

Usage

require "human_file_size"

class ConverterExample
  getter :file_size

  YAML.mapping(
    file_size: {
      type:      BigFloat,
      converter: HumanFileSize,
    }
  )

  JSON.mapping(
    file_size: {
      type:      BigFloat,
      converter: HumanFileSize,
    }
  )
end

ce = ConverterExample.from_yaml("file_size: \"1 KB\"")
ce.to_yaml => "1000 B" # always writes as bytes at the moment

Contributing

  1. Fork it ( https://github.com/johnjansen/human_file_size.cr/fork )
  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 a new Pull Request

Contributors

Repository

human_file_size.cr

Owner
Statistic
  • 1
  • 0
  • 1
  • 0
  • 0
  • about 7 years ago
  • August 30, 2017
License

MIT License

Links
Synced at

Mon, 18 Nov 2024 02:24:38 GMT

Languages