trackman 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (309) hide show
  1. data/.gitignore +4 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +5 -0
  4. data/Gemfile.lock +49 -0
  5. data/LICENSE +17 -0
  6. data/README.md +96 -0
  7. data/Rakefile +52 -0
  8. data/lib/tasks.rb +7 -0
  9. data/lib/trackman/assets/asset.rb +97 -0
  10. data/lib/trackman/assets/components/asset_factory.rb +41 -0
  11. data/lib/trackman/assets/components/asset_factory.rb.orig +54 -0
  12. data/lib/trackman/assets/components/composite_asset.rb +39 -0
  13. data/lib/trackman/assets/components/conventions.rb +23 -0
  14. data/lib/trackman/assets/components/diffable.rb +29 -0
  15. data/lib/trackman/assets/components/hashable.rb +30 -0
  16. data/lib/trackman/assets/components/path_resolver.rb +34 -0
  17. data/lib/trackman/assets/components/rails32_path_resolver.rb +49 -0
  18. data/lib/trackman/assets/components/rails_path_resolver.rb +34 -0
  19. data/lib/trackman/assets/components/shippable.rb +31 -0
  20. data/lib/trackman/assets/components.rb +11 -0
  21. data/lib/trackman/assets/css_asset.rb +11 -0
  22. data/lib/trackman/assets/errors/asset_not_found_error.rb +8 -0
  23. data/lib/trackman/assets/errors/config_not_found_error.rb +8 -0
  24. data/lib/trackman/assets/errors.rb +10 -0
  25. data/lib/trackman/assets/html_asset.rb +30 -0
  26. data/lib/trackman/assets/remote_asset.rb +72 -0
  27. data/lib/trackman/assets.rb +37 -0
  28. data/lib/trackman/rack_middleware.rb +12 -0
  29. data/lib/trackman/railtie.rb +7 -0
  30. data/lib/trackman/version.rb +3 -0
  31. data/lib/trackman.rb +34 -0
  32. data/rails_generators/trackman/templates/trackman.rake +59 -0
  33. data/rails_generators/trackman/trackman_generator.rb +8 -0
  34. data/spec/asset_all_spec.rb +136 -0
  35. data/spec/asset_factory_spec.rb +70 -0
  36. data/spec/asset_spec.rb +99 -0
  37. data/spec/composite_asset_spec.rb +12 -0
  38. data/spec/css_asset_spec.rb +39 -0
  39. data/spec/diffable_spec.rb +57 -0
  40. data/spec/fixtures/rails2311/fully-loaded/README +243 -0
  41. data/spec/fixtures/rails2311/fully-loaded/Rakefile +10 -0
  42. data/spec/fixtures/rails2311/fully-loaded/app/controllers/application_controller.rb +10 -0
  43. data/spec/fixtures/rails2311/fully-loaded/app/helpers/application_helper.rb +3 -0
  44. data/spec/fixtures/rails2311/fully-loaded/config/boot.rb +114 -0
  45. data/spec/fixtures/rails2311/fully-loaded/config/database.yml +22 -0
  46. data/spec/fixtures/rails2311/fully-loaded/config/environment.rb +41 -0
  47. data/spec/fixtures/rails2311/fully-loaded/config/environments/development.rb +17 -0
  48. data/spec/fixtures/rails2311/fully-loaded/config/environments/production.rb +28 -0
  49. data/spec/fixtures/rails2311/fully-loaded/config/environments/test.rb +28 -0
  50. data/spec/fixtures/rails2311/fully-loaded/config/initializers/backtrace_silencers.rb +7 -0
  51. data/spec/fixtures/rails2311/fully-loaded/config/initializers/cookie_verification_secret.rb +7 -0
  52. data/spec/fixtures/rails2311/fully-loaded/config/initializers/inflections.rb +10 -0
  53. data/spec/fixtures/rails2311/fully-loaded/config/initializers/mime_types.rb +5 -0
  54. data/spec/fixtures/rails2311/fully-loaded/config/initializers/new_rails_defaults.rb +21 -0
  55. data/spec/fixtures/rails2311/fully-loaded/config/initializers/session_store.rb +15 -0
  56. data/spec/fixtures/rails2311/fully-loaded/config/locales/en.yml +5 -0
  57. data/spec/fixtures/rails2311/fully-loaded/config/routes.rb +43 -0
  58. data/spec/fixtures/rails2311/fully-loaded/db/seeds.rb +7 -0
  59. data/spec/fixtures/rails2311/fully-loaded/doc/README_FOR_APP +2 -0
  60. data/spec/fixtures/rails2311/fully-loaded/log/development.log +0 -0
  61. data/spec/fixtures/rails2311/fully-loaded/log/production.log +0 -0
  62. data/spec/fixtures/rails2311/fully-loaded/log/server.log +0 -0
  63. data/spec/fixtures/rails2311/fully-loaded/log/test.log +0 -0
  64. data/spec/fixtures/rails2311/fully-loaded/public/404.html +30 -0
  65. data/spec/fixtures/rails2311/fully-loaded/public/422.html +30 -0
  66. data/spec/fixtures/rails2311/fully-loaded/public/500.html +30 -0
  67. data/spec/fixtures/rails2311/fully-loaded/public/503-error.html +24 -0
  68. data/spec/fixtures/rails2311/fully-loaded/public/503-error.html~ +24 -0
  69. data/spec/fixtures/rails2311/fully-loaded/public/503.html +275 -0
  70. data/spec/fixtures/rails2311/fully-loaded/public/503.html~ +275 -0
  71. data/spec/fixtures/rails2311/fully-loaded/public/favicon.ico +0 -0
  72. data/spec/fixtures/rails2311/fully-loaded/public/images/rails.png +0 -0
  73. data/spec/fixtures/rails2311/fully-loaded/public/index.html +275 -0
  74. data/spec/fixtures/rails2311/fully-loaded/public/javascripts/application.js +2 -0
  75. data/spec/fixtures/rails2311/fully-loaded/public/javascripts/controls.js +963 -0
  76. data/spec/fixtures/rails2311/fully-loaded/public/javascripts/dragdrop.js +973 -0
  77. data/spec/fixtures/rails2311/fully-loaded/public/javascripts/effects.js +1128 -0
  78. data/spec/fixtures/rails2311/fully-loaded/public/javascripts/prototype.js +4320 -0
  79. data/spec/fixtures/rails2311/fully-loaded/public/robots.txt +5 -0
  80. data/spec/fixtures/rails2311/fully-loaded/public/stylesheets/application.css +13 -0
  81. data/spec/fixtures/rails2311/fully-loaded/public/stylesheets/some-other-css.css +3 -0
  82. data/spec/fixtures/rails2311/fully-loaded/public/stylesheets/sub-css/sub-css.css +1 -0
  83. data/spec/fixtures/rails2311/fully-loaded/script/about +4 -0
  84. data/spec/fixtures/rails2311/fully-loaded/script/console +3 -0
  85. data/spec/fixtures/rails2311/fully-loaded/script/dbconsole +3 -0
  86. data/spec/fixtures/rails2311/fully-loaded/script/destroy +3 -0
  87. data/spec/fixtures/rails2311/fully-loaded/script/generate +3 -0
  88. data/spec/fixtures/rails2311/fully-loaded/script/performance/benchmarker +3 -0
  89. data/spec/fixtures/rails2311/fully-loaded/script/performance/profiler +3 -0
  90. data/spec/fixtures/rails2311/fully-loaded/script/plugin +3 -0
  91. data/spec/fixtures/rails2311/fully-loaded/script/runner +3 -0
  92. data/spec/fixtures/rails2311/fully-loaded/script/server +3 -0
  93. data/spec/fixtures/rails2311/fully-loaded/test/performance/browsing_test.rb +9 -0
  94. data/spec/fixtures/rails2311/fully-loaded/test/test_helper.rb +38 -0
  95. data/spec/fixtures/rails2311/template/README +243 -0
  96. data/spec/fixtures/rails2311/template/Rakefile +10 -0
  97. data/spec/fixtures/rails2311/template/app/controllers/application_controller.rb +10 -0
  98. data/spec/fixtures/rails2311/template/app/helpers/application_helper.rb +3 -0
  99. data/spec/fixtures/rails2311/template/config/boot.rb +114 -0
  100. data/spec/fixtures/rails2311/template/config/database.yml +22 -0
  101. data/spec/fixtures/rails2311/template/config/environment.rb +41 -0
  102. data/spec/fixtures/rails2311/template/config/environments/development.rb +17 -0
  103. data/spec/fixtures/rails2311/template/config/environments/production.rb +28 -0
  104. data/spec/fixtures/rails2311/template/config/environments/test.rb +28 -0
  105. data/spec/fixtures/rails2311/template/config/initializers/backtrace_silencers.rb +7 -0
  106. data/spec/fixtures/rails2311/template/config/initializers/cookie_verification_secret.rb +7 -0
  107. data/spec/fixtures/rails2311/template/config/initializers/inflections.rb +10 -0
  108. data/spec/fixtures/rails2311/template/config/initializers/mime_types.rb +5 -0
  109. data/spec/fixtures/rails2311/template/config/initializers/new_rails_defaults.rb +21 -0
  110. data/spec/fixtures/rails2311/template/config/initializers/session_store.rb +15 -0
  111. data/spec/fixtures/rails2311/template/config/locales/en.yml +5 -0
  112. data/spec/fixtures/rails2311/template/config/routes.rb +43 -0
  113. data/spec/fixtures/rails2311/template/db/seeds.rb +7 -0
  114. data/spec/fixtures/rails2311/template/doc/README_FOR_APP +2 -0
  115. data/spec/fixtures/rails2311/template/log/development.log +0 -0
  116. data/spec/fixtures/rails2311/template/log/production.log +0 -0
  117. data/spec/fixtures/rails2311/template/log/server.log +0 -0
  118. data/spec/fixtures/rails2311/template/log/test.log +0 -0
  119. data/spec/fixtures/rails2311/template/public/404.html +30 -0
  120. data/spec/fixtures/rails2311/template/public/422.html +30 -0
  121. data/spec/fixtures/rails2311/template/public/500.html +30 -0
  122. data/spec/fixtures/rails2311/template/public/favicon.ico +0 -0
  123. data/spec/fixtures/rails2311/template/public/images/rails.png +0 -0
  124. data/spec/fixtures/rails2311/template/public/index.html +275 -0
  125. data/spec/fixtures/rails2311/template/public/javascripts/application.js +2 -0
  126. data/spec/fixtures/rails2311/template/public/javascripts/controls.js +963 -0
  127. data/spec/fixtures/rails2311/template/public/javascripts/dragdrop.js +973 -0
  128. data/spec/fixtures/rails2311/template/public/javascripts/effects.js +1128 -0
  129. data/spec/fixtures/rails2311/template/public/javascripts/prototype.js +4320 -0
  130. data/spec/fixtures/rails2311/template/public/robots.txt +5 -0
  131. data/spec/fixtures/rails2311/template/script/about +4 -0
  132. data/spec/fixtures/rails2311/template/script/console +3 -0
  133. data/spec/fixtures/rails2311/template/script/dbconsole +3 -0
  134. data/spec/fixtures/rails2311/template/script/destroy +3 -0
  135. data/spec/fixtures/rails2311/template/script/generate +3 -0
  136. data/spec/fixtures/rails2311/template/script/performance/benchmarker +3 -0
  137. data/spec/fixtures/rails2311/template/script/performance/profiler +3 -0
  138. data/spec/fixtures/rails2311/template/script/plugin +3 -0
  139. data/spec/fixtures/rails2311/template/script/runner +3 -0
  140. data/spec/fixtures/rails2311/template/script/server +3 -0
  141. data/spec/fixtures/rails2311/template/test/performance/browsing_test.rb +9 -0
  142. data/spec/fixtures/rails2311/template/test/test_helper.rb +38 -0
  143. data/spec/fixtures/rails32/clean-install/.gitignore +15 -0
  144. data/spec/fixtures/rails32/clean-install/Gemfile +38 -0
  145. data/spec/fixtures/rails32/clean-install/README.rdoc +261 -0
  146. data/spec/fixtures/rails32/clean-install/Rakefile +7 -0
  147. data/spec/fixtures/rails32/clean-install/app/assets/images/rails.png +0 -0
  148. data/spec/fixtures/rails32/clean-install/app/assets/javascripts/application.js +15 -0
  149. data/spec/fixtures/rails32/clean-install/app/assets/stylesheets/application.css +13 -0
  150. data/spec/fixtures/rails32/clean-install/app/controllers/application_controller.rb +3 -0
  151. data/spec/fixtures/rails32/clean-install/app/helpers/application_helper.rb +2 -0
  152. data/spec/fixtures/rails32/clean-install/app/mailers/.gitkeep +0 -0
  153. data/spec/fixtures/rails32/clean-install/app/models/.gitkeep +0 -0
  154. data/spec/fixtures/rails32/clean-install/app/views/layouts/application.html.erb +14 -0
  155. data/spec/fixtures/rails32/clean-install/config/application.rb +59 -0
  156. data/spec/fixtures/rails32/clean-install/config/boot.rb +6 -0
  157. data/spec/fixtures/rails32/clean-install/config/database.yml +25 -0
  158. data/spec/fixtures/rails32/clean-install/config/environment.rb +5 -0
  159. data/spec/fixtures/rails32/clean-install/config/environments/development.rb +37 -0
  160. data/spec/fixtures/rails32/clean-install/config/environments/production.rb +67 -0
  161. data/spec/fixtures/rails32/clean-install/config/environments/test.rb +37 -0
  162. data/spec/fixtures/rails32/clean-install/config/initializers/backtrace_silencers.rb +7 -0
  163. data/spec/fixtures/rails32/clean-install/config/initializers/inflections.rb +15 -0
  164. data/spec/fixtures/rails32/clean-install/config/initializers/mime_types.rb +5 -0
  165. data/spec/fixtures/rails32/clean-install/config/initializers/secret_token.rb +7 -0
  166. data/spec/fixtures/rails32/clean-install/config/initializers/session_store.rb +8 -0
  167. data/spec/fixtures/rails32/clean-install/config/initializers/wrap_parameters.rb +14 -0
  168. data/spec/fixtures/rails32/clean-install/config/locales/en.yml +5 -0
  169. data/spec/fixtures/rails32/clean-install/config/routes.rb +58 -0
  170. data/spec/fixtures/rails32/clean-install/config.ru +4 -0
  171. data/spec/fixtures/rails32/clean-install/db/seeds.rb +7 -0
  172. data/spec/fixtures/rails32/clean-install/doc/README_FOR_APP +2 -0
  173. data/spec/fixtures/rails32/clean-install/lib/assets/.gitkeep +0 -0
  174. data/spec/fixtures/rails32/clean-install/lib/tasks/.gitkeep +0 -0
  175. data/spec/fixtures/rails32/clean-install/log/.gitkeep +0 -0
  176. data/spec/fixtures/rails32/clean-install/public/404.html +26 -0
  177. data/spec/fixtures/rails32/clean-install/public/422.html +26 -0
  178. data/spec/fixtures/rails32/clean-install/public/500.html +25 -0
  179. data/spec/fixtures/rails32/clean-install/public/favicon.ico +0 -0
  180. data/spec/fixtures/rails32/clean-install/public/index.html +241 -0
  181. data/spec/fixtures/rails32/clean-install/public/robots.txt +5 -0
  182. data/spec/fixtures/rails32/clean-install/script/rails +6 -0
  183. data/spec/fixtures/rails32/clean-install/test/fixtures/.gitkeep +0 -0
  184. data/spec/fixtures/rails32/clean-install/test/functional/.gitkeep +0 -0
  185. data/spec/fixtures/rails32/clean-install/test/integration/.gitkeep +0 -0
  186. data/spec/fixtures/rails32/clean-install/test/performance/browsing_test.rb +12 -0
  187. data/spec/fixtures/rails32/clean-install/test/test_helper.rb +13 -0
  188. data/spec/fixtures/rails32/clean-install/test/unit/.gitkeep +0 -0
  189. data/spec/fixtures/rails32/clean-install/vendor/assets/javascripts/.gitkeep +0 -0
  190. data/spec/fixtures/rails32/clean-install/vendor/assets/stylesheets/.gitkeep +0 -0
  191. data/spec/fixtures/rails32/clean-install/vendor/plugins/.gitkeep +0 -0
  192. data/spec/fixtures/rails32/fully-loaded/Gemfile +37 -0
  193. data/spec/fixtures/rails32/fully-loaded/README.rdoc +261 -0
  194. data/spec/fixtures/rails32/fully-loaded/Rakefile +7 -0
  195. data/spec/fixtures/rails32/fully-loaded/app/assets/images/rails.png +0 -0
  196. data/spec/fixtures/rails32/fully-loaded/app/assets/images/riding-you.jpg +0 -0
  197. data/spec/fixtures/rails32/fully-loaded/app/assets/javascripts/application.js +16 -0
  198. data/spec/fixtures/rails32/fully-loaded/app/assets/stylesheets/application.css +13 -0
  199. data/spec/fixtures/rails32/fully-loaded/app/assets/stylesheets/some-other-css.css +3 -0
  200. data/spec/fixtures/rails32/fully-loaded/app/assets/stylesheets/sub-css/sub-css.css +1 -0
  201. data/spec/fixtures/rails32/fully-loaded/app/controllers/application_controller.rb +3 -0
  202. data/spec/fixtures/rails32/fully-loaded/app/helpers/application_helper.rb +2 -0
  203. data/spec/fixtures/rails32/fully-loaded/app/views/layouts/application.html.erb +14 -0
  204. data/spec/fixtures/rails32/fully-loaded/config/application.rb +65 -0
  205. data/spec/fixtures/rails32/fully-loaded/config/boot.rb +6 -0
  206. data/spec/fixtures/rails32/fully-loaded/config/environment.rb +5 -0
  207. data/spec/fixtures/rails32/fully-loaded/config/environments/development.rb +31 -0
  208. data/spec/fixtures/rails32/fully-loaded/config/environments/production.rb +64 -0
  209. data/spec/fixtures/rails32/fully-loaded/config/environments/test.rb +35 -0
  210. data/spec/fixtures/rails32/fully-loaded/config/initializers/backtrace_silencers.rb +7 -0
  211. data/spec/fixtures/rails32/fully-loaded/config/initializers/inflections.rb +15 -0
  212. data/spec/fixtures/rails32/fully-loaded/config/initializers/mime_types.rb +5 -0
  213. data/spec/fixtures/rails32/fully-loaded/config/initializers/secret_token.rb +7 -0
  214. data/spec/fixtures/rails32/fully-loaded/config/initializers/session_store.rb +8 -0
  215. data/spec/fixtures/rails32/fully-loaded/config/initializers/wrap_parameters.rb +10 -0
  216. data/spec/fixtures/rails32/fully-loaded/config/locales/en.yml +5 -0
  217. data/spec/fixtures/rails32/fully-loaded/config/routes.rb +58 -0
  218. data/spec/fixtures/rails32/fully-loaded/config.ru +4 -0
  219. data/spec/fixtures/rails32/fully-loaded/db/seeds.rb +7 -0
  220. data/spec/fixtures/rails32/fully-loaded/doc/README_FOR_APP +2 -0
  221. data/spec/fixtures/rails32/fully-loaded/public/404.html +26 -0
  222. data/spec/fixtures/rails32/fully-loaded/public/422.html +26 -0
  223. data/spec/fixtures/rails32/fully-loaded/public/500.html +25 -0
  224. data/spec/fixtures/rails32/fully-loaded/public/503-error.html +25 -0
  225. data/spec/fixtures/rails32/fully-loaded/public/503.html +13 -0
  226. data/spec/fixtures/rails32/fully-loaded/public/favicon.ico +0 -0
  227. data/spec/fixtures/rails32/fully-loaded/public/index.html +241 -0
  228. data/spec/fixtures/rails32/fully-loaded/public/robots.txt +5 -0
  229. data/spec/fixtures/rails32/fully-loaded/script/rails +6 -0
  230. data/spec/fixtures/rails32/happy-path/Gemfile +37 -0
  231. data/spec/fixtures/rails32/happy-path/README.rdoc +261 -0
  232. data/spec/fixtures/rails32/happy-path/Rakefile +7 -0
  233. data/spec/fixtures/rails32/happy-path/app/assets/images/rails.png +0 -0
  234. data/spec/fixtures/rails32/happy-path/app/assets/javascripts/application.js +15 -0
  235. data/spec/fixtures/rails32/happy-path/app/assets/stylesheets/application.css +13 -0
  236. data/spec/fixtures/rails32/happy-path/app/controllers/application_controller.rb +3 -0
  237. data/spec/fixtures/rails32/happy-path/app/helpers/application_helper.rb +2 -0
  238. data/spec/fixtures/rails32/happy-path/app/views/layouts/application.html.erb +14 -0
  239. data/spec/fixtures/rails32/happy-path/config/application.rb +65 -0
  240. data/spec/fixtures/rails32/happy-path/config/boot.rb +6 -0
  241. data/spec/fixtures/rails32/happy-path/config/environment.rb +5 -0
  242. data/spec/fixtures/rails32/happy-path/config/environments/development.rb +31 -0
  243. data/spec/fixtures/rails32/happy-path/config/environments/production.rb +64 -0
  244. data/spec/fixtures/rails32/happy-path/config/environments/test.rb +35 -0
  245. data/spec/fixtures/rails32/happy-path/config/initializers/backtrace_silencers.rb +7 -0
  246. data/spec/fixtures/rails32/happy-path/config/initializers/inflections.rb +15 -0
  247. data/spec/fixtures/rails32/happy-path/config/initializers/mime_types.rb +5 -0
  248. data/spec/fixtures/rails32/happy-path/config/initializers/secret_token.rb +7 -0
  249. data/spec/fixtures/rails32/happy-path/config/initializers/session_store.rb +8 -0
  250. data/spec/fixtures/rails32/happy-path/config/initializers/wrap_parameters.rb +10 -0
  251. data/spec/fixtures/rails32/happy-path/config/locales/en.yml +5 -0
  252. data/spec/fixtures/rails32/happy-path/config/routes.rb +58 -0
  253. data/spec/fixtures/rails32/happy-path/config.ru +4 -0
  254. data/spec/fixtures/rails32/happy-path/db/seeds.rb +7 -0
  255. data/spec/fixtures/rails32/happy-path/doc/README_FOR_APP +2 -0
  256. data/spec/fixtures/rails32/happy-path/public/404.html +26 -0
  257. data/spec/fixtures/rails32/happy-path/public/422.html +26 -0
  258. data/spec/fixtures/rails32/happy-path/public/500.html +25 -0
  259. data/spec/fixtures/rails32/happy-path/public/503-error.html +12 -0
  260. data/spec/fixtures/rails32/happy-path/public/503.html +11 -0
  261. data/spec/fixtures/rails32/happy-path/public/favicon.ico +0 -0
  262. data/spec/fixtures/rails32/happy-path/public/index.html +241 -0
  263. data/spec/fixtures/rails32/happy-path/public/robots.txt +5 -0
  264. data/spec/fixtures/rails32/happy-path/script/rails +6 -0
  265. data/spec/helpers/app_creator.rb +28 -0
  266. data/spec/helpers/fakable_pathman_tester.rb +117 -0
  267. data/spec/html_asset_spec.rb +51 -0
  268. data/spec/path_spec.rb +6 -0
  269. data/spec/paths/fakable_pathman_tester_spec.rb +36 -0
  270. data/spec/paths/pathman_spec.rb +64 -0
  271. data/spec/paths/rails32_pathman_spec.rb +80 -0
  272. data/spec/rails2311/first_push_spec.rb +29 -0
  273. data/spec/rails32/first_push_spec.rb +76 -0
  274. data/spec/remote_asset_spec.rb +80 -0
  275. data/spec/shippable_spec.rb +79 -0
  276. data/spec/spec_helper.rb +22 -0
  277. data/spec/sync_spec.rb +85 -0
  278. data/spec/test_data/a.js +3 -0
  279. data/spec/test_data/all/1.css +4 -0
  280. data/spec/test_data/all/2.gif +0 -0
  281. data/spec/test_data/all/3.js +3 -0
  282. data/spec/test_data/all/all.html +8 -0
  283. data/spec/test_data/all/all2.html +7 -0
  284. data/spec/test_data/all/all3.html +8 -0
  285. data/spec/test_data/b.js +1 -0
  286. data/spec/test_data/c.js +5 -0
  287. data/spec/test_data/css/image/riding-you.jpg +0 -0
  288. data/spec/test_data/css/image/with-image.css +24 -0
  289. data/spec/test_data/css/imported-loop1.css +25 -0
  290. data/spec/test_data/css/imported-loop2.css +25 -0
  291. data/spec/test_data/css/imported.css +13 -0
  292. data/spec/test_data/css/imported2.css +13 -0
  293. data/spec/test_data/css/recursive/html-with-css.html +40 -0
  294. data/spec/test_data/css/recursive/imported-lvl2.css +25 -0
  295. data/spec/test_data/css/recursive/imported-lvl3.css +24 -0
  296. data/spec/test_data/css/recursive/imported-recursive.css +25 -0
  297. data/spec/test_data/css/recursive/riding-you.jpg +0 -0
  298. data/spec/test_data/css/with-asset.css +25 -0
  299. data/spec/test_data/css/with-multiple-assets.css +26 -0
  300. data/spec/test_data/external_paths/1.css +4 -0
  301. data/spec/test_data/external_paths/1.html +9 -0
  302. data/spec/test_data/sample.html +15 -0
  303. data/spec/test_data/test1.jpeg +0 -0
  304. data/spec/test_data/test2.png +0 -0
  305. data/spec/test_data/test3.gif +0 -0
  306. data/spec/test_data/y.css +1 -0
  307. data/spec/test_data/z.css +3 -0
  308. data/trackman.gemspec +27 -0
  309. metadata +437 -0
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "heroku", ">= 2.26.2"
data/Gemfile.lock ADDED
@@ -0,0 +1,49 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ trackman (0.0.5)
5
+ json
6
+ nokogiri
7
+ rack
8
+ rest-client
9
+
10
+ GEM
11
+ remote: http://rubygems.org/
12
+ specs:
13
+ addressable (2.2.8)
14
+ diff-lcs (1.1.3)
15
+ excon (0.14.0)
16
+ heroku (2.26.6)
17
+ heroku-api (~> 0.2.4)
18
+ launchy (>= 0.3.2)
19
+ netrc (~> 0.7.2)
20
+ rest-client (~> 1.6.1)
21
+ rubyzip
22
+ heroku-api (0.2.4)
23
+ excon (~> 0.14.0)
24
+ json (1.7.3)
25
+ launchy (2.1.0)
26
+ addressable (~> 2.2.6)
27
+ mime-types (1.18)
28
+ netrc (0.7.4)
29
+ nokogiri (1.5.3)
30
+ rack (1.4.1)
31
+ rest-client (1.6.7)
32
+ mime-types (>= 1.16)
33
+ rspec (2.10.0)
34
+ rspec-core (~> 2.10.0)
35
+ rspec-expectations (~> 2.10.0)
36
+ rspec-mocks (~> 2.10.0)
37
+ rspec-core (2.10.1)
38
+ rspec-expectations (2.10.0)
39
+ diff-lcs (~> 1.1.3)
40
+ rspec-mocks (2.10.1)
41
+ rubyzip (0.9.8)
42
+
43
+ PLATFORMS
44
+ ruby
45
+
46
+ DEPENDENCIES
47
+ heroku (>= 2.26.2)
48
+ rspec
49
+ trackman!
data/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ Copyright (c) 2012 Fabre Jeremy and Petre Emanuel
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this
4
+ software and associated documentation files (the "Software"), to deal in the Software
5
+ without restriction, including without limitation the rights to use, copy, modify, merge,
6
+ publish, distribute, sublicense, and/or sell copies of the Software, and to permit
7
+ persons to whom the Software is furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or
10
+ substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15
+ FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17
+ DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # Trackman
2
+
3
+ Trackman is a Heroku add-on that enables you to handle your maintenance and error pages with the rest of your app and hosts the production version of those files in the cloud when you deploy.
4
+
5
+ * It works with rails-like conventions.
6
+ * It is rack-based.
7
+ * It will push your pages and all their internal assets upon application initialization.
8
+
9
+ ## Information
10
+
11
+ ### Platform support
12
+
13
+ Trackman works out of the box for Ruby(1.8.7 and 1.9.3) on
14
+
15
+ * Rails 2
16
+ * Rails 3
17
+
18
+
19
+ ## Getting started
20
+ ### Step 1 - Install the heroku add-on
21
+ ```console
22
+ heroku addons:add trackman
23
+ ```
24
+ ### Step 2 - Add the client gem to your Gemfile
25
+ ```console
26
+ gem 'trackman'
27
+ ```
28
+
29
+ ##### Step 2.1 - Rails 2 only
30
+ ```console
31
+ ./script/generate trackman
32
+ ```
33
+ This will add trackman.rake to lib/tasks/
34
+
35
+ ### Step 3 - Setup
36
+ ```console
37
+ rake trackman:setup
38
+ ```
39
+ Sets up your initial configuration and add custom error page add-on if you don't have it yet.
40
+
41
+ ### Optional
42
+ ```console
43
+ rake trackman:sync
44
+ ```
45
+ Performs a manual sync of your error/maintenance pages and their related assets.
46
+ This normally gets executed everytime you deploy to heroku.
47
+
48
+ ### For best results, make sure you have those installed:
49
+ * Heroku >= 2.26.2
50
+ * Bundler >= 1.1.3
51
+
52
+ ### Notes
53
+ By convention, we assume your maintenance page is located at
54
+
55
+ ```console
56
+ public/503.html
57
+ ```
58
+
59
+ If you want two different pages for maintenance and when your app is down, we expect:
60
+
61
+ For maintenance
62
+ ```console
63
+ public/503.html
64
+ ```
65
+ Broken app
66
+ ```console
67
+ public/503-error.html
68
+ ```
69
+
70
+ After the add-on installation
71
+
72
+ * On the first publish or manual sync, your html file(s) and every internal assets referenced by your pages(s) will be pushed to our server so that we can store them properly on S3.
73
+ * On the next publications, only modified assets will be published.
74
+ * Any renamed or missing asset will be handled properly on our side.
75
+
76
+ ### Bug reports
77
+
78
+ Any bug report can be submitted here.
79
+ https://github.com/jfabre/trackman/issues
80
+
81
+
82
+ ### Creators / Maintainers
83
+
84
+ * Jeremy Fabre (https://github.com/jfabre)
85
+ * Emanuel Petre (https://github.com/epetre)
86
+
87
+ ###Copyright
88
+
89
+ Copyright © 2012 Emanuel Petre, Jeremy Fabre
90
+
91
+ ## License
92
+
93
+ Trackman is released under the MIT license:
94
+
95
+ [LICENSE](https://github.com/jfabre/trackman/blob/master/LICENSE)
96
+
data/Rakefile ADDED
@@ -0,0 +1,52 @@
1
+ require "bundler/gem_tasks"
2
+
3
+
4
+ desc "creates a new app to the server and outputs the credentials"
5
+ task :create_app do
6
+ require 'trackman'
7
+ RemoteAsset = Trackman::Assets::RemoteAsset
8
+
9
+ user = ENV['HEROKU_USERNAME']
10
+ pass = ENV['HEROKU_PASSWORD']
11
+ server = RemoteAsset.class_variable_get :@@server
12
+
13
+ url = "http://#{user}:#{pass}@#{server}/heroku/resources"
14
+ puts "\nPosting on : #{url}\n\n"
15
+ response = RestClient.post url, :plan => 'test', :heroku_id => 123
16
+ json = JSON.parse response
17
+
18
+ puts "export TRACKMAN_USER=#{json['config']['TRACKMAN_USER']}"
19
+ puts "export TRACKMAN_PASSWORD=#{json['config']['TRACKMAN_PASSWORD']}"
20
+ puts "export TRACKMAN_APP_ID=#{json['id']}\n\n"
21
+
22
+ puts "Have fun!"
23
+ end
24
+
25
+ namespace :setup do
26
+ namespace :rails32 do
27
+ desc "runs rails new for a given name and removes useless files"
28
+ task :fixture, :name do |t, args|
29
+ name = response = args[:name]
30
+ puts "rails _3.2.0_ new spec/fixtures/rails32/#{name} -G -O -T"
31
+ `rails _3.2.0_ new spec/fixtures/rails32/#{name} -G -O -T`
32
+ end
33
+ end
34
+
35
+ namespace :rails309 do
36
+ desc "runs rails new for a given name and removes useless files"
37
+ task :fixture, :name do |t, args|
38
+ name = response = args[:name]
39
+ puts "rails _3.0.9_ new spec/fixtures/rails309/#{name} -G -O -T"
40
+ `rails _3.0.9_ new spec/fixtures/rails309/#{name} -G -O -T`
41
+ end
42
+ end
43
+
44
+ namespace :rails2311 do
45
+ desc "runs rails new for a given name and removes useless files"
46
+ task :fixture, :name do |t, args|
47
+ name = response = args[:name]
48
+ puts "cp spec/fixtures/rails2311/template spec/fixtures/rails2311/#{name}"
49
+ `cp -r spec/fixtures/rails2311/template spec/fixtures/rails2311/#{name}`
50
+ end
51
+ end
52
+ end
data/lib/tasks.rb ADDED
@@ -0,0 +1,7 @@
1
+ if defined?(Rails) && ::Rails::VERSION::STRING =~ /^[3-9]\.[1-9]/
2
+ class Tasks < Rails::Railtie
3
+ rake_tasks do
4
+ Dir[File.join(File.dirname(__FILE__),'../rails_generators/trackman/templates/*.rake')].each { |f| load f }
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,97 @@
1
+ module Trackman
2
+ module Assets
3
+ class Asset
4
+ extend Components::AssetFactory
5
+ extend Components::Conventions
6
+ extend Components::Diffable
7
+ extend Components::Shippable
8
+ include Components::Hashable
9
+ include Comparable
10
+
11
+ def initialize attributes = {}
12
+ @assets = []
13
+ self.path = attributes[:path]
14
+ end
15
+
16
+ attr_reader :path, :assets
17
+
18
+ def to_remote
19
+ RemoteAsset.new(:path => @path)
20
+ end
21
+
22
+ def ==(other)
23
+ return false if other.nil?
24
+ other_path = other.path.is_a?(Pathname) ? other.path : Pathname.new(other.path)
25
+ other_path.to_s == path.to_s || path.realpath == other_path.realpath
26
+ end
27
+
28
+ def <=>(another)
29
+ result = 0
30
+
31
+ if self.path.extname == '.html' && another.path.extname == '.html'
32
+ result = self.path.to_s <=> another.path.to_s
33
+ elsif @path.extname == '.html' || another.path.extname == '.html'
34
+ result += 1 if self.path.extname == '.html'
35
+ result -= 1 if another.path.extname == '.html'
36
+ elsif is_child_of(another)
37
+ result += -1
38
+ elsif another.is_child_of(self)
39
+ result += 1
40
+ end
41
+
42
+ result
43
+ end
44
+
45
+ def is_child_of(parent)
46
+ parent.is_a?(Components::CompositeAsset) && parent.assets.include?(self)
47
+ end
48
+
49
+ def self.all
50
+ return [] unless maintenance_path.exist?
51
+
52
+ assets = [maintenance_page] + maintenance_page.assets
53
+ assets = assets + [error_page] + error_page.assets if error_path.exist?
54
+
55
+ assets.uniq{|a| a.path.realpath }.sort
56
+ end
57
+
58
+ def self.sync
59
+ local = Asset.all
60
+ remote = RemoteAsset.all
61
+ diff_result = diff(local, remote)
62
+ ship diff_result
63
+
64
+ true
65
+ end
66
+
67
+ def self.autosync
68
+ autosync = ENV['TRACKMAN_AUTOSYNC'] || true
69
+ autosync = autosync !~ /(0|false|FALSE)/ unless autosync.is_a? TrueClass
70
+ if const_defined?(:Rails)
71
+ autosync = autosync && Rails.env.production?
72
+ end
73
+
74
+ begin
75
+ return sync if autosync
76
+ rescue
77
+ return false
78
+ end
79
+ autosync
80
+ end
81
+
82
+ protected
83
+ def validate_path?
84
+ true
85
+ end
86
+ def path=(value)
87
+ value = Pathname.new value unless value.nil? || value.is_a?(Pathname)
88
+ if validate_path?
89
+ unless value && value.exist? && value.file?
90
+ raise Errors::AssetNotFoundError, "The path '#{value}' is invalid or is not a file"
91
+ end
92
+ end
93
+ @path = value
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,41 @@
1
+ module Trackman
2
+ module Assets
3
+ module Components
4
+ module AssetFactory
5
+ def create attributes = {}
6
+ path = attributes[:path]
7
+
8
+ if File.extname(path) == '.html'
9
+ parent = HtmlAsset
10
+ elsif File.extname(path) == '.css'
11
+ parent = CssAsset
12
+ else
13
+ parent = Asset
14
+ end
15
+
16
+ instance = parent.new attributes
17
+
18
+ if asset_pipeline_enabled?
19
+ instance.extend Rails32PathResolver
20
+ elsif rails_defined? #fallback to rails without asset pipeline
21
+ instance.extend RailsPathResolver
22
+ end
23
+
24
+ instance
25
+ end
26
+
27
+ def rails_defined?
28
+ Object.const_defined?(:Rails)
29
+ end
30
+
31
+ def asset_pipeline_enabled?
32
+ rails_defined? &&
33
+ Rails.respond_to?(:application) &&
34
+ Rails.application.respond_to?(:config) &&
35
+ Rails.application.config.respond_to?(:assets) &&
36
+ Rails.application.config.assets.enabled
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,54 @@
1
+ module Trackman
2
+ module Assets
3
+ module Components
4
+ module AssetFactory
5
+ def create attributes = {}
6
+ path = attributes[:path]
7
+
8
+ if File.extname(path) == '.html'
9
+ parent = HtmlAsset
10
+ elsif File.extname(path) == '.css'
11
+ parent = CssAsset
12
+ else
13
+ parent = Asset
14
+ end
15
+
16
+ instance = parent.new attributes
17
+ <<<<<<< HEAD
18
+ instance.extend Rails32PathResolver if asset_pipeline_enabled?
19
+ instance
20
+ end
21
+
22
+ def rails_defined?
23
+ const_defined? :Rails
24
+ =======
25
+
26
+ if uses_rails32?
27
+ instance.extend Rails32PathResolver
28
+ elsif uses_rails? #fallback to rails without asset pipeline
29
+ instance.extend RailsPathResolver
30
+ end
31
+
32
+ instance
33
+ end
34
+
35
+ def uses_rails?
36
+ const_defined?(:Rails)
37
+ end
38
+
39
+ def uses_rails32?
40
+ uses_rails? && ::Rails::VERSION::STRING =~ /^[3-9]\.[1-9]/
41
+ >>>>>>> c8c05bfdca05b2ee989fd7040676cebe6f2f2b88
42
+ end
43
+
44
+ def asset_pipeline_enabled?
45
+ rails_defined? &&
46
+ Rails.respond_to?(:application) &&
47
+ Rails.application.respond_to?(:config) &&
48
+ Rails.application.config.respond_to?(:assets) &&
49
+ Rails.application.config.assets.enabled
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,39 @@
1
+ module Trackman
2
+ module Assets
3
+ module Components
4
+ module CompositeAsset
5
+
6
+ def self.included(mod)
7
+ mod.send(:include, PathResolver)
8
+ end
9
+ def self.extended(mod)
10
+ mod.send(:extend, PathResolver)
11
+ end
12
+
13
+ def assets
14
+ result = children_paths.select{|p| p.internal_path? }.inject([]) do |array, p|
15
+ asset = Asset.create(:path => translate(p, path))
16
+ array << asset
17
+ array.concat(asset.assets.select{|a| !array.include?(a) })
18
+ array
19
+ end
20
+
21
+ result
22
+ end
23
+
24
+ def inner_css_paths
25
+ @@url ||= /url\(['"]?([^'")]+)['"]?\)/
26
+ @@import ||= /url\(['"]?[^'"]+['"]?\)/
27
+
28
+ data.scan(@@import).collect{|x| @@url.match(x)[1] }
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ class String
36
+ def internal_path?
37
+ self !~ /^http/
38
+ end
39
+ end
@@ -0,0 +1,23 @@
1
+ module Trackman
2
+ module Assets
3
+ module Components
4
+ module Conventions
5
+ Asset = Trackman::Assets::Asset
6
+
7
+ def maintenance_path
8
+ Pathname.new 'public/503.html'
9
+ end
10
+ def error_path
11
+ Pathname.new 'public/503-error.html'
12
+ end
13
+ def maintenance_page
14
+ Asset.create(:path => maintenance_path)
15
+ end
16
+ def error_page
17
+ Asset.create(:path => error_path)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,29 @@
1
+ module Trackman
2
+ module Assets
3
+ module Components
4
+ module Diffable
5
+ def diff local, remote
6
+ to_create = local.select{|a| remote.all? { |s| a.path != s.path } }.map{|a| a.to_remote }.to_a
7
+ {
8
+ :create => to_create,
9
+ :update => remote.select{|a| local.any?{ |s| a.path == s.path && a.file_hash != s.file_hash }}.to_a,
10
+ :delete => define_deleted(local, remote) do |a|
11
+ to_create.any?{ |c| c.path.basename == a.path.basename }
12
+ end
13
+ }
14
+ end
15
+
16
+ private
17
+ # will not delete an html for now.
18
+ # this behaviour is to avoid the removal of the default templates.
19
+ def define_deleted local, remote
20
+ to_delete = remote.select do |a|
21
+ local.all? { |s| s.path != a.path }
22
+ end
23
+
24
+ to_delete.reject{|a| a.path.to_s =~ /.html$/ }.to_a
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,30 @@
1
+ require 'digest/md5'
2
+
3
+ module Trackman
4
+ module Assets
5
+ module Components
6
+ module Hashable
7
+
8
+ def data
9
+ @data ||= read_file
10
+ end
11
+
12
+ def file_hash
13
+ Digest::MD5.hexdigest(data)
14
+ end
15
+
16
+ protected
17
+ def read_file
18
+ begin
19
+ file = File.open(path)
20
+ return file.read
21
+ rescue
22
+ return nil
23
+ ensure
24
+ file.close
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,34 @@
1
+ module Trackman
2
+ module Assets
3
+ module Components
4
+ module PathResolver
5
+ def translate url, parent_url
6
+ raise "parent_url: #{parent_url} is required to be relative" if Pathname.new(parent_url).absolute?
7
+
8
+ url = Pathname.new(url) unless url.is_a? Pathname
9
+ parent_url = Pathname.new(parent_url) unless parent_url.is_a? Pathname
10
+
11
+ if url.relative?
12
+ parent = parent_of(parent_url)
13
+ child = url
14
+ else
15
+ parent = working_dir
16
+ s = url.to_s
17
+ child = Pathname.new(s[1...s.length])
18
+ end
19
+
20
+ (parent + child).relative_path_from(working_dir).to_s
21
+ end
22
+
23
+ def working_dir
24
+ Pathname.new Dir.pwd
25
+ end
26
+
27
+ def parent_of(url)
28
+ (working_dir + url).parent
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+
@@ -0,0 +1,49 @@
1
+ module Trackman
2
+ module Assets
3
+ module Components
4
+ module Rails32PathResolver
5
+ extend PathResolver
6
+
7
+ class << self
8
+ alias old_translate translate
9
+ alias old_parent_of parent_of
10
+
11
+ def parent_of(url)
12
+ if url.to_s.include?('assets')
13
+ old_parent_of(url).ascend do |p|
14
+ return p if p.basename.to_s == 'assets'
15
+ end
16
+ else
17
+ return old_parent_of(url)
18
+ end
19
+ end
20
+ end
21
+
22
+ def translate url, parent_url
23
+ path = Rails32PathResolver.old_translate(url, parent_url)
24
+ parts = path.split('/')
25
+ parts.insert(0, 'app') if parts.first == 'assets'
26
+
27
+ if parts.first == 'app' && parts[1] == 'assets'
28
+ parts.insert(2, subfolder(parts.last))
29
+ elsif parts.first != 'public'
30
+ parts.insert(0, 'public')
31
+ end
32
+
33
+ parts.join('/')
34
+ end
35
+
36
+ def subfolder(file)
37
+ if file.include?('.js')
38
+ subfolder = "javascripts"
39
+ elsif file.include?('.css')
40
+ subfolder = "stylesheets"
41
+ else
42
+ subfolder = "images"
43
+ end
44
+ subfolder
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,34 @@
1
+ module Trackman
2
+ module Assets
3
+ module Components
4
+ module RailsPathResolver
5
+
6
+ #way 2
7
+ extend PathResolver
8
+ class << self
9
+ alias old_translate translate
10
+ alias old_parent_of parent_of
11
+
12
+ def parent_of(url)
13
+ if url.to_s.include?('assets')
14
+ old_parent_of(url).ascend do |p|
15
+ return p if p.basename.to_s == 'assets'
16
+ end
17
+ else
18
+ return old_parent_of(url)
19
+ end
20
+ end
21
+ end
22
+
23
+ def translate url, parent_url
24
+ path = RailsPathResolver.old_translate(url, parent_url)
25
+
26
+ parts = path.split('/')
27
+ parts.insert(0, 'public') if parts.first != 'public'
28
+
29
+ parts.join('/')
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end