prosperity 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +31 -0
  4. data/app/assets/javascripts/prosperity/application.js.coffee +42 -0
  5. data/app/assets/stylesheets/prosperity/application.css.scss +19 -0
  6. data/app/controllers/prosperity/application_controller.rb +4 -0
  7. data/app/controllers/prosperity/metrics_controller.rb +9 -0
  8. data/app/helpers/prosperity/application_helper.rb +7 -0
  9. data/app/helpers/prosperity/metrics_helper.rb +11 -0
  10. data/app/views/layouts/prosperity/application.html.haml +37 -0
  11. data/app/views/prosperity/metrics/index.html.haml +7 -0
  12. data/config/routes.rb +5 -0
  13. data/db/migrate/20131026214127_test.rb +4 -0
  14. data/lib/prosperity/engine.rb +9 -0
  15. data/lib/prosperity/exception.rb +11 -0
  16. data/lib/prosperity/extractors/base.rb +11 -0
  17. data/lib/prosperity/extractors/count.rb +18 -0
  18. data/lib/prosperity/extractors/group.rb +23 -0
  19. data/lib/prosperity/metric.rb +48 -0
  20. data/lib/prosperity/metric_finder.rb +14 -0
  21. data/lib/prosperity/metrics/option.rb +9 -0
  22. data/lib/prosperity/metrics.rb +5 -0
  23. data/lib/prosperity/period.rb +11 -0
  24. data/lib/prosperity/periods.rb +6 -0
  25. data/lib/prosperity/version.rb +3 -0
  26. data/lib/prosperity.rb +4 -0
  27. data/lib/tasks/prosperity_tasks.rake +4 -0
  28. data/spec/controllers/prosperity/metrics_controller_spec.rb +14 -0
  29. data/spec/dummy/README.rdoc +28 -0
  30. data/spec/dummy/Rakefile +8 -0
  31. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  32. data/spec/dummy/app/assets/javascripts/users.js +2 -0
  33. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  34. data/spec/dummy/app/assets/stylesheets/scaffold.css +56 -0
  35. data/spec/dummy/app/assets/stylesheets/users.css +4 -0
  36. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  37. data/spec/dummy/app/controllers/users_controller.rb +58 -0
  38. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  39. data/spec/dummy/app/helpers/users_helper.rb +2 -0
  40. data/spec/dummy/app/models/user.rb +2 -0
  41. data/spec/dummy/app/prosperity/users_metric.rb +3 -0
  42. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  43. data/spec/dummy/app/views/users/_form.html.erb +25 -0
  44. data/spec/dummy/app/views/users/edit.html.erb +6 -0
  45. data/spec/dummy/app/views/users/index.html.erb +29 -0
  46. data/spec/dummy/app/views/users/new.html.erb +5 -0
  47. data/spec/dummy/app/views/users/show.html.erb +14 -0
  48. data/spec/dummy/bin/bundle +3 -0
  49. data/spec/dummy/bin/rails +4 -0
  50. data/spec/dummy/bin/rake +4 -0
  51. data/spec/dummy/config/application.rb +23 -0
  52. data/spec/dummy/config/boot.rb +5 -0
  53. data/spec/dummy/config/database.yml +24 -0
  54. data/spec/dummy/config/environment.rb +5 -0
  55. data/spec/dummy/config/environments/development.rb +29 -0
  56. data/spec/dummy/config/environments/production.rb +80 -0
  57. data/spec/dummy/config/environments/test.rb +36 -0
  58. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  59. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  60. data/spec/dummy/config/initializers/inflections.rb +16 -0
  61. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  62. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  63. data/spec/dummy/config/initializers/session_store.rb +3 -0
  64. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  65. data/spec/dummy/config/locales/en.yml +23 -0
  66. data/spec/dummy/config/routes.rb +6 -0
  67. data/spec/dummy/config.ru +4 -0
  68. data/spec/dummy/db/development.sqlite3 +0 -0
  69. data/spec/dummy/db/migrate/20131026214807_create_users.rb +10 -0
  70. data/spec/dummy/db/schema.rb +26 -0
  71. data/spec/dummy/db/seeds.rb +7 -0
  72. data/spec/dummy/db/test.sqlite3 +0 -0
  73. data/spec/dummy/log/development.log +18945 -0
  74. data/spec/dummy/log/test.log +1992 -0
  75. data/spec/dummy/public/404.html +58 -0
  76. data/spec/dummy/public/422.html +58 -0
  77. data/spec/dummy/public/500.html +57 -0
  78. data/spec/dummy/public/favicon.ico +0 -0
  79. data/spec/dummy/tmp/cache/assets/development/sass/34a577735054231563e7022ea73e1468db9203ba/application.css.scssc +0 -0
  80. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_alerts.scssc +0 -0
  81. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_badges.scssc +0 -0
  82. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_bootstrap.scssc +0 -0
  83. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_breadcrumbs.scssc +0 -0
  84. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_button-groups.scssc +0 -0
  85. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_buttons.scssc +0 -0
  86. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_carousel.scssc +0 -0
  87. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_close.scssc +0 -0
  88. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_code.scssc +0 -0
  89. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_component-animations.scssc +0 -0
  90. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_dropdowns.scssc +0 -0
  91. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_forms.scssc +0 -0
  92. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_glyphicons.scssc +0 -0
  93. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_grid.scssc +0 -0
  94. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_input-groups.scssc +0 -0
  95. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_jumbotron.scssc +0 -0
  96. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_labels.scssc +0 -0
  97. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_list-group.scssc +0 -0
  98. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_media.scssc +0 -0
  99. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_mixins.scssc +0 -0
  100. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_modals.scssc +0 -0
  101. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_navbar.scssc +0 -0
  102. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_navs.scssc +0 -0
  103. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_normalize.scssc +0 -0
  104. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_pager.scssc +0 -0
  105. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_pagination.scssc +0 -0
  106. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_panels.scssc +0 -0
  107. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_popovers.scssc +0 -0
  108. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_print.scssc +0 -0
  109. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_progress-bars.scssc +0 -0
  110. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_responsive-utilities.scssc +0 -0
  111. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_scaffolding.scssc +0 -0
  112. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_tables.scssc +0 -0
  113. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_thumbnails.scssc +0 -0
  114. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_tooltip.scssc +0 -0
  115. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_type.scssc +0 -0
  116. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_utilities.scssc +0 -0
  117. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_variables.scssc +0 -0
  118. data/spec/dummy/tmp/cache/assets/development/sass/994e9de37e7f58fef085c22ad997b3c9ce2a4b39/_wells.scssc +0 -0
  119. data/spec/dummy/tmp/cache/assets/development/sass/be34d2a735e9e523a3c8b9414be4508380964813/bootstrap.scssc +0 -0
  120. data/spec/dummy/tmp/cache/assets/development/sprockets/043337ddb7f545a88004b2eb2a069b4d +0 -0
  121. data/spec/dummy/tmp/cache/assets/development/sprockets/05ee6e5d8777628542d4ed27eab34c5a +0 -0
  122. data/spec/dummy/tmp/cache/assets/development/sprockets/07080bfb6d1d7b60d61990c547c0f47a +0 -0
  123. data/spec/dummy/tmp/cache/assets/development/sprockets/073948f1a0c619142ecfcb14a5806302 +0 -0
  124. data/spec/dummy/tmp/cache/assets/development/sprockets/07e8fb2db7d85e29590a6b05160ca825 +0 -0
  125. data/spec/dummy/tmp/cache/assets/development/sprockets/0800f54ee19cf3cee10b956fa9786799 +0 -0
  126. data/spec/dummy/tmp/cache/assets/development/sprockets/12eb9637e2c654371ecf7033d5a5cb36 +0 -0
  127. data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  128. data/spec/dummy/tmp/cache/assets/development/sprockets/1502b34f91cda1f4222490f78c0fea39 +0 -0
  129. data/spec/dummy/tmp/cache/assets/development/sprockets/1533bcf4a8f5a745dfda80cebd88d217 +0 -0
  130. data/spec/dummy/tmp/cache/assets/development/sprockets/177ca1f3e92db4f8a8f6e7ad9786ebfc +0 -0
  131. data/spec/dummy/tmp/cache/assets/development/sprockets/18d7d771937643bc7e9210b1a80e5763 +0 -0
  132. data/spec/dummy/tmp/cache/assets/development/sprockets/197492ed379339e17a0f5d01d3b01b8c +0 -0
  133. data/spec/dummy/tmp/cache/assets/development/sprockets/1c55cf24465f311353197ce336df0178 +0 -0
  134. data/spec/dummy/tmp/cache/assets/development/sprockets/1cb94582c835e73b3fd3c276f9a7de56 +0 -0
  135. data/spec/dummy/tmp/cache/assets/development/sprockets/203047a4141cf08162077e7290421bbb +0 -0
  136. data/spec/dummy/tmp/cache/assets/development/sprockets/210050da208fb75a75b701bfa4e8470f +0 -0
  137. data/spec/dummy/tmp/cache/assets/development/sprockets/29a6c93aeb91d07a5533b3adba7697d0 +0 -0
  138. data/spec/dummy/tmp/cache/assets/development/sprockets/29ac2be474969468157245a7f8737fa4 +0 -0
  139. data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  140. data/spec/dummy/tmp/cache/assets/development/sprockets/314e44d29ecc7449c9ca3b754329c245 +0 -0
  141. data/spec/dummy/tmp/cache/assets/development/sprockets/3162d1398d6940ee5e933b7ab4d2273d +0 -0
  142. data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  143. data/spec/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
  144. data/spec/dummy/tmp/cache/assets/development/sprockets/3d80e2a5faaf2bd987d804c17aead745 +0 -0
  145. data/spec/dummy/tmp/cache/assets/development/sprockets/4050a4e5062ab95c9f32e9b6940821ea +0 -0
  146. data/spec/dummy/tmp/cache/assets/development/sprockets/4155a156cc6ffb880b56dbc34346fbc0 +0 -0
  147. data/spec/dummy/tmp/cache/assets/development/sprockets/4166fe47cddf4ba18c53b843d69b4c5f +0 -0
  148. data/spec/dummy/tmp/cache/assets/development/sprockets/4432a4b71ce9551df8d4b3860f4b9be3 +0 -0
  149. data/spec/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
  150. data/spec/dummy/tmp/cache/assets/development/sprockets/5479c7b4fba9179d4d1dc59ae64964c1 +0 -0
  151. data/spec/dummy/tmp/cache/assets/development/sprockets/5a3ab9afd151c265cf11c621c0ddbe00 +0 -0
  152. data/spec/dummy/tmp/cache/assets/development/sprockets/5f1a0d05e77ca8b9a1fc2a47e17a8174 +0 -0
  153. data/spec/dummy/tmp/cache/assets/development/sprockets/647038c58f26163a9217646e1e5f09ae +0 -0
  154. data/spec/dummy/tmp/cache/assets/development/sprockets/64e0150fafbd9aaa3822efa1abb0211d +0 -0
  155. data/spec/dummy/tmp/cache/assets/development/sprockets/6536a3eb4b5d05368d260a46f2485ead +0 -0
  156. data/spec/dummy/tmp/cache/assets/development/sprockets/65c2d908dbca1bc833ae0b552f6c27fa +0 -0
  157. data/spec/dummy/tmp/cache/assets/development/sprockets/6882b260ae69f1594eff540d803e5ac3 +0 -0
  158. data/spec/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
  159. data/spec/dummy/tmp/cache/assets/development/sprockets/726d3f6850549a59954f0bf5584cfd9f +0 -0
  160. data/spec/dummy/tmp/cache/assets/development/sprockets/75f2f1e32219e0b89c069e43b49e0e49 +0 -0
  161. data/spec/dummy/tmp/cache/assets/development/sprockets/7ab9ac7cc2529219a4c68fd7854d5c0f +0 -0
  162. data/spec/dummy/tmp/cache/assets/development/sprockets/7abbc975e6786a54d660e0cf19aab1f0 +0 -0
  163. data/spec/dummy/tmp/cache/assets/development/sprockets/7bac3aca131c870ad5b07d8ccdc86e06 +0 -0
  164. data/spec/dummy/tmp/cache/assets/development/sprockets/7ffb7c821c008cd2a390dc7aba74361f +0 -0
  165. data/spec/dummy/tmp/cache/assets/development/sprockets/80392355fc6e00cf69b2cd46978ebcbe +0 -0
  166. data/spec/dummy/tmp/cache/assets/development/sprockets/8084620ce7f95d2b2aeb65c977c62af1 +0 -0
  167. data/spec/dummy/tmp/cache/assets/development/sprockets/874b42463fefbb0bce47775722ebb4ae +0 -0
  168. data/spec/dummy/tmp/cache/assets/development/sprockets/87b209c0c9da28094a8d5581a21262c6 +0 -0
  169. data/spec/dummy/tmp/cache/assets/development/sprockets/87ef8ddd2847d19f22a16d726b88b433 +0 -0
  170. data/spec/dummy/tmp/cache/assets/development/sprockets/91ae0bd43f98b4f1f111e0bdc178302c +0 -0
  171. data/spec/dummy/tmp/cache/assets/development/sprockets/9a7970620504bfe92af14fd57ee08365 +0 -0
  172. data/spec/dummy/tmp/cache/assets/development/sprockets/9c8440c4efec99d4a380eeda42f089c7 +0 -0
  173. data/spec/dummy/tmp/cache/assets/development/sprockets/9e4cf41800946fd32bcfa3591b304eb6 +0 -0
  174. data/spec/dummy/tmp/cache/assets/development/sprockets/a2b14d5c46db32da9183354fb3fcd0bf +0 -0
  175. data/spec/dummy/tmp/cache/assets/development/sprockets/a6d6196cfd275dea0718553a95f997a5 +0 -0
  176. data/spec/dummy/tmp/cache/assets/development/sprockets/a7a8652a3fb42ef81fac3ab77949f82d +0 -0
  177. data/spec/dummy/tmp/cache/assets/development/sprockets/a9d839f632f9ce73fc221b79b39b0924 +0 -0
  178. data/spec/dummy/tmp/cache/assets/development/sprockets/bae0ea1201e2ec9420712ff54b3254aa +0 -0
  179. data/spec/dummy/tmp/cache/assets/development/sprockets/c05c4a514cf0b61ad7b223ee732cd6df +0 -0
  180. data/spec/dummy/tmp/cache/assets/development/sprockets/c29c465933e7e86d6f6224f5e78c5baf +0 -0
  181. data/spec/dummy/tmp/cache/assets/development/sprockets/c975834a35907ecd2d314bbd6844ee88 +0 -0
  182. data/spec/dummy/tmp/cache/assets/development/sprockets/cebc6db0bbb8120f430da3970b173d2f +0 -0
  183. data/spec/dummy/tmp/cache/assets/development/sprockets/cf4affc50c6303e717d6514380d1f417 +0 -0
  184. data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  185. data/spec/dummy/tmp/cache/assets/development/sprockets/d0194b0fba4290072cfff0be06b348fd +0 -0
  186. data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  187. data/spec/dummy/tmp/cache/assets/development/sprockets/d8487b3a1dc72a1361b96fbbc93255c6 +0 -0
  188. data/spec/dummy/tmp/cache/assets/development/sprockets/d8b357d5741711da2dd710af0e15d268 +0 -0
  189. data/spec/dummy/tmp/cache/assets/development/sprockets/e02b5049cf477b43a72b4a00e2fceb46 +0 -0
  190. data/spec/dummy/tmp/cache/assets/development/sprockets/e0be9bf6ab486a790bda60b51224b404 +0 -0
  191. data/spec/dummy/tmp/cache/assets/development/sprockets/e22a1b318499e7f06ea9274e18ab004f +0 -0
  192. data/spec/dummy/tmp/cache/assets/development/sprockets/e298cc3a8203ab1fb6978a90254f8926 +0 -0
  193. data/spec/dummy/tmp/cache/assets/development/sprockets/e2a9bdd87a2d19256837fce6544a122c +0 -0
  194. data/spec/dummy/tmp/cache/assets/development/sprockets/e868f358fe87542c483951a2d9f532b6 +0 -0
  195. data/spec/dummy/tmp/cache/assets/development/sprockets/e8a6adf580ebd1942f4aabe6738678c2 +0 -0
  196. data/spec/dummy/tmp/cache/assets/development/sprockets/ea081ed20ad78a3e8f41a529b6baa2e1 +0 -0
  197. data/spec/dummy/tmp/cache/assets/development/sprockets/ec956e1f28c818063bb61958fe5ae855 +0 -0
  198. data/spec/dummy/tmp/cache/assets/development/sprockets/ed71f99e0a9653296abd5d6f501dd898 +0 -0
  199. data/spec/dummy/tmp/cache/assets/development/sprockets/eee3cb53f216eaa12dd927f144640d0d +0 -0
  200. data/spec/dummy/tmp/cache/assets/development/sprockets/efe6f2d16d3a1819817efb8734daf8af +0 -0
  201. data/spec/dummy/tmp/cache/assets/development/sprockets/f03e99bdb4159ae3485ca2858716e19b +0 -0
  202. data/spec/dummy/tmp/cache/assets/development/sprockets/f29bc513eb7c7d4b79d53d51363f7f1f +0 -0
  203. data/spec/dummy/tmp/cache/assets/development/sprockets/f56253b5f374fff1a33fbbc9881c9124 +0 -0
  204. data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  205. data/spec/dummy/tmp/cache/assets/development/sprockets/fc2c22310cbb7abb26ae64d4aafa37cb +0 -0
  206. data/spec/dummy/tmp/restart.txt +0 -0
  207. data/spec/helpers/prosperity/metrics_helper_spec.rb +6 -0
  208. data/spec/lib/prosperity/extractors/base_spec.rb +8 -0
  209. data/spec/lib/prosperity/extractors/count_spec.rb +35 -0
  210. data/spec/lib/prosperity/extractors/group_spec.rb +34 -0
  211. data/spec/lib/prosperity/metric_finder_spec.rb +20 -0
  212. data/spec/lib/prosperity/metric_spec.rb +49 -0
  213. data/spec/lib/prosperity/metrics/option_spec.rb +7 -0
  214. data/spec/lib/prosperity/period_spec.rb +7 -0
  215. data/spec/lib/prosperity/periods_spec.rb +7 -0
  216. data/spec/spec_helper.rb +17 -0
  217. data/spec/support/test_database.rb +18 -0
  218. data/spec/test_files/metrics/users_metric.rb +4 -0
  219. data/vendor/assets/javascripts/chart.js +1426 -0
  220. data/vendor/assets/stylesheets/bootstrap-theme.min.css +9 -0
  221. data/vendor/assets/stylesheets/bootstrap.min.css +9 -0
  222. metadata +526 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9a60131d02562924806b4b7671c421c139309d69
4
+ data.tar.gz: 12a50361dd49b9388935a4305a2f3b1a937bc332
5
+ SHA512:
6
+ metadata.gz: 2ce04e142220a10b870d9c767a762fd63e7043e559fdf841adeb76b42fa7e106184401d76e22ebec78c597a47cde82160d4965a3c4b978e5ea3de5743f7df289
7
+ data.tar.gz: e72d9ba8a6bfb344ecaca189d251469b91ef9bd855669ad3cf7b31f6e6212a8e86e2f0ad97701d96e0c0c7276cae67a89fe36a4f20bdf438423e4c687ffd5913
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ require 'rdoc/task'
10
+
11
+ RDoc::Task.new(:rdoc) do |rdoc|
12
+ rdoc.rdoc_dir = 'rdoc'
13
+ rdoc.title = 'Prosperity'
14
+ rdoc.options << '--line-numbers'
15
+ rdoc.rdoc_files.include('README.rdoc')
16
+ rdoc.rdoc_files.include('lib/**/*.rb')
17
+ end
18
+
19
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
20
+ load 'rails/tasks/engine.rake'
21
+
22
+
23
+
24
+ Bundler::GemHelper.install_tasks
25
+
26
+ require 'rspec/core/rake_task'
27
+
28
+ RSpec::Core::RakeTask.new(:spec)
29
+
30
+ task :default => :spec
31
+
@@ -0,0 +1,42 @@
1
+ # This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ # listed below.
3
+ #
4
+ # Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ # or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ #
7
+ # It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ # compiled file.
9
+ #
10
+ # Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ # about supported directives.
12
+ #
13
+ #= require jquery
14
+ #= require jquery_ujs
15
+ #= require chart
16
+ #= require twitter/bootstrap
17
+ #= require_tree .
18
+
19
+ $ ->
20
+ $("canvas.metric").each (i, el) ->
21
+ ctx = el.getContext("2d")
22
+ points = $(el).data('points')
23
+
24
+ datasets = []
25
+
26
+ size = 0
27
+ for key, data of points
28
+ datasets.push
29
+ data: data
30
+ fillColor : "rgba(151,187,205,0)",
31
+ strokeColor : "rgba(0,0,0,1)",
32
+
33
+
34
+ size = Math.max(size, data.length)
35
+
36
+ data =
37
+ labels : (i for i in [0..size])
38
+ datasets: datasets
39
+
40
+ myNewChart = new Chart(ctx).Line(data)
41
+
42
+
@@ -0,0 +1,19 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require bootstrap.min
12
+ *= require bootstrap-theme.min
13
+ *= require_self
14
+ *= require_tree .
15
+ */
16
+
17
+ .main {
18
+ padding: 40px 15px;
19
+ }
@@ -0,0 +1,4 @@
1
+ module Prosperity
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,9 @@
1
+ require_dependency "prosperity/application_controller"
2
+
3
+ module Prosperity
4
+ class MetricsController < ApplicationController
5
+ def index
6
+ @metrics = MetricFinder.all
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module Prosperity
2
+ module ApplicationHelper
3
+ def app_name
4
+ "Prosperity"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ module Prosperity
2
+ module MetricsHelper
3
+ def data_for_metric(metric)
4
+ metric.extractors.inject({}) do |h, ext_klass|
5
+ ext = ext_klass.new(metric, 12.month.ago, Time.now, Prosperity::Periods::MONTH)
6
+ h[ext.key] = ext.to_a
7
+ h
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,37 @@
1
+ !!! 5
2
+ %html(lang="en")
3
+ %head
4
+ %meta(charset="utf-8")
5
+ %meta(http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1")
6
+ %meta(name="viewport" content="width=device-width, initial-scale=1.0")
7
+ %title= content_for?(:title) ? yield(:title) : app_name
8
+ = csrf_meta_tags
9
+ / Le HTML5 shim, for IE6-8 support of HTML elements
10
+ /[if lt IE 9]
11
+ = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js"
12
+ = stylesheet_link_tag "prosperity/application", :media => "all"
13
+
14
+ %body
15
+
16
+ .navbar.navbar-inverse.navbar-fixed-top
17
+ .container
18
+ .navbar-header
19
+ %button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", type: "button"}
20
+ %span.icon-bar
21
+ %span.icon-bar
22
+ %span.icon-bar
23
+ %a.navbar-brand{href: "#"}= app_name
24
+ .collapse.navbar-collapse
25
+ %ul.nav.navbar-nav
26
+ %li.active
27
+ %a{href: "#"} Home
28
+ %li
29
+ %a{href: "#about"} About
30
+ %li
31
+ %a{href: "#contact"} Contact
32
+
33
+ .container
34
+ .main
35
+ = yield
36
+
37
+ = javascript_include_tag "prosperity/application"
@@ -0,0 +1,7 @@
1
+ %h1 Metrics
2
+
3
+ - @metrics.each do |metric|
4
+ %h2= metric.to_s.underscore.humanize
5
+
6
+ - data = data_for_metric(metric.new).to_json
7
+ %canvas.metric{id: "my_metric", width:"800", height:"400", data: {points: data}}
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ Prosperity::Engine.routes.draw do
2
+ resources :metrics
3
+
4
+ root to: 'metrics#index'
5
+ end
@@ -0,0 +1,4 @@
1
+ class Test < ActiveRecord::Migration
2
+ def change
3
+ end
4
+ end
@@ -0,0 +1,9 @@
1
+ module Prosperity
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Prosperity
4
+ config.autoload_paths << File.expand_path("../../", __FILE__)
5
+ config.after_initialize do
6
+ require "prosperity/exception"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module Prosperity
2
+ class Exception < ::Exception
3
+ end
4
+
5
+ class MissingScope < Exception
6
+ def initialize
7
+ super "You must specify a scope for all metrics."
8
+ end
9
+ end
10
+ end
11
+
@@ -0,0 +1,11 @@
1
+ module Prosperity
2
+ class Extractors::Base
3
+ attr_reader :metric, :start_time, :end_time, :period
4
+
5
+ def initialize(metric, start_time, end_time, period)
6
+ @metric, @start_time, @end_time, @period =
7
+ metric, start_time, end_time, period
8
+ end
9
+ end
10
+ end
11
+
@@ -0,0 +1,18 @@
1
+ module Prosperity
2
+ class Extractors::Count < Extractors::Base
3
+ def key
4
+ "count"
5
+ end
6
+
7
+ def to_a
8
+ data = []
9
+
10
+ period.each_period(start_time, end_time) do |start_time|
11
+ data << @metric.scope.where("#{metric.group_by} < ?", start_time).count
12
+ end
13
+
14
+ data
15
+ end
16
+ end
17
+ end
18
+
@@ -0,0 +1,23 @@
1
+ module Prosperity
2
+ class Extractors::Group < Extractors::Base
3
+ def key
4
+ "group"
5
+ end
6
+
7
+ def to_a
8
+ s = @metric.scope.where("#{metric.group_by} BETWEEN ? AND ?", @start_time, @end_time)
9
+ s = s.group("to_char(#{metric.group_by}, '#{period.db_strf_str}')").count
10
+
11
+ data = []
12
+
13
+ period.each_period(start_time, end_time) do |start_time|
14
+ str = start_time.strftime(period.ruby_strf_str)
15
+ value = s.has_key?(str) ? s[str].to_f : 0.0
16
+ data << value
17
+ end
18
+
19
+ data
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,48 @@
1
+ module Prosperity
2
+ class Metric
3
+ def self.scope(&block)
4
+ if block_given?
5
+ @scope = block.call
6
+ else
7
+ raise MissingScope.new if @scope.nil?
8
+ @scope
9
+ end
10
+ end
11
+
12
+ def self.options(name = nil, &block)
13
+ @options ||= default_options
14
+ if block_given?
15
+ @options[name] = Metrics::Option.new(name, &block)
16
+ else
17
+ raise MissingScope.new if @options.nil?
18
+ @options
19
+ end
20
+ end
21
+
22
+ def extractors
23
+ [Extractors::Group, Extractors::Count]
24
+ end
25
+
26
+ def group_by
27
+ :created_at
28
+ end
29
+
30
+ def scope
31
+ self.class.scope
32
+ end
33
+
34
+ def options
35
+ self.class.options
36
+ end
37
+
38
+ private
39
+
40
+ def self.default_options
41
+ o = Metrics::Option.new("default") do |scope|
42
+ scope
43
+ end
44
+ {"default" => o}
45
+ end
46
+ end
47
+ end
48
+
@@ -0,0 +1,14 @@
1
+ module Prosperity
2
+ class MetricFinder < Struct.new(:directory)
3
+ def metrics
4
+ Dir[File.join(directory, "**/*_metric.rb")].map do |metric|
5
+ File.basename(metric, ".rb").camelcase.constantize
6
+ end
7
+ end
8
+
9
+ def self.all
10
+ self.new(File.join(Rails.root, "app/prosperity")).metrics
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,9 @@
1
+ module Prosperity
2
+ class Metrics::Option
3
+ def initialize(name, &block)
4
+ @name = name
5
+ @block = block
6
+ end
7
+ end
8
+ end
9
+
@@ -0,0 +1,5 @@
1
+ module Prosperity
2
+ module Metrics
3
+ end
4
+ end
5
+
@@ -0,0 +1,11 @@
1
+ module Prosperity
2
+ class Period < Struct.new(:db_strf_str, :ruby_strf_str, :duration)
3
+ def each_period(start_time, end_time)
4
+ while start_time < end_time
5
+ yield start_time
6
+ start_time += duration
7
+ end
8
+ end
9
+ end
10
+ end
11
+
@@ -0,0 +1,6 @@
1
+ module Prosperity
2
+ class Periods
3
+ MONTH = Period.new("YYYY-MM", "%Y-%m", 1.month)
4
+ end
5
+ end
6
+
@@ -0,0 +1,3 @@
1
+ module Prosperity
2
+ VERSION = "0.0.1"
3
+ end
data/lib/prosperity.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "prosperity/engine"
2
+
3
+ module Prosperity
4
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :prosperity do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ module Prosperity
4
+ describe MetricsController do
5
+ routes { Prosperity::Engine.routes }
6
+
7
+ describe "GET index" do
8
+ it "returns successfully" do
9
+ get :index
10
+ response.should be_success
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ ## Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ ## for example lib/tasks/capistrano.rake, and they will automatically be
4
+ #available to Rake.
5
+
6
+ require File.expand_path('../config/application', __FILE__)
7
+
8
+ Dummy::Application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,58 @@
1
+ class UsersController < ApplicationController
2
+ before_action :set_user, only: [:show, :edit, :update, :destroy]
3
+
4
+ # GET /users
5
+ def index
6
+ @users = User.all
7
+ end
8
+
9
+ # GET /users/1
10
+ def show
11
+ end
12
+
13
+ # GET /users/new
14
+ def new
15
+ @user = User.new
16
+ end
17
+
18
+ # GET /users/1/edit
19
+ def edit
20
+ end
21
+
22
+ # POST /users
23
+ def create
24
+ @user = User.new(user_params)
25
+
26
+ if @user.save
27
+ redirect_to @user, notice: 'User was successfully created.'
28
+ else
29
+ render action: 'new'
30
+ end
31
+ end
32
+
33
+ # PATCH/PUT /users/1
34
+ def update
35
+ if @user.update(user_params)
36
+ redirect_to @user, notice: 'User was successfully updated.'
37
+ else
38
+ render action: 'edit'
39
+ end
40
+ end
41
+
42
+ # DELETE /users/1
43
+ def destroy
44
+ @user.destroy
45
+ redirect_to users_url, notice: 'User was successfully destroyed.'
46
+ end
47
+
48
+ private
49
+ # Use callbacks to share common setup or constraints between actions.
50
+ def set_user
51
+ @user = User.find(params[:id])
52
+ end
53
+
54
+ # Only allow a trusted parameter "white list" through.
55
+ def user_params
56
+ params.require(:user).permit(:email, :name)
57
+ end
58
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module UsersHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ class User < ActiveRecord::Base
2
+ end
@@ -0,0 +1,3 @@
1
+ class UsersMetric < Prosperity::Metric
2
+ scope { User }
3
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6
+ <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>