Added support for Crystal language

This commit is contained in:
Mark Tofan 2016-04-07 00:00:20 +03:00
parent 9add49118e
commit 0df1d8a5df
6 changed files with 145 additions and 0 deletions

View File

@ -0,0 +1,49 @@
# A unicorn is a **legendary animal** (see the `Legendary` module) that has been
# described since antiquity as a beast with a large, spiraling horn projecting
# from its forhead.
#
# To create a unicorn:
#
# ```
# unicorn = Unicorn.new
# unicorn.speak
# ```
#
# The above produces:
#
# ```text
# "I'm a unicorn"
# ```
#
# Check the number of horns with `#horns`.
class Unicorn
include Legendary
# Creates a unicorn with the specified number of *horns*.
def initialize(@horns = 1)
raise "Not a unicorn" if @horns != 1
end
# Returns the number of horns this unicorn has
#
# ```
# Unicorn.new.horns # => 1
# ```
def horns
@horns
end
# ditto
def number_of_horns
horns
end
# Makes the unicorn speak to STDOUT
def speak
puts "I'm a unicorn"
end
# :nodoc:
class Helper
end
end

View File

@ -0,0 +1,49 @@
# A unicorn is a **legendary animal** (see the `Legendary` module) that has been
# described since antiquity as a beast with a large, spiraling horn projecting
# from its forhead.
#
# To create a unicorn:
#
# ```
# unicorn = Unicorn.new
# unicorn.speak
# ```
#
# The above produces:
#
# ```text
# "I'm a unicorn"
# ```
#
# Check the number of horns with `#horns`.
class Unicorn
include Legendary
# Creates a unicorn with the specified number of *horns*.
def initialize(@horns = 1)
raise "Not a unicorn" if @horns != 1
end
# Returns the number of horns this unicorn has
#
# ```
# Unicorn.new.horns # => 1
# ```
def horns
@horns
end
# ditto
def number_of_horns
horns
end
# Makes the unicorn speak to STDOUT
def speak
puts "I'm a unicorn"
end
# :nodoc:
class Helper
end
end

View File

@ -0,0 +1,23 @@
###
Requires https://github.com/jaspervdj/stylish-haskell
###
"use strict"
Beautifier = require('./beautifier')
module.exports = class Crystal extends Beautifier
name: "crystal"
options: {
Crystal: false
}
beautify: (text, language, options) ->
@run("crystal", [
'tool'
'format'
tempFile = @tempFile("temp", text)
], {ignoreReturnCode: true})
.then(=>
@readFile(tempFile)
)

View File

@ -38,6 +38,7 @@ module.exports = class Beautifiers extends EventEmitter
'coffee-formatter' 'coffee-formatter'
'coffee-fmt' 'coffee-fmt'
'clang-format' 'clang-format'
'crystal'
'dfmt' 'dfmt'
'elm-format' 'elm-format'
'htmlbeautifier' 'htmlbeautifier'

View File

@ -0,0 +1,22 @@
module.exports = {
name: "Crystal"
namespace: "crystal"
###
Supported Grammars
###
grammars: [
"Crystal"
]
###
Supported extensions
###
extensions: [
"cr"
]
options: []
}

View File

@ -19,6 +19,7 @@ module.exports = class Languages
"coffeescript" "coffeescript"
"coldfusion" "coldfusion"
"cpp" "cpp"
"crystal"
"css" "css"
"csv" "csv"
"d" "d"