Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Replaced the global extname with full path_module.extname in busser, …

…because the latest coffeescript did not approve. Cleaning up arguments passed to ChanceProcessor constructor. Adding frameworkName as a property of ChanceProcessor and ChanceParser.
  • Loading branch information...
commit 52e9cc3d42099feb70f861f03af9bbadc06af563 1 parent 1fffd5c
@geojeff authored
Showing with 21 additions and 17 deletions.
  1. +11 −11 src/busser.coffee
  2. +10 −6 src/chance.coffee
View
22 src/busser.coffee
@@ -102,13 +102,13 @@ exists = (path) ->
# Use the node.js path module to pull the file extension from the path.
#
-extname = (path) ->
- path_module.extname(path)
+#extname = (path) ->
+# path_module.extname(path)
# The *fileType* function is used to identify paths by their file extension.
#
fileType = (path) ->
- ext = extname(path)
+ ext = path_module.extname(path)
return "stylesheet" if /^\.(css|less|scss|styl)$/.test ext
return "script" if (ext is ".js") or (ext is ".handlebars") and not /tests\//.test(path)
return "test" if ext is ".js" and /tests\//.test(path)
@@ -575,11 +575,11 @@ class Busser
if @next?
@next.exec file, request, (response) ->
- response.contentType = contentTypes[extname(file.path)]
+ response.contentType = contentTypes[path_module.extname(file.path)]
callback response
else
# [TODO] does this make any sense? (There should always be a next? because contentType is never last)
- callback contentType: contentTypes[extname(file.path)]
+ callback contentType: contentTypes[path_module.extname(file.path)]
# *minifyStylesheet* is a static utility method that uses yuicompressor
# to minify data.
@@ -684,8 +684,8 @@ class Busser
if path not in resourceUrls
for prefix in [ "", "images" ]
- for extname in ResourceFile.resourceExtensions
- alternatePath = path_module.join(dirname, prefix, match[3] + extname)
+ for extension in ResourceFile.resourceExtensions
+ alternatePath = path_module.join(dirname, prefix, match[3] + extension)
if alternatePath in resourceUrls
path = alternatePath
break
@@ -862,7 +862,7 @@ class Busser
#
# scss:
# exec: (file, request, callback) ->
-# if scss? and extname(file.path) is ".css" # not .less, not .scss, not .styl
+# if scss? and path_module.extname(file.path) is ".css" # not .less, not .scss, not .styl
# if @next?
# @next.exec file, request, (response) ->
# Busser.scssify file.framework.path, response.data, (scssifiedData) ->
@@ -886,7 +886,7 @@ class Busser
#
# less:
# exec: (file, request, callback) ->
-# if less? and extname(file.path) is ".css" # not .less, not .scss, not .styl
+# if less? and path_module.extname(file.path) is ".css" # not .less, not .scss, not .styl
# if @next?
# @next.exec file, request, (response) ->
# #Busser.lessify file.framework.path, response.data, (lessifiedData) ->
@@ -958,7 +958,7 @@ class Busser
exec: (file, request, callback) ->
if @next?
@next.exec file, request, (response) ->
- if extname(file.path) is ".handlebars"
+ if path_module.extname(file.path) is ".handlebars"
re = /[^\/]+\/templates\/(.+)\.handlebars/
filename = re.exec(file.url())[1]
response.data = "SC.TEMPLATES['#{filename}'] = SC.Handlebars.compile(#{JSON.stringify(response.data.toString("utf8"))});"
@@ -966,7 +966,7 @@ class Busser
else
callback response
else
- if extname(file.path) is ".handlebars"
+ if path_module.extname(file.path) is ".handlebars"
re = /[^\/]+\/templates\/(.+)\.handlebars/
filename = re.exec(file.url())[1]
file.content file.path, (err, data) ->
View
16 src/chance.coffee
@@ -179,6 +179,9 @@ class ChanceParser
@slices = @opts["slices"] # we update the slices given to us
@theme = @opts["theme"]
+ @frameworkName = @opts["frameworkName"]
+
+ console.log 'ChanceParser...', @frameworkName
@UNTIL_SINGLE_QUOTE: /(?!\\)'/
@UNTIL_DOUBLE_QUOTE: /(?!\\)"/
@@ -597,7 +600,7 @@ class ChanceParser
# the image could be quoted or not; in any case, use parse_string to
# parse it. Sure, at the moment, we don't parse quoted strings properly,
# but it should work for most cases. single-quoted strings are out, though...
- slice["filename"] = @parse_string slice[0]
+ slice["filename"] = "#{@frameworkName}/#{@parse_string slice[0]}"
# now that we have all of the info, we can get the actual slice information.
# This process will create a slice entry if needed.
@@ -909,17 +912,18 @@ class ChanceProcessor
@uid: 0
@generation: 0
- constructor: (chance, options={}) ->
- @chance = chance
- @options = {}
- @options[key] = options[key] for own key of options
+ constructor: (@chance, @options={}) ->
+ console.log 'ChanceProcessor...', @options
+ #@options[key] = options[key] for own key of options
@options["theme"] ?= ""
@options["optimizeSprites"] ?= true
@options["padSpritesForDebugging"] ?= true
- @options["frameworkName"] ?= ""
if options["theme"]? and options["theme"].length > 0 and options["theme"][0] isnt "."
@options["theme"] = ".#{options["theme"]}"
+ @frameworkName = @options["frameworkName"]
+
+ console.log 'ChanceProcessor...', @frameworkName
console.log 'cssTheme', @options["theme"]
ChanceProcessor.uid += 1
Please sign in to comment.
Something went wrong with that request. Please try again.