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 - item
1. one 1. one
2. two 2. two
3. three 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_start AS proj_start,
ca.ca_date_end AS proj_end, ca.ca_date_end AS proj_end,
(SELECT count(*) (SELECT COUNT(*)
FROM rotations r FROM rotations r
WHERE r.proj_id = proj_id WHERE r.proj_id = proj_id
AND r.r_status = 'R' AND r.r_status = 'R'
@ -20,6 +20,6 @@ WHERE ca.client_id = 12345
AND ca.client_id = c.client_id AND ca.client_id = c.client_id
AND ca_type = 'zzz' AND ca_type = 'zzz'
AND c.agency_id = 0 AND c.agency_id = 0
AND ca.client_id = nvl(caa.client_id, ca.client_id) AND ca.client_id = NVL(caa.client_id, ca.client_id)
AND proj_id = nvl(caa.proj_id, proj_id) AND proj_id = NVL(caa.proj_id, proj_id)
AND caa.contact_id = 7890 AND caa.contact_id = 7890

View File

@ -1,8 +1,9 @@
- item # heading 1
- item - item
- item - item
- item
1. one
2. two
3. three
## 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 stuff

View File

@ -1,7 +1,11 @@
# heading 1
- item - item
- item - item
- item - item
## heading 2
1. one 1. one
2. two 2. two
2. three 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 client (host, description, created_at)
INSERT INTO thread (thread, description, created_at, client_id) VALUES(1, 'Living room camera', CURRENT_TIMESTAMP, 1); VALUES('hallpclnx',
INSERT INTO thread (thread, description, created_at, client_id) VALUES(2, 'Porch camera', CURRENT_TIMESTAMP, 1); 'My linux machine',
INSERT INTO thread (thread, description, created_at, client_id) VALUES(2, 'Garden camera', CURRENT_TIMESTAMP, 1); CURRENT_TIMESTAMP);
INSERT INTO client (host, description, created_at) VALUES('shedpclnx', 'My shed 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 # Check for beautification errors
if text isnt expectedContents if text isnt expectedContents
# console.warn(allOptions, text, expectedContents) # console.warn(allOptions, text, expectedContents)
fileName = originalTestPath fileName = expectedTestPath
oldStr=text oldStr=text
newStr=expectedContents newStr=expectedContents
oldHeader="original" oldHeader="beautified"
newHeader="expected" newHeader="expected"
diff = JsDiff.createPatch(fileName, oldStr, newStr, oldHeader, newHeader) diff = JsDiff.createPatch(fileName, oldStr, newStr, oldHeader, newHeader)
throw new Error("Beautifier output does not match expected output:\n"+diff) throw new Error("Beautifier output does not match expected output:\n"+diff)
#expect(text).toEqual expectedContents
# All done! # All done!
beautifyCompleted = true beautifyCompleted = true

View File

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

View File

@ -101,21 +101,27 @@ module.exports = class Beautifiers
# Get language # Get language
fileExtension = path.extname(filePath) fileExtension = path.extname(filePath)
languages = @languages.getLanguages(grammar, fileExtension) languages = @languages.getLanguages({grammar, fileExtension})
# TODO: select appropriate language # TODO: select appropriate language
language = languages[0] language = languages[0]
# Options for Language
# TODO: support fallback for options
options = @getOptions(language.namespace, allOptions) || {}
console.log('options', options)
# Beautify! # Beautify!
unsupportedGrammar = false 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) 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 # Get Beautifiers
# console.log(grammar, language) # console.log(grammar, language)
beautifiers = @getBeautifiers(language.name, options) beautifiers = @getBeautifiers(language.name, options)
@ -127,6 +133,32 @@ module.exports = class Beautifiers
else else
# TODO: select beautifier # TODO: select beautifier
beautifier = beautifiers[0] 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) console.log('beautify!', beautifier, language, options)
beautifier.beautify(text, language.name, options) beautifier.beautify(text, language.name, options)
.then(resolve) .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 # Check to see if config file uses nested object format to split up js/css/html options
for key of currOptions for key of currOptions
# Check if is supported language # 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 containsNested = true
break # Found, break out of loop, no need to continue break # Found, break out of loop, no need to continue
# console.log(containsNested, currOptions); # console.log(containsNested, currOptions);

View File

@ -8,12 +8,47 @@ module.exports = class PrettyDiff extends Beautifier
options: { options: {
CSV: true CSV: true
HTML: true HTML: true
JavaScript: true JavaScript:
CSS: true inchar: "indent_char"
SCSS: true insize: "indent_size"
Sass: true 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 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: { LESS: {
inchar: "indent_char" inchar: "indent_char"
insize: "indent_size" insize: "indent_size"
@ -40,7 +75,7 @@ module.exports = class PrettyDiff extends Beautifier
lang = "html" lang = "html"
when "JavaScript", "JSON", "JSX" when "JavaScript", "JSON", "JSX"
lang = "javascript" lang = "javascript"
when "CSS", "LESS", "SCSS", "SASS" when "CSS", "LESS", "SCSS", "Sass"
lang = "css" lang = "css"
when "TSS" when "TSS"
lang = "tss" lang = "tss"
@ -57,6 +92,7 @@ module.exports = class PrettyDiff extends Beautifier
# Merge args intos options # Merge args intos options
_.merge(options, args) _.merge(options, args)
console.log('prettydiff args', args, options)
# Beautify # Beautify
output = prettydiff.api(options) output = prettydiff.api(options)

View File

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

View File

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