Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Whitespace

  • Loading branch information...
commit 0f37e4369ddbca4776b1802057fb8ee1ea935bb1 1 parent 2c27f1f
@wycats authored
Showing with 1,188 additions and 1,188 deletions.
  1. +33 −33 Buildfile
  2. +65 −65 Rakefile
  3. +23 −23 lib/sproutcore.rb
  4. +14 −14 lib/sproutcore/builders/base.rb
  5. +10 −10 lib/sproutcore/builders/bundle.rb
  6. +7 −7 lib/sproutcore/builders/combine.rb
  7. +48 −48 lib/sproutcore/builders/html.rb
  8. +9 −9 lib/sproutcore/builders/javascript.rb
  9. +4 −4 lib/sproutcore/builders/less.rb
  10. +15 −15 lib/sproutcore/builders/minify.rb
  11. +7 −7 lib/sproutcore/builders/sass.rb
  12. +7 −7 lib/sproutcore/builders/strings.rb
  13. +6 −6 lib/sproutcore/builders/stylesheet.rb
  14. +13 −13 lib/sproutcore/builders/test.rb
  15. +3 −3 lib/sproutcore/builders/test_index.rb
  16. +4 −4 lib/sproutcore/buildfile/build_task.rb
  17. +14 −14 lib/sproutcore/buildfile/buildfile_dsl.rb
  18. +3 −3 lib/sproutcore/buildfile/cloneable.rb
  19. +2 −2 lib/sproutcore/buildfile/early_time.rb
  20. +3 −3 lib/sproutcore/buildfile/invocation_chain.rb
  21. +3 −3 lib/sproutcore/buildfile/namespace.rb
  22. +1 −1  lib/sproutcore/buildfile/string_ext.rb
  23. +25 −25 lib/sproutcore/buildfile/task.rb
  24. +4 −4 lib/sproutcore/buildfile/task_arguments.rb
  25. +4 −4 lib/sproutcore/buildfile/task_manager.rb
  26. +24 −24 lib/sproutcore/helpers/cssmin.rb
  27. +30 −30 lib/sproutcore/helpers/entry_sorter.rb
  28. +20 −20 lib/sproutcore/helpers/html5_manifest.rb
  29. +20 −20 lib/sproutcore/helpers/packed_optimizer.rb
  30. +62 −62 lib/sproutcore/helpers/static_helper.rb
  31. +10 −10 lib/sproutcore/helpers/tag_helper.rb
  32. +1 −1  lib/sproutcore/helpers/text_helper.rb
  33. +92 −92 lib/sproutcore/models/generator.rb
  34. +9 −9 lib/sproutcore/models/hash_struct.rb
  35. +59 −59 lib/sproutcore/models/manifest.rb
  36. +64 −64 lib/sproutcore/models/manifest_entry.rb
  37. +51 −51 lib/sproutcore/models/project.rb
  38. +138 −138 lib/sproutcore/models/target.rb
  39. +12 −12 lib/sproutcore/rack/dev.rb
  40. +55 −55 lib/sproutcore/rack/filesystem.rb
  41. +33 −33 lib/sproutcore/rack/proxy.rb
  42. +28 −28 lib/sproutcore/rack/service.rb
  43. +4 −4 lib/sproutcore/rack/test_runner.rb
  44. +2 −2 lib/sproutcore/render_engines/erubis.rb
  45. +2 −2 lib/sproutcore/render_engines/haml.rb
  46. +73 −73 lib/sproutcore/tools.rb
  47. +16 −16 lib/sproutcore/tools/build.rb
  48. +2 −2 lib/sproutcore/tools/build_number.rb
  49. +3 −3 lib/sproutcore/tools/docs.rb
  50. +24 −24 lib/sproutcore/tools/gen.rb
  51. +7 −7 lib/sproutcore/tools/init.rb
  52. +13 −13 lib/sproutcore/tools/manifest.rb
  53. +7 −7 lib/sproutcore/tools/server.rb
View
66 Buildfile
@@ -5,7 +5,7 @@
# and contributors
# ===========================================================================
-# Default buildfile loaded by all projects. Any options you put into your
+# Default buildfile loaded by all projects. Any options you put into your
# project buildfile will override these defaults.
# Import all build tasks
@@ -14,109 +14,109 @@ import *Dir.glob(File.join(File.dirname(current_path), 'buildtasks', '**', '*.ra
mode :all do
config :all,
- # REQUIRED CONFIGS
- # You will not usually need to override these configs, but the code
+ # REQUIRED CONFIGS
+ # You will not usually need to override these configs, but the code
# assumes they will be present, so you must support them.
:build_prefix => 'tmp/build',
:staging_prefix => 'tmp/staging',
:cache_prefix => 'tmp/cache',
:url_prefix => 'static',
-
- # Defines the directories that may contain targets, and maps them to a
- # target type. When a project tries to find all of the targets in a
+
+ # Defines the directories that may contain targets, and maps them to a
+ # target type. When a project tries to find all of the targets in a
# project, it will use this map to find them.
- :target_types => {
- :apps => :app,
- :clients => :app,
+ :target_types => {
+ :apps => :app,
+ :clients => :app,
:pages => :app, # used for static pages with your site
:frameworks => :framework,
:themes => :theme,
:bundles => :framework
},
-
- # Allows the target to have other targets nested inside of it. Override
+
+ # Allows the target to have other targets nested inside of it. Override
# this in your target Buildfile to disable nesting.
:allow_nested_targets => true,
- # The default preferred language. Assets will be pulled from this
+ # The default preferred language. Assets will be pulled from this
# language unless otherwise specified.
:preferred_language => :en,
-
+
# Do not include fixtures in built project.
:load_fixtures => false,
-
+
# Do not include debug directory in built project
:load_debug => false,
-
+
# Do not load protocols in production mode
:load_protocols => false,
-
+
# Do not build tests.
:load_tests => false,
-
+
# Generate a combined javascript and stylesheet
:combine_javascript => true,
:combine_stylesheets => true,
# by default all targets autobuild
:autobuild => true,
-
+
# by default minify javacript and stylesheets
:minify => true,
:minify_css => true,
-
+
# use the default layout defined in SproutCore
:layout => 'sproutcore:lib/index.rhtml',
:test_layout => 'sproutcore:lib/index.rhtml',
-
+
# name a framework to use as the theme. will be included in required
# frameworks automatically if found.
:theme => 'sproutcore/standard_theme',
-
+
# use default bootstrap framework
:bootstrap_inline => 'sproutcore/bootstrap:javascript',
# In design mode, load the designer
:design_required => ['sproutcore/designer'],
-
+
:use_packed => true,
# If set to true, the specified framework, if loaded via the SC.loadBundle
# API, will be set up to be lazily instantiated when loaded.
:lazy_instantiation => false,
-
+
# if set to true then the index.html will build into the global language
# and target directory. This can interfere with deploying multiple builds
# at one but it is more convenient.
:overwrite_current => false,
-
+
# causes the default index.html file to add an overflow:hidden statement
# to the body tag. This is usually preferred since it makes drag and drop
# look nicer
:hide_body_overflow => true
-
+
end
mode :debug do
config :all,
-
+
# in debug mode, load fixtures, debug, tests, and protocols
:load_fixtures => true,
:load_debug => true,
:load_tests => true,
:load_protocols => true,
-
+
# Do not combine javascript and stylesheet
:combine_javascript => false,
:combine_stylesheets => true,
-
+
:minify_javascript => false,
:minify_css => false,
-
+
:build_prefix => 'tmp/debug/build',
:staging_prefix => 'tmp/debug/staging',
-
+
# debug settings for sc-server
:serve_exceptions => true,
:reload_project => true,
@@ -125,14 +125,14 @@ mode :debug do
# to ensure the latest version is always loaded.
:build_number => :current,
- # Instructs the URL builders to include a timestamp token at the end of
+ # Instructs the URL builders to include a timestamp token at the end of
# urls. This option is only useful in development mode since browsers
# will respect the timestamp token as a way to unique the url. This
# should not be used in production as some proxies on the internet do
# not respect tokens.
:timestamp_urls => true,
-
- # Do not pack javascripts in development mode, we want each file to
+
+ # Do not pack javascripts in development mode, we want each file to
# load independently.
:use_packed => false
end
View
130 Rakefile
@@ -20,8 +20,8 @@ DIST = YAML.load File.read(DIST_PATH)
LOCAL_DIST_PATH = File.expand_path(File.join(ROOT_PATH, 'LOCAL.yml'))
if File.exists? LOCAL_DIST_PATH
-
- # merged each item in the top level hash. This allows for key-by-key
+
+ # merged each item in the top level hash. This allows for key-by-key
# overrides
(YAML.load(File.read(LOCAL_DIST_PATH)) || {}).each do |key, opts|
if DIST[key]
@@ -30,7 +30,7 @@ if File.exists? LOCAL_DIST_PATH
DIST[KEY] = opts
end
end
-
+
puts "Using local overrides for distribution"
end
@@ -53,7 +53,7 @@ begin
$:.unshift(ROOT_PATH / 'lib')
require 'sproutcore'
-
+
rescue LoadError => e
$stderr.puts "WARN: some required gems are not installed (try rake init to setup)"
$stderr.puts e
@@ -64,10 +64,10 @@ end
## JEWELER PROJECT DESCRIPTION
##
-begin
+begin
require 'jeweler'
HAS_JEWELER = true
-
+
rescue LoadError => e
$stderr.puts "WARN: jeweler is not yet installed (try rake init to setup)"
$stderr.puts e
@@ -81,7 +81,7 @@ if HAS_JEWELER
gemspec.email = 'contact@sproutcore.com'
gemspec.homepage = 'http://www.sproutcore.com'
gemspec.summary = "SproutCore is a platform for building native look-and-feel applications on the web"
-
+
gemspec.add_dependency 'rack', '>= 0.9.1'
gemspec.add_dependency 'json_pure', ">= 1.1.0"
gemspec.add_dependency 'extlib', ">= 0.9.9"
@@ -94,10 +94,10 @@ if HAS_JEWELER
gemspec.rubyforge_project = "sproutcore"
gemspec.extra_rdoc_files.include *%w[History.txt README.txt]
-
+
gemspec.files.include *%w[.htaccess frameworks/sproutcore/**/*]
gemspec.files.exclude *%w[^coverage/ .gitignore .gitmodules .DS_Store tmp/ .hashinfo .svn .git]
-
+
gemspec.description = File.read(ROOT_PATH / 'README.txt')
end
@@ -114,23 +114,23 @@ def git(path, cmd, log=true)
$stdout.puts("#{path.sub(ROOT_PATH, '')}: git #{cmd}") if log
git_path = path / '.git'
git_index = git_path / 'index'
-
+
# The env can become polluted; breaking git. This will avoid that.
%x[GIT_DIR=#{git_path}; GIT_WORK_TREE=#{path}; GIT_INDEX_FILE=#{git_index}; git #{cmd}]
end
-
+
desc "performs an initial setup on the tools. Installs gems, checkout"
-task :init => [:install_gems, 'dist:init']
+task :init => [:install_gems, 'dist:init']
desc "verifies that all required gems are installed"
task :install_gems do
$stdout.puts "Installing gems (may ask for password)"
-
+
gem_names = %w(rack json json_pure extlib erubis thor jeweler gemcutter rspec)
gem_install = []
gem_update = []
-
+
# detect which ones are installed and update those
gem_names.each do |name|
if %x[gem list #{name}] =~ /#{Regexp.escape(name)} \(/
@@ -150,9 +150,9 @@ task :install_gems do
end
namespace :dist do
-
+
desc "checkout any frameworks in the distribution"
- task :init do
+ task :init do
$stdout.puts "Setup distribution"
DIST.each do |rel_path, opts|
@@ -168,13 +168,13 @@ namespace :dist do
$stdout.puts "\n> git clone #{repo_url} #{path}"
system "GIT_DIR=#{path / '.git'}; GIT_WORK_TREE=#{path}; git init"
end
-
+
# if git exists, make sure a "dist" remote exists and matches the named
# remote
remote = git(path, 'remote -v').split("\n").find do |l|
l =~ /^#{REMOTE_NAME}.+\(fetch\)/
end
-
+
if remote
cur_repo_url = remote.match(/^#{REMOTE_NAME}(.+)\(fetch\)/)[1].strip
if (cur_repo_url != repo_url)
@@ -183,12 +183,12 @@ namespace :dist do
else
$stdout.puts "Found #{rel_path}:dist => #{repo_url}"
end
-
+
# remote does not yet exist, add it...
else
$stdout.puts git(path,"remote add dist #{repo_url}")
end
-
+
$stdout.puts git(path, "fetch dist")
# Make sure a "dist" branch exists.. if not checkout against the
@@ -198,12 +198,12 @@ namespace :dist do
else
git(path,"branch dist remotes/dist/#{dist_branch}")
end
-
+
git(path, "checkout dist")
end
end
-
+
desc "Make sure each repository in the distribute is set to the target remote branch and up-to-date"
task :update => 'dist:init' do
$stdout.puts "Setup distribution"
@@ -211,7 +211,7 @@ namespace :dist do
DIST.each do |rel_path, opts|
path = ROOT_PATH / rel_path
branch = opts['branch'] || 'master'
-
+
if File.exists?(path / ".git")
$stdout.puts "\n> git checkout dist"
@@ -222,14 +222,14 @@ namespace :dist do
$stdout.puts "\n> git rebase remotes/dist/#{branch}"
$stdout.puts git(path, "rebase remotes/dist/#{branch}")
-
+
else
$stdout.puts "WARN: cannot fix version for #{rel_path}"
end
-
+
end
end
-
+
desc "make the version of each distribution item match the one in VERSION"
task :freeze => 'dist:init' do
$stdout.puts "Setup distribution"
@@ -241,10 +241,10 @@ namespace :dist do
versions = (versions['dist'] || versions[:dist]) if versions
versions ||= {}
end
-
+
DIST.each do |rel_path, opts|
path = ROOT_PATH / rel_path
-
+
if File.exists?(path / ".git") && versions[rel_path]
sha = versions[rel_path]
@@ -255,18 +255,18 @@ namespace :dist do
$stdout.puts "\n> git checkout #{sha}"
$stdout.puts git(path, "checkout #{sha}")
end
-
+
else
$stdout.puts "WARN: cannot fix version for #{rel_path}"
end
-
+
end
end
end
namespace :release do
-
+
desc "tags the current repository and any distribution repositories. if you can push to distribution, then push tag as well"
task :tag => :update_version do
tag_name = "REL-#{RELEASE_VERSION}"
@@ -275,7 +275,7 @@ namespace :release do
git(full_path, "tag -f #{tag_name}")
end
end
-
+
task :push_tags => :tag do
tag_name = "REL-#{RELEASE_VERSION}"
DIST.keys.push('abbot').each do |rel_path|
@@ -283,17 +283,17 @@ namespace :release do
git(full_path, "push origin #{tag_name}")
end
end
-
-
+
+
desc "prepare release. verify clean, update version, tag"
task :prepare => ['git:verify_clean', :update_version, :tag, :push_tags]
-
+
desc "release to rubyforge for old skool folks"
task :rubyforge => [:prepare, 'rubyforge:release']
-
+
desc "release to gemcutter for new skool kids"
task :gemcutter => [:prepare, 'gemcutter:release']
-
+
desc "one release to rule them all"
task :all => [:prepare, 'release:gemcutter']
@@ -301,11 +301,11 @@ end
desc "computes the current hash of the code. used to autodetect build changes"
task :hash_content do
-
+
require 'yaml'
require 'digest/md5'
- ignore = IGNORE_CHANGES.map do |x|
+ ignore = IGNORE_CHANGES.map do |x|
if x =~ /^\^/
/^#{Regexp.escape(ROOT_PATH / x[1..-1])}/
else
@@ -318,18 +318,18 @@ task :hash_content do
hashinfo_path = ROOT_PATH / '.hashinfo.yml'
hash_date = 0
hash_digest = nil
-
+
if File.exist?(hashinfo_path)
yaml = YAML.load_file(hashinfo_path)
hash_date = yaml['date'] || yaml[:date] || hash_date
hash_digest = yaml['digest'] || yaml[:digest] || hash_digest
end
-
- # paths to search
+
+ # paths to search
paths = Dir.glob(File.join(ROOT_PATH, '**', '*')).reject do |path|
File.directory?(path) || (ignore.find { |i| path =~ i })
end
-
+
cur_date = 0
paths.each do |path|
mtime = File.mtime(path)
@@ -337,8 +337,8 @@ task :hash_content do
$stdout.puts "detected file change: #{path.gsub(ROOT_PATH,'')}" if mtime > hash_date
cur_date = mtime if mtime > cur_date
end
-
- if hash_digest.nil? || (cur_date != hash_date)
+
+ if hash_digest.nil? || (cur_date != hash_date)
digests = paths.map do |path|
Digest::SHA1.hexdigest(File.read(path))
end
@@ -346,7 +346,7 @@ task :hash_content do
hash_digest = Digest::SHA1.hexdigest(digests.join)
end
hash_date = cur_date
-
+
# write cache
File.open(hashinfo_path, 'w+') do |f|
YAML.dump({ :date => hash_date, :digest => hash_digest }, f)
@@ -356,21 +356,21 @@ task :hash_content do
CONTENT_HASH = hash_digest
$stdout.puts "CONTENT_HASH = #{CONTENT_HASH}"
end
-
+
desc "updates the VERSION file, bumbing the build rev if the current commit has changed"
task :update_version => 'hash_content' do
path = ROOT_PATH / 'VERSION.yml'
-
+
require 'yaml'
-
+
# first, load the current yaml if possible
major = 1
minor = 0
build = 99
rev = '-0-'
dist = {}
-
+
if File.exist?(path)
yaml = YAML.load_file(path)
major = yaml['major'] || yaml[:major] || major
@@ -378,10 +378,10 @@ task :update_version => 'hash_content' do
build = yaml['patch'] || yaml[:patch] || build
rev = yaml['digest'] || yaml[:digest] || rev
end
-
+
build += 1 if rev != CONTENT_HASH #increment if needed
rev = CONTENT_HASH
-
+
# Update distribution versions
DIST.each do |rel_path, ignored|
dist_path = ROOT_PATH / rel_path
@@ -397,23 +397,23 @@ task :update_version => 'hash_content' do
end
end
end
-
+
$stdout.puts "write version #{[major, minor, build].join('.')} => #{path}"
File.open(path, 'w+') do |f|
- YAML.dump({
- :major => major,
- :minor => minor,
- :patch => build,
+ YAML.dump({
+ :major => major,
+ :minor => minor,
+ :patch => build,
:digest => rev,
- :dist => dist
+ :dist => dist
}, f)
end
-
+
RELEASE_VERSION = "#{major}.#{minor}.#{build}"
-
+
end
-desc "cleanup the pkg dir"
+desc "cleanup the pkg dir"
task :clean do
path = ROOT_PATH / 'pkg'
FileUtils.rm_r(path) if File.directory?(path)
@@ -421,7 +421,7 @@ task :clean do
end
namespace :git do
-
+
desc "verifies there are no pending changes to commit to git"
task :verify_clean do
DIST.keys.push('abbot').each do |repo_name|
@@ -436,10 +436,10 @@ namespace :git do
$stderr.puts " Commit your changes to git to continue.\n\n"
exit(1)
end
- end
+ end
end
end
-
+
desc "Collects the current SHA1 commit hash into COMMIT_ID"
task :collect_commit do
log = `git log HEAD^..HEAD`
@@ -451,7 +451,7 @@ namespace :git do
$stdout.puts "COMMIT_ID = #{COMMIT_ID}"
end
end
-
+
end
# Write a new version everytime we generate
View
46 lib/sproutcore.rb
@@ -19,8 +19,8 @@ class String ; def valid_encoding? ; true ; end ; end
# Ruby 1.9 Compatibility
if (RUBY_VERSION.match(/1\.9/))
# Fix for Rack Ruby 1.9 incompatibility. This makes 404s render again.
- class String
- alias each each_line unless ''.respond_to?(:each)
+ class String
+ alias each each_line unless ''.respond_to?(:each)
end
end
@@ -33,12 +33,12 @@ module SproutCore
# :stopdoc:
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
-
+
VERSION_PATH = PATH / 'VERSION.yml'
VERSION_INFO = YAML.load_file(VERSION_PATH)
-
+
VERSION = [VERSION_INFO[:major], VERSION_INFO[:minor], VERSION_INFO[:patch]].join('.')
-
+
# :startdoc:
# Returns the version string for the library.
@@ -75,7 +75,7 @@ def self.require_all_libs_relative_to( fname, dir = nil )
Dir.glob(search_me).sort.each {|rb| require rb}
end
-
+
# Global variable that can store specific environmental settings. This is
# where you will find the build mode among other things set by sc-build.
#
@@ -83,34 +83,34 @@ def self.env
@env ||= HashStruct.new(:build_mode => :debug, :buildfile_names => %w(Buildfile sc-config sc-config.rb))
end
def self.env=(hash); @env = HashStruct.new(hash); end
-
+
# Returns a standard logger object. You can replace this with your own
# logger to redirect all SproutCore log output if needed. Otherwise, a
- # logger will bre created based on your env.log_level and env.logfile
+ # logger will bre created based on your env.log_level and env.logfile
# options.
- def self.logger
+ def self.logger
return @logger unless @logger.nil?
-
+
if env.logfile
@logger = Logger.new env.logfile, 10, 1024000
else
@logger = Logger.new $stderr
-
+
# if we are logging to the screen, no reason to use a std loggin fmt
@logger.formatter = lambda do |severity, time, progname, msg|
- [severity, '~', msg.to_s, "\n"].join(' ')
+ [severity, '~', msg.to_s, "\n"].join(' ')
end
end
-
+
@logger.level = (env.log_level == :debug) ? Logger::DEBUG : ((env.log_level == :info) ? Logger::INFO : Logger::WARN)
-
+
return @logger
end
attr_writer :logger
# Returns the current build mode. The build mode is determined based on the
- # current environment build_mode settings. Note that for backwards
- # compatibility reasons, :development and :debug are treated as being
+ # current environment build_mode settings. Note that for backwards
+ # compatibility reasons, :development and :debug are treated as being
# identical.
def self.build_mode
ret = env.build_mode || :production
@@ -118,27 +118,27 @@ def self.build_mode
ret = :debug if ret == :development # backwards compatibility
ret
end
-
+
def self.build_mode=(new_mode)
new_mode = new_mode.to_sym
new_mode = :debug if new_mode == :development
env.build_mode = new_mode
self.build_mode
end
-
+
# Returns a project instance representing the builtin library
def self.builtin_project
@builtin_project ||= SC::Project.new(PATH)
end
-
- # Returns the current project, if defined. This is normally only set
+
+ # Returns the current project, if defined. This is normally only set
# when you start sc-server in interactive mode.
def self.project; @project; end
def self.project=(project); @project = project; end
-
+
# Attempts to load a project for the current working directory or from the
# passed directory location. Returns nil if no project could be detected.
- # This is just a shorthand for creating a Project object. It is useful
+ # This is just a shorthand for creating a Project object. It is useful
# when using the build tools as a Ruby library
def self.load_project(path = nil, opts = {})
path = File.expand_path(path.nil? ? Dir.pwd : path)
@@ -148,7 +148,7 @@ def self.load_project(path = nil, opts = {})
SC::Project.load_nearest_project path, :parent => SC.builtin_project
end
end
-
+
end # module SC
SC = SproutCore # alias
View
28 lib/sproutcore/builders/base.rb
@@ -6,21 +6,21 @@
# ===========================================================================
module SC
-
- # Builder classes implement the more complex algorithms for building
- # resources in SproutCore such as building HTML, JavaScript or CSS.
+
+ # Builder classes implement the more complex algorithms for building
+ # resources in SproutCore such as building HTML, JavaScript or CSS.
# Builders are usually invoked from within build tasks which are, in-turn,
# selected by the manifest.
#
- module Builder
-
+ module Builder
+
# The base class extended by most builder classes. This contains some
# default functionality for handling loading and writing files. Usually
# you will want to consult the specific classes instead for more info.
#
class Base
# entry the current builder is working on
- attr_accessor :entry
+ attr_accessor :entry
def initialize(entry=nil)
@entry =entry
@@ -35,10 +35,10 @@ def self.build(entry, dst_path)
new(entry).build(dst_path)
end
- # Reads the lines from the source file. If the source file does not
+ # Reads the lines from the source file. If the source file does not
# exist, returns empty array.
def readlines(src_path)
- if File.exist?(src_path) && !File.directory?(src_path)
+ if File.exist?(src_path) && !File.directory?(src_path)
File.readlines(src_path)
else
[]
@@ -66,26 +66,26 @@ def replace_static_url(line)
entry_name = $2
entry_name = "#{$2}:index.html" if $1 == 'sc_target'
static_entry = entry.manifest.find_entry($2)
-
+
if static_entry.nil?
url = ''
elsif $1 == 'sc_target'
url = static_entry.friendly_url || static_entry.cacheable_url
else
- url = static_entry.cacheable_url
+ url = static_entry.cacheable_url
end
-
+
static_url(url)
end
end
# Generates the proper output for a given static url and a given target
- # this is often overridden by subclasses. the default just wraps in
+ # this is often overridden by subclasses. the default just wraps in
# quotes.
def static_url(url='')
["'", url.gsub('"','\"'),"'"].join('')
end
end # class
-
+
end # module Builder
-end # module SC
+end # module SC
View
20 lib/sproutcore/builders/bundle.rb
@@ -12,30 +12,30 @@ module SC
# Builds a bundle_loaded.js file which MUST be the last JavaScript to load
# in a framework.
class Builder::BundleLoaded < Builder::Base
-
+
def build(dst_path)
writelines dst_path, ["; if ((typeof SC !== 'undefined') && SC && SC.bundleDidLoad) SC.bundleDidLoad('#{entry.target.target_name.to_s.sub(/^\//,'')}');"]
end
-
+
end
-
- # Builds a bundle_info.js file which MUST be run *before* the framework is
+
+ # Builds a bundle_info.js file which MUST be run *before* the framework is
# loaded by the application or framework doing the loading.
class Builder::BundleInfo < Builder::Base
-
+
def build(dst_path)
begin
require 'erubis'
rescue
raise "Cannot render bundle_info.js because erubis is not installed. Try running 'sudo gem install erubis' and try again."
end
-
+
eruby = Erubis::Eruby.new <<-EOT
;(function() {
var target_name = '<%= @target_name %>' ;
if (!SC.BUNDLE_INFO) throw "SC.BUNDLE_INFO is not defined!" ;
if (SC.BUNDLE_INFO[target_name]) return ; <%# not an error... %>
-
+
<%# first time, so add a Hash with this target's bundle_info %>
SC.BUNDLE_INFO[target_name] = {
requires: [<%= @requires.join(',') %>],
@@ -44,7 +44,7 @@ def build(dst_path)
}
})();
EOT
-
+
output = ""
entry.targets.each do |t|
bundle_info = t.bundle_info({ :debug => entry.debug, :test => entry.test, :theme => entry.theme, :variation => entry.variation })
@@ -57,7 +57,7 @@ def build(dst_path)
end
writelines dst_path, [output]
end
-
+
end
-
+
end
View
14 lib/sproutcore/builders/combine.rb
@@ -16,11 +16,11 @@ module SC
# build directives such sc_static().
#
class Builder::Combine < Builder::Base
-
+
def build(dst_path)
lines = []
entries = entry.ordered_entries || entry.source_entries
-
+
target_name = entry.target.target_name.to_s.sub(/^\//,'')
if entry.top_level_lazy_instantiation && entry.combined
lines << ";
@@ -33,13 +33,13 @@ def build(dst_path)
SC.LAZY_INSTANTIATION['#{target_name}'].push(
(
function() {
-"
- end
+"
+ end
entries.each do |entry|
src_path = entry.stage!.staging_path
next unless File.exist?(src_path)
-
+
lines << "/* >>>>>>>>>> BEGIN #{entry.filename} */\n"
lines += readlines(src_path)
lines << "\n"
@@ -54,7 +54,7 @@ def build(dst_path)
end
writelines dst_path, lines
end
-
+
end
-
+
end
View
96 lib/sproutcore/builders/html.rb
@@ -12,56 +12,56 @@ module SC
# Builds an HTML files. This will setup an HtmlContext and then invokes
# the render engines for each source before finally rendering the layout.
class Builder::Html < Builder::Base
-
+
include SC::Helpers::TagHelper
include SC::Helpers::TextHelper
include SC::Helpers::CaptureHelper
include SC::Helpers::StaticHelper
include SC::Helpers::DomIdHelper
include SC::ViewHelpers
-
+
# the entry we are building
attr_reader :entry
-
+
# bundle is an alias for target included for backwards compatibility
attr_reader :target, :bundle
-
+
# the full set of entries we plan to build
attr_reader :entries
-
+
# the final filename
attr_reader :filename
-
+
# the current builder language
attr_reader :language
-
+
# library is an alias for project for backwards compatibility
attr_reader :project, :library
-
+
# the current render
attr_reader :renderer
-
+
# manifest owning the current entry
attr_reader :manifest
-
+
def target_name; target.target_name.to_s.sub(/^\//,''); end
alias_method :bundle_name, :target_name # backwards compat
-
+
def config; target.config; end
-
- # The entry for the layout we want to build. this will be used to
+
+ # The entry for the layout we want to build. this will be used to
# stage the layout if needed..
def layout_entry
@manifest.entry_for(@layout) || @manifest.entry_for(@layout, :hidden => true)
end
-
- # the path to the current layout for the resource. this is computed
+
+ # the path to the current layout for the resource. this is computed
# from the layout property, which is a relative pathname.
def layout_path
entry = layout_entry
entry.nil? ? nil : entry.staging_path
end
-
+
def initialize(entry)
super(entry)
@target = @bundle = entry.manifest.target
@@ -70,10 +70,10 @@ def initialize(entry)
@project = @library = @target.project
@manifest = entry.manifest
@renderer = nil
-
+
# set the current layout from the target's config.layout
@layout = @target.config.layout || 'lib/index.rhtml'
-
+
# find all entries -- use source_Entries + required if needed
@entries = entry.source_entries.dup
if entry.include_required_targets?
@@ -87,30 +87,30 @@ def initialize(entry)
end
# Returns the expanded list of required targets for the passed target.
- # This method can be overridden by subclasses to provide specific
+ # This method can be overridden by subclasses to provide specific
# config settings.
def expand_required_targets(target, opts = {})
opts[:debug] = target.config.load_debug
opts[:theme] = true
return target.expand_required_targets(opts)
end
-
- # Renders the html file, returning the resulting string which can be
+
+ # Renders the html file, returning the resulting string which can be
# written to a file.
def render
-
+
# render each entry...
@entries.each { |entry| render_entry(entry) }
-
+
# then finally compile the layout.
if self.layout_path.nil?
- raise "html_builder could not find a layout file for #{@layout}"
+ raise "html_builder could not find a layout file for #{@layout}"
end
-
+
compile(SC::RenderEngine::Erubis.new(self), self.layout_path, :_final_)
return @content_for__final_
end
-
+
def build(dst_path)
if CONFIG.html5_manifest
$to_html5_manifest << dst_path
@@ -119,10 +119,10 @@ def build(dst_path)
end
writelines dst_path, [self.render]
end
-
+
def default_content_for_key; :resources; end
-
- # Loads the passed input file and then hands it to the render_engine
+
+ # Loads the passed input file and then hands it to the render_engine
# instance to compile th file. the results will be targeted at the
# @content_for_resources area by default unless you pass an optional
# content_for_key or otherwise override in your template.
@@ -136,37 +136,37 @@ def default_content_for_key; :resources; end
# self
#
def compile(render_engine, input_path, content_for_key = nil)
-
+
if content_for_key.nil?
if @in_partial
- content_for_key = :_partial_
+ content_for_key = :_partial_
else
- content_for_key = self.default_content_for_key
+ content_for_key = self.default_content_for_key
end
end
-
+
if !File.exist?(input_path)
- raise "html_builder could compile file at #{input_path} because the file could not be found"
+ raise "html_builder could compile file at #{input_path} because the file could not be found"
end
-
+
old_renderer = @renderer
@renderer = render_engine # save for capture...
-
+
input = File.read(input_path)
-
+
content_for content_for_key do
_render_compiled_template( render_engine.compile(input) )
end
-
+
@render = old_renderer
return self
end
private
-
+
# Renders an entry as a partial. This will insert the results inline
# instead of into a content div.
- def render_partial(entry)
+ def render_partial(entry)
# save off
old_partial = @content_for__partial_
@@ -178,22 +178,22 @@ def render_partial(entry)
ret = @content_for__partial_
@content_for__partial_ = old_partial
@in_partial = old_in_partial
-
+
return ret
-
+
end
-
- # Renders a single entry. The entry will be staged and then its
+
+ # Renders a single entry. The entry will be staged and then its
# render task will be executed.
def render_entry(entry)
@content_for_designer = '<script type="text/javascript">SC.suppressMain = YES;</script>' if $design_mode
entry.stage!
entry.target.buildfile.invoke entry.render_task,
- :entry => entry,
+ :entry => entry,
:src_path => entry.staging_path,
:context => self
end
-
+
# Renders a compiled template within this context
def _render_compiled_template(compiled_template)
self.instance_eval "def __render(); #{compiled_template}; end"
@@ -205,7 +205,7 @@ def _render_compiled_template(compiled_template)
class << self; self end.class_eval{ remove_method(:__render) } rescue nil
end
end
-
+
end
-
+
end
View
18 lib/sproutcore/builders/javascript.rb
@@ -11,15 +11,15 @@
module SC
# This build is used to process a single javascript file. It will
- # substitute any calls to sc_super and sc_static() (or static_url()). It
- # does NOT product a combined JavaScript for production. See the
+ # substitute any calls to sc_super and sc_static() (or static_url()). It
+ # does NOT product a combined JavaScript for production. See the
# Builder::CombinedJavaScript for more.
class Builder::JavaScript < Builder::Base
-
+
def build(dst_path)
lines = []
target_name = entry.target.target_name.to_s.sub(/^\//,'')
-
+
if entry.lazy_instantiation && entry.notify_onload
lines << ";
if ((typeof SC !== 'undefined') && SC && !SC.LAZY_INSTANTIATION) {
@@ -48,13 +48,13 @@ def build(dst_path)
);
"
end
-
+
writelines dst_path, lines
end
# Returns true if the current entry is a localized strings file. These
# files receive some specialized processing to allow for server-side only
- # strings. -- You can name a string key beginning with "@@" and it will
+ # strings. -- You can name a string key beginning with "@@" and it will
# be removed.
def localized_strings?
@lstrings ||= entry.localized? && entry.filename =~ /strings.js$/
@@ -67,7 +67,7 @@ def rewrite_inline_code(line)
if localized_strings?
line = line.gsub(/["']@@.*["']\s*?:\s*?["'].*["']\s*,\s*$/,'')
- # Otherwise process sc_super
+ # Otherwise process sc_super
else
return unless (line.valid_encoding?)
if line.match(/sc_super\(\s*\)/)
@@ -81,7 +81,7 @@ def rewrite_inline_code(line)
# and finally rewrite static_url
return replace_static_url(line)
end
-
+
end
-
+
end
View
8 lib/sproutcore/builders/less.rb
@@ -12,7 +12,7 @@ module SC
# This build can compile a Less stylesheet.
class Builder::Less < Builder::Stylesheet
-
+
def build(dst_path)
begin
require 'less'
@@ -27,7 +27,7 @@ def build(dst_path)
css.each_line { |l| lines << rewrite_inline_code(l) }
writelines dst_path, lines
rescue Exception => e
-
+
# explain sass syntax error a bit more...
if e.is_a? Less::SyntaxError
e.message << " of #{@entry.source_path}"
@@ -35,7 +35,7 @@ def build(dst_path)
raise e # reraise
end # rescue
end # def
-
+
end
-
+
end
View
30 lib/sproutcore/builders/minify.rb
@@ -16,22 +16,22 @@ module SC
# build directives such sc_static().
#
class Builder::Minify < Builder::Base
-
+
# main entry called by build tasls
def self.build(entry, dst_path, kind)
new(entry, kind).build(dst_path)
end
-
+
def initialize(entry=nil, kind=nil)
super(entry)
@kind = kind
end
-
+
# override this method in subclasses to actually do build
def build(dst_path)
send("build_#{@kind}".to_sym, dst_path)
end
-
+
def build_css(dst_path)
a = Regexp.new('^'+MANIFEST.build_root)
if dst_path =~ a
@@ -45,7 +45,7 @@ def build_css(dst_path)
filecompress = "java -jar " + jar_path + " --charset utf-8 --line-break 0 --nomunge --preserve-semi --disable-optimizations " + entry.source_path + " -o \"" + dst_path + "\" 2>&1"
SC.logger.info 'Compressing CSS with YUI .... '+ dst_path
SC.logger.debug `#{filecompress}`
-
+
if $?.exitstatus != 0
_report_error(output, entry.filename, entry.source_path)
SC.logger.fatal("!!!!YUI compressor failed, please check that your css code is valid.")
@@ -53,7 +53,7 @@ def build_css(dst_path)
end
end
end
-
+
# Minify some javascript by invoking the YUI compressor.
def build_javascript(dst_path)
a = Regexp.new('^'+MANIFEST.build_root)
@@ -67,7 +67,7 @@ def build_javascript(dst_path)
FileUtils.mkdir_p(File.dirname(dst_path)) # make sure loc exists...
filecompress = "java -jar " + jar_path + " --charset utf-8 --line-break 80 " + entry.source_path + " -o \"" + dst_path + "\" 2>&1"
SC.logger.info 'Compressing with YUI: '+ dst_path + "..."
-
+
output = `#{filecompress}` # It'd be nice to just read STDERR, but
# I can't find a reasonable, commonly-
# installed, works-on-all-OSes solution.
@@ -78,7 +78,7 @@ def build_javascript(dst_path)
end
end
end
-
+
def build_inline_javascript(dst_path)
SC.logger.info 'Compressing inline Javascript with YUI: ' + dst_path + "..."
yui_root = File.expand_path(File.join(LIBPATH, '..', 'vendor', 'yui-compressor'))
@@ -96,8 +96,8 @@ def build_inline_javascript(dst_path)
SC.logger.fatal("!!!!Failed compressing ... "+ dst_path)
end
end
-
-
+
+
def _report_error(output, input_filename, input_filepath)
# The output might have some clues to what exactly was wrong, and it'll
# be convenient for users if we include the subset. So we'll read the
@@ -129,7 +129,7 @@ def _report_error(output, input_filename, input_filepath)
message += " [#{line_number - 1}] #{previous_line}"
end
message += " --> [#{line_number}] #{file_line}"
-
+
SC.logger.error message
outputted_line = true
break
@@ -142,14 +142,14 @@ def _report_error(output, input_filename, input_filepath)
rescue => err
SC.logger.error "Could not read the actual line from the file: #{err}"
end
-
+
if !outputted_line
SC.logger.error "YUI compressor error: #{output_line}, but couldn't read that line in the input file"
end
end
end
}
-
+
# If we didn't handle at least one line of output specially, then
# just output it all.
if !parsed_a_line
@@ -157,8 +157,8 @@ def _report_error(output, input_filename, input_filepath)
end
end
end
-
+
end
-
+
end
View
14 lib/sproutcore/builders/sass.rb
@@ -11,18 +11,18 @@
module SC
# This build can compile a Sass stylesheet. At this point it does no
- # further processing than simply executing the Sass. It would be nice to
+ # further processing than simply executing the Sass. It would be nice to
# add support for sc_static and other directives at some point.
#
class Builder::Sass < Builder::Stylesheet
@@sass_syntax = :sass
-
+
# main entry called by build tasks
def self.build(entry, dst_path, sass_syntax=:sass)
@@sass_syntax =sass_syntax
new(entry).build(dst_path)
end
-
+
def build(dst_path)
begin
require 'sass'
@@ -38,7 +38,7 @@ def build(dst_path)
css.each_line { |l| lines << rewrite_inline_code(l) }
writelines dst_path, lines
rescue Exception => e
-
+
# explain sass syntax error a bit more...
if e.is_a? Sass::SyntaxError
e_string = "#{e.class}: #{e.message}"
@@ -56,10 +56,10 @@ def build(dst_path)
raise e_string
else
raise e # reraise
- end
+ end
end # rescue
end # def
-
+
end
-
+
end
View
14 lib/sproutcore/builders/strings.rb
@@ -11,15 +11,15 @@
module SC
# This builder is used to generate a file containing all of the loc strings
- # for a particular manifest. The strings file is used when generating
+ # for a particular manifest. The strings file is used when generating
# HTML try to map localized strings
class Builder::Strings < Builder::Base
-
+
def build(dst_path)
data = parse_strings_js(entry.source_path)
writelines dst_path, [data.to_yaml]
end
-
+
def parse_strings_js(source_path)
return {} if !File.exists?(source_path)
@@ -35,10 +35,10 @@ def parse_strings_js(source_path)
y = eval(%[<<__EOF__\n#{y}\n__EOF__]).chop
ret[x] = y
end
- return ret
+ return ret
end
-
-
+
+
end
-
+
end
View
12 lib/sproutcore/builders/stylesheet.rb
@@ -11,13 +11,13 @@
module SC
# This builder is used to process a single CSS stylesheet. Converts any
- # build tool directives (such as sc_require() and sc_resource()) into
- # comments. It will also substitute any calls to sc_static() (or
+ # build tool directives (such as sc_require() and sc_resource()) into
+ # comments. It will also substitute any calls to sc_static() (or
# static_url()) This builder does NOT handle combining multiple stylesheets
# into one. See the Builder::CombineStylesheets builder instead.
#
class Builder::Stylesheet < Builder::Base
-
+
def build(dst_path)
lines = readlines(entry.source_path).map { |l| rewrite_inline_code(l) }
writelines dst_path, lines
@@ -32,9 +32,9 @@ def rewrite_inline_code(line)
line = line.gsub(/((sc_require|require|sc_resource)\(\s*['"].*["']\s*\)\s*\;)/, '/* \1 */')
line = replace_static_url(line)
end
-
+
def static_url(url=''); "url('#{url}')" ; end
-
+
end
-
+
end
View
26 lib/sproutcore/builders/test.rb
@@ -12,21 +12,21 @@ module SC
# Builds an HTML files. This will setup an HtmlContext and then invokes
# the render engines for each source before finally rendering the layout.
class Builder::Test < Builder::Html
-
+
def initialize(entry)
super(entry)
@layout = @target.config.test_layout || 'lib/test.rhtml'
end
-
- # Always include any required test targets as well when loading unit
+
+ # Always include any required test targets as well when loading unit
# tests.
def expand_required_targets(target, opts = {})
opts[:test] = true
super(target, opts)
end
-
- protected
-
+
+ protected
+
def render_entry(entry)
entry.stage!
@@ -35,16 +35,16 @@ def render_entry(entry)
render_jstest(entry)
when 'rhtml'
entry.target.buildfile.invoke 'render:erubis',
- :entry => entry,
+ :entry => entry,
:src_path => entry.staging_path,
:context => self
end
end
-
+
def default_content_for_key; :body; end
-
- # Renders an individual test into a script tag. Also places the test
- # into its own closure so that globals defined by one test will not
+
+ # Renders an individual test into a script tag. Also places the test
+ # into its own closure so that globals defined by one test will not
# conflict with any others.
def render_jstest(entry)
lines = readlines(entry.staging_path)
@@ -53,7 +53,7 @@ def render_jstest(entry)
lines.push %[\n})();\n</script>\n]
@content_for_final = (@content_for_final || '') + lines.join("")
end
-
+
end
-
+
end
View
6 lib/sproutcore/builders/test_index.rb
@@ -12,7 +12,7 @@ module SC
# Builds an HTML files. This will setup an HtmlContext and then invokes
# the render engines for each source before finally rendering the layout.
class Builder::TestIndex < Builder::Base
-
+
def build(dst_path)
require 'json'
items = entry.source_entries.map do |e|
@@ -20,7 +20,7 @@ def build(dst_path)
end
writelines dst_path, [items.to_json]
end
-
+
end
-
+
end
View
8 lib/sproutcore/buildfile/build_task.rb
@@ -20,14 +20,14 @@ def needed?
dst_mtime = File.mtime(DST_PATH)
SRC_PATHS.each do |path|
next if path.nil? # skip incase of bad src paths...
-
+
timestamp = File.exist?(path) ? File.mtime(path) : EARLY
ret = ret || (dst_mtime < timestamp)
break if ret
end
- return ret
+ return ret
end
-
+
end
end
-
+
View
28 lib/sproutcore/buildfile/buildfile_dsl.rb
@@ -8,7 +8,7 @@
module SC
class Buildfile
-
+
# Describe the domain-specific-language helpers supported by buildfiles.
# This is included as a mixin for the buildfile.
module Commands
@@ -23,7 +23,7 @@ module Commands
def task(*args, &block)
define_task(::SC::Buildfile::Task, *args, &block)
end
-
+
# Replace an existing task instead of enhancing it.
#
# Example:
@@ -40,7 +40,7 @@ def replace_task(*args, &block)
raise e
end
end
-
+
# Define a build task. A build task will not run if the destination
# file is newer than the source files.
#
@@ -48,9 +48,9 @@ def build_task(*args, &block)
define_task(::SC::Buildfile::BuildTask, *args, &block)
end
- # Import the partial Rakefiles +fn+. Imported files are loaded _after_
- # the current file is completely loaded. This allows the import statement
- # to appear anywhere in the importing file, and yet allowing the imported
+ # Import the partial Rakefiles +fn+. Imported files are loaded _after_
+ # the current file is completely loaded. This allows the import statement
+ # to appear anywhere in the importing file, and yet allowing the imported
# files to depend on objects defined in the importing file.
#
# A common use of the import statement is to include files containing
@@ -61,14 +61,14 @@ def build_task(*args, &block)
#
def import(*args)
base_path = current_path.nil? ? nil : File.dirname(current_path)
- args.each do |fn|
+ args.each do |fn|
fn = File.expand_path(fn, base_path)
add_import(fn)
end
end
-
+
# Create a new rake namespace and use it for evaluating the given block.
- # Returns a NameSpace object that can be used to lookup tasks defined in
+ # Returns a NameSpace object that can be used to lookup tasks defined in
# the namespace.
#
# E.g.
@@ -108,7 +108,7 @@ def task_options(opts)
# Scope any config statements inside the passed block to the named mode.
# Normally if you call a config statement outside of a mode block, it will
- # scope to all modes.
+ # scope to all modes.
#
# Example:
# mode :debug do
@@ -146,17 +146,17 @@ def config(config_name, opts = {}, &block)
def proxy(proxy_path, opts={})
add_proxy proxy_path, opts
end
-
+
# Register info about this buildfile as a project
def project(name=nil, type=nil)
self.project_name = name.nil? ? :default : name.to_sym
self.project_type = type.nil? ? :default : type.to_sym
self.project!
end
-
+
end
-
+
include Commands
end
-
+
end
View
6 lib/sproutcore/buildfile/cloneable.rb
@@ -6,7 +6,7 @@
# ===========================================================================
module SC
-
+
# Mixing for creating easily cloned objects. Borrowed from Rake 0.8.3
module Cloneable
@@ -29,6 +29,6 @@ def clone
sibling
end
end
-
-
+
+
end
View
4 lib/sproutcore/buildfile/early_time.rb
@@ -9,7 +9,7 @@
require 'time'
module SC
-
+
# EarlyTime is a fake timestamp that occurs _before_ any other time value.
# Borrowed from Rake 0.8.3
class EarlyTime < Time
@@ -27,4 +27,4 @@ def to_s
EARLY = EarlyTime.instance
-end
+end
View
6 lib/sproutcore/buildfile/invocation_chain.rb
@@ -6,7 +6,7 @@
# ===========================================================================
module SC
-
+
# InvocationChain tracks the chain of task invocations to detect
# circular dependencies. Borrowed from Rake 0.8.3
class InvocationChain
@@ -22,7 +22,7 @@ def member?(obj)
def already_invoked?(task)
(task == @value) || @tail.already_invoked?(task)
end
-
+
def append(value)
if member?(value)
raise "Circular dependency detected: #{to_s} => #{value}"
@@ -61,4 +61,4 @@ def already_invoked?(task); false; end
end # class InvocationChain
-end
+end
View
6 lib/sproutcore/buildfile/namespace.rb
@@ -6,7 +6,7 @@
# ===========================================================================
module SC
-
+
# The NameSpace class will lookup task names in the the scope
# defined by a +namespace+ command. Borrowed from Rake 0.8.3
#
@@ -29,5 +29,5 @@ def tasks
@task_manager.tasks
end
end # NameSpace
-
-end
+
+end
View
2  lib/sproutcore/buildfile/string_ext.rb
@@ -74,7 +74,7 @@ def pathmap_partial(n)
File.join(partial_dirs)
end
protected :pathmap_partial
-
+
# Preform the pathmap replacement operations on the given path. The
# patterns take the form 'pat1,rep1;pat2,rep2...'.
def pathmap_replace(patterns, &block)
View
50 lib/sproutcore/buildfile/task.rb
@@ -6,8 +6,8 @@
# ===========================================================================
module SC
-
- # Buildfile tasks are rake tasks with a few extras added to support
+
+ # Buildfile tasks are rake tasks with a few extras added to support
# unique buildfile constraints. Much of this source code is borrowed from
# Rake 0.8.3
#
@@ -33,17 +33,17 @@ class Buildfile::Task
# Array of nested namespaces names used for task lookup by this task.
attr_reader :scope
- # The number of times this task has been invoked. Use to ensure that
+ # The number of times this task has been invoked. Use to ensure that
# the task was invoked during some call chain...
attr_reader :invoke_count
-
- # The number of times the task was actually executed. This may differ
+
+ # The number of times the task was actually executed. This may differ
# from the invoke_count if the task was invoked but was not needed.
attr_reader :execute_count
-
+
# Various options you can set on the task to control log level, etc.
attr_reader :task_options
-
+
# Return task name
def to_s
name
@@ -75,7 +75,7 @@ def dup(app=nil)
sibling.taint if tainted?
sibling
end
-
+
# Create a task named +task_name+ with no actions or prerequisites. Use
# +enhance+ to add actions and prerequisites.
def initialize(task_name, app)
@@ -151,53 +151,53 @@ def invoke(*args)
def self.log_indent
@task_indent ||= ''
end
-
+
def self.indent_logs
@task_indent = (@task_indent || '') + ' '
end
-
+
def self.outdent_logs
@task_indent = (@task_indent || '')[0..-3]
end
-
+
# Same as invoke, but explicitly pass a call chain to detect
# circular dependencies.
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
-
+
# 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
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_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
end
return invocation_chain
@@ -225,7 +225,7 @@ def format_trace_flags
# Execute the actions associated with this task.
def execute(args=nil)
-
+
@execute_count += 1
args ||= EMPTY_TASK_ARGS
return if SC.env.dryrun
@@ -238,7 +238,7 @@ def execute(args=nil)
act.call(self, args)
end
end
-
+
end
# Is this task needed?
@@ -265,7 +265,7 @@ def add_options(task_options)
return if !task_options
@task_options = task_options
end
-
+
# Writing to the comment attribute is the same as adding a description.
def comment=(description)
add_description(description)
@@ -315,18 +315,18 @@ def investigation
end
class <<self
-
+
# Apply the scope to the task name according to the rules for
# this kind of task. Generic tasks will accept the scope as
# part of the name.
def scope_name(scope, task_name)
(scope + [task_name]).join(':')
end
-
+
end
end
end
-
+
View
8 lib/sproutcore/buildfile/task_arguments.rb
@@ -6,7 +6,7 @@
# ===========================================================================
module SC
-
+
# TaskAguments manage the arguments passed to a task. Borrowed from Rake
# 0.8.3
#
@@ -65,9 +65,9 @@ def to_s
def inspect
to_s
end
-
+
protected
-
+
def lookup(name)
if @hash.has_key?(name)
@hash[name]
@@ -82,5 +82,5 @@ def lookup(name)
end
EMPTY_TASK_ARGS = TaskArguments.new([], [])
-
+
end
View
8 lib/sproutcore/buildfile/task_manager.rb
@@ -6,7 +6,7 @@
# ===========================================================================
module SC
-
+
# Manages a set of tasks. Borrowed from Rake 0.8.3
module TaskManager
# Track the last comment made in the Rakefile.
@@ -14,7 +14,7 @@ module TaskManager
alias :last_comment :last_description # Backwards compatibility
attr_accessor :last_task_options
-
+
def initialize
super
@tasks = Hash.new
@@ -86,7 +86,7 @@ def resolve_args_without_dependencies(args)
[task_name, arg_names, []]
end
private :resolve_args_without_dependencies
-
+
# Resolve task arguments for a task or rule when there are
# dependencies declared.
#
@@ -117,7 +117,7 @@ def resolve_args_with_dependencies(args, hash) # :nodoc:
[task_name, arg_names, deps]
end
private :resolve_args_with_dependencies
-
+
# List of all defined tasks in this application.
def tasks
@tasks.values.sort_by { |t| t.name }
View
48 lib/sproutcore/helpers/cssmin.rb
@@ -12,11 +12,11 @@
#
# == About
#
-# Rainpress is a compressor for CSS. It's written in ruby, but should not be
+# Rainpress is a compressor for CSS. It's written in ruby, but should not be
# limited to ruby projects.
#
-# Rainpress does not apply common compression algorithms like gzip, it removes
-# unnecessary characters and replaces some attributes with a shorter equivalent
+# Rainpress does not apply common compression algorithms like gzip, it removes
+# unnecessary characters and replaces some attributes with a shorter equivalent
# name.
#
# == Links
@@ -42,12 +42,12 @@ module SC::Helpers
# packer = SproutCore::CSSPacker.new
# compressed_style = packer.compress(style)
class CSSPacker
-
+
# Use always this functions if you want to compress your CSS-style
#
# <b>Options:</b>
#
- # * <tt>:preserveComments</tt> - if set to true, comments will not be
+ # * <tt>:preserveComments</tt> - if set to true, comments will not be
# removed
# * <tt>:preserveNewline</tt> - if set to true, newlines will not be removed
# * <tt>:preserveSpaces</tt> - if set to true, spaces will not be removed
@@ -57,30 +57,30 @@ class CSSPacker
def compress(style, options = {})
# remove comments
style = remove_comments(style) unless options[:preserveComments]
-
+
# remove newlines
style = remove_newlines(style) unless options[:preserveNewlines]
-
+
# remove unneeded spaces
style = remove_spaces(style) unless options[:preserveSpaces]
-
+
# replace colours with shorter names
style = shorten_colors(style) unless options[:preserveColors]
-
+
# make all other things
style = do_misc(style) unless options[:skipMisc]
-
+
style
end
-
+
# Remove all comments out of the CSS-Document
def remove_comments(script)
input = script
script = ''
-
+
while input.length > 0 do
pos = input.index("/*");
-
+
# No more comments
if pos == nil
script += input
@@ -93,7 +93,7 @@ def remove_comments(script)
input = input[(pos+2)..-1]
end
end
-
+
# return
script
end
@@ -102,7 +102,7 @@ def remove_comments(script)
def remove_newlines(script)
script.gsub(/\n|\r/,'')
end
-
+
# 1. Turn mutiple spaces into a single
# 2. Remove spaces around ;:{},
# 3. Remove tabs
@@ -115,7 +115,7 @@ def remove_spaces(script)
script = script.gsub(/\s*,\s*/,',')
script.gsub("\t",'');
end
-
+
# Replace color values with their shorter equivalent
#
# 1. Turn rgb(,,)-colors into #-values
@@ -130,7 +130,7 @@ def shorten_colors(style)
style = style.gsub(/rgb\s*\(\s*([0-9,\s]+)\s*\)/) do |match|
out = '#'
$1.split(',').each do |num|
- if num.to_i < 16
+ if num.to_i < 16
out += '0'
end
out += num.to_i.to_s(16) # convert to hex
@@ -139,9 +139,9 @@ def shorten_colors(style)
end
# #AABBCC to #ABC, keep if preceed by a '='
style = style.gsub(/([^\"'=\s])(\s*)#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/) do |match|
- out = match
+ out = match
if ($3.downcase == $4.downcase) and ($5.downcase == $6.downcase) and ($7.downcase == $8.downcase)
- out = $1 + '#' + $3.downcase + $5.downcase + $7.downcase
+ out = $1 + '#' + $3.downcase + $5.downcase + $7.downcase
end
out
end
@@ -153,10 +153,10 @@ def shorten_colors(style)
# shotern several numbers to names
style = style.gsub(/:[\s]*#([fF]00|[fF]{2}0000);/, ':red;')
style = style.gsub(/:[\s]*#([fF]00|[fF]{2}0000)\}/, ':red}')
-
+
style
end
-
+
# Do miscellaneous compression methods on the style
def do_misc(script)
# Replace 0(pt,px,em,%) with 0 but only when preceded by : or a white-space
@@ -193,10 +193,10 @@ def do_misc(script)
script = script.gsub(/font[\s]*:[\s]*bold[\s;\}]*/) do |match|
match.sub('bold', '700')
end
-
+
script
end
-
+
end
-
+
end
View
60 lib/sproutcore/helpers/entry_sorter.rb
@@ -6,33 +6,33 @@
# ===========================================================================
module SC
-
+
module Helpers
-
+
# Sorts a set of entries, respecting any "requires" found in the entries.
# To use the sorter, just call the class method EntrySorter.sort() passing
# the entries to sort along with any filenames you prefer to have added to
# the top. If you don't specify any filenames, then the entries will be
# sorted alphabetically except for requires.
- #
+ #
# When bundle_info.js is present, it will always be sorted first.
# When bundle_loaded.js is present, it will always be sorted last.
class EntrySorter
-