Skip to content

Commit

Permalink
Replaced the global extname with full path_module.extname in busser, …
Browse files Browse the repository at this point in the history
…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
geojeff committed May 21, 2012
1 parent 1fffd5c commit 52e9cc3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
22 changes: 11 additions & 11 deletions src/busser.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) ->
Expand All @@ -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) ->
Expand Down Expand Up @@ -958,15 +958,15 @@ 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"))});"
callback response
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) ->
Expand Down
16 changes: 10 additions & 6 deletions src/chance.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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: /(?!\\)"/
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 52e9cc3

Please sign in to comment.