All tests should pass with new internal API

This commit is contained in:
Glavin Wiechert 2015-04-30 13:23:41 -03:00
parent b245e98461
commit 0b1d0216d9
16 changed files with 171 additions and 41 deletions

View File

@ -1,5 +1,4 @@
- item
1. one
2. two
3. three
- item
1. one
2. two
3. three

View File

@ -3,7 +3,7 @@ SELECT ca.proj_id AS proj_id,
ca.ca_date_start AS proj_start,
ca.ca_date_end AS proj_end,
(SELECT count(*)
(SELECT COUNT(*)
FROM rotations r
WHERE r.proj_id = proj_id
AND r.r_status = 'R'
@ -20,6 +20,6 @@ WHERE ca.client_id = 12345
AND ca.client_id = c.client_id
AND ca_type = 'zzz'
AND c.agency_id = 0
AND ca.client_id = nvl(caa.client_id, ca.client_id)
AND proj_id = nvl(caa.proj_id, proj_id)
AND ca.client_id = NVL(caa.client_id, ca.client_id)
AND proj_id = NVL(caa.proj_id, proj_id)
AND caa.contact_id = 7890

View File

@ -1,8 +1,9 @@
- item
- item
- item
1. one
2. two
3. three
# heading 1
- item
- item
- item
## heading 2
1. one
2. two
3. three

View File

@ -1,5 +1,5 @@
---
title: "This is a title!"
title: 'This is a title!'
---
stuff

View File

@ -1,7 +1,11 @@
# heading 1
- item
- item
- item
## heading 2
1. one
2. two
2. three

View File

@ -1 +1,25 @@
SELECT ca.proj_id AS proj_id, ca.ca_name AS proj_name, ca.ca_date_start AS proj_start, ca.ca_date_end AS proj_end,(SELECT COUNT(*) FROM rotations r WHERE r.proj_id = proj_id AND r.r_status = 'R' GROUP BY r.proj_id) r_count, (SELECT count(*) FROM rotations r WHERE r.proj_id = proj_id AND r.channel_id = 24 ) r_rtb_count FROM projs ca, clients c, proj_auth caa WHERE ca.client_id = 12345 AND ca.client_id = c.client_id AND ca_type = 'zzz' AND c.agency_id = 0 AND ca.client_id = NVL( caa.client_id, ca.client_id ) AND proj_id = NVL( caa.proj_id, proj_id ) AND caa.contact_id = 7890
SELECT ca.proj_id AS proj_id,
ca.ca_name AS proj_name,
ca.ca_date_start AS proj_start,
ca.ca_date_end AS proj_end,
(SELECT COUNT(*)
FROM rotations r
WHERE r.proj_id = proj_id
AND r.r_status = 'R'
GROUP BY r.proj_id) r_count,
(SELECT count(*)
FROM rotations r
WHERE r.proj_id = proj_id
AND r.channel_id = 24) r_rtb_count
FROM projs ca,
clients c,
proj_auth caa
WHERE ca.client_id = 12345
AND ca.client_id = c.client_id
AND ca_type = 'zzz'
AND c.agency_id = 0
AND ca.client_id = NVL(caa.client_id, ca.client_id)
AND proj_id = NVL(caa.proj_id, proj_id)
AND caa.contact_id = 7890

View File

@ -1,5 +1,32 @@
INSERT INTO client (host, description, created_at) VALUES('hallpclnx', 'My linux machine', CURRENT_TIMESTAMP);
INSERT INTO thread (thread, description, created_at, client_id) VALUES(1, 'Living room camera', CURRENT_TIMESTAMP, 1);
INSERT INTO thread (thread, description, created_at, client_id) VALUES(2, 'Porch camera', CURRENT_TIMESTAMP, 1);
INSERT INTO thread (thread, description, created_at, client_id) VALUES(2, 'Garden camera', CURRENT_TIMESTAMP, 1);
INSERT INTO client (host, description, created_at) VALUES('shedpclnx', 'My shed linux machine', CURRENT_TIMESTAMP);
INSERT INTO client (host, description, created_at)
VALUES('hallpclnx',
'My linux machine',
CURRENT_TIMESTAMP);
INSERT INTO thread (thread, description, created_at, client_id)
VALUES(1,
'Living room camera',
CURRENT_TIMESTAMP,
1);
INSERT INTO thread (thread, description, created_at, client_id)
VALUES(2,
'Porch camera',
CURRENT_TIMESTAMP,
1);
INSERT INTO thread (thread, description, created_at, client_id)
VALUES(2,
'Garden camera',
CURRENT_TIMESTAMP,
1);
INSERT INTO client (host, description, created_at)
VALUES('shedpclnx',
'My shed linux machine',
CURRENT_TIMESTAMP);

View File

@ -139,14 +139,13 @@ describe "BeautifyLanguages", ->
# Check for beautification errors
if text isnt expectedContents
# console.warn(allOptions, text, expectedContents)
fileName = originalTestPath
fileName = expectedTestPath
oldStr=text
newStr=expectedContents
oldHeader="original"
oldHeader="beautified"
newHeader="expected"
diff = JsDiff.createPatch(fileName, oldStr, newStr, oldHeader, newHeader)
throw new Error("Beautifier output does not match expected output:\n"+diff)
#expect(text).toEqual expectedContents
# All done!
beautifyCompleted = true

View File

@ -84,14 +84,19 @@ module.exports = class Beautifier
# Resolve executable
Promise.resolve(executable)
.then((exe) ->
console.log('exe', exe)
# Flatten args first
args = _.flatten(args)
console.log('flat args', args)
# Resolve all args
Promise.all(args)
.then((args) ->
return new Promise((resolve, reject) ->
console.log('resolved args', args)
# Remove null values
args = _.without(args, undefined)
args = _.without(args, null)
console.log('args without undefined/null', args)
# Spawn command
stdout = ""
stderr = ""
@ -107,6 +112,7 @@ module.exports = class Beautifier
cmd.stderr.on('data', (data) -> stderr += data )
# when the spawn child process exits, check if there were any errors and close the writeable stream
cmd.on('exit', (code) ->
console.log('spawn done', code, stderr, stdout)
# If return code is not 0 then error occured
if code isnt 0
reject(stderr)

View File

@ -101,21 +101,27 @@ module.exports = class Beautifiers
# Get language
fileExtension = path.extname(filePath)
languages = @languages.getLanguages(grammar, fileExtension)
languages = @languages.getLanguages({grammar, fileExtension})
# TODO: select appropriate language
language = languages[0]
# Options for Language
# TODO: support fallback for options
options = @getOptions(language.namespace, allOptions) || {}
console.log('options', options)
# Beautify!
unsupportedGrammar = false
if atom.config.get("atom-beautify.disabledLanguages")?.indexOf(grammar) > - 1
if atom.config.get("atom-beautify.disabledLanguages")?.indexOf(language) > - 1
return resolve(null)
# Options for Language
console.log('allOptions', allOptions)
options = @getOptions(language.namespace, allOptions) || {}
# Support fallback for options
if language.fallback?
for fallback in language.fallback
# Merge current options on top of fallback options
console.log(fallback)
options = _.merge(@getOptions(fallback, allOptions) || {}, options)
console.log('options', options)
# Get Beautifiers
# console.log(grammar, language)
beautifiers = @getBeautifiers(language.name, options)
@ -127,6 +133,32 @@ module.exports = class Beautifiers
else
# TODO: select beautifier
beautifier = beautifiers[0]
# Transform options, if applicable
beautifierOptions = beautifier.options[language.name]
console.log('beautifierOptions', beautifierOptions)
if typeof beautifierOptions is "boolean"
if beautifierOptions isnt true
# Disable options
options = {}
else if typeof beautifierOptions is "object"
# Transform the options
transformedOptions = {}
for field, op of beautifierOptions
if typeof op is "string"
# Rename
transformedOptions[field] = options[op]
else if typeof op is "function"
# Transform
transformedOptions[field] = op(options)
else if typeof op is "boolean"
# Enable/Disable
if op is true
transformedOptions[field] = options[field]
# Replace old options with new transformed options
options = transformedOptions
else
console.warn("Unsupported Language options: ",beautifierOptions)
console.log('beautify!', beautifier, language, options)
beautifier.beautify(text, language.name, options)
.then(resolve)
@ -360,7 +392,7 @@ module.exports = class Beautifiers
# Check to see if config file uses nested object format to split up js/css/html options
for key of currOptions
# Check if is supported language
if _.indexOf(self.languages, key) >= 0 and typeof currOptions[key] is "object" # Check if nested object (more options in value)
if _.indexOf(self.languages.namespaces, key) >= 0 and typeof currOptions[key] is "object" # Check if nested object (more options in value)
containsNested = true
break # Found, break out of loop, no need to continue
# console.log(containsNested, currOptions);

View File

@ -8,12 +8,47 @@ module.exports = class PrettyDiff extends Beautifier
options: {
CSV: true
HTML: true
JavaScript: true
CSS: true
SCSS: true
Sass: true
JavaScript:
inchar: "indent_char"
insize: "indent_size"
alphasort: (options) ->
options.alphasort or false
preserve: (options) ->
if (options.preserve_newlines is true ) then \
"all" else "none"
CSS:
inchar: "indent_char"
insize: "indent_size"
alphasort: (options) ->
options.alphasort or false
preserve: (options) ->
if (options.preserve_newlines is true ) then \
"all" else "none"
SCSS:
inchar: "indent_char"
insize: "indent_size"
alphasort: (options) ->
options.alphasort or false
preserve: (options) ->
if (options.preserve_newlines is true ) then \
"all" else "none"
Sass:
inchar: "indent_char"
insize: "indent_size"
alphasort: (options) ->
options.alphasort or false
preserve: (options) ->
if (options.preserve_newlines is true ) then \
"all" else "none"
JSON: true
TSS: true
TSS:
inchar: "indent_char"
insize: "indent_size"
alphasort: (options) ->
options.alphasort or false
preserve: (options) ->
if (options.preserve_newlines is true ) then \
"all" else "none"
LESS: {
inchar: "indent_char"
insize: "indent_size"
@ -40,7 +75,7 @@ module.exports = class PrettyDiff extends Beautifier
lang = "html"
when "JavaScript", "JSON", "JSX"
lang = "javascript"
when "CSS", "LESS", "SCSS", "SASS"
when "CSS", "LESS", "SCSS", "Sass"
lang = "css"
when "TSS"
lang = "tss"
@ -57,6 +92,7 @@ module.exports = class PrettyDiff extends Beautifier
# Merge args intos options
_.merge(options, args)
console.log('prettydiff args', args, options)
# Beautify
output = prettydiff.api(options)

View File

@ -8,7 +8,7 @@ Beautifier = require('./beautifier')
module.exports = class RubyBeautify extends Beautifier
options: {
SQL: true
Ruby: true
}
cli: (options) ->

View File

@ -72,9 +72,11 @@ module.exports = class Languages
###
Get language for grammar and extension
###
getLanguages: (grammar, extension) ->
getLanguages: ({name, namespace, grammar, extension}) ->
# console.log(grammar, extension, @languages)
_.union(
_.filter(@languages, (language) -> _.contains(language.name, name))
_.filter(@languages, (language) -> _.contains(language.namespace, namespace))
_.filter(@languages, (language) -> _.contains(language.grammars, grammar))
_.filter(@languages, (language) -> _.contains(language.extensions, extension))
)