sproutit-sproutcore 1.0.0.20090407205609
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Buildfile +115 -0
- data/History.txt +7 -0
- data/README.txt +102 -0
- data/Rakefile +54 -0
- data/Todo.txt +1 -0
- data/bin/sc-build +13 -0
- data/bin/sc-build-number +13 -0
- data/bin/sc-gen +13 -0
- data/bin/sc-init +13 -0
- data/bin/sc-manifest +13 -0
- data/bin/sc-server +13 -0
- data/bin/sproutcore +14 -0
- data/buildtasks/build.rake +73 -0
- data/buildtasks/entry.rake +59 -0
- data/buildtasks/manifest.rake +469 -0
- data/buildtasks/render.rake +21 -0
- data/buildtasks/target.rake +42 -0
- data/gen/Buildfile +16 -0
- data/gen/app/Buildfile +36 -0
- data/gen/app/README +1 -0
- data/gen/app/USAGE +13 -0
- data/gen/app/templates/apps/{target_name}/core.js +27 -0
- data/gen/app/templates/apps/{target_name}/english.lproj/loading.rhtml +9 -0
- data/gen/app/templates/apps/{target_name}/english.lproj/main_page.js +22 -0
- data/gen/app/templates/apps/{target_name}/english.lproj/strings.js +15 -0
- data/gen/app/templates/apps/{target_name}/main.js +30 -0
- data/gen/controller/Buildfile +18 -0
- data/gen/controller/README +1 -0
- data/gen/controller/USAGE +13 -0
- data/gen/controller/templates/controllers/{filename}.js +18 -0
- data/gen/controller/templates/tests/controllers/{filename}.js +15 -0
- data/gen/framework/Buildfile +36 -0
- data/gen/framework/README +1 -0
- data/gen/framework/USAGE +13 -0
- data/gen/framework/templates/frameworks/{target_name}/core.js +21 -0
- data/gen/framework/templates/frameworks/{target_name}/english.lproj/strings.js +15 -0
- data/gen/language/Buildfile +26 -0
- data/gen/language/README +1 -0
- data/gen/language/USAGE +13 -0
- data/gen/language/templates/{filename}/strings.js +14 -0
- data/gen/model/Buildfile +16 -0
- data/gen/model/README +1 -0
- data/gen/model/USAGE +15 -0
- data/gen/model/templates/fixtures/{filename}.js +35 -0
- data/gen/model/templates/models/{filename}.js +19 -0
- data/gen/model/templates/tests/models/{filename}.js +15 -0
- data/gen/project/Buildfile +45 -0
- data/gen/project/INIT +3 -0
- data/gen/project/README +1 -0
- data/gen/project/USAGE +2 -0
- data/gen/project/templates/{filename}/Buildfile +7 -0
- data/gen/project/templates/{filename}/README +7 -0
- data/gen/test/Buildfile +25 -0
- data/gen/test/README +1 -0
- data/gen/test/USAGE +12 -0
- data/gen/test/templates/tests/{filename}.js +15 -0
- data/gen/theme/Buildfile +36 -0
- data/gen/theme/README +1 -0
- data/gen/theme/USAGE +13 -0
- data/gen/theme/templates/themes/{target_name}/english.lproj/strings.js +15 -0
- data/gen/view/Buildfile +18 -0
- data/gen/view/README +1 -0
- data/gen/view/USAGE +13 -0
- data/gen/view/templates/tests/views/{filename}.js +15 -0
- data/gen/view/templates/views/{filename}.js +18 -0
- data/lib/sproutcore.rb +130 -0
- data/lib/sproutcore/builders/base.rb +79 -0
- data/lib/sproutcore/builders/combine.rb +37 -0
- data/lib/sproutcore/builders/html.rb +177 -0
- data/lib/sproutcore/builders/javascript.rb +55 -0
- data/lib/sproutcore/builders/minify.rb +67 -0
- data/lib/sproutcore/builders/sass.rb +55 -0
- data/lib/sproutcore/builders/strings.rb +44 -0
- data/lib/sproutcore/builders/stylesheet.rb +40 -0
- data/lib/sproutcore/builders/test.rb +58 -0
- data/lib/sproutcore/builders/test_index.rb +26 -0
- data/lib/sproutcore/buildfile.rb +483 -0
- data/lib/sproutcore/buildfile/build_task.rb +33 -0
- data/lib/sproutcore/buildfile/buildfile_dsl.rb +162 -0
- data/lib/sproutcore/buildfile/cloneable.rb +34 -0
- data/lib/sproutcore/buildfile/early_time.rb +29 -0
- data/lib/sproutcore/buildfile/invocation_chain.rb +64 -0
- data/lib/sproutcore/buildfile/namespace.rb +33 -0
- data/lib/sproutcore/buildfile/string_ext.rb +198 -0
- data/lib/sproutcore/buildfile/task.rb +304 -0
- data/lib/sproutcore/buildfile/task_arguments.rb +86 -0
- data/lib/sproutcore/buildfile/task_manager.rb +193 -0
- data/lib/sproutcore/deprecated/view_helper.rb +662 -0
- data/lib/sproutcore/helpers/capture_helper.rb +30 -0
- data/lib/sproutcore/helpers/cssmin.rb +202 -0
- data/lib/sproutcore/helpers/dom_id_helper.rb +21 -0
- data/lib/sproutcore/helpers/entry_sorter.rb +105 -0
- data/lib/sproutcore/helpers/packed_optimizer.rb +102 -0
- data/lib/sproutcore/helpers/static_helper.rb +268 -0
- data/lib/sproutcore/helpers/tag_helper.rb +117 -0
- data/lib/sproutcore/helpers/text_helper.rb +303 -0
- data/lib/sproutcore/models/generator.rb +493 -0
- data/lib/sproutcore/models/hash_struct.rb +109 -0
- data/lib/sproutcore/models/manifest.rb +342 -0
- data/lib/sproutcore/models/manifest_entry.rb +232 -0
- data/lib/sproutcore/models/project.rb +270 -0
- data/lib/sproutcore/models/target.rb +403 -0
- data/lib/sproutcore/rack/builder.rb +269 -0
- data/lib/sproutcore/rack/dev.rb +51 -0
- data/lib/sproutcore/rack/docs.rb +24 -0
- data/lib/sproutcore/rack/proxy.rb +92 -0
- data/lib/sproutcore/rack/service.rb +141 -0
- data/lib/sproutcore/rack/test_runner.rb +24 -0
- data/lib/sproutcore/render_engines/erubis.rb +55 -0
- data/lib/sproutcore/render_engines/haml.rb +39 -0
- data/lib/sproutcore/tools.rb +311 -0
- data/lib/sproutcore/tools/build.rb +80 -0
- data/lib/sproutcore/tools/build_number.rb +23 -0
- data/lib/sproutcore/tools/gen.rb +99 -0
- data/lib/sproutcore/tools/init.rb +40 -0
- data/lib/sproutcore/tools/manifest.rb +84 -0
- data/lib/sproutcore/tools/server.rb +45 -0
- data/spec/buildtasks/build/copy_spec.rb +60 -0
- data/spec/buildtasks/build/spec_helper.rb +36 -0
- data/spec/buildtasks/manifest/catalog_spec.rb +48 -0
- data/spec/buildtasks/manifest/hide_buildfiles_spec.rb +125 -0
- data/spec/buildtasks/manifest/localize_spec.rb +97 -0
- data/spec/buildtasks/manifest/prepare_build_tasks/combine_spec.rb +246 -0
- data/spec/buildtasks/manifest/prepare_build_tasks/css_spec.rb +87 -0
- data/spec/buildtasks/manifest/prepare_build_tasks/html_spec.rb +175 -0
- data/spec/buildtasks/manifest/prepare_build_tasks/javascript_spec.rb +65 -0
- data/spec/buildtasks/manifest/prepare_build_tasks/minify_spec.rb +70 -0
- data/spec/buildtasks/manifest/prepare_build_tasks/packed_spec.rb +152 -0
- data/spec/buildtasks/manifest/prepare_build_tasks/sass_spec.rb +98 -0
- data/spec/buildtasks/manifest/prepare_build_tasks/strings_spec.rb +64 -0
- data/spec/buildtasks/manifest/prepare_build_tasks/tests_spec.rb +163 -0
- data/spec/buildtasks/manifest/prepare_spec.rb +43 -0
- data/spec/buildtasks/manifest/spec_helper.rb +35 -0
- data/spec/buildtasks/target_spec.rb +214 -0
- data/spec/fixtures/builder_tests/Buildfile +15 -0
- data/spec/fixtures/builder_tests/apps/combine_test/a.js +1 -0
- data/spec/fixtures/builder_tests/apps/combine_test/b.js +1 -0
- data/spec/fixtures/builder_tests/apps/combine_test/c.js +1 -0
- data/spec/fixtures/builder_tests/apps/combine_test/english.lproj/a.css +1 -0
- data/spec/fixtures/builder_tests/apps/combine_test/english.lproj/b.css +1 -0
- data/spec/fixtures/builder_tests/apps/combine_test/english.lproj/c.css +1 -0
- data/spec/fixtures/builder_tests/apps/html_test/english.lproj/bar1_sample.rhtml +2 -0
- data/spec/fixtures/builder_tests/apps/html_test/english.lproj/erb_sample.html.erb +1 -0
- data/spec/fixtures/builder_tests/apps/html_test/english.lproj/icons/image.png +0 -0
- data/spec/fixtures/builder_tests/apps/html_test/english.lproj/image.jpg +0 -0
- data/spec/fixtures/builder_tests/apps/html_test/english.lproj/rhtml_sample.rhtml +1 -0
- data/spec/fixtures/builder_tests/apps/html_test/english.lproj/strings.js +4 -0
- data/spec/fixtures/builder_tests/apps/html_test/english.lproj/style.css +0 -0
- data/spec/fixtures/builder_tests/apps/html_test/french.lproj/french-icons/fr.png +0 -0
- data/spec/fixtures/builder_tests/apps/html_test/french.lproj/strings.js +4 -0
- data/spec/fixtures/builder_tests/apps/html_test/lib/layout_template.rhtml +1 -0
- data/spec/fixtures/builder_tests/apps/html_test/scripts.js +0 -0
- data/spec/fixtures/builder_tests/apps/javascript_test/sc_static.js +15 -0
- data/spec/fixtures/builder_tests/apps/javascript_test/sc_super.js +4 -0
- data/spec/fixtures/builder_tests/apps/javascript_test/strings.js +7 -0
- data/spec/fixtures/builder_tests/apps/sass_test/sample.sass +3 -0
- data/spec/fixtures/builder_tests/apps/strings_test/lproj/strings.js +8 -0
- data/spec/fixtures/builder_tests/apps/stylesheet_test/build_directives.css +9 -0
- data/spec/fixtures/builder_tests/apps/stylesheet_test/sc_static.css +12 -0
- data/spec/fixtures/builder_tests/apps/test_test/lib/alt_layout.rhtml +1 -0
- data/spec/fixtures/builder_tests/apps/test_test/lib/test_layout.rhtml +3 -0
- data/spec/fixtures/builder_tests/apps/test_test/tests/qunit_test.js +1 -0
- data/spec/fixtures/builder_tests/apps/test_test/tests/qunit_test2.js +1 -0
- data/spec/fixtures/builder_tests/apps/test_test/tests/rhtml_test.rhtml +4 -0
- data/spec/fixtures/builder_tests/frameworks/debug/core.js +0 -0
- data/spec/fixtures/builder_tests/frameworks/debug/english.lproj/dummy.css +0 -0
- data/spec/fixtures/builder_tests/frameworks/qunit/core.js +0 -0
- data/spec/fixtures/builder_tests/frameworks/qunit/english.lproj/dummy.css +0 -0
- data/spec/fixtures/builder_tests/frameworks/req_target_1/english.lproj/req_style_1.css +0 -0
- data/spec/fixtures/builder_tests/frameworks/req_target_1/english.lproj/strings.js +4 -0
- data/spec/fixtures/builder_tests/frameworks/req_target_1/english.lproj/test.rhtml +1 -0
- data/spec/fixtures/builder_tests/frameworks/req_target_1/req_js_1.js +0 -0
- data/spec/fixtures/builder_tests/frameworks/req_target_2/english.lproj/req_style_2.css +0 -0
- data/spec/fixtures/builder_tests/frameworks/req_target_2/english.lproj/test.rhtml +1 -0
- data/spec/fixtures/builder_tests/frameworks/req_target_2/javascript.js +1 -0
- data/spec/fixtures/builder_tests/frameworks/req_target_2/lib/alt_layout.rhtml +0 -0
- data/spec/fixtures/builder_tests/frameworks/req_target_2/req_js_2.js +0 -0
- data/spec/fixtures/builder_tests/themes/sample_theme/Buildfile +1 -0
- data/spec/fixtures/buildfiles/basic/Buildfile +16 -0
- data/spec/fixtures/buildfiles/basic/task_module.rake +6 -0
- data/spec/fixtures/buildfiles/installed/Buildfile +7 -0
- data/spec/fixtures/buildfiles/installed/Buildfile2 +5 -0
- data/spec/fixtures/buildfiles/project_test/Buildfile +4 -0
- data/spec/fixtures/buildfiles/project_test/not_project/Buildfile +2 -0
- data/spec/fixtures/buildfiles/project_test/not_project/child/PLACEHOLDER +0 -0
- data/spec/fixtures/entry_for_project/Buildfile +1 -0
- data/spec/fixtures/entry_for_project/apps/test_app/entry.txt +0 -0
- data/spec/fixtures/entry_for_project/apps/test_app/frameworks/nested/PLACEHOLDER +0 -0
- data/spec/fixtures/entry_for_project/frameworks/shared/PLACEHOLDER +0 -0
- data/spec/fixtures/find_targets/custom/Buildfile +8 -0
- data/spec/fixtures/find_targets/custom/bars/bar1/bars/bar1/PLACEHOLDER +0 -0
- data/spec/fixtures/find_targets/custom/bars/bar1/bars/bar2/PLACEHOLDER +0 -0
- data/spec/fixtures/find_targets/custom/bars/bar1/foos/foo1/PLACEHOLDER +0 -0
- data/spec/fixtures/find_targets/custom/bars/bar1/foos/foo2/PLACEHOLDER +0 -0
- data/spec/fixtures/find_targets/custom/foos/custom_foos/Buildfile +5 -0
- data/spec/fixtures/find_targets/custom/foos/custom_foos/custom_foodir/foo1/PLACEHOLDER +0 -0
- data/spec/fixtures/find_targets/custom/foos/custom_foos/custom_foodir/foo2/PLACEHOLDER +0 -0
- data/spec/fixtures/find_targets/custom/foos/custom_foos/foos/not_foo1/PLACEHOLDER +0 -0
- data/spec/fixtures/find_targets/custom/foos/foo1/bars/bar1/PLACEHOLDER +0 -0
- data/spec/fixtures/find_targets/custom/foos/foo1/bars/bar2/PLACEHOLDER +0 -0
- data/spec/fixtures/find_targets/nested/Buildfile +8 -0
- data/spec/fixtures/find_targets/nested/apps/app1/Buildfile +1 -0
- data/spec/fixtures/find_targets/nested/apps/app1/apps/nested_app/PLACEHOLDER +0 -0
- data/spec/fixtures/find_targets/standard/Apps/app1/frameworks/framework1/PLACEHOLDER +0 -0
- data/spec/fixtures/find_targets/standard/Apps/app1/frameworks/framework2/PLACEHOLDER +0 -0
- data/spec/fixtures/find_targets/standard/clients/client1/PLACEHOLDER +0 -0
- data/spec/fixtures/find_targets/standard/frameworks/framework1/frameworks/framework1/PLACEHOLDER +0 -0
- data/spec/fixtures/find_targets/standard/frameworks/framework2/PLACEHOLDER +0 -0
- data/spec/fixtures/find_targets/standard/themes/theme1/PLACEHOLDER +0 -0
- data/spec/fixtures/find_targets/standard/themes/theme2/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/caps_long_names/English.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/caps_long_names/FreNCH.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/caps_long_names/UnknOWN.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/long_names/english.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/long_names/french.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/long_names/german.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/long_names/italian.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/long_names/japanese.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/long_names/spanish.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/long_names/unknown.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/no_names/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/short_names/de.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/short_names/en-CA.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/short_names/en-GB.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/short_names/en-US.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/short_names/en.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/short_names/es.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/short_names/foo.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/short_names/fr.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/short_names/it.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/languages/apps/short_names/ja.lproj/PLACEHOLDER +0 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/1.js +1 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/B.js +1 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/a.js +1 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/a/a.js +1 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/a/b.js +1 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/b/a.js +1 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/c.js +1 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/core.js +1 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/english.lproj/B.css +0 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/english.lproj/a.css +0 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/english.lproj/a/a.css +0 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/english.lproj/a/b.css +0 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/english.lproj/b/a.css +0 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/english.lproj/c.css +0 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/lproj/strings.js +1 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/utils.js +1 -0
- data/spec/fixtures/ordered_entries/apps/with_requires/a.js +2 -0
- data/spec/fixtures/ordered_entries/apps/with_requires/b.js +3 -0
- data/spec/fixtures/ordered_entries/apps/with_requires/c.js +2 -0
- data/spec/fixtures/ordered_entries/apps/with_requires/english.lproj/a.css +2 -0
- data/spec/fixtures/ordered_entries/apps/with_requires/english.lproj/b.css +2 -0
- data/spec/fixtures/ordered_entries/apps/with_requires/english.lproj/c.css +2 -0
- data/spec/fixtures/ordered_entries/apps/with_requires/english.lproj/d.js +1 -0
- data/spec/fixtures/real_world/Buildfile +12 -0
- data/spec/fixtures/real_world/apps/account/README +1 -0
- data/spec/fixtures/real_world/apps/calendar/README +1 -0
- data/spec/fixtures/real_world/apps/contacts/README_BEFORE_EDITING +1 -0
- data/spec/fixtures/real_world/apps/files/README +1 -0
- data/spec/fixtures/real_world/apps/mail/README +1 -0
- data/spec/fixtures/real_world/apps/mobile_photos/README +1 -0
- data/spec/fixtures/real_world/apps/photos/README +1 -0
- data/spec/fixtures/real_world/apps/uploader/README +1 -0
- data/spec/fixtures/real_world/frameworks/core_files/PLACEHOLDER +0 -0
- data/spec/fixtures/real_world/frameworks/core_photos/PLACEHOLDER +0 -0
- data/spec/fixtures/real_world/frameworks/shared/PLACEHOLDER +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/Buildfile +26 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/README +1 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/apps/docs/PLACEHOLDER +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/apps/test_runner/PLACEHOLDER +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/core.js +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/debug/debug-resource.html +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/debug/sample_debug.js +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/demo2.js +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/debug/sample_debug-loc.js +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/demo.css +4 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/demo.html +1 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/demo2.sass +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/file_extension_test.haml +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/file_extension_test.html.erb +1 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/file_extension_test.rhtml +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/fixtures/sample_fixtures-loc.js +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/has_require.css +4 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/no_require.css +1 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/no_sc_resource.rhtml +1 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/protocols/sample-loc.js +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/sc_resource.css +6 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/sc_resource.rhtml +3 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/strings.js +1 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/tests/sample-loc.js +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/fixtures/sample-json-fixture.json +1 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/fixtures/sample_fixtures.js +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/application/PLACEHOLDER +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/costello/core.js +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/data_store/PLACEHOLDER +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/debug/PLACEHOLDER +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/desktop/PLACEHOLDER +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/empty_theme/PLACEHOLDER +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/foundation/PLACEHOLDER +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/mobile/PLACEHOLDER +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/qunit/PLACEHOLDER +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/uploader/PLACEHOLDER +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/french.lproj/french-resource.js +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/french.lproj/strings.js +1 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/german.lproj/german-resource.js +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/german.lproj/strings.js +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/has_require.js +4 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/lib/index.html +1 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/no_require.js +1 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/protocols/sample.js +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/sc_resource.js +6 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/tests/nested/sample1.js +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/tests/nested/sample2.js +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/tests/sample.js +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/tests/sample.rhtml +1 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/themes/standard_theme/README +0 -0
- data/spec/fixtures/real_world/frameworks/sproutcore/views/view.js +1 -0
- data/spec/fixtures/real_world/generators/sample_custom/Buildfile +0 -0
- data/spec/fixtures/real_world/generators/sample_custom/templates/{filename}.js +1 -0
- data/spec/fixtures/recursive_project/Buildfile +8 -0
- data/spec/fixtures/recursive_project/frameworks/sproutcore/frameworks/costello/PLACEHOLDER +0 -0
- data/spec/lib/builders/combine_spec.rb +67 -0
- data/spec/lib/builders/html_spec.rb +577 -0
- data/spec/lib/builders/javascript_spec.rb +81 -0
- data/spec/lib/builders/sass_spec.rb +43 -0
- data/spec/lib/builders/spec_helper.rb +30 -0
- data/spec/lib/builders/strings_spec.rb +52 -0
- data/spec/lib/builders/stylesheet_spec.rb +63 -0
- data/spec/lib/builders/test_index_spec.rb +44 -0
- data/spec/lib/builders/test_spec.rb +135 -0
- data/spec/lib/buildfile/config_for_spec.rb +81 -0
- data/spec/lib/buildfile/define_spec.rb +59 -0
- data/spec/lib/buildfile/dup_spec.rb +65 -0
- data/spec/lib/buildfile/invoke_spec.rb +130 -0
- data/spec/lib/buildfile/load_spec.rb +49 -0
- data/spec/lib/buildfile/task/dup_spec.rb +55 -0
- data/spec/lib/buildfile/task_defined_spec.rb +17 -0
- data/spec/lib/buildfile_commands/build_task_spec.rb +19 -0
- data/spec/lib/buildfile_commands/config_spec.rb +97 -0
- data/spec/lib/buildfile_commands/import_spec.rb +17 -0
- data/spec/lib/buildfile_commands/namespace_spec.rb +18 -0
- data/spec/lib/buildfile_commands/proxies_spec.rb +38 -0
- data/spec/lib/buildfile_commands/replace_task_spec.rb +29 -0
- data/spec/lib/buildfile_commands/task_spec.rb +36 -0
- data/spec/lib/helpers/packing_optimizer/optimize_spec.rb +26 -0
- data/spec/lib/models/hash_struct/deep_clone_spec.rb +27 -0
- data/spec/lib/models/hash_struct/has_options_spec.rb +32 -0
- data/spec/lib/models/hash_struct/hash_spec.rb +64 -0
- data/spec/lib/models/hash_struct/merge_spec.rb +26 -0
- data/spec/lib/models/hash_struct/method_missing.rb +41 -0
- data/spec/lib/models/manifest/add_entry_spec.rb +36 -0
- data/spec/lib/models/manifest/add_transform_spec.rb +90 -0
- data/spec/lib/models/manifest/build_spec.rb +78 -0
- data/spec/lib/models/manifest/entry_for_spec.rb +94 -0
- data/spec/lib/models/manifest/find_entry.rb +84 -0
- data/spec/lib/models/manifest/prepare_spec.rb +62 -0
- data/spec/lib/models/manifest_entry/cacheable_url_spec.rb +31 -0
- data/spec/lib/models/manifest_entry/prepare_spec.rb +54 -0
- data/spec/lib/models/project/add_target_spec.rb +44 -0
- data/spec/lib/models/project/buildfile_spec.rb +35 -0
- data/spec/lib/models/project/find_targets_for_spec.rb +77 -0
- data/spec/lib/models/project/load_nearest_project_spec.rb +23 -0
- data/spec/lib/models/project/target_for_spec.rb +33 -0
- data/spec/lib/models/project/targets_spec.rb +62 -0
- data/spec/lib/models/target/compute_build_number_spec.rb +125 -0
- data/spec/lib/models/target/config_spec.rb +30 -0
- data/spec/lib/models/target/expand_required_targets_spec.rb +48 -0
- data/spec/lib/models/target/installed_languages_spec.rb +47 -0
- data/spec/lib/models/target/lproj_for_spec.rb +38 -0
- data/spec/lib/models/target/manifest_for_spec.rb +42 -0
- data/spec/lib/models/target/parent_target_spec.rb +21 -0
- data/spec/lib/models/target/prepare_spec.rb +53 -0
- data/spec/lib/models/target/required_targets_spec.rb +119 -0
- data/spec/lib/models/target/target_for_spec.rb +56 -0
- data/spec/lib/tools/build_number_spec.rb +28 -0
- data/spec/lib/tools/gen_spec.rb +207 -0
- data/spec/lib/tools/tools_spec.rb +78 -0
- data/spec/spec_helper.rb +138 -0
- data/sproutcore.gemspec +47 -0
- data/vendor/github_gem_lint.rb +22 -0
- data/vendor/yui-compressor/yuicompressor-2.4.2.jar +0 -0
- metadata +1084 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
# ===========================================================================
|
2
|
+
# Project: Abbot - SproutCore Build Tools
|
3
|
+
# Copyright: ©2009 Apple, Inc.
|
4
|
+
# portions copyright @2006-2009 Sprout Systems, Inc.
|
5
|
+
# and contributors
|
6
|
+
# ===========================================================================
|
7
|
+
|
8
|
+
require 'json'
|
9
|
+
|
10
|
+
module SC
|
11
|
+
module Rack
|
12
|
+
|
13
|
+
# Hosts general dev environment-related JSON assets.
|
14
|
+
class Dev
|
15
|
+
|
16
|
+
def initialize(project)
|
17
|
+
@project = project
|
18
|
+
end
|
19
|
+
|
20
|
+
def call(env)
|
21
|
+
url = env['PATH_INFO']
|
22
|
+
case url
|
23
|
+
when '/sc/targets.json' # returns description of targets
|
24
|
+
return [200, {}, get_targets_json]
|
25
|
+
else
|
26
|
+
return [404, {}, "not found"]
|
27
|
+
end
|
28
|
+
|
29
|
+
return [404, {}, "not found"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_targets_json
|
33
|
+
targets = @project.targets.values.map do |target|
|
34
|
+
target.prepare!
|
35
|
+
parent = target.parent_target
|
36
|
+
parent = parent.kind_of?(SC::Target) ? parent.target_name : ''
|
37
|
+
{
|
38
|
+
"name" => target.target_name,
|
39
|
+
"kind" => target.target_type,
|
40
|
+
"parent" => parent,
|
41
|
+
"link_tests" => [target.url_root, 'en', target.build_number, 'tests', '-index.json'].join('/'),
|
42
|
+
"link_docs" => [target.url_root, 'en', target.build_number, 'docs', '-index.json'].join('/'),
|
43
|
+
"link_root" => target.url_root
|
44
|
+
}
|
45
|
+
end
|
46
|
+
targets.to_json
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# ===========================================================================
|
2
|
+
# Project: Abbot - SproutCore Build Tools
|
3
|
+
# Copyright: ©2009 Apple, Inc.
|
4
|
+
# portions copyright @2006-2009 Sprout Systems, Inc.
|
5
|
+
# and contributors
|
6
|
+
# ===========================================================================
|
7
|
+
|
8
|
+
module SC
|
9
|
+
module Rack
|
10
|
+
|
11
|
+
# Rewrites relevant requests to load the SproutCore docs tools for a
|
12
|
+
# given project.
|
13
|
+
class Docs
|
14
|
+
|
15
|
+
def initialize(project)
|
16
|
+
@project = project
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(env)
|
20
|
+
return [404, {}, "not found"]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# ===========================================================================
|
2
|
+
# Project: Abbot - SproutCore Build Tools
|
3
|
+
# Copyright: ©2009 Apple, Inc.
|
4
|
+
# portions copyright @2006-2009 Sprout Systems, Inc.
|
5
|
+
# and contributors
|
6
|
+
# ===========================================================================
|
7
|
+
|
8
|
+
require 'net/http'
|
9
|
+
module SC
|
10
|
+
module Rack
|
11
|
+
|
12
|
+
# Rack application proxies requests as needed for the given project.
|
13
|
+
class Proxy
|
14
|
+
|
15
|
+
def initialize(project)
|
16
|
+
@project = project
|
17
|
+
@proxies = project.buildfile.proxies
|
18
|
+
end
|
19
|
+
|
20
|
+
def call(env)
|
21
|
+
url = env['PATH_INFO']
|
22
|
+
|
23
|
+
@proxies.each do |proxy, value|
|
24
|
+
if url.match(proxy.to_s)
|
25
|
+
return handle_proxy(value, proxy.to_s, env)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
return [404, {}, "not found"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def handle_proxy(proxy, proxy_url, env)
|
33
|
+
origin_host = env['SERVER_NAME'] # capture the origin host for cookies
|
34
|
+
http_method = env['REQUEST_METHOD'].to_s.downcase
|
35
|
+
url = env['PATH_INFO']
|
36
|
+
params = env['QUERY_STRING']
|
37
|
+
|
38
|
+
# collect headers...
|
39
|
+
headers = {}
|
40
|
+
env.each do |key, value|
|
41
|
+
next unless key =~ /^HTTP_/
|
42
|
+
key = key.gsub(/^HTTP_/,'')
|
43
|
+
headers[key] = value
|
44
|
+
end
|
45
|
+
|
46
|
+
http_host, http_port = proxy[:to].split(':')
|
47
|
+
http_port = '80' if http_port.nil?
|
48
|
+
|
49
|
+
if proxy[:url]
|
50
|
+
url = url.sub(/^#{Regexp.escape proxy_url}/, proxy[:url])
|
51
|
+
end
|
52
|
+
|
53
|
+
http_path = [url]
|
54
|
+
http_path << params if params && params.size>0
|
55
|
+
http_path = http_path.join('?')
|
56
|
+
|
57
|
+
response = nil
|
58
|
+
no_body_method = %w(delete get copy head move options trace)
|
59
|
+
::Net::HTTP.start(http_host, http_port) do |http|
|
60
|
+
if no_body_method.include?(http_method)
|
61
|
+
response = http.send(http_method, http_path, headers)
|
62
|
+
else
|
63
|
+
http_body = env['rack.input'].gets || ''
|
64
|
+
response = http.send(http_method, http_path, http_body, headers)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
status = response.code # http status code
|
69
|
+
|
70
|
+
SC.logger << "~ PROXY: #{http_method.upcase} #{status} #{url} -> http://#{http_host}:#{http_port}#{http_path}\n"
|
71
|
+
|
72
|
+
# display and construct specific response headers
|
73
|
+
response_headers = {}
|
74
|
+
ignore_headers = ['transfer-encoding', 'keep-alive', 'connection']
|
75
|
+
response.each do |key, value|
|
76
|
+
next if ignore_headers.include?(key.downcase)
|
77
|
+
# If this is a cookie, strip out the domain. This technically may
|
78
|
+
# break certain scenarios where services try to set cross-domain
|
79
|
+
# cookies, but those services should not be doing that anyway...
|
80
|
+
value.gsub!(/domain=[^\;]+\;? ?/,'') if key.downcase == 'set-cookie'
|
81
|
+
# Location headers should rewrite the hostname if it is included.
|
82
|
+
value.gsub!(/^http:\/\/#{http_host}(:[0-9]+)?\//, "http://#{request.host}/") if key.downcase == 'location'
|
83
|
+
|
84
|
+
SC.logger << " #{key}: #{value}\n"
|
85
|
+
response_headers[key] = value
|
86
|
+
end
|
87
|
+
|
88
|
+
return [status, ::Rack::Utils::HeaderHash.new(response_headers), [response.body]]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# ===========================================================================
|
2
|
+
# Project: Abbot - SproutCore Build Tools
|
3
|
+
# Copyright: ©2009 Apple, Inc.
|
4
|
+
# portions copyright @2006-2009 Sprout Systems, Inc.
|
5
|
+
# and contributors
|
6
|
+
# ===========================================================================
|
7
|
+
|
8
|
+
module SC
|
9
|
+
module Rack
|
10
|
+
|
11
|
+
# Configures a standard set of Rack adaptors for serving SproutCore apps.
|
12
|
+
# Based on your config settings, this will configure appropriate
|
13
|
+
# middlewear apps for each incoming project. Requests are then cascaded
|
14
|
+
# through the projects to find one that can service the request.
|
15
|
+
#
|
16
|
+
class Service
|
17
|
+
|
18
|
+
# Convenience method to start the rack service as a server. You must
|
19
|
+
# pass at least a :project => foo, or :projects => [foo, bar] option
|
20
|
+
# to this method, but you may also pass a number of other config optios
|
21
|
+
# including:
|
22
|
+
#
|
23
|
+
# === Options
|
24
|
+
# :host:: the hostname to listen on (default 0.0.0.0)
|
25
|
+
# :port:: the portname to listen on (default 4020)
|
26
|
+
# :daemonize:: if true, service will be run as daemon
|
27
|
+
# :pid:: if daemonizing, this is the path of the file to write pid to
|
28
|
+
#
|
29
|
+
def self.start(opts = {})
|
30
|
+
|
31
|
+
# load rack
|
32
|
+
begin
|
33
|
+
require 'rack'
|
34
|
+
rescue LoadError => e
|
35
|
+
gem 'rack'
|
36
|
+
require 'rack'
|
37
|
+
end
|
38
|
+
|
39
|
+
# Guess.
|
40
|
+
if ENV.include?("PHP_FCGI_CHILDREN")
|
41
|
+
server = ::Rack::Handler::FastCGI
|
42
|
+
|
43
|
+
# We already speak FastCGI
|
44
|
+
options.delete :File
|
45
|
+
options.delete :Port
|
46
|
+
elsif ENV.include?("REQUEST_METHOD")
|
47
|
+
server = ::Rack::Handler::CGI
|
48
|
+
else
|
49
|
+
begin
|
50
|
+
server = ::Rack::Handler::Mongrel
|
51
|
+
rescue LoadError => e
|
52
|
+
server = ::Rack::Handler::WEBrick
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
projects = opts.delete(:projects) || [opts.delete(:project)].compact
|
57
|
+
app = self.new(*projects)
|
58
|
+
|
59
|
+
opts[:Host] ||= opts[:host] # allow either case.
|
60
|
+
opts[:Port] ||= opts[:port] || '4020'
|
61
|
+
|
62
|
+
# If daemonize is set, do it...
|
63
|
+
if opts[:daemonize]
|
64
|
+
SC.logger.info "Daemonizing..."
|
65
|
+
pid = opts[:pid]
|
66
|
+
|
67
|
+
if RUBY_VERSION < "1.9"
|
68
|
+
return if fork
|
69
|
+
Process.setsid
|
70
|
+
return if fork
|
71
|
+
Dir.chdir "/"
|
72
|
+
File.umask 0000
|
73
|
+
STDIN.reopen "/dev/null"
|
74
|
+
STDOUT.reopen "/dev/null", "a"
|
75
|
+
STDERR.reopen "/dev/null", "a"
|
76
|
+
else
|
77
|
+
Process.daemon
|
78
|
+
end
|
79
|
+
|
80
|
+
if pid
|
81
|
+
File.open(pid, 'w'){ |f| f.write("#{Process.pid}") }
|
82
|
+
at_exit { File.delete(pid) if File.exist?(pid) }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
SC.logger << "Starting server at http://#{opts[:Host] || '0.0.0.0'}:#{opts[:Port]} in #{SC.build_mode} mode\n"
|
87
|
+
server.run app, opts
|
88
|
+
end
|
89
|
+
|
90
|
+
def initialize(*projects)
|
91
|
+
@projects = projects.flatten
|
92
|
+
|
93
|
+
# Get apps for each project & cascade if needed
|
94
|
+
@apps = @projects.map { |project| middleware_for(project) }
|
95
|
+
@app = @apps.size == 1 ? @apps.first : ::Rack::Cascade.new(@apps)
|
96
|
+
|
97
|
+
# Now put it behind some useful general optimizers...
|
98
|
+
@app = ::Rack::Recursive.new(@app)
|
99
|
+
@app = ::Rack::ConditionalGet.new(@app)
|
100
|
+
#@app = ::Rack::Deflater.new(@app)
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
def call(env); @app.call(env); end
|
105
|
+
|
106
|
+
# Construct new middleware for the named project
|
107
|
+
def middleware_for(project)
|
108
|
+
apps = []
|
109
|
+
|
110
|
+
# setup some conditional items...
|
111
|
+
config = project.config
|
112
|
+
#if config.serve_test_runner || config.serve_docs
|
113
|
+
apps << SC::Rack::Dev.new(project)
|
114
|
+
#end
|
115
|
+
if project.buildfile.proxies.size > 0
|
116
|
+
apps << SC::Rack::Proxy.new(project)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Add builder for the project itself
|
120
|
+
apps << SC::Rack::Builder.new(project)
|
121
|
+
|
122
|
+
# serve files out of the public directory if serve_public is
|
123
|
+
# configures && the public directory exists
|
124
|
+
if config.serve_public
|
125
|
+
pubdir = File.join(project.project_root, 'public')
|
126
|
+
apps << ::Rack::File.new(pubdir) if File.directory?(pubdir)
|
127
|
+
end
|
128
|
+
|
129
|
+
# Wrap'em in a cascade if needed. This will return the first
|
130
|
+
# app that does not return nil
|
131
|
+
app = apps.size == 1 ? apps.first : ::Rack::Cascade.new(apps)
|
132
|
+
|
133
|
+
# Add show exceptions handler if enabled
|
134
|
+
app = ::Rack::ShowExceptions.new(app) if config.serve_exceptions
|
135
|
+
|
136
|
+
return app # done!
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# ===========================================================================
|
2
|
+
# Project: Abbot - SproutCore Build Tools
|
3
|
+
# Copyright: ©2009 Apple, Inc.
|
4
|
+
# portions copyright @2006-2009 Sprout Systems, Inc.
|
5
|
+
# and contributors
|
6
|
+
# ===========================================================================
|
7
|
+
|
8
|
+
module SC
|
9
|
+
module Rack
|
10
|
+
|
11
|
+
# Rewrites relevant requests to load the SproutCore test runner for a
|
12
|
+
# given project.
|
13
|
+
class TestRunner
|
14
|
+
|
15
|
+
def initialize(project)
|
16
|
+
@project = project
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(env)
|
20
|
+
return [404, {}, "not found"]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# ===========================================================================
|
2
|
+
# Project: Abbot - SproutCore Build Tools
|
3
|
+
# Copyright: ©2009 Apple, Inc.
|
4
|
+
# portions copyright @2006-2009 Sprout Systems, Inc.
|
5
|
+
# and contributors
|
6
|
+
# ===========================================================================
|
7
|
+
|
8
|
+
module SC
|
9
|
+
module RenderEngine
|
10
|
+
|
11
|
+
class Erubis
|
12
|
+
def initialize(html_context)
|
13
|
+
@html_context = html_context
|
14
|
+
end
|
15
|
+
|
16
|
+
def compile(input)
|
17
|
+
begin
|
18
|
+
require 'erubis'
|
19
|
+
rescue
|
20
|
+
raise "Cannot render ERB file because erubis is not installed. Try running 'sudo gem install erubis' and try again"
|
21
|
+
end
|
22
|
+
|
23
|
+
::Erubis::Eruby.new.convert(input)
|
24
|
+
end
|
25
|
+
|
26
|
+
def concat(string, binding)
|
27
|
+
eval('_buf', binding) << string
|
28
|
+
end
|
29
|
+
|
30
|
+
def capture(*args, &block)
|
31
|
+
begin
|
32
|
+
buffer = eval('_buf', block.binding)
|
33
|
+
rescue
|
34
|
+
buffer = nil
|
35
|
+
end
|
36
|
+
|
37
|
+
if buffer.nil?
|
38
|
+
block.call(*args).to_s
|
39
|
+
else
|
40
|
+
pos = buffer.length
|
41
|
+
block.call(*args)
|
42
|
+
|
43
|
+
# get emitted data
|
44
|
+
data = buffer[pos..-1]
|
45
|
+
|
46
|
+
# remove from buffer
|
47
|
+
buffer[pos..-1] = ''
|
48
|
+
|
49
|
+
data
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# ===========================================================================
|
2
|
+
# Project: Abbot - SproutCore Build Tools
|
3
|
+
# Copyright: ©2009 Apple, Inc.
|
4
|
+
# portions copyright @2006-2009 Sprout Systems, Inc.
|
5
|
+
# and contributors
|
6
|
+
# ===========================================================================
|
7
|
+
|
8
|
+
module SC
|
9
|
+
module RenderEngine
|
10
|
+
|
11
|
+
class Haml
|
12
|
+
def initialize(html_context)
|
13
|
+
@html_context = html_context
|
14
|
+
end
|
15
|
+
|
16
|
+
def compile(input)
|
17
|
+
begin
|
18
|
+
require 'haml'
|
19
|
+
rescue
|
20
|
+
raise "Cannot render HAML file because haml is not installed. Try running 'sudo gem install haml' and try again"
|
21
|
+
end
|
22
|
+
::Haml::Engine.new(input).send(:precompiled_with_ambles, [])
|
23
|
+
end
|
24
|
+
|
25
|
+
def concat(string, binding)
|
26
|
+
eval("_hamlout", binding).push_text string
|
27
|
+
end
|
28
|
+
|
29
|
+
def capture(*args, &block)
|
30
|
+
if @html_context.respond_to?(:is_haml?) && @html_context.is_haml?
|
31
|
+
@html_context.capture_haml(nil, &block)
|
32
|
+
else
|
33
|
+
block.call(*args).to_s
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,311 @@
|
|
1
|
+
# ===========================================================================
|
2
|
+
# Project: Abbot - SproutCore Build Tools
|
3
|
+
# Copyright: ©2009 Apple, Inc.
|
4
|
+
# portions copyright @2006-2009 Sprout Systems, Inc.
|
5
|
+
# and contributors
|
6
|
+
# ===========================================================================
|
7
|
+
|
8
|
+
require File.expand_path(File.join(SC::LIBPATH, 'thor', 'lib', 'thor'))
|
9
|
+
|
10
|
+
module SC
|
11
|
+
|
12
|
+
# The tools module contain the classes that make up the command line tools
|
13
|
+
# available from SproutCore. In general, each command line tool has a peer
|
14
|
+
# class hosted in this module that implements the primary user interface.
|
15
|
+
#
|
16
|
+
# Internally SproutCore tools that chain together subtools (such as
|
17
|
+
# sc-build) will actually call these classes directly instead of taking the
|
18
|
+
# time to instantiate a whole new process.
|
19
|
+
#
|
20
|
+
# Each Tool class is implemented as a Thor subclass. You can override
|
21
|
+
# methods in these classes in your own ruby code if you want to make a
|
22
|
+
# change to how these tools execute. Any ruby you place in your Buildfile
|
23
|
+
# to modify one of these classes will actually be picked up by the
|
24
|
+
# tool itself when it runs.
|
25
|
+
#
|
26
|
+
class Tools < ::Thor
|
27
|
+
|
28
|
+
################################################
|
29
|
+
## EXCEPTIONS
|
30
|
+
##
|
31
|
+
|
32
|
+
# Raise this type of exception when a fatal error occurs because the
|
33
|
+
# user did not pass the correct options. This will be caught and
|
34
|
+
# displayed at the top level before exiting. Note that if you raise
|
35
|
+
# an exception of some other type, then a backtrace may be displayed as
|
36
|
+
# well (Which is not preferred)
|
37
|
+
class FatalException < Exception
|
38
|
+
end
|
39
|
+
|
40
|
+
# Helper method. Call this when an acception occurs that is fatal due to
|
41
|
+
# a problem with the user.
|
42
|
+
def fatal!(description)
|
43
|
+
raise FatalException, description
|
44
|
+
end
|
45
|
+
|
46
|
+
# Helper method. Call this when you want to log an info message. Logs to
|
47
|
+
# the standard logger.
|
48
|
+
def info(description)
|
49
|
+
SC.logger.info(description)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Helper method. Call this when you want to log a debug message.
|
53
|
+
def debug(description)
|
54
|
+
SC.logger.debug(description)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Log this when you need to issue a warning.
|
58
|
+
def warn(description)
|
59
|
+
SC.logger.warn(description)
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
################################################
|
64
|
+
## GLOBAL OPTIONS
|
65
|
+
##
|
66
|
+
|
67
|
+
# All sproutcore tools can take some standard options. These are
|
68
|
+
# processed automatically when the tool is loaded
|
69
|
+
method_options({ '--project' => :optional,
|
70
|
+
'--library' => :optional, # deprecated
|
71
|
+
'--mode' => :optional,
|
72
|
+
'--environment' => :optional, # deprecated
|
73
|
+
'--logfile' => :optional,
|
74
|
+
'--build' => :optional,
|
75
|
+
['--verbose', '-v'] => false,
|
76
|
+
['--very-verbose', '-V'] => false })
|
77
|
+
def initialize(options, *args)
|
78
|
+
super
|
79
|
+
end
|
80
|
+
|
81
|
+
# This is the core entry method used to run every tool. Extend this
|
82
|
+
# method with any standard preprocessing you want all tools to do before
|
83
|
+
# they do their specific thing.
|
84
|
+
def invoke(*args)
|
85
|
+
prepare_logger!
|
86
|
+
prepare_mode!
|
87
|
+
prepare_build_numbers!
|
88
|
+
super
|
89
|
+
end
|
90
|
+
|
91
|
+
# Make the options hash a HashStruct so that we can access each variable
|
92
|
+
# as a method
|
93
|
+
def options; @tool_options ||= HashStruct.new(super); end
|
94
|
+
|
95
|
+
# Configure the expected log level and log target. Handles the --verbose,
|
96
|
+
# --very-verbose and --logfile options
|
97
|
+
def prepare_logger!
|
98
|
+
SC.env.log_level = options['very-verbose'] ? :debug : (options.verbose ? :info : :warn)
|
99
|
+
SC.env.logfile = File.expand_path(options.logfile) if options.logfile
|
100
|
+
end
|
101
|
+
|
102
|
+
# Configure the current build mode. Handles the --mode and --environment
|
103
|
+
# options. (--environment is provided for backwards compatibility)
|
104
|
+
def prepare_mode!(preferred_mode = 'production')
|
105
|
+
build_mode = (options.mode || options.environment || preferred_mode).to_s.downcase.to_sym
|
106
|
+
SC.build_mode = build_mode
|
107
|
+
end
|
108
|
+
|
109
|
+
# Configure the current build numbers. Handles the --build option.
|
110
|
+
def prepare_build_numbers!
|
111
|
+
return if (numbers = options.build).nil?
|
112
|
+
numbers = numbers.split(',').map { |n| n.split(':') }
|
113
|
+
if numbers.size==1 && numbers.first.size==1
|
114
|
+
SC.env.build_number = numbers.first.first
|
115
|
+
else
|
116
|
+
hash = {}
|
117
|
+
numbers.each do |pair|
|
118
|
+
key = pair[0]
|
119
|
+
key = "/#{key}" if !(key =~ /^\//)
|
120
|
+
hash[key.to_sym] = pair[1]
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
################################################
|
126
|
+
## HELPER METHODS
|
127
|
+
##
|
128
|
+
|
129
|
+
# Set the current project. This is used mostly for unit testing.
|
130
|
+
def project=(a_project)
|
131
|
+
@project = a_project
|
132
|
+
end
|
133
|
+
|
134
|
+
# The current project. This is discovered based on the passed --project
|
135
|
+
# option or based on the current working directory. If no project can be
|
136
|
+
# found, this method will always return null.
|
137
|
+
def project
|
138
|
+
return @project if @discovered_project # cache - @project may be nil
|
139
|
+
@discovered_project = true
|
140
|
+
|
141
|
+
ret = nil
|
142
|
+
project_path = options.project || options.library
|
143
|
+
|
144
|
+
# if no project_path is named explicitly, attempt to autodiscover from
|
145
|
+
# working dir. If none is found, just set project to nil
|
146
|
+
if project_path.nil?
|
147
|
+
debug "No project path specified. Searching for projects in #{Dir.pwd}"
|
148
|
+
ret = SC::Project.load_nearest_project Dir.pwd, :parent => SC.builtin_project
|
149
|
+
|
150
|
+
# if project path is specified, look there. If no project is found
|
151
|
+
# die with a fatal exception.
|
152
|
+
else
|
153
|
+
debug "Project path specified at #{project_path}"
|
154
|
+
ret = SC::Project.load File.expand_path(project_path), :parent => SC.builtin_project
|
155
|
+
if ret.nil?
|
156
|
+
fatal! "Could not load project at #{project_path}"
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
info "Loaded project at: #{ret.project_root}" unless ret.nil?
|
161
|
+
@project = ret
|
162
|
+
end
|
163
|
+
|
164
|
+
# Attempts to discover the current project. If no project can be found
|
165
|
+
# throws a fatal exception. Use this method at the top of your tool
|
166
|
+
# method if you require a project to run.
|
167
|
+
def requires_project!
|
168
|
+
ret = project
|
169
|
+
if ret.nil?
|
170
|
+
fatal!("You do not appear to be inside of a project. Try changing to your project directory or make sure your project as a Buildfile or sc-config")
|
171
|
+
end
|
172
|
+
return ret
|
173
|
+
end
|
174
|
+
|
175
|
+
# Find one or more targets with the passed target names in the current
|
176
|
+
# project. Requires a project to function.
|
177
|
+
def find_targets(*targets)
|
178
|
+
|
179
|
+
debug "finding targets with names: '#{targets * "','"}'"
|
180
|
+
requires_project!
|
181
|
+
|
182
|
+
# If targets are specified, find the targets project or parents...
|
183
|
+
if targets.size > 0
|
184
|
+
targets = targets.map do |target_name|
|
185
|
+
ret = project.target_for(target_name)
|
186
|
+
if ret.nil?
|
187
|
+
fatal! "No target named #{target_name} could be found in project"
|
188
|
+
else
|
189
|
+
debug "Found target '#{target_name}' at PROJECT:#{ret.source_root.sub(/^#{project.project_root}\//,'')}"
|
190
|
+
end
|
191
|
+
ret
|
192
|
+
end
|
193
|
+
|
194
|
+
# IF no targets are specified, then just get all targets in project.
|
195
|
+
# If --all option was specified, include those that do not autobuild
|
196
|
+
else
|
197
|
+
targets = project.targets.values
|
198
|
+
unless options.all?
|
199
|
+
targets.reject! { |t| !t.config.autobuild? }
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
# If include required was specified, merge in all required bundles as
|
204
|
+
# well.
|
205
|
+
if options['include-required']
|
206
|
+
targets.each do |target|
|
207
|
+
targets += target.expand_required_targets :theme => true,
|
208
|
+
:debug => target.config.load_debug,
|
209
|
+
:tests => target.config.load_tests
|
210
|
+
end
|
211
|
+
|
212
|
+
targets = targets.flatten.uniq.compact
|
213
|
+
end
|
214
|
+
|
215
|
+
return targets
|
216
|
+
end
|
217
|
+
|
218
|
+
# Wraps around find_targets but raises an exception if no target is
|
219
|
+
# specified.
|
220
|
+
def requires_targets!(*target_names)
|
221
|
+
if target_names.size == 0
|
222
|
+
fatal! "You must specify a target with this command"
|
223
|
+
end
|
224
|
+
|
225
|
+
targets = find_targets(*target_names)
|
226
|
+
if targets.size == 0
|
227
|
+
fatal! "No targets matching #{target_names * ","} were found."
|
228
|
+
end
|
229
|
+
|
230
|
+
targets
|
231
|
+
end
|
232
|
+
|
233
|
+
# Requires exactly one target.
|
234
|
+
def requires_target!(*targets)
|
235
|
+
requires_targets!(*targets).first
|
236
|
+
end
|
237
|
+
|
238
|
+
# Discovers the languages requested by the user for a build. Uses the
|
239
|
+
# --languages command line option or disovers in targets.
|
240
|
+
def find_languages(*targets)
|
241
|
+
# Use passed languages. If none are specified, merge installed
|
242
|
+
# languages for all app targets.
|
243
|
+
if (languages = options.languages).nil?
|
244
|
+
languages = targets.map { |t| t.installed_languages }
|
245
|
+
else
|
246
|
+
languages = languages.split(':').map { |l| l.to_sym }
|
247
|
+
end
|
248
|
+
languages.flatten.uniq.compact
|
249
|
+
end
|
250
|
+
|
251
|
+
# Core method to process command line options and then build a manifest.
|
252
|
+
# Shared by sc-manifest and sc-build commands.
|
253
|
+
def build_manifests(*targets)
|
254
|
+
|
255
|
+
requires_project! # get project
|
256
|
+
targets = find_targets(*targets) # get targets
|
257
|
+
languages = find_languages(*targets) # get languages
|
258
|
+
|
259
|
+
# log output
|
260
|
+
SC.logger.info "Building targets: #{targets.map { |t| t.target_name } * ","}"
|
261
|
+
SC.logger.info "Building languages: #{ languages * "," }"
|
262
|
+
|
263
|
+
# Now fetch the manifests to build. One per target/language
|
264
|
+
manifests = targets.map do |target|
|
265
|
+
languages.map { |l| target.manifest_for :language => l }
|
266
|
+
end
|
267
|
+
manifests.flatten!
|
268
|
+
|
269
|
+
# Build'em
|
270
|
+
manifests.each do |manifest|
|
271
|
+
SC.logger.info "Building manifest for: #{manifest.target.target_name}:#{manifest.language}"
|
272
|
+
manifest.build!
|
273
|
+
end
|
274
|
+
|
275
|
+
return manifests
|
276
|
+
end
|
277
|
+
|
278
|
+
# Logs the contents of the passed file path to the logger
|
279
|
+
def log_file(path)
|
280
|
+
if !File.exists?(path)
|
281
|
+
warn "Could not display #{File.basename(path)} at #{File.dirname(path)} because it does not exist."
|
282
|
+
end
|
283
|
+
file_text = File.read(path)
|
284
|
+
SC.logger << file_text
|
285
|
+
SC.logger << "\n"
|
286
|
+
end
|
287
|
+
|
288
|
+
################################################
|
289
|
+
## MAIN ENTRYPOINT
|
290
|
+
##
|
291
|
+
|
292
|
+
# Fix start so that it treats command-name like command_name
|
293
|
+
def self.start(args = ARGV)
|
294
|
+
# manually check for verbose in case we don't get far enough in regular
|
295
|
+
# processing to actually set the verbose mode.
|
296
|
+
is_verbose = %w(-v -V --verbose --very-verbose).any? { |x| args.include?(x) }
|
297
|
+
begin
|
298
|
+
super(args)
|
299
|
+
rescue Exception => e
|
300
|
+
SC.logger.fatal(e)
|
301
|
+
if is_verbose && !e.kind_of?(FatalException)
|
302
|
+
SC.logger.fatal("BACKTRACE:\n#{e.backtrace.join("\n")}\n")
|
303
|
+
end
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
end
|
308
|
+
|
309
|
+
end
|
310
|
+
|
311
|
+
SC.require_all_libs_relative_to(__FILE__)
|