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.
Files changed (382) hide show
  1. data/Buildfile +115 -0
  2. data/History.txt +7 -0
  3. data/README.txt +102 -0
  4. data/Rakefile +54 -0
  5. data/Todo.txt +1 -0
  6. data/bin/sc-build +13 -0
  7. data/bin/sc-build-number +13 -0
  8. data/bin/sc-gen +13 -0
  9. data/bin/sc-init +13 -0
  10. data/bin/sc-manifest +13 -0
  11. data/bin/sc-server +13 -0
  12. data/bin/sproutcore +14 -0
  13. data/buildtasks/build.rake +73 -0
  14. data/buildtasks/entry.rake +59 -0
  15. data/buildtasks/manifest.rake +469 -0
  16. data/buildtasks/render.rake +21 -0
  17. data/buildtasks/target.rake +42 -0
  18. data/gen/Buildfile +16 -0
  19. data/gen/app/Buildfile +36 -0
  20. data/gen/app/README +1 -0
  21. data/gen/app/USAGE +13 -0
  22. data/gen/app/templates/apps/{target_name}/core.js +27 -0
  23. data/gen/app/templates/apps/{target_name}/english.lproj/loading.rhtml +9 -0
  24. data/gen/app/templates/apps/{target_name}/english.lproj/main_page.js +22 -0
  25. data/gen/app/templates/apps/{target_name}/english.lproj/strings.js +15 -0
  26. data/gen/app/templates/apps/{target_name}/main.js +30 -0
  27. data/gen/controller/Buildfile +18 -0
  28. data/gen/controller/README +1 -0
  29. data/gen/controller/USAGE +13 -0
  30. data/gen/controller/templates/controllers/{filename}.js +18 -0
  31. data/gen/controller/templates/tests/controllers/{filename}.js +15 -0
  32. data/gen/framework/Buildfile +36 -0
  33. data/gen/framework/README +1 -0
  34. data/gen/framework/USAGE +13 -0
  35. data/gen/framework/templates/frameworks/{target_name}/core.js +21 -0
  36. data/gen/framework/templates/frameworks/{target_name}/english.lproj/strings.js +15 -0
  37. data/gen/language/Buildfile +26 -0
  38. data/gen/language/README +1 -0
  39. data/gen/language/USAGE +13 -0
  40. data/gen/language/templates/{filename}/strings.js +14 -0
  41. data/gen/model/Buildfile +16 -0
  42. data/gen/model/README +1 -0
  43. data/gen/model/USAGE +15 -0
  44. data/gen/model/templates/fixtures/{filename}.js +35 -0
  45. data/gen/model/templates/models/{filename}.js +19 -0
  46. data/gen/model/templates/tests/models/{filename}.js +15 -0
  47. data/gen/project/Buildfile +45 -0
  48. data/gen/project/INIT +3 -0
  49. data/gen/project/README +1 -0
  50. data/gen/project/USAGE +2 -0
  51. data/gen/project/templates/{filename}/Buildfile +7 -0
  52. data/gen/project/templates/{filename}/README +7 -0
  53. data/gen/test/Buildfile +25 -0
  54. data/gen/test/README +1 -0
  55. data/gen/test/USAGE +12 -0
  56. data/gen/test/templates/tests/{filename}.js +15 -0
  57. data/gen/theme/Buildfile +36 -0
  58. data/gen/theme/README +1 -0
  59. data/gen/theme/USAGE +13 -0
  60. data/gen/theme/templates/themes/{target_name}/english.lproj/strings.js +15 -0
  61. data/gen/view/Buildfile +18 -0
  62. data/gen/view/README +1 -0
  63. data/gen/view/USAGE +13 -0
  64. data/gen/view/templates/tests/views/{filename}.js +15 -0
  65. data/gen/view/templates/views/{filename}.js +18 -0
  66. data/lib/sproutcore.rb +130 -0
  67. data/lib/sproutcore/builders/base.rb +79 -0
  68. data/lib/sproutcore/builders/combine.rb +37 -0
  69. data/lib/sproutcore/builders/html.rb +177 -0
  70. data/lib/sproutcore/builders/javascript.rb +55 -0
  71. data/lib/sproutcore/builders/minify.rb +67 -0
  72. data/lib/sproutcore/builders/sass.rb +55 -0
  73. data/lib/sproutcore/builders/strings.rb +44 -0
  74. data/lib/sproutcore/builders/stylesheet.rb +40 -0
  75. data/lib/sproutcore/builders/test.rb +58 -0
  76. data/lib/sproutcore/builders/test_index.rb +26 -0
  77. data/lib/sproutcore/buildfile.rb +483 -0
  78. data/lib/sproutcore/buildfile/build_task.rb +33 -0
  79. data/lib/sproutcore/buildfile/buildfile_dsl.rb +162 -0
  80. data/lib/sproutcore/buildfile/cloneable.rb +34 -0
  81. data/lib/sproutcore/buildfile/early_time.rb +29 -0
  82. data/lib/sproutcore/buildfile/invocation_chain.rb +64 -0
  83. data/lib/sproutcore/buildfile/namespace.rb +33 -0
  84. data/lib/sproutcore/buildfile/string_ext.rb +198 -0
  85. data/lib/sproutcore/buildfile/task.rb +304 -0
  86. data/lib/sproutcore/buildfile/task_arguments.rb +86 -0
  87. data/lib/sproutcore/buildfile/task_manager.rb +193 -0
  88. data/lib/sproutcore/deprecated/view_helper.rb +662 -0
  89. data/lib/sproutcore/helpers/capture_helper.rb +30 -0
  90. data/lib/sproutcore/helpers/cssmin.rb +202 -0
  91. data/lib/sproutcore/helpers/dom_id_helper.rb +21 -0
  92. data/lib/sproutcore/helpers/entry_sorter.rb +105 -0
  93. data/lib/sproutcore/helpers/packed_optimizer.rb +102 -0
  94. data/lib/sproutcore/helpers/static_helper.rb +268 -0
  95. data/lib/sproutcore/helpers/tag_helper.rb +117 -0
  96. data/lib/sproutcore/helpers/text_helper.rb +303 -0
  97. data/lib/sproutcore/models/generator.rb +493 -0
  98. data/lib/sproutcore/models/hash_struct.rb +109 -0
  99. data/lib/sproutcore/models/manifest.rb +342 -0
  100. data/lib/sproutcore/models/manifest_entry.rb +232 -0
  101. data/lib/sproutcore/models/project.rb +270 -0
  102. data/lib/sproutcore/models/target.rb +403 -0
  103. data/lib/sproutcore/rack/builder.rb +269 -0
  104. data/lib/sproutcore/rack/dev.rb +51 -0
  105. data/lib/sproutcore/rack/docs.rb +24 -0
  106. data/lib/sproutcore/rack/proxy.rb +92 -0
  107. data/lib/sproutcore/rack/service.rb +141 -0
  108. data/lib/sproutcore/rack/test_runner.rb +24 -0
  109. data/lib/sproutcore/render_engines/erubis.rb +55 -0
  110. data/lib/sproutcore/render_engines/haml.rb +39 -0
  111. data/lib/sproutcore/tools.rb +311 -0
  112. data/lib/sproutcore/tools/build.rb +80 -0
  113. data/lib/sproutcore/tools/build_number.rb +23 -0
  114. data/lib/sproutcore/tools/gen.rb +99 -0
  115. data/lib/sproutcore/tools/init.rb +40 -0
  116. data/lib/sproutcore/tools/manifest.rb +84 -0
  117. data/lib/sproutcore/tools/server.rb +45 -0
  118. data/spec/buildtasks/build/copy_spec.rb +60 -0
  119. data/spec/buildtasks/build/spec_helper.rb +36 -0
  120. data/spec/buildtasks/manifest/catalog_spec.rb +48 -0
  121. data/spec/buildtasks/manifest/hide_buildfiles_spec.rb +125 -0
  122. data/spec/buildtasks/manifest/localize_spec.rb +97 -0
  123. data/spec/buildtasks/manifest/prepare_build_tasks/combine_spec.rb +246 -0
  124. data/spec/buildtasks/manifest/prepare_build_tasks/css_spec.rb +87 -0
  125. data/spec/buildtasks/manifest/prepare_build_tasks/html_spec.rb +175 -0
  126. data/spec/buildtasks/manifest/prepare_build_tasks/javascript_spec.rb +65 -0
  127. data/spec/buildtasks/manifest/prepare_build_tasks/minify_spec.rb +70 -0
  128. data/spec/buildtasks/manifest/prepare_build_tasks/packed_spec.rb +152 -0
  129. data/spec/buildtasks/manifest/prepare_build_tasks/sass_spec.rb +98 -0
  130. data/spec/buildtasks/manifest/prepare_build_tasks/strings_spec.rb +64 -0
  131. data/spec/buildtasks/manifest/prepare_build_tasks/tests_spec.rb +163 -0
  132. data/spec/buildtasks/manifest/prepare_spec.rb +43 -0
  133. data/spec/buildtasks/manifest/spec_helper.rb +35 -0
  134. data/spec/buildtasks/target_spec.rb +214 -0
  135. data/spec/fixtures/builder_tests/Buildfile +15 -0
  136. data/spec/fixtures/builder_tests/apps/combine_test/a.js +1 -0
  137. data/spec/fixtures/builder_tests/apps/combine_test/b.js +1 -0
  138. data/spec/fixtures/builder_tests/apps/combine_test/c.js +1 -0
  139. data/spec/fixtures/builder_tests/apps/combine_test/english.lproj/a.css +1 -0
  140. data/spec/fixtures/builder_tests/apps/combine_test/english.lproj/b.css +1 -0
  141. data/spec/fixtures/builder_tests/apps/combine_test/english.lproj/c.css +1 -0
  142. data/spec/fixtures/builder_tests/apps/html_test/english.lproj/bar1_sample.rhtml +2 -0
  143. data/spec/fixtures/builder_tests/apps/html_test/english.lproj/erb_sample.html.erb +1 -0
  144. data/spec/fixtures/builder_tests/apps/html_test/english.lproj/icons/image.png +0 -0
  145. data/spec/fixtures/builder_tests/apps/html_test/english.lproj/image.jpg +0 -0
  146. data/spec/fixtures/builder_tests/apps/html_test/english.lproj/rhtml_sample.rhtml +1 -0
  147. data/spec/fixtures/builder_tests/apps/html_test/english.lproj/strings.js +4 -0
  148. data/spec/fixtures/builder_tests/apps/html_test/english.lproj/style.css +0 -0
  149. data/spec/fixtures/builder_tests/apps/html_test/french.lproj/french-icons/fr.png +0 -0
  150. data/spec/fixtures/builder_tests/apps/html_test/french.lproj/strings.js +4 -0
  151. data/spec/fixtures/builder_tests/apps/html_test/lib/layout_template.rhtml +1 -0
  152. data/spec/fixtures/builder_tests/apps/html_test/scripts.js +0 -0
  153. data/spec/fixtures/builder_tests/apps/javascript_test/sc_static.js +15 -0
  154. data/spec/fixtures/builder_tests/apps/javascript_test/sc_super.js +4 -0
  155. data/spec/fixtures/builder_tests/apps/javascript_test/strings.js +7 -0
  156. data/spec/fixtures/builder_tests/apps/sass_test/sample.sass +3 -0
  157. data/spec/fixtures/builder_tests/apps/strings_test/lproj/strings.js +8 -0
  158. data/spec/fixtures/builder_tests/apps/stylesheet_test/build_directives.css +9 -0
  159. data/spec/fixtures/builder_tests/apps/stylesheet_test/sc_static.css +12 -0
  160. data/spec/fixtures/builder_tests/apps/test_test/lib/alt_layout.rhtml +1 -0
  161. data/spec/fixtures/builder_tests/apps/test_test/lib/test_layout.rhtml +3 -0
  162. data/spec/fixtures/builder_tests/apps/test_test/tests/qunit_test.js +1 -0
  163. data/spec/fixtures/builder_tests/apps/test_test/tests/qunit_test2.js +1 -0
  164. data/spec/fixtures/builder_tests/apps/test_test/tests/rhtml_test.rhtml +4 -0
  165. data/spec/fixtures/builder_tests/frameworks/debug/core.js +0 -0
  166. data/spec/fixtures/builder_tests/frameworks/debug/english.lproj/dummy.css +0 -0
  167. data/spec/fixtures/builder_tests/frameworks/qunit/core.js +0 -0
  168. data/spec/fixtures/builder_tests/frameworks/qunit/english.lproj/dummy.css +0 -0
  169. data/spec/fixtures/builder_tests/frameworks/req_target_1/english.lproj/req_style_1.css +0 -0
  170. data/spec/fixtures/builder_tests/frameworks/req_target_1/english.lproj/strings.js +4 -0
  171. data/spec/fixtures/builder_tests/frameworks/req_target_1/english.lproj/test.rhtml +1 -0
  172. data/spec/fixtures/builder_tests/frameworks/req_target_1/req_js_1.js +0 -0
  173. data/spec/fixtures/builder_tests/frameworks/req_target_2/english.lproj/req_style_2.css +0 -0
  174. data/spec/fixtures/builder_tests/frameworks/req_target_2/english.lproj/test.rhtml +1 -0
  175. data/spec/fixtures/builder_tests/frameworks/req_target_2/javascript.js +1 -0
  176. data/spec/fixtures/builder_tests/frameworks/req_target_2/lib/alt_layout.rhtml +0 -0
  177. data/spec/fixtures/builder_tests/frameworks/req_target_2/req_js_2.js +0 -0
  178. data/spec/fixtures/builder_tests/themes/sample_theme/Buildfile +1 -0
  179. data/spec/fixtures/buildfiles/basic/Buildfile +16 -0
  180. data/spec/fixtures/buildfiles/basic/task_module.rake +6 -0
  181. data/spec/fixtures/buildfiles/installed/Buildfile +7 -0
  182. data/spec/fixtures/buildfiles/installed/Buildfile2 +5 -0
  183. data/spec/fixtures/buildfiles/project_test/Buildfile +4 -0
  184. data/spec/fixtures/buildfiles/project_test/not_project/Buildfile +2 -0
  185. data/spec/fixtures/buildfiles/project_test/not_project/child/PLACEHOLDER +0 -0
  186. data/spec/fixtures/entry_for_project/Buildfile +1 -0
  187. data/spec/fixtures/entry_for_project/apps/test_app/entry.txt +0 -0
  188. data/spec/fixtures/entry_for_project/apps/test_app/frameworks/nested/PLACEHOLDER +0 -0
  189. data/spec/fixtures/entry_for_project/frameworks/shared/PLACEHOLDER +0 -0
  190. data/spec/fixtures/find_targets/custom/Buildfile +8 -0
  191. data/spec/fixtures/find_targets/custom/bars/bar1/bars/bar1/PLACEHOLDER +0 -0
  192. data/spec/fixtures/find_targets/custom/bars/bar1/bars/bar2/PLACEHOLDER +0 -0
  193. data/spec/fixtures/find_targets/custom/bars/bar1/foos/foo1/PLACEHOLDER +0 -0
  194. data/spec/fixtures/find_targets/custom/bars/bar1/foos/foo2/PLACEHOLDER +0 -0
  195. data/spec/fixtures/find_targets/custom/foos/custom_foos/Buildfile +5 -0
  196. data/spec/fixtures/find_targets/custom/foos/custom_foos/custom_foodir/foo1/PLACEHOLDER +0 -0
  197. data/spec/fixtures/find_targets/custom/foos/custom_foos/custom_foodir/foo2/PLACEHOLDER +0 -0
  198. data/spec/fixtures/find_targets/custom/foos/custom_foos/foos/not_foo1/PLACEHOLDER +0 -0
  199. data/spec/fixtures/find_targets/custom/foos/foo1/bars/bar1/PLACEHOLDER +0 -0
  200. data/spec/fixtures/find_targets/custom/foos/foo1/bars/bar2/PLACEHOLDER +0 -0
  201. data/spec/fixtures/find_targets/nested/Buildfile +8 -0
  202. data/spec/fixtures/find_targets/nested/apps/app1/Buildfile +1 -0
  203. data/spec/fixtures/find_targets/nested/apps/app1/apps/nested_app/PLACEHOLDER +0 -0
  204. data/spec/fixtures/find_targets/standard/Apps/app1/frameworks/framework1/PLACEHOLDER +0 -0
  205. data/spec/fixtures/find_targets/standard/Apps/app1/frameworks/framework2/PLACEHOLDER +0 -0
  206. data/spec/fixtures/find_targets/standard/clients/client1/PLACEHOLDER +0 -0
  207. data/spec/fixtures/find_targets/standard/frameworks/framework1/frameworks/framework1/PLACEHOLDER +0 -0
  208. data/spec/fixtures/find_targets/standard/frameworks/framework2/PLACEHOLDER +0 -0
  209. data/spec/fixtures/find_targets/standard/themes/theme1/PLACEHOLDER +0 -0
  210. data/spec/fixtures/find_targets/standard/themes/theme2/PLACEHOLDER +0 -0
  211. data/spec/fixtures/languages/apps/caps_long_names/English.lproj/PLACEHOLDER +0 -0
  212. data/spec/fixtures/languages/apps/caps_long_names/FreNCH.lproj/PLACEHOLDER +0 -0
  213. data/spec/fixtures/languages/apps/caps_long_names/UnknOWN.lproj/PLACEHOLDER +0 -0
  214. data/spec/fixtures/languages/apps/long_names/english.lproj/PLACEHOLDER +0 -0
  215. data/spec/fixtures/languages/apps/long_names/french.lproj/PLACEHOLDER +0 -0
  216. data/spec/fixtures/languages/apps/long_names/german.lproj/PLACEHOLDER +0 -0
  217. data/spec/fixtures/languages/apps/long_names/italian.lproj/PLACEHOLDER +0 -0
  218. data/spec/fixtures/languages/apps/long_names/japanese.lproj/PLACEHOLDER +0 -0
  219. data/spec/fixtures/languages/apps/long_names/spanish.lproj/PLACEHOLDER +0 -0
  220. data/spec/fixtures/languages/apps/long_names/unknown.lproj/PLACEHOLDER +0 -0
  221. data/spec/fixtures/languages/apps/no_names/PLACEHOLDER +0 -0
  222. data/spec/fixtures/languages/apps/short_names/de.lproj/PLACEHOLDER +0 -0
  223. data/spec/fixtures/languages/apps/short_names/en-CA.lproj/PLACEHOLDER +0 -0
  224. data/spec/fixtures/languages/apps/short_names/en-GB.lproj/PLACEHOLDER +0 -0
  225. data/spec/fixtures/languages/apps/short_names/en-US.lproj/PLACEHOLDER +0 -0
  226. data/spec/fixtures/languages/apps/short_names/en.lproj/PLACEHOLDER +0 -0
  227. data/spec/fixtures/languages/apps/short_names/es.lproj/PLACEHOLDER +0 -0
  228. data/spec/fixtures/languages/apps/short_names/foo.lproj/PLACEHOLDER +0 -0
  229. data/spec/fixtures/languages/apps/short_names/fr.lproj/PLACEHOLDER +0 -0
  230. data/spec/fixtures/languages/apps/short_names/it.lproj/PLACEHOLDER +0 -0
  231. data/spec/fixtures/languages/apps/short_names/ja.lproj/PLACEHOLDER +0 -0
  232. data/spec/fixtures/ordered_entries/apps/no_requires/1.js +1 -0
  233. data/spec/fixtures/ordered_entries/apps/no_requires/B.js +1 -0
  234. data/spec/fixtures/ordered_entries/apps/no_requires/a.js +1 -0
  235. data/spec/fixtures/ordered_entries/apps/no_requires/a/a.js +1 -0
  236. data/spec/fixtures/ordered_entries/apps/no_requires/a/b.js +1 -0
  237. data/spec/fixtures/ordered_entries/apps/no_requires/b/a.js +1 -0
  238. data/spec/fixtures/ordered_entries/apps/no_requires/c.js +1 -0
  239. data/spec/fixtures/ordered_entries/apps/no_requires/core.js +1 -0
  240. data/spec/fixtures/ordered_entries/apps/no_requires/english.lproj/B.css +0 -0
  241. data/spec/fixtures/ordered_entries/apps/no_requires/english.lproj/a.css +0 -0
  242. data/spec/fixtures/ordered_entries/apps/no_requires/english.lproj/a/a.css +0 -0
  243. data/spec/fixtures/ordered_entries/apps/no_requires/english.lproj/a/b.css +0 -0
  244. data/spec/fixtures/ordered_entries/apps/no_requires/english.lproj/b/a.css +0 -0
  245. data/spec/fixtures/ordered_entries/apps/no_requires/english.lproj/c.css +0 -0
  246. data/spec/fixtures/ordered_entries/apps/no_requires/lproj/strings.js +1 -0
  247. data/spec/fixtures/ordered_entries/apps/no_requires/utils.js +1 -0
  248. data/spec/fixtures/ordered_entries/apps/with_requires/a.js +2 -0
  249. data/spec/fixtures/ordered_entries/apps/with_requires/b.js +3 -0
  250. data/spec/fixtures/ordered_entries/apps/with_requires/c.js +2 -0
  251. data/spec/fixtures/ordered_entries/apps/with_requires/english.lproj/a.css +2 -0
  252. data/spec/fixtures/ordered_entries/apps/with_requires/english.lproj/b.css +2 -0
  253. data/spec/fixtures/ordered_entries/apps/with_requires/english.lproj/c.css +2 -0
  254. data/spec/fixtures/ordered_entries/apps/with_requires/english.lproj/d.js +1 -0
  255. data/spec/fixtures/real_world/Buildfile +12 -0
  256. data/spec/fixtures/real_world/apps/account/README +1 -0
  257. data/spec/fixtures/real_world/apps/calendar/README +1 -0
  258. data/spec/fixtures/real_world/apps/contacts/README_BEFORE_EDITING +1 -0
  259. data/spec/fixtures/real_world/apps/files/README +1 -0
  260. data/spec/fixtures/real_world/apps/mail/README +1 -0
  261. data/spec/fixtures/real_world/apps/mobile_photos/README +1 -0
  262. data/spec/fixtures/real_world/apps/photos/README +1 -0
  263. data/spec/fixtures/real_world/apps/uploader/README +1 -0
  264. data/spec/fixtures/real_world/frameworks/core_files/PLACEHOLDER +0 -0
  265. data/spec/fixtures/real_world/frameworks/core_photos/PLACEHOLDER +0 -0
  266. data/spec/fixtures/real_world/frameworks/shared/PLACEHOLDER +0 -0
  267. data/spec/fixtures/real_world/frameworks/sproutcore/Buildfile +26 -0
  268. data/spec/fixtures/real_world/frameworks/sproutcore/README +1 -0
  269. data/spec/fixtures/real_world/frameworks/sproutcore/apps/docs/PLACEHOLDER +0 -0
  270. data/spec/fixtures/real_world/frameworks/sproutcore/apps/test_runner/PLACEHOLDER +0 -0
  271. data/spec/fixtures/real_world/frameworks/sproutcore/core.js +0 -0
  272. data/spec/fixtures/real_world/frameworks/sproutcore/debug/debug-resource.html +0 -0
  273. data/spec/fixtures/real_world/frameworks/sproutcore/debug/sample_debug.js +0 -0
  274. data/spec/fixtures/real_world/frameworks/sproutcore/demo2.js +0 -0
  275. data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/debug/sample_debug-loc.js +0 -0
  276. data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/demo.css +4 -0
  277. data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/demo.html +1 -0
  278. data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/demo2.sass +0 -0
  279. data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/file_extension_test.haml +0 -0
  280. data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/file_extension_test.html.erb +1 -0
  281. data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/file_extension_test.rhtml +0 -0
  282. data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/fixtures/sample_fixtures-loc.js +0 -0
  283. data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/has_require.css +4 -0
  284. data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/no_require.css +1 -0
  285. data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/no_sc_resource.rhtml +1 -0
  286. data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/protocols/sample-loc.js +0 -0
  287. data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/sc_resource.css +6 -0
  288. data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/sc_resource.rhtml +3 -0
  289. data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/strings.js +1 -0
  290. data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/tests/sample-loc.js +0 -0
  291. data/spec/fixtures/real_world/frameworks/sproutcore/fixtures/sample-json-fixture.json +1 -0
  292. data/spec/fixtures/real_world/frameworks/sproutcore/fixtures/sample_fixtures.js +0 -0
  293. data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/application/PLACEHOLDER +0 -0
  294. data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/costello/core.js +0 -0
  295. data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/data_store/PLACEHOLDER +0 -0
  296. data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/debug/PLACEHOLDER +0 -0
  297. data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/desktop/PLACEHOLDER +0 -0
  298. data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/empty_theme/PLACEHOLDER +0 -0
  299. data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/foundation/PLACEHOLDER +0 -0
  300. data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/mobile/PLACEHOLDER +0 -0
  301. data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/qunit/PLACEHOLDER +0 -0
  302. data/spec/fixtures/real_world/frameworks/sproutcore/frameworks/uploader/PLACEHOLDER +0 -0
  303. data/spec/fixtures/real_world/frameworks/sproutcore/french.lproj/french-resource.js +0 -0
  304. data/spec/fixtures/real_world/frameworks/sproutcore/french.lproj/strings.js +1 -0
  305. data/spec/fixtures/real_world/frameworks/sproutcore/german.lproj/german-resource.js +0 -0
  306. data/spec/fixtures/real_world/frameworks/sproutcore/german.lproj/strings.js +0 -0
  307. data/spec/fixtures/real_world/frameworks/sproutcore/has_require.js +4 -0
  308. data/spec/fixtures/real_world/frameworks/sproutcore/lib/index.html +1 -0
  309. data/spec/fixtures/real_world/frameworks/sproutcore/no_require.js +1 -0
  310. data/spec/fixtures/real_world/frameworks/sproutcore/protocols/sample.js +0 -0
  311. data/spec/fixtures/real_world/frameworks/sproutcore/sc_resource.js +6 -0
  312. data/spec/fixtures/real_world/frameworks/sproutcore/tests/nested/sample1.js +0 -0
  313. data/spec/fixtures/real_world/frameworks/sproutcore/tests/nested/sample2.js +0 -0
  314. data/spec/fixtures/real_world/frameworks/sproutcore/tests/sample.js +0 -0
  315. data/spec/fixtures/real_world/frameworks/sproutcore/tests/sample.rhtml +1 -0
  316. data/spec/fixtures/real_world/frameworks/sproutcore/themes/standard_theme/README +0 -0
  317. data/spec/fixtures/real_world/frameworks/sproutcore/views/view.js +1 -0
  318. data/spec/fixtures/real_world/generators/sample_custom/Buildfile +0 -0
  319. data/spec/fixtures/real_world/generators/sample_custom/templates/{filename}.js +1 -0
  320. data/spec/fixtures/recursive_project/Buildfile +8 -0
  321. data/spec/fixtures/recursive_project/frameworks/sproutcore/frameworks/costello/PLACEHOLDER +0 -0
  322. data/spec/lib/builders/combine_spec.rb +67 -0
  323. data/spec/lib/builders/html_spec.rb +577 -0
  324. data/spec/lib/builders/javascript_spec.rb +81 -0
  325. data/spec/lib/builders/sass_spec.rb +43 -0
  326. data/spec/lib/builders/spec_helper.rb +30 -0
  327. data/spec/lib/builders/strings_spec.rb +52 -0
  328. data/spec/lib/builders/stylesheet_spec.rb +63 -0
  329. data/spec/lib/builders/test_index_spec.rb +44 -0
  330. data/spec/lib/builders/test_spec.rb +135 -0
  331. data/spec/lib/buildfile/config_for_spec.rb +81 -0
  332. data/spec/lib/buildfile/define_spec.rb +59 -0
  333. data/spec/lib/buildfile/dup_spec.rb +65 -0
  334. data/spec/lib/buildfile/invoke_spec.rb +130 -0
  335. data/spec/lib/buildfile/load_spec.rb +49 -0
  336. data/spec/lib/buildfile/task/dup_spec.rb +55 -0
  337. data/spec/lib/buildfile/task_defined_spec.rb +17 -0
  338. data/spec/lib/buildfile_commands/build_task_spec.rb +19 -0
  339. data/spec/lib/buildfile_commands/config_spec.rb +97 -0
  340. data/spec/lib/buildfile_commands/import_spec.rb +17 -0
  341. data/spec/lib/buildfile_commands/namespace_spec.rb +18 -0
  342. data/spec/lib/buildfile_commands/proxies_spec.rb +38 -0
  343. data/spec/lib/buildfile_commands/replace_task_spec.rb +29 -0
  344. data/spec/lib/buildfile_commands/task_spec.rb +36 -0
  345. data/spec/lib/helpers/packing_optimizer/optimize_spec.rb +26 -0
  346. data/spec/lib/models/hash_struct/deep_clone_spec.rb +27 -0
  347. data/spec/lib/models/hash_struct/has_options_spec.rb +32 -0
  348. data/spec/lib/models/hash_struct/hash_spec.rb +64 -0
  349. data/spec/lib/models/hash_struct/merge_spec.rb +26 -0
  350. data/spec/lib/models/hash_struct/method_missing.rb +41 -0
  351. data/spec/lib/models/manifest/add_entry_spec.rb +36 -0
  352. data/spec/lib/models/manifest/add_transform_spec.rb +90 -0
  353. data/spec/lib/models/manifest/build_spec.rb +78 -0
  354. data/spec/lib/models/manifest/entry_for_spec.rb +94 -0
  355. data/spec/lib/models/manifest/find_entry.rb +84 -0
  356. data/spec/lib/models/manifest/prepare_spec.rb +62 -0
  357. data/spec/lib/models/manifest_entry/cacheable_url_spec.rb +31 -0
  358. data/spec/lib/models/manifest_entry/prepare_spec.rb +54 -0
  359. data/spec/lib/models/project/add_target_spec.rb +44 -0
  360. data/spec/lib/models/project/buildfile_spec.rb +35 -0
  361. data/spec/lib/models/project/find_targets_for_spec.rb +77 -0
  362. data/spec/lib/models/project/load_nearest_project_spec.rb +23 -0
  363. data/spec/lib/models/project/target_for_spec.rb +33 -0
  364. data/spec/lib/models/project/targets_spec.rb +62 -0
  365. data/spec/lib/models/target/compute_build_number_spec.rb +125 -0
  366. data/spec/lib/models/target/config_spec.rb +30 -0
  367. data/spec/lib/models/target/expand_required_targets_spec.rb +48 -0
  368. data/spec/lib/models/target/installed_languages_spec.rb +47 -0
  369. data/spec/lib/models/target/lproj_for_spec.rb +38 -0
  370. data/spec/lib/models/target/manifest_for_spec.rb +42 -0
  371. data/spec/lib/models/target/parent_target_spec.rb +21 -0
  372. data/spec/lib/models/target/prepare_spec.rb +53 -0
  373. data/spec/lib/models/target/required_targets_spec.rb +119 -0
  374. data/spec/lib/models/target/target_for_spec.rb +56 -0
  375. data/spec/lib/tools/build_number_spec.rb +28 -0
  376. data/spec/lib/tools/gen_spec.rb +207 -0
  377. data/spec/lib/tools/tools_spec.rb +78 -0
  378. data/spec/spec_helper.rb +138 -0
  379. data/sproutcore.gemspec +47 -0
  380. data/vendor/github_gem_lint.rb +22 -0
  381. data/vendor/yui-compressor/yuicompressor-2.4.2.jar +0 -0
  382. metadata +1084 -0
@@ -0,0 +1,33 @@
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(File.dirname(__FILE__), 'task'))
9
+
10
+ module SC
11
+
12
+ # Just like a normal task, but will not run if the destination path already
13
+ # exists and it is newer than the source.
14
+ class Buildfile::BuildTask < ::SC::Buildfile::Task
15
+
16
+ def needed?
17
+ return true if DST_PATH.nil? || SRC_PATHS.nil? # just try to build...
18
+ return true if !File.exist?(DST_PATH)
19
+ ret = false
20
+ dst_mtime = File.mtime(DST_PATH)
21
+ SRC_PATHS.each do |path|
22
+ next if path.nil? # skip incase of bad src paths...
23
+
24
+ timestamp = File.exist?(path) ? File.mtime(path) : EARLY
25
+ ret = ret || (dst_mtime < timestamp)
26
+ break if ret
27
+ end
28
+ return ret
29
+ end
30
+
31
+ end
32
+ end
33
+
@@ -0,0 +1,162 @@
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
+
10
+ class Buildfile
11
+
12
+ # Describe the domain-specific-language helpers supported by buildfiles.
13
+ # This is included as a mixin for the buildfile.
14
+ module Commands
15
+
16
+ # Declare a basic task.
17
+ #
18
+ # Example:
19
+ # task :clobber => [:clean] do
20
+ # rm_rf "html"
21
+ # end
22
+ #
23
+ def task(*args, &block)
24
+ define_task(::SC::Buildfile::Task, *args, &block)
25
+ end
26
+
27
+ # Replace an existing task instead of enhancing it.
28
+ #
29
+ # Example:
30
+ # replace_task :clobber => :clean do
31
+ # rm_rf 'javascript'
32
+ # end
33
+ #
34
+ def replace_task(*args, &block)
35
+ @is_redefining = true
36
+ begin
37
+ define_task(::SC::Buildfile::Task, *args, &block)
38
+ rescue Exception => e
39
+ @is_redefining = false
40
+ raise e
41
+ end
42
+ end
43
+
44
+ # Define a build task. A build task will not run if the destination
45
+ # file is newer than the source files.
46
+ #
47
+ def build_task(*args, &block)
48
+ define_task(::SC::Buildfile::BuildTask, *args, &block)
49
+ end
50
+
51
+ # Import the partial Rakefiles +fn+. Imported files are loaded _after_
52
+ # the current file is completely loaded. This allows the import statement
53
+ # to appear anywhere in the importing file, and yet allowing the imported
54
+ # files to depend on objects defined in the importing file.
55
+ #
56
+ # A common use of the import statement is to include files containing
57
+ # dependency declarations.
58
+ #
59
+ # Example:
60
+ # import ".depend", "my_rules"
61
+ #
62
+ def import(*args)
63
+ base_path = current_path.nil? ? nil : File.dirname(current_path)
64
+ args.each do |fn|
65
+ fn = File.expand_path(fn, base_path)
66
+ add_import(fn)
67
+ end
68
+ end
69
+
70
+ # Create a new rake namespace and use it for evaluating the given block.
71
+ # Returns a NameSpace object that can be used to lookup tasks defined in
72
+ # the namespace.
73
+ #
74
+ # E.g.
75
+ #
76
+ # ns = namespace "nested" do
77
+ # task :run
78
+ # end
79
+ # task_run = ns[:run] # find :run in the given namespace.
80
+ #
81
+ def namespace(name=nil, &block)
82
+ in_namespace(name, &block)
83
+ end
84
+
85
+ # Describe the next rake task.
86
+ #
87
+ # Example:
88
+ # desc "Run the Unit Tests"
89
+ # task :test => [:build]
90
+ # runtests
91
+ # end
92
+ #
93
+ def desc(description)
94
+ last_description = description
95
+ end
96
+
97
+ # Describe options on the next rake task.
98
+ #
99
+ # Example:
100
+ # options :log => :env|:name|:none
101
+ # task :test => [:build]
102
+ # runtests
103
+ # end
104
+ #
105
+ def task_options(opts)
106
+ last_task_options = opts
107
+ end
108
+
109
+ # Scope any config statements inside the passed block to the named mode.
110
+ # Normally if you call a config statement outside of a mode block, it will
111
+ # scope to all modes.
112
+ #
113
+ # Example:
114
+ # mode :debug do
115
+ # config :all, :combine_javascript => NO
116
+ #
117
+ def mode(build_mode, &block)
118
+ old_mode = current_mode
119
+ self.current_mode = build_mode.to_sym
120
+ yield if block_given?
121
+ self.current_mode = old_mode
122
+ return self
123
+ end
124
+
125
+ # Register the passed configuration settings scoped to a target. Optional
126
+ # pass a block to edit the config.
127
+ #
128
+ # Example:
129
+ # config :all, :url_root => "static"
130
+ # config :sproutcore do |c|
131
+ # c.url_root = "static"
132
+ # end
133
+ #
134
+ def config(config_name, opts = {}, &block)
135
+ opts = ::SC::HashStruct.new(opts)
136
+ yield(opts) if block_given?
137
+ add_config config_name, opts
138
+ return self
139
+ end
140
+
141
+ # Register a proxy setting
142
+ #
143
+ # Example:
144
+ # proxy '/url', :to => 'localhost:3000'
145
+ #
146
+ def proxy(proxy_path, opts={})
147
+ add_proxy proxy_path, opts
148
+ end
149
+
150
+ # Register info about this buildfile as a project
151
+ def project(name=nil, type=nil)
152
+ self.project_name = name.nil? ? :default : name.to_sym
153
+ self.project_type = type.nil? ? :default : type.to_sym
154
+ self.project!
155
+ end
156
+
157
+ end
158
+
159
+ include Commands
160
+ end
161
+
162
+ end
@@ -0,0 +1,34 @@
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
+
10
+ # Mixing for creating easily cloned objects. Borrowed from Rake 0.8.3
11
+ module Cloneable
12
+
13
+ # Clone an object by making a new object and setting all the instance
14
+ # variables to the same values.
15
+ def dup
16
+ sibling = self.class.new
17
+ instance_variables.each do |ivar|
18
+ value = self.instance_variable_get(ivar)
19
+ new_value = value.clone rescue value
20
+ sibling.instance_variable_set(ivar, new_value)
21
+ end
22
+ sibling.taint if tainted?
23
+ sibling
24
+ end
25
+
26
+ def clone
27
+ sibling = dup
28
+ sibling.freeze if frozen?
29
+ sibling
30
+ end
31
+ end
32
+
33
+
34
+ end
@@ -0,0 +1,29 @@
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 'singleton'
9
+
10
+ module SC
11
+
12
+ # EarlyTime is a fake timestamp that occurs _before_ any other time value.
13
+ # Borrowed from Rake 0.8.3
14
+ class EarlyTime
15
+ include Comparable
16
+ include Singleton
17
+
18
+ def <=>(other)
19
+ -1
20
+ end
21
+
22
+ def to_s
23
+ "<EARLY TIME>"
24
+ end
25
+ end
26
+
27
+ EARLY = EarlyTime.instance
28
+
29
+ end
@@ -0,0 +1,64 @@
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
+
10
+ # InvocationChain tracks the chain of task invocations to detect
11
+ # circular dependencies. Borrowed from Rake 0.8.3
12
+ class InvocationChain
13
+ def initialize(value, tail)
14
+ @value = value
15
+ @tail = tail
16
+ end
17
+
18
+ def member?(obj)
19
+ @value == obj || @tail.member?(obj)
20
+ end
21
+
22
+ def already_invoked?(task)
23
+ (task == @value) || @tail.already_invoked?(task)
24
+ end
25
+
26
+ def append(value)
27
+ if member?(value)
28
+ raise "Circular dependency detected: #{to_s} => #{value}"
29
+ end
30
+ self.class.new(value, self)
31
+ end
32
+
33
+ def to_s
34
+ "#{prefix}#{@value}"
35
+ end
36
+
37
+ def self.append(value, chain)
38
+ chain.append(value)
39
+ end
40
+
41
+ private
42
+
43
+ def prefix
44
+ "#{@tail.to_s} => "
45
+ end
46
+
47
+ class EmptyInvocationChain
48
+ def member?(obj)
49
+ false
50
+ end
51
+ def append(value)
52
+ InvocationChain.new(value, self)
53
+ end
54
+ def to_s
55
+ "TOP"
56
+ end
57
+ def already_invoked?(task); false; end
58
+ end
59
+
60
+ EMPTY = EmptyInvocationChain.new
61
+
62
+ end # class InvocationChain
63
+
64
+ end
@@ -0,0 +1,33 @@
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
+
10
+ # The NameSpace class will lookup task names in the the scope
11
+ # defined by a +namespace+ command. Borrowed from Rake 0.8.3
12
+ #
13
+ class NameSpace
14
+
15
+ # Create a namespace lookup object using the given task manager
16
+ # and the list of scopes.
17
+ def initialize(task_manager, scope_list)
18
+ @task_manager = task_manager
19
+ @scope = scope_list.dup
20
+ end
21
+
22
+ # Lookup a task named +name+ in the namespace.
23
+ def [](name)
24
+ @task_manager.lookup(name, @scope)
25
+ end
26
+
27
+ # Return the list of tasks defined in this namespace.
28
+ def tasks
29
+ @task_manager.tasks
30
+ end
31
+ end # NameSpace
32
+
33
+ end
@@ -0,0 +1,198 @@
1
+ ######################################################################
2
+ # Rake extensions to Module. - Borrowed from Rake 0.8.3
3
+ #
4
+ class Module
5
+ # Check for an existing method in the current class before extending. IF
6
+ # the method already exists, then a warning is printed and the extension is
7
+ # not added. Otherwise the block is yielded and any definitions in the
8
+ # block will take effect.
9
+ #
10
+ # Usage:
11
+ #
12
+ # class String
13
+ # rake_extension("xyz") do
14
+ # def xyz
15
+ # ...
16
+ # end
17
+ # end
18
+ # end
19
+ #
20
+ def rake_extension(method)
21
+ if instance_methods.include?(method.to_s) || instance_methods.include?(method.to_sym)
22
+ $stderr.puts "WARNING: Possible conflict with Rake extension: #{self}##{method} already exists"
23
+ else
24
+ yield
25
+ end
26
+ end
27
+ end # module Module
28
+
29
+
30
+ ######################################################################
31
+ # User defined methods to be added to String.
32
+ #
33
+ class String
34
+ rake_extension("ext") do
35
+ # Replace the file extension with +newext+. If there is no extenson on
36
+ # the string, append the new extension to the end. If the new extension
37
+ # is not given, or is the empty string, remove any existing extension.
38
+ #
39
+ # +ext+ is a user added method for the String class.
40
+ def ext(newext='')
41
+ return self.dup if ['.', '..'].include? self
42
+ newext = newext.to_s
43
+ if newext != ''
44
+ newext = (newext =~ /^\./) ? newext : ("." + newext)
45
+ end
46
+ dup.sub!(%r(([^/\\])\.[^./\\]*$)) { $1 + newext } || self + newext
47
+ end
48
+ end
49
+
50
+ rake_extension("pathmap") do
51
+ # Explode a path into individual components. Used by +pathmap+.
52
+ def pathmap_explode
53
+ head, tail = File.split(self)
54
+ return [self] if head == self
55
+ return [tail] if head == '.' || tail == '/'
56
+ return [head, tail] if head == '/'
57
+ return head.pathmap_explode + [tail]
58
+ end
59
+ protected :pathmap_explode
60
+
61
+ # Extract a partial path from the path. Include +n+ directories from the
62
+ # front end (left hand side) if +n+ is positive. Include |+n+|
63
+ # directories from the back end (right hand side) if +n+ is negative.
64
+ def pathmap_partial(n)
65
+ dirs = File.dirname(self).pathmap_explode
66
+ partial_dirs =
67
+ if n > 0
68
+ dirs[0...n]
69
+ elsif n < 0
70
+ dirs.reverse[0...-n].reverse
71
+ else
72
+ "."
73
+ end
74
+ File.join(partial_dirs)
75
+ end
76
+ protected :pathmap_partial
77
+
78
+ # Preform the pathmap replacement operations on the given path. The
79
+ # patterns take the form 'pat1,rep1;pat2,rep2...'.
80
+ def pathmap_replace(patterns, &block)
81
+ result = self
82
+ patterns.split(';').each do |pair|
83
+ pattern, replacement = pair.split(',')
84
+ pattern = Regexp.new(pattern)
85
+ if replacement == '*' && block_given?
86
+ result = result.sub(pattern, &block)
87
+ elsif replacement
88
+ result = result.sub(pattern, replacement)
89
+ else
90
+ result = result.sub(pattern, '')
91
+ end
92
+ end
93
+ result
94
+ end
95
+ protected :pathmap_replace
96
+
97
+ # Map the path according to the given specification. The specification
98
+ # controls the details of the mapping. The following special patterns are
99
+ # recognized:
100
+ #
101
+ # * <b>%p</b> -- The complete path.
102
+ # * <b>%f</b> -- The base file name of the path, with its file extension,
103
+ # but without any directories.
104
+ # * <b>%n</b> -- The file name of the path without its file extension.
105
+ # * <b>%d</b> -- The directory list of the path.
106
+ # * <b>%x</b> -- The file extension of the path. An empty string if there
107
+ # is no extension.
108
+ # * <b>%X</b> -- Everything *but* the file extension.
109
+ # * <b>%s</b> -- The alternate file separater if defined, otherwise use
110
+ # the standard file separator.
111
+ # * <b>%%</b> -- A percent sign.
112
+ #
113
+ # The %d specifier can also have a numeric prefix (e.g. '%2d'). If the
114
+ # number is positive, only return (up to) +n+ directories in the path,
115
+ # starting from the left hand side. If +n+ is negative, return (up to)
116
+ # |+n+| directories from the right hand side of the path.
117
+ #
118
+ # Examples:
119
+ #
120
+ # 'a/b/c/d/file.txt'.pathmap("%2d") => 'a/b'
121
+ # 'a/b/c/d/file.txt'.pathmap("%-2d") => 'c/d'
122
+ #
123
+ # Also the %d, %p, $f, $n, %x, and %X operators can take a
124
+ # pattern/replacement argument to perform simple string substititions on a
125
+ # particular part of the path. The pattern and replacement are speparated
126
+ # by a comma and are enclosed by curly braces. The replacement spec comes
127
+ # after the % character but before the operator letter. (e.g.
128
+ # "%{old,new}d"). Muliple replacement specs should be separated by
129
+ # semi-colons (e.g. "%{old,new;src,bin}d").
130
+ #
131
+ # Regular expressions may be used for the pattern, and back refs may be
132
+ # used in the replacement text. Curly braces, commas and semi-colons are
133
+ # excluded from both the pattern and replacement text (let's keep parsing
134
+ # reasonable).
135
+ #
136
+ # For example:
137
+ #
138
+ # "src/org/onestepback/proj/A.java".pathmap("%{^src,bin}X.class")
139
+ #
140
+ # returns:
141
+ #
142
+ # "bin/org/onestepback/proj/A.class"
143
+ #
144
+ # If the replacement text is '*', then a block may be provided to perform
145
+ # some arbitrary calculation for the replacement.
146
+ #
147
+ # For example:
148
+ #
149
+ # "/path/to/file.TXT".pathmap("%X%{.*,*}x") { |ext|
150
+ # ext.downcase
151
+ # }
152
+ #
153
+ # Returns:
154
+ #
155
+ # "/path/to/file.txt"
156
+ #
157
+ def pathmap(spec=nil, &block)
158
+ return self if spec.nil?
159
+ result = ''
160
+ spec.scan(/%\{[^}]*\}-?\d*[sdpfnxX%]|%-?\d+d|%.|[^%]+/) do |frag|
161
+ case frag
162
+ when '%f'
163
+ result << File.basename(self)
164
+ when '%n'
165
+ result << File.basename(self).ext
166
+ when '%d'
167
+ result << File.dirname(self)
168
+ when '%x'
169
+ result << $1 if self =~ /[^\/](\.[^.]+)$/
170
+ when '%X'
171
+ if self =~ /^(.*[^\/])(\.[^.]+)$/
172
+ result << $1
173
+ else
174
+ result << self
175
+ end
176
+ when '%p'
177
+ result << self
178
+ when '%s'
179
+ result << (File::ALT_SEPARATOR || File::SEPARATOR)
180
+ when '%-'
181
+ # do nothing
182
+ when '%%'
183
+ result << "%"
184
+ when /%(-?\d+)d/
185
+ result << pathmap_partial($1.to_i)
186
+ when /^%\{([^}]*)\}(\d*[dpfnxX])/
187
+ patterns, operator = $1, $2
188
+ result << pathmap('%' + operator).pathmap_replace(patterns, &block)
189
+ when /^%/
190
+ fail ArgumentError, "Unknown pathmap specifier #{frag} in '#{spec}'"
191
+ else
192
+ result << frag
193
+ end
194
+ end
195
+ result
196
+ end
197
+ end
198
+ end # class String