Created
November 16, 2012 21:50
-
-
Save r00k/4091231 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/spanWrapper.js.coffee b/spanWrapper.js.coffee | |
index 5880fa9..9de7d64 100644 | |
--- a/spanWrapper.js.coffee | |
+++ b/spanWrapper.js.coffee | |
@@ -2,6 +2,8 @@ class SpanWrapper | |
constructor: (options={}) -> | |
@tagname = options.tagname ? 'span' | |
@classname = options.classname ? '' | |
+ # BEN: This isn't really part of object construction. I think you can just put this on line 2 if | |
+ # you change it to @STRING_NOT_FOUND: -1 | |
@STRING_NOT_FOUND = -1 | |
wrap: (target, searchString) => | |
@@ -13,6 +15,11 @@ class SpanWrapper | |
else | |
wrapped | |
+ # BEN | |
+ # I'm having trouble figuring out what this method does. I think it'd be easier | |
+ # if you could find a way to split it up a bit further, with some higher-level | |
+ # names about what's happening. | |
+ | |
_wrapRecursive: (target, searchString) => | |
rangeFromSearchStringLengthToZero = [(searchString.length - 1)..0] | |
for index in rangeFromSearchStringLengthToZero | |
@@ -56,4 +63,4 @@ class SpanWrapper | |
start = target.substring(0, index) | |
extracted = target.substring(index, index + substring.length) | |
end = target.substring(index + substring.length, target.length) | |
- start: start, extracted: extracted, end: end | |
\ No newline at end of file | |
+ start: start, extracted: extracted, end: end | |
diff --git a/spanWrapperSpec.js.coffee b/spanWrapperSpec.js.coffee | |
index 9e0ae32..adf5f6f 100644 | |
--- a/spanWrapperSpec.js.coffee | |
+++ b/spanWrapperSpec.js.coffee | |
@@ -49,8 +49,12 @@ describe 'SpanWrapper', -> | |
expect(wrapped).toEqual('a <span>ran</span>dom <span>tar</span>get') | |
it 'handles discontiguous inclusions', -> | |
+ # BEN | |
+ # 'handles' is kind of a weasel word -- it doesn't really tell me anything. | |
+ # 'Handling' could be allowing, raising an exception, triggering self-destruct, etc. | |
+ # I'd change this to something more specific. I like discontiguous though. :) | |
discontiguousTarget = 'Windows 7 License Decision' | |
discontiguousSearchString = 'iss' | |
wrapped = wrapper.wrap(discontiguousTarget, discontiguousSearchString) | |
expected = 'W<span>i</span>ndow<span>s</span> 7 Licen<span>s</span>e Decision' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment