From b9902cb6f2afb14bed3698a7fe73ba242a058b87 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 15 Nov 2013 11:50:55 -0800 Subject: [PATCH] Add specs --- src/binding-set.coffee | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/src/binding-set.coffee b/src/binding-set.coffee index 6661e35da..1b93c1c66 100644 --- a/src/binding-set.coffee +++ b/src/binding-set.coffee @@ -4,49 +4,15 @@ fs = require 'fs-plus' {specificity} = require 'clear-cut' PEG = require 'pegjs' -nextBindingSetIndex = 0 - ### Internal ### module.exports = class BindingSet - @parser: null - - selector: null - commandsByKeystroke: null - parser: null - name: null + @nextBindingSetIndex: 0 constructor: (selector, commandsByKeystroke, @name) -> - @index = nextBindingSetIndex++ + @index = BindingSet.nextBindingSetIndex++ keystrokePattern = fs.readFileSync(require.resolve('./keystroke-pattern.pegjs'), 'utf8') BindingSet.parser ?= PEG.buildParser(keystrokePattern) @specificity = specificity(selector) @selector = selector.replace(/!important/g, '') - @commandsByKeystroke = @normalizeCommandsByKeystroke(commandsByKeystroke) - - # Private: - getName: -> - @name - - # Private: - getSelector: -> - @selector - - # Private: - getCommandsByKeystroke: -> - @commandsByKeystroke - - normalizeCommandsByKeystroke: (commandsByKeystroke) -> - normalizedCommandsByKeystroke = {} - for keystroke, command of commandsByKeystroke - normalizedCommandsByKeystroke[@normalizeKeystroke(keystroke)] = command - normalizedCommandsByKeystroke - - normalizeKeystroke: (keystroke) -> - normalizedKeystroke = keystroke.split(/\s+/).map (keystroke) => - keys = BindingSet.parser.parse(keystroke) - modifiers = keys[0...-1] - modifiers.sort() - [modifiers..., _.last(keys)].join('-') - normalizedKeystroke.join(' ')