• Stars
    star
    22
  • Rank 1,015,372 (Top 21 %)
  • Language
    Crystal
  • License
    MIT License
  • Created almost 9 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Mimetypes for Crystal, based on node-mime.

mime

Mimetypes for Crystal.

Installation

Add it to shard.yml file

dependencies:
  mime:
    github: spalger/crystal-mime
    version: ~> 0.1

Usage

require "mime"

This simple module maps mime-types and extensions. Read the map using either the from_ext or to_ext methods.

Mime.from_ext(extension)

Read the mime-type for an extension. Returns tye mime-type as a string, or nil if the extension is unknown.

require "mime"
Mime.from_ext("jpg") # "image/jpeg"
Mime.from_ext("js")  # "application/javascript"
Mime.from_ext("jssssss")  # nil

Mime.to_ext(type)

Read the first extension registered for a mime-type. Returns the extension as a string or nil is the mime-type is unknown.

require "mime"
Mime.to_ext("image/jpeg") # "jpeg"
Mime.to_ext("application/javascript")  # "js"

Development

Type files are pulled from the node-mime project. To update the types.json file run

make update_types

Contributing

  1. Fork it ( https://github.com/spalger/crystal-mime/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

  • spalger Spencer Alger - creator, maintainer

More Repositories

1

gulp-jshint

JSHint plugin for gulp
JavaScript
418
star
2

elasticsearch-angular-example

This is a very simple project designed to help people get going with angular and elasticsearch.
HTML
101
star
3

grunt-run

Invite external commands into your grunt process with three tasks run, wait and stop.
JavaScript
26
star
4

kibana-plugin-boilerplate

Super Simple Kibana Plugin Boilerplate
JavaScript
15
star
5

rcloader

For build system plugins that need to fetch relative config files (like .jshintrc).
JavaScript
13
star
6

redux-async-actions

Simple wrapper around common async action handling
JavaScript
9
star
7

esjs-angular2-test

HTML
3
star
8

http-asset

Class for fetching and caching an asset over http
JavaScript
2
star
9

fcb

Convert callbacks to promises
JavaScript
2
star
10

rcfinder

Find a config file (like .foorc) by walking up from a specific directory
JavaScript
2
star
11

observable-rpc

JavaScript
2
star
12

kibana-hacks

A collection of hacks for kibana
JavaScript
2
star
13

webpack-node-test-runner

Tool to help running tests built with webpack in node
JavaScript
2
star
14

html5-static-boilerplate

Boilerplate for building a static site using es6 and webcomponents.
JavaScript
2
star
15

deku-scrub

deku extensions for increased awesome
JavaScript
1
star
16

enhance

Feature request tracker
JavaScript
1
star
17

advent-of-code

My advent of code solutions
TypeScript
1
star
18

fbox

Simple flex-box grid thingy
CSS
1
star
19

micro-plus

Some helpers for working with micro
TypeScript
1
star
20

holidayjs

Magnificent sweater creator
JavaScript
1
star
21

sample-sledgehammer-kibana-plugin

JavaScript
1
star
22

expect-to-enzyme

expect-to assertion helpers for use with enzyme
JavaScript
1
star
23

vis-walk-through-example

JavaScript
1
star
24

bower-registry-editor

Super simple express app to let people edit their own bower packages
CSS
1
star
25

bs-less

basic breakdown of bootstrap to just less
CSS
1
star
26

fromnode

extraction of Bluebird's fromNode method
JavaScript
1
star
27

kpocs

JavaScript
1
star
28

adt-door-monitor

check the ADT Pulse dashboard for the status of doors in your house
JavaScript
1
star
29

kibana-jenkins

Experimental Kibana plugin that pulls in data from the Jenkins API
TypeScript
1
star
30

gulp-jshint-file-reporter

Super simple reporter that writes gulp-jshint output to a file.
JavaScript
1
star