Prompt:
VariableParser = require '../lib/variable-parser'
registry = require '../lib/variable-expressions'

describe 'VariableParser', ->
  [parser] = []

  itParses = (expression) ->
    description: ''
    as: (variables) ->
      it "parses the '#{expression}' as variables #{jasmine.pp(variables)}", ->
        results = parser.parse(expression)

        expect(results.length).toEqual(Object.keys(variables).length)
        for {name, value, range} in results
          expected = variables[name]
          if expected.value?
            expect(value).toEqual(expected.value)
          else if expected.range?
            expect(range).toEqual(expected.range)
          else
            expect(value).toEqual(expected)

      this

  beforeEach ->

Response:
parser = new VariableParser(registry)

  itParses('color = white').as('color': 'white')
  itParses('non-color = 10px').as('non-color': '10px')

  itParses('$color: white;').as('$color': 'white')
  itParses('$color: white').as('$color': 'white')
  itParses('$non-color: 10px;').as('$non-color': '10px')
  itParses('$non-color: 10px').as('$non-color': '10px')

  itParses('@color: white;').as('@color': 'white')
  itParses('@non-color: 10px;').as('@non-color': '10px')

  itParses("""
    colors = {
      red: rgb(255,0,0),
      green: rgb(0,255,0),
      blue: rgb(0,0,255)
      value: 10px
      light: {
        base: lightgrey
      }
      dark: {
        base: slategrey
      }


Response:
VariableParser = require '../lib/variable-parser'

describe 'VariableParser', ->
  [parser] = []

  itParses = (expression) ->
    description: ''
    as: (variables) ->
      it "parses the '#{expression}' as variables #{jasmine.pp(variables)}", ->
        results = parser.parse(expression)

        expect(results.length).toEqual(Object.keys(variables).length)
        for {name, value, range} in results
          expected = variables[name]
          if expected.value?
            expect(value).toEqual(expected.value)
          else if expected.range?
            expect(range).toEqual(expected.range)
          else
            expect(value).toEqual(expected)

      this

  beforeEach ->
    parser = new VariableParser

  itParses('color = white').as('color': 'white')
  itParses('non-color = 10px').as('non-color': '10px')

  itParses('$color: white;').as('$color': 'white')
  itParses('$color: white').as('$color': 'white')
  itParses('$non-color: 10px;').as('$non-color': '10px')
  itParses('$non-color: 10px').as('$non-color': '10px')

  itParses('@color: white;').as('@color': 'white')
  itParses('@non-color: 10px;').as('@non-color': '10px')

  itParses("""
    colors = {
      red: rgb(255,0,0),
      green: rgb(0,255,0),
      blue: rgb(0,0,255)
      value: 10px
      light: {
        base: lightgrey
      }
      dark: {
        base: slategrey
      }
    }


Prompt:
VariableParser = require '../lib/variable-parser'

describe 'VariableParser', ->
  [parser] = []

  itParses = (expression) ->
    description: ''
    as: (variables) ->
      it "parses the '#{expression}' as variables #{jasmine.pp(variables)}", ->
        results = parser.parse(expression)

        expect(results.length).toEqual(Object.keys(variables).length)
        for {name, value, range} in results
          expected = variables[name]
          if expected.value?
            expect(value).toEqual(expected.value)
          else if expected.range?
            expect(range).toEqual(expected.range)
          else
            expect(value).toEqual(expected)

      this

  beforeEach ->
    parser = new VariableParser

Response:
itParses('color = white').as('color': 'white')
  itParses('non-color = 10px').as('non-color': '10px')

  itParses('$color: white;').as('$color': 'white')
  itParses('$color: white').as('$color': 'white')
  itParses('$non-color: 10px;').as('$non-color': '10px')
  itParses('$non-color: 10px').as('$non-color': '10px')

  itParses('@color: white;').as('@color': 'white')
  itParses('@non-color: 10px;').as('@non-color': '10px')

  itParses("""
    colors = {
      red: rgb(255,0,0),
      green: rgb(0,255,0),
      blue: rgb(0,0,255)
      value: 10px
      light: {
        base: lightgrey
      }
      dark: {
        base: slategrey
      }
    }


Response:
semver = require('semver')

module.exports = ->
  return unless specifiedVersion = specifiedLinemanVersion()
  return unless semver.validRange(specifiedVersion)

  actualVersion = actualLinemanVersion()
  unless semver.satisfies(actualVersion, specifiedVersion)
    console.error """
                  Uh oh, your package.json specifies lineman version '#{specifiedVersion}', but Lineman is currently '#{actualVersion}'.

                  Possible solutions:
                    * Try running `npm install` to install the specified lineman version locally to `node_modules/lineman`
                    * Update (or, perhaps, remove!) the version of lineman you've specified in your `package.json` and see if it works.
                  """
    process.exit(1)

specifiedLinemanVersion = ->
  packageJson = loadPackageJson()
  packageJson?.dependencies?.lineman || packageJson?.devDependencies?.lineman

actualLinemanVersion = ->
  if process.env["LINEMAN_MAIN"] == "lineman"
    require("#{process.cwd()}/node_modules/lineman/package").version
  else
    require(process.env["LINEMAN_MAIN"]).version

loadPackageJson = ->
  try
    require("#{process.cwd()}/package.json")
  catch e
    undefined


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
semver = require('semver')

module.exports = ->
  return unless specifiedVersion = specifiedLinemanVersion()
  return unless semver.validRange(specifiedVersion)

  actualVersion = actualLinemanVersion()
  unless semver.satisfies(actualVersion, specifiedVersion)
    console.error """
                  Uh oh, your package.json specifies lineman version '#{specifiedVersion}', but Lineman is currently '#{actualVersion}'.

                  Possible solutions:
                    * Try running `npm install` to install the specified lineman version locally to `node_modules/lineman`
                    * Update (or, perhaps, remove!) the version of lineman you've specified in your `package.json` and see if it works.
                  """
    process.exit(1)

specifiedLinemanVersion = ->
  packageJson = loadPackageJson()
  packageJson?.dependencies?.lineman || packageJson?.devDependencies?.lineman

actualLinemanVersion = ->
  if process.env["LINEMAN_MAIN"] == "lineman"
    require("#{process.cwd()}/node_modules/lineman/package").version
  else
    require(process.env["LINEMAN_MAIN"]).version

loadPackageJson = ->
  try
    require("#{process.cwd()}/package.json")
  catch e
    undefined
```

Response:
var actualLinemanVersion, loadPackageJson, semver, specifiedLinemanVersion;

semver = require('semver');

module.exports = function() {
  var actualVersion, specifiedVersion;
  if (!(specifiedVersion = specifiedLinemanVersion())) {
    return;
  }
  if (!semver.validRange(specifiedVersion)) {
    return;
  }
  actualVersion = actualLinemanVersion();
  if (!semver.satisfies(actualVersion, specifiedVersion)) {
    console.error(`Uh oh, your package.json specifies lineman version '${specifiedVersion}', but Lineman is currently '${actualVersion}'.

Possible solutions:
  * Try running \`npm install\` to install the specified lineman version locally to \`node_modules/lineman\`
  * Update (or, perhaps, remove!) the version of lineman you've specified in your \`package.json\` and see if it works.`);
    return process.exit(1);
  }
};

specifiedLinemanVersion = function() {
  var packageJson, ref, ref1;
  packageJson = loadPackageJson();
  return (packageJson != null ? (ref = packageJson.dependencies) != null ? ref.lineman : void 0 : void 0) || (packageJson != null ? (ref1 = packageJson.devDependencies) != null ? ref1.lineman : void 0 : void 0);
};

actualLinemanVersion = function() {
  if (process.env["LINEMAN_MAIN"] === "lineman") {
    return require(`${process.cwd()}/node_modules/lineman/package`).version;
  } else {
    return require(process.env["LINEMAN_MAIN"]).version;
  }
};

loadPackageJson = function() {
  var e;
  try {
    return require(`${process.cwd()}/package.json`);
  } catch (error) {
    e = error;
    return void 0;
  }
};


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var actualLinemanVersion, loadPackageJson, semver, specifiedLinemanVersion;

semver = require('semver');

module.exports = function() {
  var actualVersion, specifiedVersion;
  if (!(specifiedVersion = specifiedLinemanVersion())) {
    return;
  }
  if (!semver.validRange(specifiedVersion)) {
    return;
  }
  actualVersion = actualLinemanVersion();
  if (!semver.satisfies(actualVersion, specifiedVersion)) {
    console.error(`Uh oh, your package.json specifies lineman version '${specifiedVersion}', but Lineman is currently '${actualVersion}'.

Possible solutions:
  * Try running \`npm install\` to install the specified lineman version locally to \`node_modules/lineman\`
  * Update (or, perhaps, remove!) the version of lineman you've specified in your \`package.json\` and see if it works.`);
    return process.exit(1);
  }
};

specifiedLinemanVersion = function() {
  var packageJson, ref, ref1;
  packageJson = loadPackageJson();
  return (packageJson != null ? (ref = packageJson.dependencies) != null ? ref.lineman : void 0 : void 0) || (packageJson != null ? (ref1 = packageJson.devDependencies) != null ? ref1.lineman : void 0 : void 0);
};

actualLinemanVersion = function() {
  if (process.env["LINEMAN_MAIN"] === "lineman") {
    return require(`${process.cwd()}/node_modules/lineman/package`).version;
  } else {
    return require(process.env["LINEMAN_MAIN"]).version;
  }
};

loadPackageJson = function() {
  var e;
  try {
    return require(`${process.cwd()}/package.json`);
  } catch (error) {
    e = error;
    return void 0;
  }
};
```

Response:
semver = require('semver')

module.exports = ->
  return unless specifiedVersion = specifiedLinemanVersion()
  return unless semver.validRange(specifiedVersion)

  actualVersion = actualLinemanVersion()
  unless semver.satisfies(actualVersion, specifiedVersion)
    console.error """
                  Uh oh, your package.json specifies lineman version '#{specifiedVersion}', but Lineman is currently '#{actualVersion}'.

                  Possible solutions:
                    * Try running `npm install` to install the specified lineman version locally to `node_modules/lineman`
                    * Update (or, perhaps, remove!) the version of lineman you've specified in your `package.json` and see if it works.
                  """
    process.exit(1)

specifiedLinemanVersion = ->
  packageJson = loadPackageJson()
  packageJson?.dependencies?.lineman || packageJson?.devDependencies?.lineman

actualLinemanVersion = ->
  if process.env["LINEMAN_MAIN"] == "lineman"
    require("#{process.cwd()}/node_modules/lineman/package").version
  else
    require(process.env["LINEMAN_MAIN"]).version

loadPackageJson = ->
  try
    require("#{process.cwd()}/package.json")
  catch e
    undefined


Prompt:
semver = require('semver')

module.exports = ->
  return unless specifiedVersion = specifiedLinemanVersion()
  return unless semver.validRange(specifiedVersion)

  actualVersion = actualLinemanVersion()
  unless semver.satisfies(actualVersion, specifiedVersion)
    console.error """
                  Uh oh, your package.json specifies lineman version '#{specifiedVersion}', but Lineman is currently '#{actualVersion}'.

                  Possible solutions:
                    * Try running `npm install` to install the specified lineman version locally to `node_modules/lineman`
                    * Update (or, perhaps, remove!) the version of lineman you've specified in your `package.json` and see if it works.
                  """
    process.exit(1)

Response:
specifiedLinemanVersion = ->
  packageJson = loadPackageJson()
  packageJson?.dependencies?.lineman || packageJson?.devDependencies?.lineman

actualLinemanVersion = ->
  if process.env["LINEMAN_MAIN"] == "lineman"
    require("#{process.cwd()}/node_modules/lineman/package").version
  else
    require(process.env["LINEMAN_MAIN"]).version

loadPackageJson = ->
  try
    require("#{process.cwd()}/package.json")
  catch e
    undefined


Response:
semver = require('semver')

module.exports = ->
  return unless specifiedVersion = specifiedLinemanVersion()
  return if /^git(\+(.*))?:\/\//.test(specifiedVersion)

  actualVersion = actualLinemanVersion()
  unless semver.satisfies(actualVersion, specifiedVersion)
    console.error """
                  Uh oh, your package.json specifies lineman version '#{specifiedVersion}', but Lineman is currently '#{actualVersion}'.

                  Possible solutions:
                    * Try running `npm install` to install the specified lineman version locally to `node_modules/lineman`
                    * Update (or, perhaps, remove!) the version of lineman you've specified in your `package.json` and see if it works.
                  """
    process.exit(1)

specifiedLinemanVersion = ->
  packageJson = loadPackageJson()
  packageJson?.dependencies?.lineman || packageJson?.devDependencies?.lineman

actualLinemanVersion = ->
  if process.env["LINEMAN_MAIN"] == "lineman"
    require("#{process.cwd()}/node_modules/lineman/package").version
  else
    require(process.env["LINEMAN_MAIN"]).version

loadPackageJson = ->
  try
    require("#{process.cwd()}/package.json")
  catch e
    undefined


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
semver = require('semver')

module.exports = ->
  return unless specifiedVersion = specifiedLinemanVersion()
  return if /^git(\+(.*))?:\/\//.test(specifiedVersion)

  actualVersion = actualLinemanVersion()
  unless semver.satisfies(actualVersion, specifiedVersion)
    console.error """
                  Uh oh, your package.json specifies lineman version '#{specifiedVersion}', but Lineman is currently '#{actualVersion}'.

                  Possible solutions:
                    * Try running `npm install` to install the specified lineman version locally to `node_modules/lineman`
                    * Update (or, perhaps, remove!) the version of lineman you've specified in your `package.json` and see if it works.
                  """
    process.exit(1)

specifiedLinemanVersion = ->
  packageJson = loadPackageJson()
  packageJson?.dependencies?.lineman || packageJson?.devDependencies?.lineman

actualLinemanVersion = ->
  if process.env["LINEMAN_MAIN"] == "lineman"
    require("#{process.cwd()}/node_modules/lineman/package").version
  else
    require(process.env["LINEMAN_MAIN"]).version

loadPackageJson = ->
  try
    require("#{process.cwd()}/package.json")
  catch e
    undefined
```

Response:
var actualLinemanVersion, loadPackageJson, semver, specifiedLinemanVersion;

semver = require('semver');

module.exports = function() {
  var actualVersion, specifiedVersion;
  if (!(specifiedVersion = specifiedLinemanVersion())) {
    return;
  }
  if (/^git(\+(.*))?:\/\//.test(specifiedVersion)) {
    return;
  }
  actualVersion = actualLinemanVersion();
  if (!semver.satisfies(actualVersion, specifiedVersion)) {
    console.error(`Uh oh, your package.json specifies lineman version '${specifiedVersion}', but Lineman is currently '${actualVersion}'.

Possible solutions:
  * Try running \`npm install\` to install the specified lineman version locally to \`node_modules/lineman\`
  * Update (or, perhaps, remove!) the version of lineman you've specified in your \`package.json\` and see if it works.`);
    return process.exit(1);
  }
};

specifiedLinemanVersion = function() {
  var packageJson, ref, ref1;
  packageJson = loadPackageJson();
  return (packageJson != null ? (ref = packageJson.dependencies) != null ? ref.lineman : void 0 : void 0) || (packageJson != null ? (ref1 = packageJson.devDependencies) != null ? ref1.lineman : void 0 : void 0);
};

actualLinemanVersion = function() {
  if (process.env["LINEMAN_MAIN"] === "lineman") {
    return require(`${process.cwd()}/node_modules/lineman/package`).version;
  } else {
    return require(process.env["LINEMAN_MAIN"]).version;
  }
};

loadPackageJson = function() {
  var e;
  try {
    return require(`${process.cwd()}/package.json`);
  } catch (error) {
    e = error;
    return void 0;
  }
};


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var actualLinemanVersion, loadPackageJson, semver, specifiedLinemanVersion;

semver = require('semver');

module.exports = function() {
  var actualVersion, specifiedVersion;
  if (!(specifiedVersion = specifiedLinemanVersion())) {
    return;
  }
  if (/^git(\+(.*))?:\/\//.test(specifiedVersion)) {
    return;
  }
  actualVersion = actualLinemanVersion();
  if (!semver.satisfies(actualVersion, specifiedVersion)) {
    console.error(`Uh oh, your package.json specifies lineman version '${specifiedVersion}', but Lineman is currently '${actualVersion}'.

Possible solutions:
  * Try running \`npm install\` to install the specified lineman version locally to \`node_modules/lineman\`
  * Update (or, perhaps, remove!) the version of lineman you've specified in your \`package.json\` and see if it works.`);
    return process.exit(1);
  }
};

specifiedLinemanVersion = function() {
  var packageJson, ref, ref1;
  packageJson = loadPackageJson();
  return (packageJson != null ? (ref = packageJson.dependencies) != null ? ref.lineman : void 0 : void 0) || (packageJson != null ? (ref1 = packageJson.devDependencies) != null ? ref1.lineman : void 0 : void 0);
};

actualLinemanVersion = function() {
  if (process.env["LINEMAN_MAIN"] === "lineman") {
    return require(`${process.cwd()}/node_modules/lineman/package`).version;
  } else {
    return require(process.env["LINEMAN_MAIN"]).version;
  }
};

loadPackageJson = function() {
  var e;
  try {
    return require(`${process.cwd()}/package.json`);
  } catch (error) {
    e = error;
    return void 0;
  }
};
```

Response:
semver = require('semver')

module.exports = ->
  return unless specifiedVersion = specifiedLinemanVersion()
  return if /^git(\+(.*))?:\/\//.test(specifiedVersion)

  actualVersion = actualLinemanVersion()
  unless semver.satisfies(actualVersion, specifiedVersion)
    console.error """
                  Uh oh, your package.json specifies lineman version '#{specifiedVersion}', but Lineman is currently '#{actualVersion}'.

                  Possible solutions:
                    * Try running `npm install` to install the specified lineman version locally to `node_modules/lineman`
                    * Update (or, perhaps, remove!) the version of lineman you've specified in your `package.json` and see if it works.
                  """
    process.exit(1)

specifiedLinemanVersion = ->
  packageJson = loadPackageJson()
  packageJson?.dependencies?.lineman || packageJson?.devDependencies?.lineman

actualLinemanVersion = ->
  if process.env["LINEMAN_MAIN"] == "lineman"
    require("#{process.cwd()}/node_modules/lineman/package").version
  else
    require(process.env["LINEMAN_MAIN"]).version

loadPackageJson = ->
  try
    require("#{process.cwd()}/package.json")
  catch e
    undefined


Prompt:
semver = require('semver')

module.exports = ->
  return unless specifiedVersion = specifiedLinemanVersion()
  return if /^git(\+(.*))?:\/\//.test(specifiedVersion)

  actualVersion = actualLinemanVersion()
  unless semver.satisfies(actualVersion, specifiedVersion)
    console.error """
                  Uh oh, your package.json specifies lineman version '#{specifiedVersion}', but Lineman is currently '#{actualVersion}'.

                  Possible solutions:
                    * Try running `npm install` to install the specified lineman version locally to `node_modules/lineman`
                    * Update (or, perhaps, remove!) the version of lineman you've specified in your `package.json` and see if it works.
                  """
    process.exit(1)

Response:
specifiedLinemanVersion = ->
  packageJson = loadPackageJson()
  packageJson?.dependencies?.lineman || packageJson?.devDependencies?.lineman

actualLinemanVersion = ->
  if process.env["LINEMAN_MAIN"] == "lineman"
    require("#{process.cwd()}/node_modules/lineman/package").version
  else
    require(process.env["LINEMAN_MAIN"]).version

loadPackageJson = ->
  try
    require("#{process.cwd()}/package.json")
  catch e
    undefined


Response:
semver = require('semver')

module.exports = () ->
  return unless specifiedVersion = specifiedLinemanVersion()
  actualVersion = actualLinemanVersion()

  return if /^git(\+(.*))?:\/\//.test(specifiedVersion)

  unless semver.satisfies(actualVersion, specifiedVersion)
    console.error """
                  Uh oh, your package.json specifies lineman version '#{specifiedVersion}', but Lineman is currently '#{actualVersion}'.

                  Possible solutions:
                    * Try running `npm install` to install the specified lineman version locally to `node_modules/lineman`
                    * Update (or, perhaps, remove!) the version of lineman you've specified in your `package.json` and see if it works.
                  """
    process.exit(1)

specifiedLinemanVersion = ->
  packageJson = loadPackageJson()
  packageJson?.dependencies?.lineman || packageJson?.devDependencies?.lineman

actualLinemanVersion = ->
  if process.env["LINEMAN_MAIN"] == "lineman"
    require("#{process.cwd()}/node_modules/lineman/package").version
  else
    require(process.env["LINEMAN_MAIN"]).version

loadPackageJson = ->
  try
    require("#{process.cwd()}/package.json")
  catch e
    undefined


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
semver = require('semver')

module.exports = () ->
  return unless specifiedVersion = specifiedLinemanVersion()
  actualVersion = actualLinemanVersion()

  return if /^git(\+(.*))?:\/\//.test(specifiedVersion)

  unless semver.satisfies(actualVersion, specifiedVersion)
    console.error """
                  Uh oh, your package.json specifies lineman version '#{specifiedVersion}', but Lineman is currently '#{actualVersion}'.

                  Possible solutions:
                    * Try running `npm install` to install the specified lineman version locally to `node_modules/lineman`
                    * Update (or, perhaps, remove!) the version of lineman you've specified in your `package.json` and see if it works.
                  """
    process.exit(1)

specifiedLinemanVersion = ->
  packageJson = loadPackageJson()
  packageJson?.dependencies?.lineman || packageJson?.devDependencies?.lineman

actualLinemanVersion = ->
  if process.env["LINEMAN_MAIN"] == "lineman"
    require("#{process.cwd()}/node_modules/lineman/package").version
  else
    require(process.env["LINEMAN_MAIN"]).version

loadPackageJson = ->
  try
    require("#{process.cwd()}/package.json")
  catch e
    undefined
```

Response:
var actualLinemanVersion, loadPackageJson, semver, specifiedLinemanVersion;

semver = require('semver');

module.exports = function() {
  var actualVersion, specifiedVersion;
  if (!(specifiedVersion = specifiedLinemanVersion())) {
    return;
  }
  actualVersion = actualLinemanVersion();
  if (/^git(\+(.*))?:\/\//.test(specifiedVersion)) {
    return;
  }
  if (!semver.satisfies(actualVersion, specifiedVersion)) {
    console.error(`Uh oh, your package.json specifies lineman version '${specifiedVersion}', but Lineman is currently '${actualVersion}'.

Possible solutions:
  * Try running \`npm install\` to install the specified lineman version locally to \`node_modules/lineman\`
  * Update (or, perhaps, remove!) the version of lineman you've specified in your \`package.json\` and see if it works.`);
    return process.exit(1);
  }
};

specifiedLinemanVersion = function() {
  var packageJson, ref, ref1;
  packageJson = loadPackageJson();
  return (packageJson != null ? (ref = packageJson.dependencies) != null ? ref.lineman : void 0 : void 0) || (packageJson != null ? (ref1 = packageJson.devDependencies) != null ? ref1.lineman : void 0 : void 0);
};

actualLinemanVersion = function() {
  if (process.env["LINEMAN_MAIN"] === "lineman") {
    return require(`${process.cwd()}/node_modules/lineman/package`).version;
  } else {
    return require(process.env["LINEMAN_MAIN"]).version;
  }
};

loadPackageJson = function() {
  var e;
  try {
    return require(`${process.cwd()}/package.json`);
  } catch (error) {
    e = error;
    return void 0;
  }
};


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var actualLinemanVersion, loadPackageJson, semver, specifiedLinemanVersion;

semver = require('semver');

module.exports = function() {
  var actualVersion, specifiedVersion;
  if (!(specifiedVersion = specifiedLinemanVersion())) {
    return;
  }
  actualVersion = actualLinemanVersion();
  if (/^git(\+(.*))?:\/\//.test(specifiedVersion)) {
    return;
  }
  if (!semver.satisfies(actualVersion, specifiedVersion)) {
    console.error(`Uh oh, your package.json specifies lineman version '${specifiedVersion}', but Lineman is currently '${actualVersion}'.

Possible solutions:
  * Try running \`npm install\` to install the specified lineman version locally to \`node_modules/lineman\`
  * Update (or, perhaps, remove!) the version of lineman you've specified in your \`package.json\` and see if it works.`);
    return process.exit(1);
  }
};

specifiedLinemanVersion = function() {
  var packageJson, ref, ref1;
  packageJson = loadPackageJson();
  return (packageJson != null ? (ref = packageJson.dependencies) != null ? ref.lineman : void 0 : void 0) || (packageJson != null ? (ref1 = packageJson.devDependencies) != null ? ref1.lineman : void 0 : void 0);
};

actualLinemanVersion = function() {
  if (process.env["LINEMAN_MAIN"] === "lineman") {
    return require(`${process.cwd()}/node_modules/lineman/package`).version;
  } else {
    return require(process.env["LINEMAN_MAIN"]).version;
  }
};

loadPackageJson = function() {
  var e;
  try {
    return require(`${process.cwd()}/package.json`);
  } catch (error) {
    e = error;
    return void 0;
  }
};
```

Response:
semver = require('semver')

module.exports = () ->
  return unless specifiedVersion = specifiedLinemanVersion()
  actualVersion = actualLinemanVersion()

  return if /^git(\+(.*))?:\/\//.test(specifiedVersion)

  unless semver.satisfies(actualVersion, specifiedVersion)
    console.error """
                  Uh oh, your package.json specifies lineman version '#{specifiedVersion}', but Lineman is currently '#{actualVersion}'.

                  Possible solutions:
                    * Try running `npm install` to install the specified lineman version locally to `node_modules/lineman`
                    * Update (or, perhaps, remove!) the version of lineman you've specified in your `package.json` and see if it works.
                  """
    process.exit(1)

specifiedLinemanVersion = ->
  packageJson = loadPackageJson()
  packageJson?.dependencies?.lineman || packageJson?.devDependencies?.lineman

actualLinemanVersion = ->
  if process.env["LINEMAN_MAIN"] == "lineman"
    require("#{process.cwd()}/node_modules/lineman/package").version
  else
    require(process.env["LINEMAN_MAIN"]).version

loadPackageJson = ->
  try
    require("#{process.cwd()}/package.json")
  catch e
    undefined


Prompt:
semver = require('semver')

module.exports = () ->
  return unless specifiedVersion = specifiedLinemanVersion()
  actualVersion = actualLinemanVersion()

  return if /^git(\+(.*))?:\/\//.test(specifiedVersion)

  unless semver.satisfies(actualVersion, specifiedVersion)
    console.error """
                  Uh oh, your package.json specifies lineman version '#{specifiedVersion}', but Lineman is currently '#{actualVersion}'.

                  Possible solutions:
                    * Try running `npm install` to install the specified lineman version locally to `node_modules/lineman`
                    * Update (or, perhaps, remove!) the version of lineman you've specified in your `package.json` and see if it works.
                  """

Response:
process.exit(1)

specifiedLinemanVersion = ->
  packageJson = loadPackageJson()
  packageJson?.dependencies?.lineman || packageJson?.devDependencies?.lineman

actualLinemanVersion = ->
  if process.env["LINEMAN_MAIN"] == "lineman"
    require("#{process.cwd()}/node_modules/lineman/package").version
  else
    require(process.env["LINEMAN_MAIN"]).version

loadPackageJson = ->
  try
    require("#{process.cwd()}/package.json")
  catch e
    undefined


Response:
#global module:false
module.exports = (grunt) ->
  grunt.loadNpmTasks('grunt-jasmine-bundle')


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
#global module:false
module.exports = (grunt) ->
  grunt.loadNpmTasks('grunt-jasmine-bundle')
```

Response:
//global module:false
module.exports = function(grunt) {
  return grunt.loadNpmTasks('grunt-jasmine-bundle');
};


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
//global module:false
module.exports = function(grunt) {
  return grunt.loadNpmTasks('grunt-jasmine-bundle');
};
```

Response:
#global module:false
module.exports = (grunt) ->
  grunt.loadNpmTasks('grunt-jasmine-bundle')


Response:
###
  this is the expected data for the first five commits of test-data/fiveCommits.txt.
  Only the keys in these objects are tested against the actual first five commits read
  from git log
###
module.exports = [{
  "id": "4d3547944bbac446b229838867bf60dd55289213",
  "authorName": "Bee",
  "authorDate": 1445053404,
  "message": "git-util-spec: fifth commit of spec/testData/fiveCommits.txt. only deleted a line",
  "hash": "4d35479",
  "linesAdded": 0,
  "linesDeleted": 2
}, {
  "id": "fa4aee05281c12f2ba8c92eb1100964f98901caa",
  "authorName": "Bee",
  "authorDate": 1445053316,
  "message": "git-util-spec: forth commit of spec/testData/fiveCommits.txt",
  "hash": "fa4aee0",
  "linesAdded": 1,
  "linesDeleted": 0
}, {
  "id": "010f49a2cf4fb08f7117782269ce8ede07e0797a",
  "authorName": "Bee",
  "authorDate": 1445053277,
  "message": "git-util-spec: third commit of spec/testData/fiveCommits.txt",
  "hash": "010f49a",
  "linesAdded": 2,
  "linesDeleted": 1
}, {
  "id": "3d03801db29c1f9d92550c8bfed32b21c08ced4c",
  "authorName": "Bee",
  "authorDate": 1445053179,
  "message": "git-util-spec: load correct fully qualified test file name. plus second commit of fiveCommits.txt",
  "hash": "3d03801",
  "linesAdded": 2,
  "linesDeleted": 0
}, {
  "id": "bb7b15fc68e681347185003ddb534366465c5b36",
  "authorName": "Bee",
  "authorDate": 1445052734,
  "message": "GitUtils.getFileCommitHistory should return valid data. +new failing test",
  "hash": "bb7b15f",
  "linesAdded": 7,
  "linesDeleted": 0
}]


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
###
  this is the expected data for the first five commits of test-data/fiveCommits.txt.
  Only the keys in these objects are tested against the actual first five commits read
  from git log
###
module.exports = [{
  "id": "4d3547944bbac446b229838867bf60dd55289213",
  "authorName": "Bee",
  "authorDate": 1445053404,
  "message": "git-util-spec: fifth commit of spec/testData/fiveCommits.txt. only deleted a line",
  "hash": "4d35479",
  "linesAdded": 0,
  "linesDeleted": 2
}, {
  "id": "fa4aee05281c12f2ba8c92eb1100964f98901caa",
  "authorName": "Bee",
  "authorDate": 1445053316,
  "message": "git-util-spec: forth commit of spec/testData/fiveCommits.txt",
  "hash": "fa4aee0",
  "linesAdded": 1,
  "linesDeleted": 0
}, {
  "id": "010f49a2cf4fb08f7117782269ce8ede07e0797a",
  "authorName": "Bee",
  "authorDate": 1445053277,
  "message": "git-util-spec: third commit of spec/testData/fiveCommits.txt",
  "hash": "010f49a",
  "linesAdded": 2,
  "linesDeleted": 1
}, {
  "id": "3d03801db29c1f9d92550c8bfed32b21c08ced4c",
  "authorName": "Bee",
  "authorDate": 1445053179,
  "message": "git-util-spec: load correct fully qualified test file name. plus second commit of fiveCommits.txt",
  "hash": "3d03801",
  "linesAdded": 2,
  "linesDeleted": 0
}, {
  "id": "bb7b15fc68e681347185003ddb534366465c5b36",
  "authorName": "Bee",
  "authorDate": 1445052734,
  "message": "GitUtils.getFileCommitHistory should return valid data. +new failing test",
  "hash": "bb7b15f",
  "linesAdded": 7,
  "linesDeleted": 0
}]
```

Response:
/*
    this is the expected data for the first five commits of test-data/fiveCommits.txt.
    Only the keys in these objects are tested against the actual first five commits read
    from git log
  */
module.exports = [
  {
    "id": "4d3547944bbac446b229838867bf60dd55289213",
    "authorName": "Bee",
    "authorDate": 1445053404,
    "message": "git-util-spec: fifth commit of spec/testData/fiveCommits.txt. only deleted a line",
    "hash": "4d35479",
    "linesAdded": 0,
    "linesDeleted": 2
  },
  {
    "id": "fa4aee05281c12f2ba8c92eb1100964f98901caa",
    "authorName": "Bee",
    "authorDate": 1445053316,
    "message": "git-util-spec: forth commit of spec/testData/fiveCommits.txt",
    "hash": "fa4aee0",
    "linesAdded": 1,
    "linesDeleted": 0
  },
  {
    "id": "010f49a2cf4fb08f7117782269ce8ede07e0797a",
    "authorName": "Bee",
    "authorDate": 1445053277,
    "message": "git-util-spec: third commit of spec/testData/fiveCommits.txt",
    "hash": "010f49a",
    "linesAdded": 2,
    "linesDeleted": 1
  },
  {
    "id": "3d03801db29c1f9d92550c8bfed32b21c08ced4c",
    "authorName": "Bee",
    "authorDate": 1445053179,
    "message": "git-util-spec: load correct fully qualified test file name. plus second commit of fiveCommits.txt",
    "hash": "3d03801",
    "linesAdded": 2,
    "linesDeleted": 0
  },
  {
    "id": "bb7b15fc68e681347185003ddb534366465c5b36",
    "authorName": "Bee",
    "authorDate": 1445052734,
    "message": "GitUtils.getFileCommitHistory should return valid data. +new failing test",
    "hash": "bb7b15f",
    "linesAdded": 7,
    "linesDeleted": 0
  }
];


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
/*
    this is the expected data for the first five commits of test-data/fiveCommits.txt.
    Only the keys in these objects are tested against the actual first five commits read
    from git log
  */
module.exports = [
  {
    "id": "4d3547944bbac446b229838867bf60dd55289213",
    "authorName": "Bee",
    "authorDate": 1445053404,
    "message": "git-util-spec: fifth commit of spec/testData/fiveCommits.txt. only deleted a line",
    "hash": "4d35479",
    "linesAdded": 0,
    "linesDeleted": 2
  },
  {
    "id": "fa4aee05281c12f2ba8c92eb1100964f98901caa",
    "authorName": "Bee",
    "authorDate": 1445053316,
    "message": "git-util-spec: forth commit of spec/testData/fiveCommits.txt",
    "hash": "fa4aee0",
    "linesAdded": 1,
    "linesDeleted": 0
  },
  {
    "id": "010f49a2cf4fb08f7117782269ce8ede07e0797a",
    "authorName": "Bee",
    "authorDate": 1445053277,
    "message": "git-util-spec: third commit of spec/testData/fiveCommits.txt",
    "hash": "010f49a",
    "linesAdded": 2,
    "linesDeleted": 1
  },
  {
    "id": "3d03801db29c1f9d92550c8bfed32b21c08ced4c",
    "authorName": "Bee",
    "authorDate": 1445053179,
    "message": "git-util-spec: load correct fully qualified test file name. plus second commit of fiveCommits.txt",
    "hash": "3d03801",
    "linesAdded": 2,
    "linesDeleted": 0
  },
  {
    "id": "bb7b15fc68e681347185003ddb534366465c5b36",
    "authorName": "Bee",
    "authorDate": 1445052734,
    "message": "GitUtils.getFileCommitHistory should return valid data. +new failing test",
    "hash": "bb7b15f",
    "linesAdded": 7,
    "linesDeleted": 0
  }
];
```

Response:
###
  this is the expected data for the first five commits of test-data/fiveCommits.txt.
  Only the keys in these objects are tested against the actual first five commits read
  from git log
###
module.exports = [{
  "id": "4d3547944bbac446b229838867bf60dd55289213",
  "authorName": "Bee",
  "authorDate": 1445053404,
  "message": "git-util-spec: fifth commit of spec/testData/fiveCommits.txt. only deleted a line",
  "hash": "4d35479",
  "linesAdded": 0,
  "linesDeleted": 2
}, {
  "id": "fa4aee05281c12f2ba8c92eb1100964f98901caa",
  "authorName": "Bee",
  "authorDate": 1445053316,
  "message": "git-util-spec: forth commit of spec/testData/fiveCommits.txt",
  "hash": "fa4aee0",
  "linesAdded": 1,
  "linesDeleted": 0
}, {
  "id": "010f49a2cf4fb08f7117782269ce8ede07e0797a",
  "authorName": "Bee",
  "authorDate": 1445053277,
  "message": "git-util-spec: third commit of spec/testData/fiveCommits.txt",
  "hash": "010f49a",
  "linesAdded": 2,
  "linesDeleted": 1
}, {
  "id": "3d03801db29c1f9d92550c8bfed32b21c08ced4c",
  "authorName": "Bee",
  "authorDate": 1445053179,
  "message": "git-util-spec: load correct fully qualified test file name. plus second commit of fiveCommits.txt",
  "hash": "3d03801",
  "linesAdded": 2,
  "linesDeleted": 0
}, {
  "id": "bb7b15fc68e681347185003ddb534366465c5b36",
  "authorName": "Bee",
  "authorDate": 1445052734,
  "message": "GitUtils.getFileCommitHistory should return valid data. +new failing test",
  "hash": "bb7b15f",
  "linesAdded": 7,
  "linesDeleted": 0
}]


Prompt:
###
  this is the expected data for the first five commits of test-data/fiveCommits.txt.
  Only the keys in these objects are tested against the actual first five commits read
  from git log
###
module.exports = [{
  "id": "4d3547944bbac446b229838867bf60dd55289213",
  "authorName": "Bee",
  "authorDate": 1445053404,
  "message": "git-util-spec: fifth commit of spec/testData/fiveCommits.txt. only deleted a line",
  "hash": "4d35479",
  "linesAdded": 0,
  "linesDeleted": 2
}, {
  "id": "fa4aee05281c12f2ba8c92eb1100964f98901caa",
  "authorName": "Bee",
  "authorDate": 1445053316,
  "message": "git-util-spec: forth commit of spec/testData/fiveCommits.txt",
  "hash": "fa4aee0",
  "linesAdded": 1,
  "linesDeleted": 0
}, {
  "id": "010f49a2cf4fb08f7117782269ce8ede07e0797a",

Response:
"authorName": "Bee",
  "authorDate": 1445053277,
  "message": "git-util-spec: third commit of spec/testData/fiveCommits.txt",
  "hash": "010f49a",
  "linesAdded": 2,
  "linesDeleted": 1
}, {
  "id": "3d03801db29c1f9d92550c8bfed32b21c08ced4c",
  "authorName": "Bee",
  "authorDate": 1445053179,
  "message": "git-util-spec: load correct fully qualified test file name. plus second commit of fiveCommits.txt",
  "hash": "3d03801",
  "linesAdded": 2,
  "linesDeleted": 0
}, {
  "id": "bb7b15fc68e681347185003ddb534366465c5b36",
  "authorName": "Bee",
  "authorDate": 1445052734,
  "message": "GitUtils.getFileCommitHistory should return valid data. +new failing test",
  "hash": "bb7b15f",
  "linesAdded": 7,
  "linesDeleted": 0
}]


Response:
###
Requires [puppet-link](http://puppet-lint.com/)
###
"use strict"
Beautifier = require('./beautifier')

module.exports = class PuppetFix extends Beautifier
  # this is what displays as your Default Beautifier in Language Config
  name: "puppet-lint"
  link: "http://puppet-lint.com/"

  options: {
    Puppet: true
  }

  executables: [
    {
      name: "puppet-lint"
      cmd: "puppet-lint"
      homepage: "http://puppet-lint.com/"
      installation: "http://puppet-lint.com/"
      version: {
        parse: (text) -> text.match(/puppet-lint (\d+\.\d+\.\d+)/)[1]
      }
      docker: {
        image: "unibeautify/puppet-lint"
      }
    }
  ]

  beautify: (text, language, options) ->
    @exe("puppet-lint").run([
      '--fix'
      tempFile = @tempFile("input", text)
      ], {
        ignoreReturnCode: true
        help: {
          link: "http://puppet-lint.com/"
        }
      })
      .then(=>
        @readFile(tempFile)
      )


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
###
Requires [puppet-link](http://puppet-lint.com/)
###
"use strict"
Beautifier = require('./beautifier')

module.exports = class PuppetFix extends Beautifier
  # this is what displays as your Default Beautifier in Language Config
  name: "puppet-lint"
  link: "http://puppet-lint.com/"

  options: {
    Puppet: true
  }

  executables: [
    {
      name: "puppet-lint"
      cmd: "puppet-lint"
      homepage: "http://puppet-lint.com/"
      installation: "http://puppet-lint.com/"
      version: {
        parse: (text) -> text.match(/puppet-lint (\d+\.\d+\.\d+)/)[1]
      }
      docker: {
        image: "unibeautify/puppet-lint"
      }
    }
  ]

  beautify: (text, language, options) ->
    @exe("puppet-lint").run([
      '--fix'
      tempFile = @tempFile("input", text)
      ], {
        ignoreReturnCode: true
        help: {
          link: "http://puppet-lint.com/"
        }
      })
      .then(=>
        @readFile(tempFile)
      )
```

Response:
/*
Requires [puppet-link](http://puppet-lint.com/)
*/
"use strict";
var Beautifier, PuppetFix;

Beautifier = require('./beautifier');

module.exports = PuppetFix = (function() {
  class PuppetFix extends Beautifier {
    beautify(text, language, options) {
      var tempFile;
      return this.exe("puppet-lint").run(['--fix', tempFile = this.tempFile("input", text)], {
        ignoreReturnCode: true,
        help: {
          link: "http://puppet-lint.com/"
        }
      }).then(() => {
        return this.readFile(tempFile);
      });
    }

  };

  // this is what displays as your Default Beautifier in Language Config
  PuppetFix.prototype.name = "puppet-lint";

  PuppetFix.prototype.link = "http://puppet-lint.com/";

  PuppetFix.prototype.options = {
    Puppet: true
  };

  PuppetFix.prototype.executables = [
    {
      name: "puppet-lint",
      cmd: "puppet-lint",
      homepage: "http://puppet-lint.com/",
      installation: "http://puppet-lint.com/",
      version: {
        parse: function(text) {
          return text.match(/puppet-lint (\d+\.\d+\.\d+)/)[1];
        }
      },
      docker: {
        image: "unibeautify/puppet-lint"
      }
    }
  ];

  return PuppetFix;

}).call(this);


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
/*
Requires [puppet-link](http://puppet-lint.com/)
*/
"use strict";
var Beautifier, PuppetFix;

Beautifier = require('./beautifier');

module.exports = PuppetFix = (function() {
  class PuppetFix extends Beautifier {
    beautify(text, language, options) {
      var tempFile;
      return this.exe("puppet-lint").run(['--fix', tempFile = this.tempFile("input", text)], {
        ignoreReturnCode: true,
        help: {
          link: "http://puppet-lint.com/"
        }
      }).then(() => {
        return this.readFile(tempFile);
      });
    }

  };

  // this is what displays as your Default Beautifier in Language Config
  PuppetFix.prototype.name = "puppet-lint";

  PuppetFix.prototype.link = "http://puppet-lint.com/";

  PuppetFix.prototype.options = {
    Puppet: true
  };

  PuppetFix.prototype.executables = [
    {
      name: "puppet-lint",
      cmd: "puppet-lint",
      homepage: "http://puppet-lint.com/",
      installation: "http://puppet-lint.com/",
      version: {
        parse: function(text) {
          return text.match(/puppet-lint (\d+\.\d+\.\d+)/)[1];
        }
      },
      docker: {
        image: "unibeautify/puppet-lint"
      }
    }
  ];

  return PuppetFix;

}).call(this);
```

Response:
###
Requires [puppet-link](http://puppet-lint.com/)
###
"use strict"
Beautifier = require('./beautifier')

module.exports = class PuppetFix extends Beautifier
  # this is what displays as your Default Beautifier in Language Config
  name: "puppet-lint"
  link: "http://puppet-lint.com/"

  options: {
    Puppet: true
  }

  executables: [
    {
      name: "puppet-lint"
      cmd: "puppet-lint"
      homepage: "http://puppet-lint.com/"
      installation: "http://puppet-lint.com/"
      version: {
        parse: (text) -> text.match(/puppet-lint (\d+\.\d+\.\d+)/)[1]
      }
      docker: {
        image: "unibeautify/puppet-lint"
      }
    }
  ]

  beautify: (text, language, options) ->
    @exe("puppet-lint").run([
      '--fix'
      tempFile = @tempFile("input", text)
      ], {
        ignoreReturnCode: true
        help: {
          link: "http://puppet-lint.com/"
        }
      })
      .then(=>
        @readFile(tempFile)
      )


Prompt:
###
Requires [puppet-link](http://puppet-lint.com/)
###
"use strict"
Beautifier = require('./beautifier')

module.exports = class PuppetFix extends Beautifier
  # this is what displays as your Default Beautifier in Language Config
  name: "puppet-lint"
  link: "http://puppet-lint.com/"

  options: {
    Puppet: true
  }

  executables: [
    {
      name: "puppet-lint"
      cmd: "puppet-lint"
      homepage: "http://puppet-lint.com/"
      installation: "http://puppet-lint.com/"

Response:
version: {
        parse: (text) -> text.match(/puppet-lint (\d+\.\d+\.\d+)/)[1]
      }
      docker: {
        image: "unibeautify/puppet-lint"
      }
    }
  ]

  beautify: (text, language, options) ->
    @exe("puppet-lint").run([
      '--fix'
      tempFile = @tempFile("input", text)
      ], {
        ignoreReturnCode: true
        help: {
          link: "http://puppet-lint.com/"
        }
      })
      .then(=>
        @readFile(tempFile)
      )


Response:
###
Requires [puppet-link](http://puppet-lint.com/)
###
"use strict"
Beautifier = require('./beautifier')

module.exports = class PuppetFix extends Beautifier
  # this is what displays as your Default Beautifier in Language Config
  name: "puppet-lint"
  link: "http://puppet-lint.com/"

  options: {
    Puppet: true
  }

  executables: [
    {
      name: "puppet-lint"
      cmd: "puppet-lint"
      homepage: "http://puppet-lint.com/"
      installation: "http://puppet-lint.com/"
      version: {
        parse: (text) -> text.match(/puppet-lint (\d+\.\d+\.\d+)/)[1]
      }
      docker: {
        image: "unibeautify/puppet-lint"
      }
    }
  ]

  beautify: (text, language, options) ->
    @exe("puppet-lint", [
      '--fix'
      tempFile = @tempFile("input", text)
      ], {
        ignoreReturnCode: true
        help: {
          link: "http://puppet-lint.com/"
        }
      })
      .then(=>
        @readFile(tempFile)
      )


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
###
Requires [puppet-link](http://puppet-lint.com/)
###
"use strict"
Beautifier = require('./beautifier')

module.exports = class PuppetFix extends Beautifier
  # this is what displays as your Default Beautifier in Language Config
  name: "puppet-lint"
  link: "http://puppet-lint.com/"

  options: {
    Puppet: true
  }

  executables: [
    {
      name: "puppet-lint"
      cmd: "puppet-lint"
      homepage: "http://puppet-lint.com/"
      installation: "http://puppet-lint.com/"
      version: {
        parse: (text) -> text.match(/puppet-lint (\d+\.\d+\.\d+)/)[1]
      }
      docker: {
        image: "unibeautify/puppet-lint"
      }
    }
  ]

  beautify: (text, language, options) ->
    @exe("puppet-lint", [
      '--fix'
      tempFile = @tempFile("input", text)
      ], {
        ignoreReturnCode: true
        help: {
          link: "http://puppet-lint.com/"
        }
      })
      .then(=>
        @readFile(tempFile)
      )
```

Response:
/*
Requires [puppet-link](http://puppet-lint.com/)
*/
"use strict";
var Beautifier, PuppetFix;

Beautifier = require('./beautifier');

module.exports = PuppetFix = (function() {
  class PuppetFix extends Beautifier {
    beautify(text, language, options) {
      var tempFile;
      return this.exe("puppet-lint", ['--fix', tempFile = this.tempFile("input", text)], {
        ignoreReturnCode: true,
        help: {
          link: "http://puppet-lint.com/"
        }
      }).then(() => {
        return this.readFile(tempFile);
      });
    }

  };

  // this is what displays as your Default Beautifier in Language Config
  PuppetFix.prototype.name = "puppet-lint";

  PuppetFix.prototype.link = "http://puppet-lint.com/";

  PuppetFix.prototype.options = {
    Puppet: true
  };

  PuppetFix.prototype.executables = [
    {
      name: "puppet-lint",
      cmd: "puppet-lint",
      homepage: "http://puppet-lint.com/",
      installation: "http://puppet-lint.com/",
      version: {
        parse: function(text) {
          return text.match(/puppet-lint (\d+\.\d+\.\d+)/)[1];
        }
      },
      docker: {
        image: "unibeautify/puppet-lint"
      }
    }
  ];

  return PuppetFix;

}).call(this);


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
/*
Requires [puppet-link](http://puppet-lint.com/)
*/
"use strict";
var Beautifier, PuppetFix;

Beautifier = require('./beautifier');

module.exports = PuppetFix = (function() {
  class PuppetFix extends Beautifier {
    beautify(text, language, options) {
      var tempFile;
      return this.exe("puppet-lint", ['--fix', tempFile = this.tempFile("input", text)], {
        ignoreReturnCode: true,
        help: {
          link: "http://puppet-lint.com/"
        }
      }).then(() => {
        return this.readFile(tempFile);
      });
    }

  };

  // this is what displays as your Default Beautifier in Language Config
  PuppetFix.prototype.name = "puppet-lint";

  PuppetFix.prototype.link = "http://puppet-lint.com/";

  PuppetFix.prototype.options = {
    Puppet: true
  };

  PuppetFix.prototype.executables = [
    {
      name: "puppet-lint",
      cmd: "puppet-lint",
      homepage: "http://puppet-lint.com/",
      installation: "http://puppet-lint.com/",
      version: {
        parse: function(text) {
          return text.match(/puppet-lint (\d+\.\d+\.\d+)/)[1];
        }
      },
      docker: {
        image: "unibeautify/puppet-lint"
      }
    }
  ];

  return PuppetFix;

}).call(this);
```

Response:
###
Requires [puppet-link](http://puppet-lint.com/)
###
"use strict"
Beautifier = require('./beautifier')

module.exports = class PuppetFix extends Beautifier
  # this is what displays as your Default Beautifier in Language Config
  name: "puppet-lint"
  link: "http://puppet-lint.com/"

  options: {
    Puppet: true
  }

  executables: [
    {
      name: "puppet-lint"
      cmd: "puppet-lint"
      homepage: "http://puppet-lint.com/"
      installation: "http://puppet-lint.com/"
      version: {
        parse: (text) -> text.match(/puppet-lint (\d+\.\d+\.\d+)/)[1]
      }
      docker: {
        image: "unibeautify/puppet-lint"
      }
    }
  ]

  beautify: (text, language, options) ->
    @exe("puppet-lint", [
      '--fix'
      tempFile = @tempFile("input", text)
      ], {
        ignoreReturnCode: true
        help: {
          link: "http://puppet-lint.com/"
        }
      })
      .then(=>
        @readFile(tempFile)
      )


Prompt:
###
Requires [puppet-link](http://puppet-lint.com/)
###
"use strict"
Beautifier = require('./beautifier')

module.exports = class PuppetFix extends Beautifier
  # this is what displays as your Default Beautifier in Language Config
  name: "puppet-lint"
  link: "http://puppet-lint.com/"

  options: {
    Puppet: true
  }

  executables: [
    {
      name: "puppet-lint"
      cmd: "puppet-lint"
      homepage: "http://puppet-lint.com/"
      installation: "http://puppet-lint.com/"

Response:
version: {
        parse: (text) -> text.match(/puppet-lint (\d+\.\d+\.\d+)/)[1]
      }
      docker: {
        image: "unibeautify/puppet-lint"
      }
    }
  ]

  beautify: (text, language, options) ->
    @exe("puppet-lint", [
      '--fix'
      tempFile = @tempFile("input", text)
      ], {
        ignoreReturnCode: true
        help: {
          link: "http://puppet-lint.com/"
        }
      })
      .then(=>
        @readFile(tempFile)
      )


Response:
###
Requires [puppet-link](http://puppet-lint.com/)
###
"use strict"
Beautifier = require('./beautifier')

module.exports = class PuppetFix extends Beautifier
  # this is what displays as your Default Beautifier in Language Config
  name: "puppet-lint"
  link: "http://puppet-lint.com/"
  isPreInstalled: false

  options: {
    Puppet: true
  }

  cli: (options) ->
    if not options.puppet_path?
      return new Error("'puppet-lint' path is not set!" +
        " Please set this in the Atom Beautify package settings.")
    else
      return options.puppet_path

  beautify: (text, language, options) ->
    @run("puppet-lint", [
      '--fix'
      tempFile = @tempFile("input", text)
      ], {
        ignoreReturnCode: true
        help: {
          link: "http://puppet-lint.com/"
        }
      })
      .then(=>
        @readFile(tempFile)
      )


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
###
Requires [puppet-link](http://puppet-lint.com/)
###
"use strict"
Beautifier = require('./beautifier')

module.exports = class PuppetFix extends Beautifier
  # this is what displays as your Default Beautifier in Language Config
  name: "puppet-lint"
  link: "http://puppet-lint.com/"
  isPreInstalled: false

  options: {
    Puppet: true
  }

  cli: (options) ->
    if not options.puppet_path?
      return new Error("'puppet-lint' path is not set!" +
        " Please set this in the Atom Beautify package settings.")
    else
      return options.puppet_path

  beautify: (text, language, options) ->
    @run("puppet-lint", [
      '--fix'
      tempFile = @tempFile("input", text)
      ], {
        ignoreReturnCode: true
        help: {
          link: "http://puppet-lint.com/"
        }
      })
      .then(=>
        @readFile(tempFile)
      )
```

Response:
/*
Requires [puppet-link](http://puppet-lint.com/)
*/
"use strict";
var Beautifier, PuppetFix;

Beautifier = require('./beautifier');

module.exports = PuppetFix = (function() {
  class PuppetFix extends Beautifier {
    cli(options) {
      if (options.puppet_path == null) {
        return new Error("'puppet-lint' path is not set!" + " Please set this in the Atom Beautify package settings.");
      } else {
        return options.puppet_path;
      }
    }

    beautify(text, language, options) {
      var tempFile;
      return this.run("puppet-lint", ['--fix', tempFile = this.tempFile("input", text)], {
        ignoreReturnCode: true,
        help: {
          link: "http://puppet-lint.com/"
        }
      }).then(() => {
        return this.readFile(tempFile);
      });
    }

  };

  // this is what displays as your Default Beautifier in Language Config
  PuppetFix.prototype.name = "puppet-lint";

  PuppetFix.prototype.link = "http://puppet-lint.com/";

  PuppetFix.prototype.isPreInstalled = false;

  PuppetFix.prototype.options = {
    Puppet: true
  };

  return PuppetFix;

}).call(this);


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
/*
Requires [puppet-link](http://puppet-lint.com/)
*/
"use strict";
var Beautifier, PuppetFix;

Beautifier = require('./beautifier');

module.exports = PuppetFix = (function() {
  class PuppetFix extends Beautifier {
    cli(options) {
      if (options.puppet_path == null) {
        return new Error("'puppet-lint' path is not set!" + " Please set this in the Atom Beautify package settings.");
      } else {
        return options.puppet_path;
      }
    }

    beautify(text, language, options) {
      var tempFile;
      return this.run("puppet-lint", ['--fix', tempFile = this.tempFile("input", text)], {
        ignoreReturnCode: true,
        help: {
          link: "http://puppet-lint.com/"
        }
      }).then(() => {
        return this.readFile(tempFile);
      });
    }

  };

  // this is what displays as your Default Beautifier in Language Config
  PuppetFix.prototype.name = "puppet-lint";

  PuppetFix.prototype.link = "http://puppet-lint.com/";

  PuppetFix.prototype.isPreInstalled = false;

  PuppetFix.prototype.options = {
    Puppet: true
  };

  return PuppetFix;

}).call(this);
```

Response:
###
Requires [puppet-link](http://puppet-lint.com/)
###
"use strict"
Beautifier = require('./beautifier')

module.exports = class PuppetFix extends Beautifier
  # this is what displays as your Default Beautifier in Language Config
  name: "puppet-lint"
  link: "http://puppet-lint.com/"
  isPreInstalled: false

  options: {
    Puppet: true
  }

  cli: (options) ->
    if not options.puppet_path?
      return new Error("'puppet-lint' path is not set!" +
        " Please set this in the Atom Beautify package settings.")
    else
      return options.puppet_path

  beautify: (text, language, options) ->
    @run("puppet-lint", [
      '--fix'
      tempFile = @tempFile("input", text)
      ], {
        ignoreReturnCode: true
        help: {
          link: "http://puppet-lint.com/"
        }
      })
      .then(=>
        @readFile(tempFile)
      )


Prompt:
###
Requires [puppet-link](http://puppet-lint.com/)
###
"use strict"
Beautifier = require('./beautifier')

module.exports = class PuppetFix extends Beautifier
  # this is what displays as your Default Beautifier in Language Config
  name: "puppet-lint"
  link: "http://puppet-lint.com/"
  isPreInstalled: false

  options: {
    Puppet: true
  }

  cli: (options) ->
    if not options.puppet_path?

Response:
return new Error("'puppet-lint' path is not set!" +
        " Please set this in the Atom Beautify package settings.")
    else
      return options.puppet_path

  beautify: (text, language, options) ->
    @run("puppet-lint", [
      '--fix'
      tempFile = @tempFile("input", text)
      ], {
        ignoreReturnCode: true
        help: {
          link: "http://puppet-lint.com/"
        }
      })
      .then(=>
        @readFile(tempFile)
      )


Response:
React = require 'react'
ReactDOM = require 'react-dom'
recorder = require 'actions-recorder'

schema = require '../schema'
updater = require '../updater'

require('./main.less')
require '../network/receiver'

dispatcher = require '../dispatcher'

Util    = require '../util/util'

handlers = require './handlers'

routes = require './routes'
Container = React.createFactory require '../guest-app/container'

if Util.parseUA(window.navigator.userAgent).os is 'windows'
  document.body.className = 'is-windows'

# initialize app

recorder.setup
  initial: schema.database
  inProduction: false
  updater: updater

render = (core) ->
  store = core.get('store')
  ReactDOM.render Container({store, core}), document.querySelector('.app')

recorder.request render
recorder.subscribe render

# initialize networks
handlers.initialize()

if module.hot
  module.hot.accept ['../guest-app/container'], ->
    Container = React.createFactory require '../guest-app/container'
    recorder.request render


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
React = require 'react'
ReactDOM = require 'react-dom'
recorder = require 'actions-recorder'

schema = require '../schema'
updater = require '../updater'

require('./main.less')
require '../network/receiver'

dispatcher = require '../dispatcher'

Util    = require '../util/util'

handlers = require './handlers'

routes = require './routes'
Container = React.createFactory require '../guest-app/container'

if Util.parseUA(window.navigator.userAgent).os is 'windows'
  document.body.className = 'is-windows'

# initialize app

recorder.setup
  initial: schema.database
  inProduction: false
  updater: updater

render = (core) ->
  store = core.get('store')
  ReactDOM.render Container({store, core}), document.querySelector('.app')

recorder.request render
recorder.subscribe render

# initialize networks
handlers.initialize()

if module.hot
  module.hot.accept ['../guest-app/container'], ->
    Container = React.createFactory require '../guest-app/container'
    recorder.request render
```

Response:
var Container, React, ReactDOM, Util, dispatcher, handlers, recorder, render, routes, schema, updater;

React = require('react');

ReactDOM = require('react-dom');

recorder = require('actions-recorder');

schema = require('../schema');

updater = require('../updater');

require('./main.less');

require('../network/receiver');

dispatcher = require('../dispatcher');

Util = require('../util/util');

handlers = require('./handlers');

routes = require('./routes');

Container = React.createFactory(require('../guest-app/container'));

if (Util.parseUA(window.navigator.userAgent).os === 'windows') {
  document.body.className = 'is-windows';
}

// initialize app
recorder.setup({
  initial: schema.database,
  inProduction: false,
  updater: updater
});

render = function(core) {
  var store;
  store = core.get('store');
  return ReactDOM.render(Container({store, core}), document.querySelector('.app'));
};

recorder.request(render);

recorder.subscribe(render);

// initialize networks
handlers.initialize();

if (module.hot) {
  module.hot.accept(['../guest-app/container'], function() {
    Container = React.createFactory(require('../guest-app/container'));
    return recorder.request(render);
  });
}


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var Container, React, ReactDOM, Util, dispatcher, handlers, recorder, render, routes, schema, updater;

React = require('react');

ReactDOM = require('react-dom');

recorder = require('actions-recorder');

schema = require('../schema');

updater = require('../updater');

require('./main.less');

require('../network/receiver');

dispatcher = require('../dispatcher');

Util = require('../util/util');

handlers = require('./handlers');

routes = require('./routes');

Container = React.createFactory(require('../guest-app/container'));

if (Util.parseUA(window.navigator.userAgent).os === 'windows') {
  document.body.className = 'is-windows';
}

// initialize app
recorder.setup({
  initial: schema.database,
  inProduction: false,
  updater: updater
});

render = function(core) {
  var store;
  store = core.get('store');
  return ReactDOM.render(Container({store, core}), document.querySelector('.app'));
};

recorder.request(render);

recorder.subscribe(render);

// initialize networks
handlers.initialize();

if (module.hot) {
  module.hot.accept(['../guest-app/container'], function() {
    Container = React.createFactory(require('../guest-app/container'));
    return recorder.request(render);
  });
}
```

Response:
React = require 'react'
ReactDOM = require 'react-dom'
recorder = require 'actions-recorder'

schema = require '../schema'
updater = require '../updater'

require('./main.less')
require '../network/receiver'

dispatcher = require '../dispatcher'

Util    = require '../util/util'

handlers = require './handlers'

routes = require './routes'
Container = React.createFactory require '../guest-app/container'

if Util.parseUA(window.navigator.userAgent).os is 'windows'
  document.body.className = 'is-windows'

# initialize app

recorder.setup
  initial: schema.database
  inProduction: false
  updater: updater

render = (core) ->
  store = core.get('store')
  ReactDOM.render Container({store, core}), document.querySelector('.app')

recorder.request render
recorder.subscribe render

# initialize networks
handlers.initialize()

if module.hot
  module.hot.accept ['../guest-app/container'], ->
    Container = React.createFactory require '../guest-app/container'
    recorder.request render


Prompt:
React = require 'react'
ReactDOM = require 'react-dom'
recorder = require 'actions-recorder'

schema = require '../schema'
updater = require '../updater'

require('./main.less')
require '../network/receiver'

dispatcher = require '../dispatcher'

Util    = require '../util/util'

handlers = require './handlers'

routes = require './routes'
Container = React.createFactory require '../guest-app/container'

if Util.parseUA(window.navigator.userAgent).os is 'windows'
  document.body.className = 'is-windows'

Response:
# initialize app

recorder.setup
  initial: schema.database
  inProduction: false
  updater: updater

render = (core) ->
  store = core.get('store')
  ReactDOM.render Container({store, core}), document.querySelector('.app')

recorder.request render
recorder.subscribe render

# initialize networks
handlers.initialize()

if module.hot
  module.hot.accept ['../guest-app/container'], ->
    Container = React.createFactory require '../guest-app/container'
    recorder.request render


Response:
config = require '../config'

# Returns whether track was succesful
exports.track = (args...) ->
    if config.logOnAnalytics
        console.log "Tracking event"
        console.log args

    if config.environment == 'production'
        if window.analytics?
            window.analytics.track(args...)
            return true

        else
            return false
    else
        return true


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
config = require '../config'

# Returns whether track was succesful
exports.track = (args...) ->
    if config.logOnAnalytics
        console.log "Tracking event"
        console.log args

    if config.environment == 'production'
        if window.analytics?
            window.analytics.track(args...)
            return true

        else
            return false
    else
        return true
```

Response:
var config;

config = require('../config');

// Returns whether track was succesful
exports.track = function(...args) {
  if (config.logOnAnalytics) {
    console.log("Tracking event");
    console.log(args);
  }
  if (config.environment === 'production') {
    if (window.analytics != null) {
      window.analytics.track(...args);
      return true;
    } else {
      return false;
    }
  } else {
    return true;
  }
};


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var config;

config = require('../config');

// Returns whether track was succesful
exports.track = function(...args) {
  if (config.logOnAnalytics) {
    console.log("Tracking event");
    console.log(args);
  }
  if (config.environment === 'production') {
    if (window.analytics != null) {
      window.analytics.track(...args);
      return true;
    } else {
      return false;
    }
  } else {
    return true;
  }
};
```

Response:
config = require '../config'

# Returns whether track was succesful
exports.track = (args...) ->
    if config.logOnAnalytics
        console.log "Tracking event"
        console.log args

    if config.environment == 'production'
        if window.analytics?
            window.analytics.track(args...)
            return true

        else
            return false
    else
        return true


Prompt:
config = require '../config'

# Returns whether track was succesful
exports.track = (args...) ->
    if config.logOnAnalytics
        console.log "Tracking event"
        console.log args

Response:
if config.environment == 'production'
        if window.analytics?
            window.analytics.track(args...)
            return true

        else
            return false
    else
        return true


Response:
PublishForwarder = require '../src/publish-forwarder'
TestDatabase = require './test-database'

describe 'PublishForwarder', ->
  beforeEach (done) ->
    TestDatabase.open (error, database) =>
      {@devices,@subscriptions}  = database
      @devices.find {}, (error, devices) =>
        done error

  beforeEach ->
    @publisher = publish: sinon.stub().yields null
    @messageWebhook = send: sinon.stub().yields null
    @MessageWebhook = sinon.spy =>
      @messageWebhook
    @sut = new PublishForwarder {@publisher}, {@devices, @MessageWebhook, @subscriptions}

  describe '-> forward', ->
    beforeEach (done) ->
      @receiverUuid = 'dc8331b5-33b6-47b0-85db-2106930d0601'
      record =
        name: 'Receiver'
        uuid: @receiverUuid
      @devices.insert record, done

    context 'sent', ->
      context 'with a subscription', ->
        beforeEach (done) ->
          @forwarderUuid = '9749b660-b6dc-4189-b248-1248e72ecb51'
          record =
            name: 'Forwarder'
            uuid: @forwarderUuid
            configureWhitelist: [ @receiverUuid ]
          @devices.insert record, done

        beforeEach (done) ->
          record =
            emitterUuid: @forwarderUuid
            subscriberUuid: @receiverUuid
            type: 'sent'
          @subscriptions.insert record, done


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
PublishForwarder = require '../src/publish-forwarder'
TestDatabase = require './test-database'

describe 'PublishForwarder', ->
  beforeEach (done) ->
    TestDatabase.open (error, database) =>
      {@devices,@subscriptions}  = database
      @devices.find {}, (error, devices) =>
        done error

  beforeEach ->
    @publisher = publish: sinon.stub().yields null
    @messageWebhook = send: sinon.stub().yields null
    @MessageWebhook = sinon.spy =>
      @messageWebhook
    @sut = new PublishForwarder {@publisher}, {@devices, @MessageWebhook, @subscriptions}

  describe '-> forward', ->
    beforeEach (done) ->
      @receiverUuid = 'dc8331b5-33b6-47b0-85db-2106930d0601'
      record =
        name: 'Receiver'
        uuid: @receiverUuid
      @devices.insert record, done

    context 'sent', ->
      context 'with a subscription', ->
        beforeEach (done) ->
          @forwarderUuid = '9749b660-b6dc-4189-b248-1248e72ecb51'
          record =
            name: 'Forwarder'
            uuid: @forwarderUuid
            configureWhitelist: [ @receiverUuid ]
          @devices.insert record, done

        beforeEach (done) ->
          record =
            emitterUuid: @forwarderUuid
            subscriberUuid: @receiverUuid
            type: 'sent'
          @subscriptions.insert record, done
```

Response:
var PublishForwarder, TestDatabase;

PublishForwarder = require('../src/publish-forwarder');

TestDatabase = require('./test-database');

describe('PublishForwarder', function() {
  beforeEach(function(done) {
    return TestDatabase.open((error, database) => {
      ({devices: this.devices, subscriptions: this.subscriptions} = database);
      return this.devices.find({}, (error, devices) => {
        return done(error);
      });
    });
  });
  beforeEach(function() {
    this.publisher = {
      publish: sinon.stub().yields(null)
    };
    this.messageWebhook = {
      send: sinon.stub().yields(null)
    };
    this.MessageWebhook = sinon.spy(() => {
      return this.messageWebhook;
    });
    return this.sut = new PublishForwarder({publisher: this.publisher}, {devices: this.devices, MessageWebhook: this.MessageWebhook, subscriptions: this.subscriptions});
  });
  return describe('-> forward', function() {
    beforeEach(function(done) {
      var record;
      this.receiverUuid = 'dc8331b5-33b6-47b0-85db-2106930d0601';
      record = {
        name: 'Receiver',
        uuid: this.receiverUuid
      };
      return this.devices.insert(record, done);
    });
    return context('sent', function() {
      return context('with a subscription', function() {
        beforeEach(function(done) {
          var record;
          this.forwarderUuid = '9749b660-b6dc-4189-b248-1248e72ecb51';
          record = {
            name: 'Forwarder',
            uuid: this.forwarderUuid,
            configureWhitelist: [this.receiverUuid]
          };
          return this.devices.insert(record, done);
        });
        return beforeEach(function(done) {
          var record;
          record = {
            emitterUuid: this.forwarderUuid,
            subscriberUuid: this.receiverUuid,
            type: 'sent'
          };
          return this.subscriptions.insert(record, done);
        });
      });
    });
  });
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var PublishForwarder, TestDatabase;

PublishForwarder = require('../src/publish-forwarder');

TestDatabase = require('./test-database');

describe('PublishForwarder', function() {
  beforeEach(function(done) {
    return TestDatabase.open((error, database) => {
      ({devices: this.devices, subscriptions: this.subscriptions} = database);
      return this.devices.find({}, (error, devices) => {
        return done(error);
      });
    });
  });
  beforeEach(function() {
    this.publisher = {
      publish: sinon.stub().yields(null)
    };
    this.messageWebhook = {
      send: sinon.stub().yields(null)
    };
    this.MessageWebhook = sinon.spy(() => {
      return this.messageWebhook;
    });
    return this.sut = new PublishForwarder({publisher: this.publisher}, {devices: this.devices, MessageWebhook: this.MessageWebhook, subscriptions: this.subscriptions});
  });
  return describe('-> forward', function() {
    beforeEach(function(done) {
      var record;
      this.receiverUuid = 'dc8331b5-33b6-47b0-85db-2106930d0601';
      record = {
        name: 'Receiver',
        uuid: this.receiverUuid
      };
      return this.devices.insert(record, done);
    });
    return context('sent', function() {
      return context('with a subscription', function() {
        beforeEach(function(done) {
          var record;
          this.forwarderUuid = '9749b660-b6dc-4189-b248-1248e72ecb51';
          record = {
            name: 'Forwarder',
            uuid: this.forwarderUuid,
            configureWhitelist: [this.receiverUuid]
          };
          return this.devices.insert(record, done);
        });
        return beforeEach(function(done) {
          var record;
          record = {
            emitterUuid: this.forwarderUuid,
            subscriberUuid: this.receiverUuid,
            type: 'sent'
          };
          return this.subscriptions.insert(record, done);
        });
      });
    });
  });
});
```

Response:
PublishForwarder = require '../src/publish-forwarder'
TestDatabase = require './test-database'

describe 'PublishForwarder', ->
  beforeEach (done) ->
    TestDatabase.open (error, database) =>
      {@devices,@subscriptions}  = database
      @devices.find {}, (error, devices) =>
        done error

  beforeEach ->
    @publisher = publish: sinon.stub().yields null
    @messageWebhook = send: sinon.stub().yields null
    @MessageWebhook = sinon.spy =>
      @messageWebhook
    @sut = new PublishForwarder {@publisher}, {@devices, @MessageWebhook, @subscriptions}

  describe '-> forward', ->
    beforeEach (done) ->
      @receiverUuid = 'dc8331b5-33b6-47b0-85db-2106930d0601'
      record =
        name: 'Receiver'
        uuid: @receiverUuid
      @devices.insert record, done

    context 'sent', ->
      context 'with a subscription', ->
        beforeEach (done) ->
          @forwarderUuid = '9749b660-b6dc-4189-b248-1248e72ecb51'
          record =
            name: 'Forwarder'
            uuid: @forwarderUuid
            configureWhitelist: [ @receiverUuid ]
          @devices.insert record, done

        beforeEach (done) ->
          record =
            emitterUuid: @forwarderUuid
            subscriberUuid: @receiverUuid
            type: 'sent'
          @subscriptions.insert record, done


Prompt:
PublishForwarder = require '../src/publish-forwarder'
TestDatabase = require './test-database'

describe 'PublishForwarder', ->
  beforeEach (done) ->
    TestDatabase.open (error, database) =>
      {@devices,@subscriptions}  = database
      @devices.find {}, (error, devices) =>
        done error

  beforeEach ->
    @publisher = publish: sinon.stub().yields null
    @messageWebhook = send: sinon.stub().yields null
    @MessageWebhook = sinon.spy =>
      @messageWebhook
    @sut = new PublishForwarder {@publisher}, {@devices, @MessageWebhook, @subscriptions}

  describe '-> forward', ->
    beforeEach (done) ->
      @receiverUuid = 'dc8331b5-33b6-47b0-85db-2106930d0601'

Response:
record =
        name: 'Receiver'
        uuid: @receiverUuid
      @devices.insert record, done

    context 'sent', ->
      context 'with a subscription', ->
        beforeEach (done) ->
          @forwarderUuid = '9749b660-b6dc-4189-b248-1248e72ecb51'
          record =
            name: 'Forwarder'
            uuid: @forwarderUuid
            configureWhitelist: [ @receiverUuid ]
          @devices.insert record, done

        beforeEach (done) ->
          record =
            emitterUuid: @forwarderUuid
            subscriberUuid: @receiverUuid
            type: 'sent'
          @subscriptions.insert record, done


Response:
beforeEach (done) ->
          uuid = @forwarderUuid
          type = 'sent'
          message =
            devices: ['*']
          @sut.forward {uuid, type, message}, (error) =>
            done error

        it 'should forward a message', ->
          newMessage =
            devices: ['*']
            forwardedFor: [@forwarderUuid]

          expect(@publisher.publish).to.have.been.calledWith 'sent', @receiverUuid, newMessage

      context 'type: webhook', ->
        beforeEach (done) ->
          @hookOptions =
            type: 'webhook'
            url: 'http://example.com'
          @forwarderUuid = '27aa53ae-a5c0-4b1b-8051-389c65c98df2'
          record =
            name: 'Forwarder'
            uuid: @forwarderUuid
            meshblu:
              forwarders:
                sent: [ @hookOptions ]
          @devices.insert record, done

        beforeEach (done) ->
          uuid = @forwarderUuid
          type = 'sent'
          message =
            devices: ['*']
          @sut.forward {uuid, type, message}, (error) =>
            done error

        it 'should send a webhook', ->
          newMessage =
            devices: ['*']
            forwardedFor: [@forwarderUuid]


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
beforeEach (done) ->
          uuid = @forwarderUuid
          type = 'sent'
          message =
            devices: ['*']
          @sut.forward {uuid, type, message}, (error) =>
            done error

        it 'should forward a message', ->
          newMessage =
            devices: ['*']
            forwardedFor: [@forwarderUuid]

          expect(@publisher.publish).to.have.been.calledWith 'sent', @receiverUuid, newMessage

      context 'type: webhook', ->
        beforeEach (done) ->
          @hookOptions =
            type: 'webhook'
            url: 'http://example.com'
          @forwarderUuid = '27aa53ae-a5c0-4b1b-8051-389c65c98df2'
          record =
            name: 'Forwarder'
            uuid: @forwarderUuid
            meshblu:
              forwarders:
                sent: [ @hookOptions ]
          @devices.insert record, done

        beforeEach (done) ->
          uuid = @forwarderUuid
          type = 'sent'
          message =
            devices: ['*']
          @sut.forward {uuid, type, message}, (error) =>
            done error

        it 'should send a webhook', ->
          newMessage =
            devices: ['*']
            forwardedFor: [@forwarderUuid]
```

Response:
beforeEach(function(done) {
  var message, type, uuid;
  uuid = this.forwarderUuid;
  type = 'sent';
  message = {
    devices: ['*']
  };
  return this.sut.forward({uuid, type, message}, (error) => {
    return done(error);
  });
});

it('should forward a message', function() {
  var newMessage;
  newMessage = {
    devices: ['*'],
    forwardedFor: [this.forwarderUuid]
  };
  return expect(this.publisher.publish).to.have.been.calledWith('sent', this.receiverUuid, newMessage);
});

context('type: webhook', function() {
  beforeEach(function(done) {
    var record;
    this.hookOptions = {
      type: 'webhook',
      url: 'http://example.com'
    };
    this.forwarderUuid = '27aa53ae-a5c0-4b1b-8051-389c65c98df2';
    record = {
      name: 'Forwarder',
      uuid: this.forwarderUuid,
      meshblu: {
        forwarders: {
          sent: [this.hookOptions]
        }
      }
    };
    return this.devices.insert(record, done);
  });
  beforeEach(function(done) {
    var message, type, uuid;
    uuid = this.forwarderUuid;
    type = 'sent';
    message = {
      devices: ['*']
    };
    return this.sut.forward({uuid, type, message}, (error) => {
      return done(error);
    });
  });
  return it('should send a webhook', function() {
    var newMessage;
    return newMessage = {
      devices: ['*'],
      forwardedFor: [this.forwarderUuid]
    };
  });
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
beforeEach(function(done) {
  var message, type, uuid;
  uuid = this.forwarderUuid;
  type = 'sent';
  message = {
    devices: ['*']
  };
  return this.sut.forward({uuid, type, message}, (error) => {
    return done(error);
  });
});

it('should forward a message', function() {
  var newMessage;
  newMessage = {
    devices: ['*'],
    forwardedFor: [this.forwarderUuid]
  };
  return expect(this.publisher.publish).to.have.been.calledWith('sent', this.receiverUuid, newMessage);
});

context('type: webhook', function() {
  beforeEach(function(done) {
    var record;
    this.hookOptions = {
      type: 'webhook',
      url: 'http://example.com'
    };
    this.forwarderUuid = '27aa53ae-a5c0-4b1b-8051-389c65c98df2';
    record = {
      name: 'Forwarder',
      uuid: this.forwarderUuid,
      meshblu: {
        forwarders: {
          sent: [this.hookOptions]
        }
      }
    };
    return this.devices.insert(record, done);
  });
  beforeEach(function(done) {
    var message, type, uuid;
    uuid = this.forwarderUuid;
    type = 'sent';
    message = {
      devices: ['*']
    };
    return this.sut.forward({uuid, type, message}, (error) => {
      return done(error);
    });
  });
  return it('should send a webhook', function() {
    var newMessage;
    return newMessage = {
      devices: ['*'],
      forwardedFor: [this.forwarderUuid]
    };
  });
});
```

Response:
beforeEach (done) ->
          uuid = @forwarderUuid
          type = 'sent'
          message =
            devices: ['*']
          @sut.forward {uuid, type, message}, (error) =>
            done error

        it 'should forward a message', ->
          newMessage =
            devices: ['*']
            forwardedFor: [@forwarderUuid]

          expect(@publisher.publish).to.have.been.calledWith 'sent', @receiverUuid, newMessage

      context 'type: webhook', ->
        beforeEach (done) ->
          @hookOptions =
            type: 'webhook'
            url: 'http://example.com'
          @forwarderUuid = '27aa53ae-a5c0-4b1b-8051-389c65c98df2'
          record =
            name: 'Forwarder'
            uuid: @forwarderUuid
            meshblu:
              forwarders:
                sent: [ @hookOptions ]
          @devices.insert record, done

        beforeEach (done) ->
          uuid = @forwarderUuid
          type = 'sent'
          message =
            devices: ['*']
          @sut.forward {uuid, type, message}, (error) =>
            done error

        it 'should send a webhook', ->
          newMessage =
            devices: ['*']
            forwardedFor: [@forwarderUuid]


Prompt:
beforeEach (done) ->
          uuid = @forwarderUuid
          type = 'sent'
          message =
            devices: ['*']
          @sut.forward {uuid, type, message}, (error) =>
            done error

        it 'should forward a message', ->
          newMessage =
            devices: ['*']
            forwardedFor: [@forwarderUuid]

          expect(@publisher.publish).to.have.been.calledWith 'sent', @receiverUuid, newMessage

      context 'type: webhook', ->
        beforeEach (done) ->
          @hookOptions =
            type: 'webhook'
            url: 'http://example.com'

Response:
@forwarderUuid = '27aa53ae-a5c0-4b1b-8051-389c65c98df2'
          record =
            name: 'Forwarder'
            uuid: @forwarderUuid
            meshblu:
              forwarders:
                sent: [ @hookOptions ]
          @devices.insert record, done

        beforeEach (done) ->
          uuid = @forwarderUuid
          type = 'sent'
          message =
            devices: ['*']
          @sut.forward {uuid, type, message}, (error) =>
            done error

        it 'should send a webhook', ->
          newMessage =
            devices: ['*']
            forwardedFor: [@forwarderUuid]


Response:
expect(@MessageWebhook).to.have.been.calledWith uuid: @forwarderUuid, type: 'sent', options: @hookOptions
          expect(@messageWebhook.send).to.have.been.calledWith newMessage

    context 'received', ->
      context 'with a subscription', ->
        beforeEach (done) ->
          @forwarderUuid = 'eb76dac1-83d6-415b-a4e5-d4847d190ff8'
          record =
            name: 'Forwarder'
            uuid: @forwarderUuid
            configureWhitelist: [ @receiverUuid ]
          @devices.insert record, done

        beforeEach (done) ->
          record =
            emitterUuid: @forwarderUuid
            subscriberUuid: @receiverUuid
            type: 'received'
          @subscriptions.insert record, done

        beforeEach (done) ->
          uuid = @forwarderUuid
          type = 'received'
          message =
            devices: ['*']
          @sut.forward {uuid, type, message}, (error) =>
            done error

        it 'should forward a message', ->
          newMessage =
            devices: ['*']
            forwardedFor: [@forwarderUuid]

          expect(@publisher.publish).to.have.been.calledWith 'received', @receiverUuid, newMessage


Prompt:
expect(@MessageWebhook).to.have.been.calledWith uuid: @forwarderUuid, type: 'sent', options: @hookOptions
          expect(@messageWebhook.send).to.have.been.calledWith newMessage

    context 'received', ->
      context 'with a subscription', ->
        beforeEach (done) ->
          @forwarderUuid = 'eb76dac1-83d6-415b-a4e5-d4847d190ff8'
          record =
            name: 'Forwarder'
            uuid: @forwarderUuid
            configureWhitelist: [ @receiverUuid ]
          @devices.insert record, done

        beforeEach (done) ->
          record =
            emitterUuid: @forwarderUuid
            subscriberUuid: @receiverUuid

Response:
type: 'received'
          @subscriptions.insert record, done

        beforeEach (done) ->
          uuid = @forwarderUuid
          type = 'received'
          message =
            devices: ['*']
          @sut.forward {uuid, type, message}, (error) =>
            done error

        it 'should forward a message', ->
          newMessage =
            devices: ['*']
            forwardedFor: [@forwarderUuid]

          expect(@publisher.publish).to.have.been.calledWith 'received', @receiverUuid, newMessage


Response:
# Copied from react-lite-layered,
# that module is on react 0.14

React = require 'react'
keycode = require 'keycode'

mixinLayered = require '../mixin/layered'

Transition = React.createFactory require './transition'

div    = React.createFactory 'div'
span   = React.createFactory 'span'
a      = React.createFactory 'a'
button = React.createFactory 'button'

T = React.PropTypes
cx = require 'classnames'

module.exports = React.createClass
  displayName: 'lite-dialog'
  mixins: [mixinLayered]

  propTypes:
    # this components accepts children
    cancel:       T.string
    confirm:      T.string
    content:      T.string
    flexible:     T.bool
    show:         T.bool.isRequired
    onCloseClick: T.func.isRequired
    onConfirm:    T.func.isRequired

  bindWindowEvents: ->
    window.addEventListener 'keydown', @onWindowKeydown

  unbindWindowEvents: ->
    window.removeEventListener 'keydown', @onWindowKeydown

  onWindowKeydown: (event) ->
    if keycode(event.keyCode) is 'esc'
      @onCloseClick(event)

  onCloseClick: (event) ->
    event.stopPropagation()
    @props.onCloseClick()

  onConfirmClick: (event) ->
    @props.onConfirm()
    @onCloseClick(event)


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
# Copied from react-lite-layered,
# that module is on react 0.14

React = require 'react'
keycode = require 'keycode'

mixinLayered = require '../mixin/layered'

Transition = React.createFactory require './transition'

div    = React.createFactory 'div'
span   = React.createFactory 'span'
a      = React.createFactory 'a'
button = React.createFactory 'button'

T = React.PropTypes
cx = require 'classnames'

module.exports = React.createClass
  displayName: 'lite-dialog'
  mixins: [mixinLayered]

  propTypes:
    # this components accepts children
    cancel:       T.string
    confirm:      T.string
    content:      T.string
    flexible:     T.bool
    show:         T.bool.isRequired
    onCloseClick: T.func.isRequired
    onConfirm:    T.func.isRequired

  bindWindowEvents: ->
    window.addEventListener 'keydown', @onWindowKeydown

  unbindWindowEvents: ->
    window.removeEventListener 'keydown', @onWindowKeydown

  onWindowKeydown: (event) ->
    if keycode(event.keyCode) is 'esc'
      @onCloseClick(event)

  onCloseClick: (event) ->
    event.stopPropagation()
    @props.onCloseClick()

  onConfirmClick: (event) ->
    @props.onConfirm()
    @onCloseClick(event)
```

Response:
// Copied from react-lite-layered,
// that module is on react 0.14
var React, T, Transition, a, button, cx, div, keycode, mixinLayered, span;

React = require('react');

keycode = require('keycode');

mixinLayered = require('../mixin/layered');

Transition = React.createFactory(require('./transition'));

div = React.createFactory('div');

span = React.createFactory('span');

a = React.createFactory('a');

button = React.createFactory('button');

T = React.PropTypes;

cx = require('classnames');

module.exports = React.createClass({
  displayName: 'lite-dialog',
  mixins: [mixinLayered],
  propTypes: {
    // this components accepts children
    cancel: T.string,
    confirm: T.string,
    content: T.string,
    flexible: T.bool,
    show: T.bool.isRequired,
    onCloseClick: T.func.isRequired,
    onConfirm: T.func.isRequired
  },
  bindWindowEvents: function() {
    return window.addEventListener('keydown', this.onWindowKeydown);
  },
  unbindWindowEvents: function() {
    return window.removeEventListener('keydown', this.onWindowKeydown);
  },
  onWindowKeydown: function(event) {
    if (keycode(event.keyCode) === 'esc') {
      return this.onCloseClick(event);
    }
  },
  onCloseClick: function(event) {
    event.stopPropagation();
    return this.props.onCloseClick();
  },
  onConfirmClick: function(event) {
    this.props.onConfirm();
    return this.onCloseClick(event);
  }
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
// Copied from react-lite-layered,
// that module is on react 0.14
var React, T, Transition, a, button, cx, div, keycode, mixinLayered, span;

React = require('react');

keycode = require('keycode');

mixinLayered = require('../mixin/layered');

Transition = React.createFactory(require('./transition'));

div = React.createFactory('div');

span = React.createFactory('span');

a = React.createFactory('a');

button = React.createFactory('button');

T = React.PropTypes;

cx = require('classnames');

module.exports = React.createClass({
  displayName: 'lite-dialog',
  mixins: [mixinLayered],
  propTypes: {
    // this components accepts children
    cancel: T.string,
    confirm: T.string,
    content: T.string,
    flexible: T.bool,
    show: T.bool.isRequired,
    onCloseClick: T.func.isRequired,
    onConfirm: T.func.isRequired
  },
  bindWindowEvents: function() {
    return window.addEventListener('keydown', this.onWindowKeydown);
  },
  unbindWindowEvents: function() {
    return window.removeEventListener('keydown', this.onWindowKeydown);
  },
  onWindowKeydown: function(event) {
    if (keycode(event.keyCode) === 'esc') {
      return this.onCloseClick(event);
    }
  },
  onCloseClick: function(event) {
    event.stopPropagation();
    return this.props.onCloseClick();
  },
  onConfirmClick: function(event) {
    this.props.onConfirm();
    return this.onCloseClick(event);
  }
});
```

Response:
# Copied from react-lite-layered,
# that module is on react 0.14

React = require 'react'
keycode = require 'keycode'

mixinLayered = require '../mixin/layered'

Transition = React.createFactory require './transition'

div    = React.createFactory 'div'
span   = React.createFactory 'span'
a      = React.createFactory 'a'
button = React.createFactory 'button'

T = React.PropTypes
cx = require 'classnames'

module.exports = React.createClass
  displayName: 'lite-dialog'
  mixins: [mixinLayered]

  propTypes:
    # this components accepts children
    cancel:       T.string
    confirm:      T.string
    content:      T.string
    flexible:     T.bool
    show:         T.bool.isRequired
    onCloseClick: T.func.isRequired
    onConfirm:    T.func.isRequired

  bindWindowEvents: ->
    window.addEventListener 'keydown', @onWindowKeydown

  unbindWindowEvents: ->
    window.removeEventListener 'keydown', @onWindowKeydown

  onWindowKeydown: (event) ->
    if keycode(event.keyCode) is 'esc'
      @onCloseClick(event)

  onCloseClick: (event) ->
    event.stopPropagation()
    @props.onCloseClick()

  onConfirmClick: (event) ->
    @props.onConfirm()
    @onCloseClick(event)


Prompt:
# Copied from react-lite-layered,
# that module is on react 0.14

React = require 'react'
keycode = require 'keycode'

mixinLayered = require '../mixin/layered'

Transition = React.createFactory require './transition'

div    = React.createFactory 'div'
span   = React.createFactory 'span'
a      = React.createFactory 'a'
button = React.createFactory 'button'

T = React.PropTypes
cx = require 'classnames'

module.exports = React.createClass
  displayName: 'lite-dialog'
  mixins: [mixinLayered]

  propTypes:
    # this components accepts children

Response:
cancel:       T.string
    confirm:      T.string
    content:      T.string
    flexible:     T.bool
    show:         T.bool.isRequired
    onCloseClick: T.func.isRequired
    onConfirm:    T.func.isRequired

  bindWindowEvents: ->
    window.addEventListener 'keydown', @onWindowKeydown

  unbindWindowEvents: ->
    window.removeEventListener 'keydown', @onWindowKeydown

  onWindowKeydown: (event) ->
    if keycode(event.keyCode) is 'esc'
      @onCloseClick(event)

  onCloseClick: (event) ->
    event.stopPropagation()
    @props.onCloseClick()

  onConfirmClick: (event) ->
    @props.onConfirm()
    @onCloseClick(event)


Response:
onBackdropClick: (event) ->
    if event.target is event.currentTarget
      @onCloseClick(event)

  renderActions: ->
    div className: 'actions line',
      button className: 'button is-link', onClick: @onCloseClick,
        @props.cancel
      button className: 'button is-danger', onClick: @onConfirmClick,
        @props.confirm

  renderLayer: (afterTransition) ->
    className = "lite-dialog is-for-#{@props.name}"
    boxClassName = cx 'box', 'flex': @props.flexible
    Transition transitionName: 'fade', enterTimeout: 200, leaveTimeout: 350,
      if @props.show and afterTransition
        div className: className, onClick: @onBackdropClick,
          div className: 'wrapper', onClick: @onBackdropClick,
            div className: boxClassName,
              div className: 'content',
                div className: 'inner', @props.content
                @props.children
                @renderActions()

  render: ->
    div()


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
onBackdropClick: (event) ->
    if event.target is event.currentTarget
      @onCloseClick(event)

  renderActions: ->
    div className: 'actions line',
      button className: 'button is-link', onClick: @onCloseClick,
        @props.cancel
      button className: 'button is-danger', onClick: @onConfirmClick,
        @props.confirm

  renderLayer: (afterTransition) ->
    className = "lite-dialog is-for-#{@props.name}"
    boxClassName = cx 'box', 'flex': @props.flexible
    Transition transitionName: 'fade', enterTimeout: 200, leaveTimeout: 350,
      if @props.show and afterTransition
        div className: className, onClick: @onBackdropClick,
          div className: 'wrapper', onClick: @onBackdropClick,
            div className: boxClassName,
              div className: 'content',
                div className: 'inner', @props.content
                @props.children
                @renderActions()

  render: ->
    div()
```

Response:
({
  onBackdropClick: function(event) {
    if (event.target === event.currentTarget) {
      return this.onCloseClick(event);
    }
  },
  renderActions: function() {
    return div({
      className: 'actions line'
    }, button({
      className: 'button is-link',
      onClick: this.onCloseClick
    }, this.props.cancel), button({
      className: 'button is-danger',
      onClick: this.onConfirmClick
    }, this.props.confirm));
  },
  renderLayer: function(afterTransition) {
    var boxClassName, className;
    className = `lite-dialog is-for-${this.props.name}`;
    boxClassName = cx('box', {
      'flex': this.props.flexible
    });
    return Transition({
      transitionName: 'fade',
      enterTimeout: 200,
      leaveTimeout: 350
    }, this.props.show && afterTransition ? div({
      className: className,
      onClick: this.onBackdropClick
    }, div({
      className: 'wrapper',
      onClick: this.onBackdropClick
    }, div({
      className: boxClassName
    }, div({
      className: 'content'
    }, div({
      className: 'inner'
    }, this.props.content), this.props.children, this.renderActions())))) : void 0);
  },
  render: function() {
    return div();
  }
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
({
  onBackdropClick: function(event) {
    if (event.target === event.currentTarget) {
      return this.onCloseClick(event);
    }
  },
  renderActions: function() {
    return div({
      className: 'actions line'
    }, button({
      className: 'button is-link',
      onClick: this.onCloseClick
    }, this.props.cancel), button({
      className: 'button is-danger',
      onClick: this.onConfirmClick
    }, this.props.confirm));
  },
  renderLayer: function(afterTransition) {
    var boxClassName, className;
    className = `lite-dialog is-for-${this.props.name}`;
    boxClassName = cx('box', {
      'flex': this.props.flexible
    });
    return Transition({
      transitionName: 'fade',
      enterTimeout: 200,
      leaveTimeout: 350
    }, this.props.show && afterTransition ? div({
      className: className,
      onClick: this.onBackdropClick
    }, div({
      className: 'wrapper',
      onClick: this.onBackdropClick
    }, div({
      className: boxClassName
    }, div({
      className: 'content'
    }, div({
      className: 'inner'
    }, this.props.content), this.props.children, this.renderActions())))) : void 0);
  },
  render: function() {
    return div();
  }
});
```

Response:
onBackdropClick: (event) ->
    if event.target is event.currentTarget
      @onCloseClick(event)

  renderActions: ->
    div className: 'actions line',
      button className: 'button is-link', onClick: @onCloseClick,
        @props.cancel
      button className: 'button is-danger', onClick: @onConfirmClick,
        @props.confirm

  renderLayer: (afterTransition) ->
    className = "lite-dialog is-for-#{@props.name}"
    boxClassName = cx 'box', 'flex': @props.flexible
    Transition transitionName: 'fade', enterTimeout: 200, leaveTimeout: 350,
      if @props.show and afterTransition
        div className: className, onClick: @onBackdropClick,
          div className: 'wrapper', onClick: @onBackdropClick,
            div className: boxClassName,
              div className: 'content',
                div className: 'inner', @props.content
                @props.children
                @renderActions()

  render: ->
    div()