33var patternEngines = require ( './pattern_engines' ) ;
44var path = require ( 'path' ) ;
55var extend = require ( 'util' ) . _extend ;
6+ // patternPrefixMatcher is intended to match the leading maybe-underscore,
7+ // zero or more digits, and maybe-dash at the beginning of a pattern file name we can hack them
8+ // off and get at the good part.
9+ var patternPrefixMatcher = / ^ _ ? ( \d + - ) ? / ;
610
711// Pattern properties
812
@@ -22,21 +26,21 @@ var Pattern = function (relPath, data, patternlab) {
2226 this . jsonFileData = data || { } ;
2327
2428 // strip leading "00-" from the file name and flip tildes to dashes
25- this . patternBaseName = this . fileName . replace ( / ^ \d * \- / , '' ) . replace ( '~' , '-' ) ; // 'colors'
29+ this . patternBaseName = this . fileName . replace ( patternPrefixMatcher , '' ) . replace ( '~' , '-' ) ; // 'colors'
2630
2731 // Fancy name. No idea how this works. 'Colors'
2832 this . patternName = this . patternBaseName . split ( '-' ) . reduce ( function ( val , working ) {
2933 return val . charAt ( 0 ) . toUpperCase ( ) + val . slice ( 1 ) + ' ' + working . charAt ( 0 ) . toUpperCase ( ) + working . slice ( 1 ) ;
3034 } , '' ) . trim ( ) ; //this is the display name for the ui. strip numeric + hyphen prefixes
3135
3236 // the top-level pattern group this pattern belongs to. 'atoms'
33- this . patternGroup = this . subdir . split ( path . sep ) [ 0 ] . replace ( / ^ \d * - / , '' ) ;
37+ this . patternGroup = this . subdir . split ( path . sep ) [ 0 ] . replace ( patternPrefixMatcher , '' ) ;
3438
3539 //00-atoms if needed
3640 this . patternType = this . subdir . split ( path . sep ) [ 0 ] ;
3741
3842 // the sub-group this pattern belongs to.
39- this . patternSubGroup = path . basename ( this . subdir ) . replace ( / ^ \d * - / , '' ) ; // 'global'
43+ this . patternSubGroup = path . basename ( this . subdir ) . replace ( patternPrefixMatcher , '' ) ; // 'global'
4044
4145 //00-colors if needed
4246 this . patternSubType = path . basename ( this . subdir ) ;
@@ -52,6 +56,10 @@ var Pattern = function (relPath, data, patternlab) {
5256 // name of the pattern. UPDATE: this.key is now known as this.patternPartial
5357 this . patternPartial = this . patternGroup + '-' + this . patternBaseName ;
5458
59+ // Let's calculate the verbose name ahead of time! We don't use path.sep here
60+ // on purpose. This isn't a file name!
61+ this . verbosePartial = this . subdir + '/' + this . fileName ;
62+
5563 this . isPattern = true ;
5664 this . isFlatPattern = this . patternGroup === this . patternSubGroup ;
5765 this . patternState = '' ;
0 commit comments