Merge pull request #1 from petrui/crystal-lang

Added support for Crystal language
This commit is contained in:
Petru 2016-04-07 00:04:55 +03:00
commit 086b35c5d2
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-fmt'
'clang-format'
'crystal'
'dfmt'
'elm-format'
'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"
"coldfusion"
"cpp"
"crystal"
"css"
"csv"
"d"