Added support for Crystal language
This commit is contained in:
parent
9add49118e
commit
0df1d8a5df
|
@ -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
|
|
@ -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
|
|
@ -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)
|
||||
)
|
|
@ -38,6 +38,7 @@ module.exports = class Beautifiers extends EventEmitter
|
|||
'coffee-formatter'
|
||||
'coffee-fmt'
|
||||
'clang-format'
|
||||
'crystal'
|
||||
'dfmt'
|
||||
'elm-format'
|
||||
'htmlbeautifier'
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
module.exports = {
|
||||
|
||||
name: "Crystal"
|
||||
namespace: "crystal"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"Crystal"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"cr"
|
||||
]
|
||||
|
||||
options: []
|
||||
|
||||
}
|
|
@ -19,6 +19,7 @@ module.exports = class Languages
|
|||
"coffeescript"
|
||||
"coldfusion"
|
||||
"cpp"
|
||||
"crystal"
|
||||
"css"
|
||||
"csv"
|
||||
"d"
|
||||
|
|
Loading…
Reference in New Issue