2010-10-12 23:28:46 +00:00
|
|
|
include FileUtils
|
2010-01-06 00:36:58 +00:00
|
|
|
|
2010-10-08 23:43:40 +00:00
|
|
|
ANGULAR = [
|
|
|
|
|
'src/Angular.js',
|
|
|
|
|
'src/JSON.js',
|
|
|
|
|
'src/Compiler.js',
|
|
|
|
|
'src/Scope.js',
|
|
|
|
|
'src/Injector.js',
|
2010-10-27 22:20:05 +00:00
|
|
|
'src/parser.js',
|
2010-10-08 23:43:40 +00:00
|
|
|
'src/Resource.js',
|
|
|
|
|
'src/Browser.js',
|
2010-10-19 04:20:47 +00:00
|
|
|
'src/sanitizer.js',
|
2010-10-08 23:43:40 +00:00
|
|
|
'src/jqLite.js',
|
|
|
|
|
'src/apis.js',
|
|
|
|
|
'src/filters.js',
|
|
|
|
|
'src/formatters.js',
|
|
|
|
|
'src/validators.js',
|
|
|
|
|
'src/services.js',
|
|
|
|
|
'src/directives.js',
|
|
|
|
|
'src/markups.js',
|
|
|
|
|
'src/widgets.js',
|
|
|
|
|
'src/AngularPublic.js',
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
ANGULAR_SCENARIO = [
|
|
|
|
|
'src/scenario/Scenario.js',
|
|
|
|
|
'src/scenario/Application.js',
|
|
|
|
|
'src/scenario/Describe.js',
|
|
|
|
|
'src/scenario/Future.js',
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
'src/scenario/ObjectModel.js',
|
2010-10-08 23:43:40 +00:00
|
|
|
'src/scenario/Describe.js',
|
|
|
|
|
'src/scenario/Runner.js',
|
|
|
|
|
'src/scenario/SpecRunner.js',
|
|
|
|
|
'src/scenario/dsl.js',
|
|
|
|
|
'src/scenario/matchers.js',
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
'src/scenario/output/Html.js',
|
|
|
|
|
'src/scenario/output/Json.js',
|
|
|
|
|
'src/scenario/output/Xml.js',
|
|
|
|
|
'src/scenario/output/Object.js',
|
2010-10-08 23:43:40 +00:00
|
|
|
]
|
|
|
|
|
|
2010-10-20 04:19:28 +00:00
|
|
|
BUILD_DIR = 'build'
|
2010-10-08 23:43:40 +00:00
|
|
|
|
2010-01-26 19:27:50 +00:00
|
|
|
task :default => [:compile, :test]
|
|
|
|
|
|
2010-10-16 04:38:41 +00:00
|
|
|
|
2010-10-21 00:14:31 +00:00
|
|
|
desc 'Init the build workspace'
|
|
|
|
|
task :init do
|
|
|
|
|
FileUtils.mkdir(BUILD_DIR) unless File.directory?(BUILD_DIR)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2010-10-16 04:38:41 +00:00
|
|
|
desc 'Clean Generated Files'
|
|
|
|
|
task :clean do
|
2010-10-20 04:19:28 +00:00
|
|
|
FileUtils.rm_r(BUILD_DIR, :force => true)
|
|
|
|
|
FileUtils.mkdir(BUILD_DIR)
|
2010-10-16 04:38:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2010-05-25 21:23:52 +00:00
|
|
|
desc 'Compile Scenario'
|
2010-10-21 00:14:31 +00:00
|
|
|
task :compile_scenario => :init do
|
2010-10-19 22:34:58 +00:00
|
|
|
|
2010-10-08 23:43:40 +00:00
|
|
|
deps = [
|
|
|
|
|
'lib/jquery/jquery-1.4.2.js',
|
|
|
|
|
'src/scenario/angular.prefix',
|
|
|
|
|
ANGULAR,
|
|
|
|
|
ANGULAR_SCENARIO,
|
|
|
|
|
'src/scenario/angular.suffix',
|
|
|
|
|
]
|
2010-10-16 04:38:41 +00:00
|
|
|
|
2010-10-08 23:43:40 +00:00
|
|
|
concat = 'cat ' + deps.flatten.join(' ')
|
2010-10-16 04:38:41 +00:00
|
|
|
|
2010-10-20 04:19:28 +00:00
|
|
|
File.open(path_to('angular-scenario.js'), 'w') do |f|
|
2010-10-16 04:38:41 +00:00
|
|
|
f.write(%x{#{concat}})
|
2010-10-19 22:34:58 +00:00
|
|
|
f.write(gen_css('css/angular.css') + "\n")
|
2010-10-16 04:38:41 +00:00
|
|
|
f.write(gen_css('css/angular-scenario.css'))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
desc 'Generate IE css js patch'
|
2010-10-21 00:14:31 +00:00
|
|
|
task :generate_ie_compat => :init do
|
2010-10-16 04:38:41 +00:00
|
|
|
css = File.open('css/angular.css', 'r') {|f| f.read }
|
|
|
|
|
|
|
|
|
|
# finds all css rules that contain backround images and extracts the rule name(s), content type of
|
|
|
|
|
# the image and base64 encoded image data
|
|
|
|
|
r = /\n([^\{\n]+)\s*\{[^\}]*background-image:\s*url\("data:([^;]+);base64,([^"]+)"\);[^\}]*\}/
|
|
|
|
|
|
|
|
|
|
images = css.scan(r)
|
|
|
|
|
|
|
|
|
|
# create a js file with multipart header containing the extracted images. the entire file *must*
|
|
|
|
|
# be CRLF (\r\n) delimited
|
2010-10-20 04:19:28 +00:00
|
|
|
File.open(path_to('angular-ie-compat.js'), 'w') do |f|
|
2010-10-16 04:38:41 +00:00
|
|
|
f.write("/*\r\n" +
|
|
|
|
|
"Content-Type: multipart/related; boundary=\"_\"\r\n" +
|
|
|
|
|
"\r\n")
|
2010-10-20 04:19:28 +00:00
|
|
|
|
2010-10-16 04:38:41 +00:00
|
|
|
images.each_index do |idx|
|
|
|
|
|
f.write("--_\r\n" +
|
|
|
|
|
"Content-Location:img#{idx}\r\n" +
|
|
|
|
|
"Content-Transfer-Encoding:base64\r\n" +
|
|
|
|
|
"\r\n" +
|
|
|
|
|
images[idx][2] + "\r\n")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
f.write("--_--\r\n" +
|
|
|
|
|
"*/\r\n")
|
|
|
|
|
|
|
|
|
|
# generate a css string containing *background-image rules for IE that point to the mime type
|
|
|
|
|
# images in the header
|
|
|
|
|
cssString = ''
|
|
|
|
|
images.each_index do |idx|
|
|
|
|
|
cssString += "#{images[idx][0]}{*background-image:url(\"mhtml:' + jsUri + '!img#{idx}\")}"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# generate a javascript closure that contains a function which will append the generated css
|
|
|
|
|
# string as a stylesheet to the current html document
|
|
|
|
|
jsString = "(function(){ \r\n" +
|
|
|
|
|
" var jsUri = document.location.href.replace(/\\/[^\/]+(#.*)?$/, '/') + " +
|
|
|
|
|
" document.getElementById('ng-ie-compat').src; \r\n" +
|
|
|
|
|
" var css = '#{cssString}' \r\n" +
|
|
|
|
|
" var s = document.createElement('style'); \r\n" +
|
|
|
|
|
" s.setAttribute('type', 'text/css'); \r\n" +
|
|
|
|
|
" if (s.styleSheet) { \r\n" +
|
|
|
|
|
" s.styleSheet.cssText = css; \r\n" +
|
|
|
|
|
" } else { \r\n" +
|
|
|
|
|
" s.appendChild(document.createTextNode(css)); \r\n" +
|
|
|
|
|
" } \r\n" +
|
|
|
|
|
" document.getElementsByTagName('head')[0].appendChild(s); \r\n" +
|
|
|
|
|
"})();\r\n"
|
|
|
|
|
|
|
|
|
|
f.write(jsString)
|
|
|
|
|
end
|
2010-05-25 21:23:52 +00:00
|
|
|
end
|
|
|
|
|
|
2010-10-16 04:38:41 +00:00
|
|
|
|
2010-01-06 00:36:58 +00:00
|
|
|
desc 'Compile JavaScript'
|
2010-10-21 00:14:31 +00:00
|
|
|
task :compile => [:init, :compile_scenario, :generate_ie_compat] do
|
2010-01-10 16:58:57 +00:00
|
|
|
|
2010-10-08 23:43:40 +00:00
|
|
|
deps = [
|
|
|
|
|
'src/angular.prefix',
|
|
|
|
|
ANGULAR,
|
|
|
|
|
'src/angular.suffix',
|
|
|
|
|
]
|
2010-10-16 04:38:41 +00:00
|
|
|
|
2010-10-20 04:19:28 +00:00
|
|
|
File.open(path_to('angular.js'), 'w') do |f|
|
2010-10-16 04:38:41 +00:00
|
|
|
concat = 'cat ' + deps.flatten.join(' ')
|
|
|
|
|
f.write(%x{#{concat}})
|
|
|
|
|
f.write(gen_css('css/angular.css', true))
|
|
|
|
|
end
|
2010-01-06 00:36:58 +00:00
|
|
|
|
|
|
|
|
%x(java -jar lib/compiler-closure/compiler.jar \
|
2010-08-11 18:17:55 +00:00
|
|
|
--compilation_level SIMPLE_OPTIMIZATIONS \
|
2010-10-20 04:19:28 +00:00
|
|
|
--js #{path_to('angular.js')} \
|
|
|
|
|
--js_output_file #{path_to('angular.min.js')})
|
2010-01-06 00:36:58 +00:00
|
|
|
end
|
|
|
|
|
|
2010-10-16 04:38:41 +00:00
|
|
|
|
2010-10-27 22:31:10 +00:00
|
|
|
desc 'Generate docs'
|
|
|
|
|
task :docs do
|
|
|
|
|
`node docs/collect.js`
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2010-10-12 23:28:46 +00:00
|
|
|
desc 'Create angular distribution'
|
2010-10-27 22:31:10 +00:00
|
|
|
task :package => [:clean, :compile, :docs] do
|
2010-10-20 04:19:28 +00:00
|
|
|
v = YAML::load( File.open( 'version.yaml' ) )['version']
|
|
|
|
|
match = v.match(/^([^-]*)(-snapshot)?$/)
|
|
|
|
|
version = match[1] + (match[2] ? ('-' + %x(git rev-parse HEAD)[0..7]) : '')
|
|
|
|
|
|
|
|
|
|
tarball = "angular-#{version}.tgz"
|
|
|
|
|
|
|
|
|
|
pkg_dir = path_to("pkg/angular-#{version}")
|
|
|
|
|
FileUtils.rm_r(path_to('pkg'), :force => true)
|
|
|
|
|
FileUtils.mkdir_p(pkg_dir)
|
|
|
|
|
|
|
|
|
|
['test/angular-mocks.js',
|
|
|
|
|
path_to('angular.js'),
|
|
|
|
|
path_to('angular.min.js'),
|
|
|
|
|
path_to('angular-ie-compat.js'),
|
|
|
|
|
path_to('angular-scenario.js')
|
|
|
|
|
].each do |src|
|
|
|
|
|
dest = src.gsub(/^[^\/]+\//, '').gsub(/((\.min)?\.js)$/, "-#{version}\\1")
|
|
|
|
|
FileUtils.cp(src, pkg_dir + '/' + dest)
|
|
|
|
|
end
|
2010-10-12 23:52:33 +00:00
|
|
|
|
2010-10-27 22:31:10 +00:00
|
|
|
FileUtils.cp_r path_to('docs'), "#{pkg_dir}/docs-#{version}"
|
|
|
|
|
|
|
|
|
|
File.open("#{pkg_dir}/docs-#{version}/index.html", File::RDWR) do |f|
|
|
|
|
|
text = f.read
|
|
|
|
|
f.rewind
|
|
|
|
|
f.write text.sub('angular.min.js', "angular-#{version}.min.js")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
File.open("#{pkg_dir}/docs-#{version}/docs-scenario.html", File::RDWR) do |f|
|
|
|
|
|
text = f.read
|
|
|
|
|
f.rewind
|
|
|
|
|
f.write text.sub('angular-scenario.js', "angular-scenario-#{version}.js")
|
|
|
|
|
end
|
|
|
|
|
|
2010-10-20 04:19:28 +00:00
|
|
|
%x(tar -czf #{path_to(tarball)} -C #{path_to('pkg')} .)
|
2010-10-12 23:28:46 +00:00
|
|
|
|
2010-10-20 04:19:28 +00:00
|
|
|
puts "Package created: #{path_to(tarball)}"
|
2010-10-12 23:28:46 +00:00
|
|
|
end
|
|
|
|
|
|
2010-10-16 04:38:41 +00:00
|
|
|
|
2010-01-06 00:36:58 +00:00
|
|
|
namespace :server do
|
2010-10-16 04:38:41 +00:00
|
|
|
|
2010-01-06 00:36:58 +00:00
|
|
|
desc 'Run JsTestDriver Server'
|
|
|
|
|
task :start do
|
|
|
|
|
sh %x(java -jar lib/jstestdriver/JsTestDriver.jar --browser open --port 9876)
|
|
|
|
|
end
|
|
|
|
|
|
2010-10-16 04:38:41 +00:00
|
|
|
desc 'Run JavaScript tests against the server'
|
2010-01-06 00:36:58 +00:00
|
|
|
task :test do
|
|
|
|
|
sh %(java -jar lib/jstestdriver/JsTestDriver.jar --tests all)
|
|
|
|
|
end
|
2010-10-16 04:38:41 +00:00
|
|
|
|
2010-01-06 00:36:58 +00:00
|
|
|
end
|
|
|
|
|
|
2010-10-16 04:38:41 +00:00
|
|
|
|
|
|
|
|
desc 'Run JavaScript tests'
|
2010-01-06 00:36:58 +00:00
|
|
|
task :test do
|
|
|
|
|
sh %(java -jar lib/jstestdriver/JsTestDriver.jar --tests all --browser open --port 9876)
|
|
|
|
|
end
|
|
|
|
|
|
2010-10-16 04:38:41 +00:00
|
|
|
|
2010-01-06 00:36:58 +00:00
|
|
|
desc 'Lint'
|
|
|
|
|
task :lint do
|
|
|
|
|
out = %x(lib/jsl/jsl -conf lib/jsl/jsl.default.conf)
|
|
|
|
|
print out
|
|
|
|
|
end
|
2010-08-14 18:03:36 +00:00
|
|
|
|
2010-10-16 04:38:41 +00:00
|
|
|
|
2010-09-22 11:24:40 +00:00
|
|
|
desc 'push_angularjs'
|
2010-10-16 04:38:41 +00:00
|
|
|
task :push_angularjs => :compile do
|
2010-08-14 18:03:36 +00:00
|
|
|
sh %(cat angularjs.ftp | ftp -N angularjs.netrc angularjs.org)
|
|
|
|
|
end
|
2010-10-16 04:38:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###################
|
|
|
|
|
# utility methods #
|
|
|
|
|
###################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
|
# generates css snippet from a given files and optionally applies simple minification rules
|
|
|
|
|
#
|
|
|
|
|
def gen_css(cssFile, minify = false)
|
|
|
|
|
css = ''
|
|
|
|
|
File.open(cssFile, 'r') do |f|
|
|
|
|
|
css = f.read
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if minify
|
|
|
|
|
css.gsub! /\n/, ''
|
|
|
|
|
css.gsub! /\/\*.*?\*\//, ''
|
|
|
|
|
css.gsub! /:\s+/, ':'
|
|
|
|
|
css.gsub! /\s*\{\s*/, '{'
|
|
|
|
|
css.gsub! /\s*\}\s*/, '}'
|
|
|
|
|
css.gsub! /\s*\,\s*/, ','
|
|
|
|
|
css.gsub! /\s*\;\s*/, ';'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#escape for js
|
2010-10-19 22:34:58 +00:00
|
|
|
css.gsub! /\\/, "\\\\\\"
|
|
|
|
|
css.gsub! /'/, "\\\\'"
|
2010-10-16 04:38:41 +00:00
|
|
|
css.gsub! /\n/, "\\n"
|
|
|
|
|
|
|
|
|
|
return %Q{document.write('<style type="text/css">#{css}</style>');}
|
2010-10-20 04:19:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
|
# returns path to the file in the build directory
|
|
|
|
|
#
|
|
|
|
|
def path_to(filename)
|
2010-10-27 22:31:10 +00:00
|
|
|
return File.join(BUILD_DIR, *filename)
|
2010-10-20 04:19:28 +00:00
|
|
|
end
|