Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

tests are green; down below 1100ms for a cold boot

  • Loading branch information...
commit 2285c77340e70972fbf9168b117473b3e0758e18 1 parent 580af47
@wycats wycats authored
Showing with 217 additions and 190 deletions.
  1. +41 −32 lib/buildtasks/entry.rake
  2. +5 −5 lib/sproutcore/builders/bundle.rb
  3. +21 −13 lib/sproutcore/buildfile.rb
  4. +8 −1 lib/sproutcore/buildfile/buildfile_dsl.rb
  5. +24 −27 lib/sproutcore/buildfile/task.rb
  6. +15 −13 lib/sproutcore/buildfile/task_manager.rb
  7. +30 −52 lib/sproutcore/helpers/entry_sorter.rb
  8. +2 −2 lib/sproutcore/models/hash_struct.rb
  9. +11 −1 lib/sproutcore/models/manifest.rb
  10. +10 −2 lib/sproutcore/models/manifest_entry.rb
  11. +5 −7 lib/sproutcore/models/target.rb
  12. +11 −1 lib/sproutcore/rack/builder.rb
  13. +1 −1  spec/buildtasks/manifest/prepare_build_tasks/css_spec.rb
  14. +1 −1  spec/buildtasks/manifest/prepare_build_tasks/javascript_spec.rb
  15. +1 −1  spec/lib/buildfile/invoke_spec.rb
  16. +17 −17 spec/lib/buildfile_commands/config_spec.rb
  17. +6 −6 spec/lib/buildfile_commands/proxies_spec.rb
  18. +2 −2 spec/lib/models/hash_struct/hash_spec.rb
  19. +1 −1  spec/lib/models/manifest/build_spec.rb
  20. +1 −1  spec/lib/models/manifest/prepare_spec.rb
  21. +1 −1  spec/lib/models/manifest_entry/prepare_spec.rb
  22. +1 −1  spec/lib/models/project/targets_spec.rb
  23. +2 −2 spec/lib/models/target/prepare_spec.rb
View
73 lib/buildtasks/entry.rake
@@ -3,7 +3,7 @@
# copyright 2008, Sprout Systems, Inc. and Apple Inc. all rights reserved
# ===========================================================================
-# Tasks invoked while building ManifestEntry objects. You can override these
+# Tasks invoked while building ManifestEntry objects. You can override these
# tasks in your buildfiles.
namespace :entry do
@@ -11,52 +11,61 @@ namespace :entry do
# standard properties. The default implementation ensures that the entry
# has at least a source_path, build_path, staging_path, url and build_task
#
- # With this task in place, you can build an entry by simply providing a
+ # With this task in place, you can build an entry by simply providing a
# filename and, optionally a source_path or source_entries.
task_options :log => :none # no logging -- too much detail
task :prepare do
- filename = ENTRY[:filename]
- raise "All entries must have a filename!" if filename.nil?
-
+ entry, manifest = ENTRY, MANIFEST
+
+ filename = entry[:filename]
+ raise "All entries must have a filename!" unless filename
+
filename_parts = filename.split('/')
-
- # If this is a composite entry, then the source_paths array should
+
+ # If this is a composite entry, then the source_paths array should
# contain the staging_path from the source_entries. The source_path
# is simply the first source_paths.
- if ENTRY.composite?
- ENTRY[:source_entries] ||= [ENTRY[:source_entry]].compact
- ENTRY[:source_paths] ||= ENTRY[:source_entries].map { |e| e[:staging_path] }
- ENTRY[:source_path] ||= ENTRY[:source_paths].first
- ENTRY[:source_entry] ||= ENTRY[:source_entries].first
-
+ if entry.composite?
+ if source_entries = entry[:source_entries]
+ entry[:source_entry] ||= source_entries.first
+ else
+ source_entries = entry[:source_entries] = Array(entry[:source_entry])
+ end
+
+ unless source_paths = entry[:source_paths]
+ source_paths = entry[:source_paths] = source_entries.map { |e| e[:staging_path] }
+ end
+
+ entry[:source_path] ||= source_paths.first
+
# Otherwise, the source_path is where we will pull from and source_paths
# is simply the source_path in an array.
else
- ENTRY[:source_path] ||= File.join(MANIFEST[:source_root], filename_parts)
- ENTRY[:source_paths] ||= [ENTRY[:source_path]]
+ entry[:source_path] ||= File.join(manifest[:source_root], filename_parts)
+ entry[:source_paths] ||= [entry[:source_path]]
end
-
+
# Construct some easier paths if needed
- ENTRY[:build_path] ||= File.join(MANIFEST[:build_root], filename_parts)
- ENTRY[:url] ||= [MANIFEST[:url_root], filename_parts].join('/')
-
+ entry[:build_path] ||= File.join(manifest[:build_root], filename_parts)
+ entry[:url] ||= [manifest[:url_root], filename_parts].join('/')
+
# Fill in a default build task
- ENTRY[:build_task] ||= 'build:copy'
-
- ENTRY.ext = File.extname(filename)[1..-1]
-
- # If the build_task is build:copy, make the staging path equal the
- # source_root. This is an optimization that will avoid unnecessary
+ entry[:build_task] ||= 'build:copy'
+
+ entry[:ext] = File.extname(filename)[1..-1]
+
+ # If the build_task is build:copy, make the staging path equal the
+ # source_root. This is an optimization that will avoid unnecessary
# copying. All other build_tasks we build a staging path from the root.
- if ENTRY[:build_task].to_s == 'build:copy'
- ENTRY[:staging_path] ||= ENTRY[:source_path]
+ if entry[:build_task] == 'build:copy'
+ entry[:staging_path] ||= entry[:source_path]
else
- ENTRY[:staging_path] ||= MANIFEST.unique_staging_path(File.join(MANIFEST[:staging_root], filename_parts))
+ entry[:staging_path] ||= manifest.unique_staging_path(File.join(manifest[:staging_root], filename_parts))
end
-
- ENTRY[:cache_path] = MANIFEST.unique_cache_path(File.join(MANIFEST[:cache_root], filename_parts))
-
+
+ entry[:cache_path] = manifest.unique_cache_path(File.join(manifest[:cache_root], filename_parts))
+
end
-
+
end
View
10 lib/sproutcore/builders/bundle.rb
@@ -47,12 +47,12 @@ def build(dst_path)
output = ""
entry.targets.each do |t|
- bundle_info = t.bundle_info({ :debug => entry.debug, :test => entry.test, :theme => entry.theme, :variation => entry.variation })
+ bundle_info = t.bundle_info({ :debug => entry[:debug], :test => entry[:test], :theme => entry[:theme], :variation => entry[:variation] })
output << eruby.evaluate({
- :target_name => t.target_name.to_s.sub(/^\//,''),
- :requires => bundle_info.requires.map{ |t| "'#{t.target_name.to_s.sub(/^\//,'')}'" },
- :styles => bundle_info.css_urls.map{ |url| "'#{url}'" },
- :scripts => bundle_info.js_urls.map{ |url| "'#{url}'" }
+ :target_name => t[:target_name].to_s.sub(/^\//,''),
+ :requires => bundle_info[:requires].map{ |t| "'#{t[:target_name].to_s.sub(/^\//,'')}'" },
+ :styles => bundle_info[:css_urls].map{ |url| "'#{url}'" },
+ :scripts => bundle_info[:js_urls].map{ |url| "'#{url}'" }
})
end
writelines dst_path, [output]
View
34 lib/sproutcore/buildfile.rb
@@ -212,9 +212,10 @@ def loaded_paths; @loaded_paths ||= []; end
# task_name:: the full name of the task, including namespaces
# consts:: Optional hash of constant values to set on the env
def invoke(task_name, consts = nil)
- consts = set_kernel_consts consts # save to restore
- self[task_name.to_s].invoke
- set_kernel_consts consts # clear constants
+ original = set_kernel_consts consts
+ self[task_name].invoke
+ ensure
+ set_kernel_consts original
end
# Returns true if the buildfile has the named task defined
@@ -320,7 +321,7 @@ def add_config(config_name, config_mode, opts=nil)
# Perform Merge
mode_configs = (self.configs[config_mode.to_sym] ||= HashStruct.new)
- config = (mode_configs[config_name.to_sym] ||= HashStruct.new)
+ config = (mode_configs[config_name.to_sym] ||= ::SC::Buildfile::Config.new)
config.merge!(opts)
end
@@ -346,7 +347,7 @@ def config_for(config_name, mode_name=nil)
# collect the hashes
all_configs = configs[:all]
cur_configs = configs[mode_name]
- ret = HashStruct.new
+ ret = ::SC::Buildfile::Config.new
# now merge em! -- note that this assumes the merge method will handle
# self.merge(self) & self.merge(nil) gracefully
@@ -444,25 +445,25 @@ def reset_define_context(context=nil)
# For each key in the passed hash, this will register a global
def set_kernel_consts(env = nil)
- return env if env.nil?
+ return env unless env
# for each item in the passed environment, convert to uppercase constant
# and set in global namespace. Save the old value so that it can be
# restored later.
ret = {}
env.each do |key, value|
- const_key = key.to_s.upcase.to_sym
+ const_key = key.to_s.upcase
# Save the old const value
- ret[key] = Kernel.const_get(const_key) rescue nil
+ ret[key] = Object.const_get(const_key) if Object.const_defined?(const_key)
# Reset
- Kernel.const_reset(const_key, value)
+ Object.const_reset(const_key, value)
end
# Also, save env. Used mostly for logging
- ret['TASK_ENV'] = Kernel.const_get('TASK_ENV') rescue nil
- Kernel.const_reset('TASK_ENV', env)
+ ret['TASK_ENV'] = Object.const_get('TASK_ENV') if Object.const_defined?("TASK_ENV")
+ Object.const_reset('TASK_ENV', env)
return ret
end
@@ -473,13 +474,20 @@ def set_kernel_consts(env = nil)
# Add public method to kernel to remove defined constant using private
# method.
-module Kernel
- def const_reset(key, value)
+class Object
+ def self.const_reset(key, value)
remove_const(key) if const_defined?(key)
const_set key, value
end
end
+# back-compat
+module Kernel
+ def self.const_reset(key, value)
+ Object.const_reset(key, value)
+ end
+end
+
require "sproutcore/buildfile/build_task"
require "sproutcore/buildfile/buildfile_dsl"
require "sproutcore/buildfile/early_time"
View
9 lib/sproutcore/buildfile/buildfile_dsl.rb
@@ -9,6 +9,13 @@ module SC
class Buildfile
+ # This class allows us to memoize common computations
+ class Config < HashStruct
+ def target_names
+ @target_names ||= self[:target_types].keys
+ end
+ end
+
# Describe the domain-specific-language helpers supported by buildfiles.
# This is included as a mixin for the buildfile.
module Commands
@@ -132,7 +139,7 @@ def mode(build_mode, &block)
# end
#
def config(config_name, opts = {}, &block)
- opts = ::SC::HashStruct.new(opts)
+ opts = ::SC::Buildfile::Config.new(opts)
yield(opts) if block_given?
add_config config_name, opts
return self
View
51 lib/sproutcore/buildfile/task.rb
@@ -64,7 +64,7 @@ def source
@sources.first if defined?(@sources)
end
- IGNORE = %w(@lock @application)
+ IGNORE = %w(@application)
def dup(app=nil)
app = application if app.nil?
sibling = self.class.new(name, app)
@@ -84,7 +84,6 @@ def initialize(task_name, app)
@actions = []
@full_comment = nil
@comment = nil
- @lock = Monitor.new
@application = app
@scope = app.current_scope
@arg_names = nil
@@ -165,40 +164,38 @@ def self.outdent_logs
def invoke_with_call_chain(task_args, invocation_chain) # :nodoc:
unless invocation_chain.already_invoked?(self)
invocation_chain = InvocationChain.append(self, invocation_chain)
- @lock.synchronize do
- indent = self.class.indent_logs
+ indent = self.class.indent_logs
- # Use logging options to decide what to output
- # one of :env, :name, :none
- log_opt = task_options[:log] || :none
- if [:name, :env].include?(log_opt)
- SC.logger.debug "#{indent}invoke ~ #{name} #{format_trace_flags}"
- end
+ # Use logging options to decide what to output
+ # one of :env, :name, :none
+ log_opt = task_options[:log] || :none
+ if [:name, :env].include?(log_opt)
+ SC.logger.debug "#{indent}invoke ~ #{name} #{format_trace_flags}"
+ end
- if log_opt == :env
- TASK_ENV.each do |key, value|
- next if %w(config task_env).include?(key.to_s.downcase)
- SC.logger.debug "#{indent} #{key} = #{value.inspect}"
- end
+ if log_opt == :env
+ TASK_ENV.each do |key, value|
+ next if %w(config task_env).include?(key.to_s.downcase)
+ SC.logger.debug "#{indent} #{key} = #{value.inspect}"
end
+ end
- t_start = Time.now.to_f * 1000
-
- invocation_chain = invoke_prerequisites(task_args, invocation_chain)
- @invoke_count += 1
- execute(task_args) if needed?
+ t_start = Time.now.to_f * 1000
- t_end = Time.now.to_f * 1000
- t_diff = t_end - t_start
+ invocation_chain = invoke_prerequisites(task_args, invocation_chain)
+ @invoke_count += 1
+ execute(task_args) if needed?
- # ignore short tasks
- if t_diff > 10
- SC.logger.debug "#{indent}long task ~ #{name}: #{t_diff.to_i} msec"
- end
- self.class.outdent_logs
+ t_end = Time.now.to_f * 1000
+ t_diff = t_end - t_start
+ # ignore short tasks
+ if t_diff > 10
+ SC.logger.debug "#{indent}long task ~ #{name}: #{t_diff.to_i} msec"
end
+ self.class.outdent_logs
+
end
return invocation_chain
end
View
28 lib/sproutcore/buildfile/task_manager.rb
@@ -17,6 +17,7 @@ module TaskManager
def initialize
super
+ @task_cache = Hash.new {|h,k| h[k] = {} }
@tasks = Hash.new
@rules = Array.new
@scope = Array.new
@@ -51,8 +52,7 @@ def intern(task_class, task_name)
# Find a matching task for +task_name+.
def [](task_name, scopes=nil)
- task_name = task_name.to_s
- self.lookup(task_name, scopes) or
+ lookup(task_name, scopes) or
raise "Don't know how to build task '#{task_name}'"
end
@@ -135,18 +135,20 @@ def clear
# are recognized. If no scope argument is supplied, use the
# current scope. Return nil if the task cannot be found.
def lookup(task_name, initial_scope=nil)
- initial_scope ||= @scope
- task_name = task_name.to_s
- if task_name =~ /^rake:/
- scopes = []
- task_name = task_name.sub(/^rake:/, '')
- elsif task_name =~ /^(\^+)/
- scopes = initial_scope[0, initial_scope.size - $1.size]
- task_name = task_name.sub(/^(\^+)/, '')
- else
- scopes = initial_scope
+ @task_cache[initial_scope][task_name] ||= begin
+ initial_scope ||= @scope
+ task_name = task_name.to_s
+ if task_name =~ /^rake:/
+ scopes = []
+ task_name = task_name.sub(/^rake:/, '')
+ elsif task_name =~ /^(\^+)/
+ scopes = initial_scope[0, initial_scope.size - $1.size]
+ task_name = task_name.sub(/^(\^+)/, '')
+ else
+ scopes = initial_scope
+ end
+ lookup_in_scope(task_name, scopes)
end
- lookup_in_scope(task_name, scopes)
end
# Lookup the task name
View
82 lib/sproutcore/helpers/entry_sorter.rb
@@ -5,6 +5,8 @@
# and contributors
# ===========================================================================
+require "set"
+
module SC
module Helpers
@@ -33,12 +35,19 @@ def sort(entries)
bundleInfoEntry = []
bundleLoadedEntry = []
+ all_entries = {}
+ entries.each do |e|
+ name = e.extensionless_filename
+ all_entries[name] = e
+ end
+
+
# first remove bundle entries which MUST be first or last
entries = entries.select do |entry|
- if entry[:filename] == 'bundle_info.js'
+ if entry.normalized_filename == 'bundle_info.js'
bundleInfoEntry = [entry]
false
- elsif entry[:filename] == 'bundle_loaded.js'
+ elsif entry.normalized_filename == 'bundle_loaded.js'
bundleLoadedEntry = [entry]
false
else
@@ -46,31 +55,28 @@ def sort(entries)
end
end
- # then sort remaining entries by filename - ignoring case
- entries = entries.sort do |a,b|
- a = (a[:filename] || '').to_s.downcase
- b = (b[:filename] || '').to_s.downcase
+ entries.sort_by! do |entry|
+ name = entry.normalized_filename
- # lproj/foo_page.js and main.js are loaded last
- a_kind = (a =~ /(lproj|resources)\/.+_page\.js$/) ? 1 : -1
- a_kind = 2 if a =~ /main.js$/
-
- b_kind = (b =~ /(lproj|resources)\/.+_page\.js$/) ? 1 : -1
- b_kind = 2 if b =~ /main.js$/
-
- if a_kind != b_kind
- a_kind <=> b_kind
+ result = case name
+ when /main\.js$/
+ [2, name]
+ when /(?:lproj|resources)\/.+_page\.js$/
+ [1, name]
+ when /lproj\/strings.js$/
+ [-2, name]
else
- a <=> b
+ [-1, name]
end
+ # force preferred filenames to the front on the list
+ result.unshift (@preferred_filenames.include?(name) ? -1 : 1)
end
- all_entries = entries.dup # needed for sort...
# now process each entry to handle requires
- seen = []
+ seen = Set.new
ret = []
- while cur = next_entry(entries)
+ while cur = entries.shift
add_entry_to_set(cur, ret, seen, entries, all_entries)
end
@@ -81,44 +87,17 @@ def sort(entries)
# Converts a passed set of requires into entries
def required_entries(required, entries, requiring_entry, all_entries)
- return [] if required.nil?
- required.map do |filename|
- filename = filename.to_s.downcase.ext('')
- source_filename = "source/#{filename}"
- entry = all_entries.find do |e|
- e[:filename].to_s.downcase.ext('') == source_filename
- end
+ return [] unless required
- # try localized version...
- if entry.nil? && !(filename =~ /^lproj\//)
- source_filename = "source/lproj/#{filename}"
- entry = all_entries.find do |e|
- e[:filename].to_s.downcase.ext('') == source_filename
- end
- end
+ required.map do |filename|
+ entry = all_entries["source/#{filename}"] || all_entries["source/lproj/#{filename}"]
- if entry.nil?
+ unless entry
SC.logger.warn "Could not find entry '#{filename}' required in #{requiring_entry.target[:target_name].to_s.sub(/^\//,'')}:#{requiring_entry[:filename]}"
end
entry
- end
- end
-
- # Returns the next entry from the set of entries based on required order.
- # Removed entry from array.
- def next_entry(entries)
- ret = nil
-
- # look for preferred entries first...
- @preferred_filenames.each do |filename|
- ret = entries.find { |e| e[:filename].to_s.downcase == filename }
- break if ret
- end
-
- ret ||= entries.first # else fallback to first entry in set
- entries.delete(ret) if ret
- return ret
+ end.compact
end
# Adds the specified entry to the ordered array, adding required first
@@ -128,7 +107,6 @@ def add_entry_to_set(entry, ret, seen, entries, all_entries)
seen << entry
req = required_entries(entry[:required], entries, entry, all_entries)
req.each do |required|
- next if required.nil?
add_entry_to_set(required, ret, seen, entries, all_entries)
end
ret << entry
View
4 lib/sproutcore/models/hash_struct.rb
@@ -31,7 +31,7 @@ def deep_clone
# Returns true if the receiver has all of the options set
def has_options?(opts = {})
opts.each do |key, value|
- return false if self[key] != value
+ return false if self[key.to_sym] != value
end
return true
end
@@ -71,7 +71,7 @@ def method_missing(id, *args)
!!self[method_name[0..-2].to_sym]
else
print_first_caller(method_name)
- self[method_name]
+ self[method_name.to_sym]
end
end
View
12 lib/sproutcore/models/manifest.rb
@@ -28,6 +28,7 @@ def initialize(target, opts)
super(opts)
@target = target
@entries = []
+ @staging_uuid = 0
end
def inspect
@@ -348,10 +349,19 @@ def find_entry(fragment, opts = {}, seen=nil)
return ret
end
+ def unique_path(key, path)
+ paths = entries(:hidden => true).map { |e| e[keys] }
+ while paths.include?(path)
+ path = path.sub(/(__\$[0-9]+)?(\.\w+)?$/,"__#{next_staging_uuid}\\2")
+ end
+ return path
+ end
+
# Finds a unique staging path starting with the root proposed staging
# path.
def unique_staging_path(path)
paths = entries(:hidden => true).map { |e| e[:staging_path] }
+ p paths.size
while paths.include?(path)
path = path.sub(/(__\$[0-9]+)?(\.\w+)?$/,"__#{next_staging_uuid}\\2")
end
@@ -371,7 +381,7 @@ def unique_cache_path(path)
protected
def next_staging_uuid
- self[:staging_uuid] = (self[:staging_uuid] || 0) + 1
+ @staging_uuid += 1
end
end
View
12 lib/sproutcore/models/manifest_entry.rb
@@ -26,10 +26,18 @@ module SC
class ManifestEntry < HashStruct
def initialize(manifest, opts={})
- @manifest = manifest # store manifest has ivar
+ @manifest = manifest
super(opts)
end
+ def normalized_filename
+ @normalized_filename = self[:filename].to_s.downcase
+ end
+
+ def extensionless_filename
+ @extensionless_filename ||= normalized_filename.ext("")
+ end
+
# invoked whenever the manifest entry is first created. This will invoke
# the entry:prepare task if defined.
def prepare!
@@ -51,7 +59,7 @@ def prepare!
def prepared?; @is_prepared || false; end
def inspect
- "SC::ManifestEntry(#{filename}, build_task=>#{self.build_task}, entry_type=>#{self.entry_type}, is_hidden=>#{self.hidden?})"
+ "SC::ManifestEntry(#{self[:filename]}, build_task=>#{self[:build_task]}, entry_type=>#{self[:entry_type]}, is_hidden=>#{self.hidden?})"
end
def to_hash(opts={})
View
12 lib/sproutcore/models/target.rb
@@ -41,6 +41,7 @@ module SC
# entirely synthesized from other sources.
#
class Target < HashStruct
+ # WYCATS TODO: Can these be memoized?
def source_root
self[:source_root]
end
@@ -294,14 +295,11 @@ def _expand_required_targets(opts, seen)
# Returns true if the passed path appears to be a target directory
# according to the target's current config.
- def target_directory?(path, root_path=nil)
- root_path = self.source_root if root_path.nil?
- @target_names ||= self.config[:target_types].keys
- path = path.to_s.sub /^#{Regexp.escape root_path}\//, ''
- @target_names.each do |name|
- return true if path =~ /^#{Regexp.escape name.to_s}/
+ def target_directory?(path, root_path=source_root)
+ path = path.sub /^#{Regexp.escape root_path}\//, ''
+ config.target_names.find do |name|
+ path.index(name.to_s) == 0
end
- return false
end
# path to attr_cache file
View
12 lib/sproutcore/rack/builder.rb
@@ -122,8 +122,17 @@ def call(env)
if [:html, :test].include?(entry[:entry_type])
#if did_reload || !File.exist?(build_path)
#always clean html files...
+ if ENV["PROFILE"]
+ require "ruby-prof"
+ RubyProf.start
entry.clean!.build!
- #end
+ result = RubyProf.stop
+ printer = RubyProf::CallStackPrinter.new(result)
+ printer.print(File.open("output.html", "w"), :min_percent => 0)
+ exit!
+ else
+ entry.clean!.build!
+ end
else
entry.build!
end
@@ -197,6 +206,7 @@ def reload_project!
end
def monitor_project!
+ return
if !@should_monitor
@should_monitor = true
@project_root = @project.project_root
View
2  spec/buildtasks/manifest/prepare_build_tasks/css_spec.rb
@@ -26,7 +26,7 @@ def run_task
entries = @manifest.entries.select { |e| e.entry_type == :css }
entries.each do |entry|
%w(filename url build_path).each do |key|
- entry[key].should =~ /source\//
+ entry[key.to_sym].should =~ /source\//
end
end
end
View
2  spec/buildtasks/manifest/prepare_build_tasks/javascript_spec.rb
@@ -25,7 +25,7 @@ def run_task
entries = @manifest.entries.select { |e| e.entry_type == :javascript }
entries.each do |entry|
%w(filename url build_path).each do |key|
- entry[key].should =~ /source\//
+ entry[key.to_sym].should =~ /source\//
end
end
end
View
2  spec/lib/buildfile/invoke_spec.rb
@@ -50,7 +50,7 @@
const1 = {}
const2 = {}
- Kernel.const_reset(:CONSTANT, const1)
+ Object.const_reset(:CONSTANT, const1)
buildfile.invoke :task2, :constant => const2
# now add some keys so we can tell them apart...
View
34 spec/lib/buildfile_commands/config_spec.rb
@@ -16,8 +16,8 @@
configs = a.configs
- configs.all['/test1'].should_not be_nil
- configs.all['/test1'].foo.should eql(:bar)
+ configs.all[:'/test1'].should_not be_nil
+ configs.all[:'/test1'].foo.should eql(:bar)
end
it "should merge options when same config is named mode than once" do
@@ -27,8 +27,8 @@
end
configs = a.configs
- configs.all['/test1'].test1.should eql(:bar)
- configs.all['/test1'].test2.should eql(:foo)
+ configs.all[:'/test1'].test1.should eql(:bar)
+ configs.all[:'/test1'].test2.should eql(:foo)
end
it "should both accept an options hash, accept a block, or both" do
@@ -48,10 +48,10 @@
end
end
- a.configs.all['/test1'].foo.should eql(:bar)
- b.configs.all['/test1'].foo.should eql(:bar)
- c.configs.all['/test1'].test1.should eql(:bar)
- c.configs.all['/test1'].test2.should eql(:foo)
+ a.configs.all[:'/test1'].foo.should eql(:bar)
+ b.configs.all[:'/test1'].foo.should eql(:bar)
+ c.configs.all[:'/test1'].test1.should eql(:bar)
+ c.configs.all[:'/test1'].test2.should eql(:foo)
end
it "should allow OpenStruct-style setting of configs when passed to block" do
@@ -60,7 +60,7 @@
c.foo = :bar
end
end
- a.configs.all['/test1'].foo.should eql(:bar)
+ a.configs.all[:'/test1'].foo.should eql(:bar)
end
it "should merge configs on top of a base buildfile configs without changing the root config" do
@@ -72,11 +72,11 @@
config :bundle, :test1 => :bar
end
- b.configs.all['/bundle'].test1.should eql(:bar)
- b.configs.all['/bundle'].test2.should eql(:foo)
+ b.configs.all[:'/bundle'].test1.should eql(:bar)
+ b.configs.all[:'/bundle'].test2.should eql(:foo)
- a.configs.all['/bundle'].test1.should eql(:foo)
- a.configs.all['/bundle'].test2.should eql(:foo)
+ a.configs.all[:'/bundle'].test1.should eql(:foo)
+ a.configs.all[:'/bundle'].test2.should eql(:foo)
end
it "should store configs inside of a specific mode when specified" do
@@ -87,11 +87,11 @@
config :bundle, :bar => :bar
end
- a.configs.all['/bundle'].bar.should eql(:bar)
- a.configs.all['/bundle'].foo.should be_nil
+ a.configs.all[:'/bundle'].bar.should eql(:bar)
+ a.configs.all[:'/bundle'].foo.should be_nil
- a.configs.debug['/bundle'].bar.should be_nil
- a.configs.debug['/bundle'].foo.should eql(:foo)
+ a.configs.debug[:'/bundle'].bar.should be_nil
+ a.configs.debug[:'/bundle'].foo.should eql(:foo)
end
end
View
12 spec/lib/buildfile_commands/proxies_spec.rb
@@ -7,7 +7,7 @@
b = SC::Buildfile.define do
proxy '/url', :foo => :bar
end
- b.proxies['/url'].foo.should eql(:bar)
+ b.proxies[:'/url'].foo.should eql(:bar)
end
it "should save the REPLACE opts for multiple calls to proxy" do
@@ -15,8 +15,8 @@
proxy '/url', :test1 => :foo, :test2 => :foo
proxy '/url', :test1 => :bar
end
- b.proxies['/url'].test1.should eql(:bar)
- b.proxies['/url'].test2.should be_nil
+ b.proxies[:'/url'].test1.should eql(:bar)
+ b.proxies[:'/url'].test2.should be_nil
end
it "should merge multiple proxy urls and REPLACE opts for chained files" do
@@ -29,9 +29,9 @@
proxy '/url1', :test1 => :bar
end
- b.proxies['/url1'].test1.should eql(:bar)
- b.proxies['/url1'].test2.should be_nil
- b.proxies['/url2'].test1.should eql(:foo)
+ b.proxies[:'/url1'].test1.should eql(:bar)
+ b.proxies[:'/url1'].test2.should be_nil
+ b.proxies[:'/url2'].test1.should eql(:foo)
end
end
View
4 spec/lib/models/hash_struct/hash_spec.rb
@@ -26,13 +26,13 @@
e[:foo].should eql(:bar)
end
- it "should treat string and hash keys as the same" do
+ it "should treat string and hash keys as the same for writing, but not reading" do
e = SC::HashStruct.new
e['foo'] = :bar
e[:foo].should eql(:bar)
e[:foo2] = :bar
- e['foo2'].should eql(:bar)
+ e['foo2'].should eql(nil)
end
it "should convert all keys to symbols (i.e. if you get keys, they will always be symbols)" do
View
2  spec/lib/models/manifest/build_spec.rb
@@ -43,7 +43,7 @@
# get an empty project with no build tasks...
project = empty_project
project.add_target '/default', :default, :source_root => project.project_root
- target = project.targets['/default']
+ target = project.targets[:'/default']
target.buildfile.lookup('manifest:build').should be_nil
manifest = target.manifest_for :language => :en
View
2  spec/lib/models/manifest/prepare_spec.rb
@@ -44,7 +44,7 @@
# get an empty project with no build tasks...
project = empty_project
project.add_target '/default', :default, :source_root => project.project_root
- target = project.targets['/default']
+ target = project.targets[:'/default']
target.buildfile.lookup('manifest:prepare').should be_nil
manifest = target.manifest_for :language => :en
View
2  spec/lib/models/manifest_entry/prepare_spec.rb
@@ -36,7 +36,7 @@
# get an empty project with no build tasks...
project = empty_project
project.add_target '/default', :default, :source_root => project.project_root
- target = project.targets['/default']
+ target = project.targets[:'/default']
target.buildfile.lookup('entry:prepare').should be_nil
manifest = target.manifest_for :language => :en
entry = SC::ManifestEntry.new(manifest, :filename => 'filename')
View
2  spec/lib/models/project/targets_spec.rb
@@ -20,7 +20,7 @@ def find_targets_for(root_path, root_name, config)
project = SC::Project.new fixture_path('buildfiles', 'empty_project'), :parent => parent
project.targets.size.should eql(1)
- t = project.targets['base1']
+ t = project.targets[:'base1']
t.target_name.should == :base1
t.target_type.should == :dummy_type
t.source_root.should == "foo"
View
4 spec/lib/models/target/prepare_spec.rb
@@ -8,7 +8,7 @@
@project = fixture_project(:real_world)
# get target from project manually since target_for() calls prepare!
- @target = @project.targets['/contacts']
+ @target = @project.targets[:'/contacts']
@target.buildfile.define! do
replace_task 'target:prepare' do
@@ -34,7 +34,7 @@
# get an empty project with no build tasks...
project = empty_project
project.add_target '/default', :default, :source_root => project.project_root
- target = project.targets['/default']
+ target = project.targets[:'/default']
target.buildfile.lookup('target:prepare').should be_nil
lambda { target.prepare! }.should_not raise_error
Please sign in to comment.
Something went wrong with that request. Please try again.