Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cleanup

  • Loading branch information...
commit 69c286c93c4b0a36486762598fba4ec3b1e190fe 1 parent be1e6a5
@searls searls authored
Showing with 14 additions and 18 deletions.
  1. +14 −18 lib/processes_jasmine_directives.rb
View
32 lib/processes_jasmine_directives.rb
@@ -1,25 +1,16 @@
require 'jasmine-core'
class ProcessesJasmineDirectives
+ ASSET_TYPES = ["css","js"]
- # jasmine_config = Jasmine::Config.new
- #
- # if asset_type == "css"
- # require_jasmine_css
- # require_user_css(jasmine_config)
- # else
- # require_jasmine_javascript
- # require_user_javascript(jasmine_config)
- # end
-
def process_require_jasmine_directive(asset_type)
- return unless ["css", "js"].include?(asset_type)
+ return unless ASSET_TYPES.include?(asset_type)
send("require_jasmine_#{asset_type}")
send("require_user_#{asset_type}")
end
- ["css", "js"].each do |asset_type|
+ ASSET_TYPES.each do |asset_type|
define_method "require_jasmine_#{asset_type}" do
Jasmine::Core.send("#{asset_type}_files").each do |f|
context.require_asset "/#{Jasmine::Core.path}/#{f}"
@@ -29,13 +20,18 @@ def process_require_jasmine_directive(asset_type)
define_method "require_user_#{asset_type}" do
config = Jasmine::Config.new
config.send("#{asset_type}_files").each do |f|
- asset_file = if f.include?(config.spec_path)
- f.gsub(/#{config.spec_path}/,config.spec_dir)
- else
- "#{Rails.root}#{f}"
- end
- context.require_asset asset_file
+ context.require_asset full_path_for(f,config)
end
end
end
+
+ private
+
+ def full_path_for(partial_path,config)
+ if partial_path.include?(config.spec_path)
+ partial_path.gsub(/#{config.spec_path}/,config.spec_dir)
+ else
+ "#{Rails.root}#{partial_path}"
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.