shell-spinner 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (476) hide show
  1. data/.gitignore +22 -4
  2. data/.rspec +1 -0
  3. data/.rvmrc +53 -0
  4. data/Gemfile +90 -3
  5. data/Gemfile.lock +479 -0
  6. data/README.md +56 -0
  7. data/Rakefile +7 -1
  8. data/app/admin/carriers.rb +17 -0
  9. data/app/admin/dashboards.rb +31 -0
  10. data/app/admin/interviews.rb +77 -0
  11. data/app/admin/users.rb +40 -0
  12. data/app/assets/images/icons/ajax-loader.gif +0 -0
  13. data/app/assets/images/icons/clear-results.png +0 -0
  14. data/app/assets/images/icons/clipboard.png +0 -0
  15. data/app/assets/images/icons/magnify.png +0 -0
  16. data/app/assets/images/icons/social/facebook.png +0 -0
  17. data/app/assets/images/icons/social/google.png +0 -0
  18. data/app/assets/images/icons/social/linkedin.png +0 -0
  19. data/app/assets/images/icons/social/small/facebook.png +0 -0
  20. data/app/assets/images/icons/social/small/google.png +0 -0
  21. data/app/assets/images/icons/social/small/linkedin.png +0 -0
  22. data/app/assets/images/icons/social/small/twitter.png +0 -0
  23. data/app/assets/images/icons/social/small/windowslive.png +0 -0
  24. data/app/assets/images/icons/social/small/yahoo.png +0 -0
  25. data/app/assets/images/icons/social/twitter.png +0 -0
  26. data/app/assets/images/icons/social/windowslive.png +0 -0
  27. data/app/assets/images/icons/social/yahoo.png +0 -0
  28. data/app/assets/images/logo.png +0 -0
  29. data/app/assets/javascripts/active_admin.js.coffee +18 -0
  30. data/app/assets/javascripts/admin/base.coffee +0 -0
  31. data/app/assets/javascripts/admin/interview_form.coffee +95 -0
  32. data/app/assets/javascripts/app/controllers/questions.js.coffee +12 -0
  33. data/app/assets/javascripts/app/index.js.coffee +25 -0
  34. data/app/assets/javascripts/app/lib/view.js.coffee +3 -0
  35. data/app/assets/javascripts/app/models/interview_template.js.coffee +6 -0
  36. data/app/assets/javascripts/app/models/question.js.coffee +6 -0
  37. data/app/assets/javascripts/app/views/questions/show.jst.hamljs +2 -0
  38. data/app/assets/javascripts/application.coffee +48 -0
  39. data/app/assets/javascripts/attachment_form.coffee +31 -0
  40. data/app/assets/javascripts/clipboard_control.coffee +30 -0
  41. data/app/assets/javascripts/invitation_form.coffee +72 -0
  42. data/app/assets/javascripts/recommendation_form.coffee +19 -0
  43. data/app/assets/javascripts/recommendations_list.coffee +11 -0
  44. data/app/assets/javascripts/search_contacts_form.coffee +36 -0
  45. data/app/assets/javascripts/templates/empty_recipients_list.tmpl +1 -0
  46. data/app/assets/javascripts/templates/recipient.tmpl +5 -0
  47. data/app/assets/stylesheets/active_admin.css.scss +28 -0
  48. data/app/assets/stylesheets/application.sass +24 -0
  49. data/app/assets/stylesheets/includes/_authorisation.sass +29 -0
  50. data/app/assets/stylesheets/includes/_bootstrap_tweaks.sass +2 -0
  51. data/app/assets/stylesheets/includes/_campaigns.sass +44 -0
  52. data/app/assets/stylesheets/includes/_controls.sass +41 -0
  53. data/app/assets/stylesheets/includes/_form.sass +23 -0
  54. data/app/assets/stylesheets/includes/_formatting.sass +8 -0
  55. data/app/assets/stylesheets/includes/_icons.sass +31 -0
  56. data/app/assets/stylesheets/includes/_interview.sass +16 -0
  57. data/app/assets/stylesheets/includes/_interview_form.sass +170 -0
  58. data/app/assets/stylesheets/includes/_interview_management.sass +3 -0
  59. data/app/assets/stylesheets/includes/_invitation_form.sass +190 -0
  60. data/app/assets/stylesheets/includes/_layout.sass +69 -0
  61. data/app/assets/stylesheets/includes/_mixins.sass +42 -0
  62. data/app/assets/stylesheets/includes/_navigation.sass +16 -0
  63. data/app/assets/stylesheets/includes/_recommendations.sass +34 -0
  64. data/app/concerns/authenticate_users.rb +72 -0
  65. data/app/concerns/conditional_redirect_after_signing_in.rb +24 -0
  66. data/app/concerns/eventable.rb +16 -0
  67. data/app/controllers/application_controller.rb +31 -0
  68. data/app/controllers/attachments_controller.rb +36 -0
  69. data/app/controllers/campaigns_controller.rb +23 -0
  70. data/app/controllers/contacts_controller.rb +37 -0
  71. data/app/controllers/interview_result_invitations_controller.rb +21 -0
  72. data/app/controllers/interview_results_controller.rb +39 -0
  73. data/app/controllers/interview_templates_controller.rb +3 -0
  74. data/app/controllers/pages_controller.rb +6 -0
  75. data/app/controllers/questions_controller.rb +5 -0
  76. data/app/controllers/recommendations_controller.rb +64 -0
  77. data/app/controllers/resources_controller.rb +1 -0
  78. data/app/controllers/users/omniauth_callbacks_controller.rb +52 -0
  79. data/app/helpers/admin/interview_helper.rb +14 -0
  80. data/app/helpers/answers_helper.rb +8 -0
  81. data/app/helpers/application_helper.rb +1 -0
  82. data/app/helpers/attachments_helper.rb +5 -0
  83. data/app/helpers/campaigns_helper.rb +5 -0
  84. data/app/helpers/layout_helper.rb +5 -0
  85. data/app/helpers/recommendation_helper.rb +14 -0
  86. data/app/mailers/invitation_mailer.rb +13 -0
  87. data/app/models/ability.rb +23 -0
  88. data/app/models/answer.rb +36 -0
  89. data/app/models/answer_choice.rb +28 -0
  90. data/app/models/attachment.rb +34 -0
  91. data/app/models/buying_attempt.rb +31 -0
  92. data/app/models/campaign.rb +37 -0
  93. data/app/models/carrier.rb +30 -0
  94. data/app/models/cell_phone_insurance_interview.rb +17 -0
  95. data/app/models/contact.rb +31 -0
  96. data/app/models/default_interview.rb +17 -0
  97. data/app/models/interesting_fact.rb +30 -0
  98. data/app/models/interview_result.rb +65 -0
  99. data/app/models/interview_template.rb +52 -0
  100. data/app/models/invitation.rb +45 -0
  101. data/app/models/invitation_identifier.rb +29 -0
  102. data/app/models/numeric_question.rb +19 -0
  103. data/app/models/one_correct_question.rb +27 -0
  104. data/app/models/possible_answer.rb +54 -0
  105. data/app/models/question.rb +96 -0
  106. data/app/models/recommendation.rb +27 -0
  107. data/app/models/scale_question.rb +42 -0
  108. data/app/models/user.rb +102 -0
  109. data/app/models/yes_no_question.rb +18 -0
  110. data/app/renderers/nav_links_renderer.rb +10 -0
  111. data/app/uploaders/attachement_uploader.rb +55 -0
  112. data/app/uploaders/file_uploader.rb +20 -0
  113. data/app/views/admin/interviews/_form.html.haml +36 -0
  114. data/app/views/admin/interviews/_possible_answer_fields.html.haml +6 -0
  115. data/app/views/admin/interviews/_question_fields.html.haml +28 -0
  116. data/app/views/admin/interviews/_wrapper_question_fields.html.haml +2 -0
  117. data/app/views/admin/interviews/numeric_question/_fields.html.haml +7 -0
  118. data/app/views/admin/interviews/one_correct_question/_answer_fields.html.haml +6 -0
  119. data/app/views/admin/interviews/one_correct_question/_fields.html.haml +18 -0
  120. data/app/views/admin/interviews/scale_question/_fields.html.haml +7 -0
  121. data/app/views/admin/interviews/scale_question/_start_end_values.html.haml +6 -0
  122. data/app/views/admin/interviews/yes_no_question/_fields.html.haml +3 -0
  123. data/app/views/attachments/_form.html.haml +5 -0
  124. data/app/views/attachments/_interesting_facts.html.haml +11 -0
  125. data/app/views/attachments/_resource.html.haml +13 -0
  126. data/app/views/attachments/buttons/_delete.html.haml +3 -0
  127. data/app/views/attachments/index.html.haml +28 -0
  128. data/app/views/attachments/new.html.haml +1 -0
  129. data/app/views/attachments/show.html.haml +1 -0
  130. data/app/views/campaigns/_form.html.haml +7 -0
  131. data/app/views/campaigns/_form_actions.html.haml +4 -0
  132. data/app/views/campaigns/edit.html.haml +7 -0
  133. data/app/views/campaigns/index.html.haml +14 -0
  134. data/app/views/campaigns/new.html.haml +7 -0
  135. data/app/views/campaigns/show.html.haml +15 -0
  136. data/app/views/contacts/_list.html.haml +17 -0
  137. data/app/views/contacts/_table.html.haml +8 -0
  138. data/app/views/contacts/search.html.haml +1 -0
  139. data/app/views/interesting_facts/_fact.html.haml +4 -0
  140. data/app/views/interview_result_invitations/new.html.haml +29 -0
  141. data/app/views/interview_results/_answer_choice.html.haml +11 -0
  142. data/app/views/interview_results/_form.html.haml +16 -0
  143. data/app/views/interview_results/_list.html.haml +3 -0
  144. data/app/views/interview_results/_numeric_question.html.haml +3 -0
  145. data/app/views/interview_results/_one_correct_question.html.haml +3 -0
  146. data/app/views/interview_results/_scale_question.html.haml +6 -0
  147. data/app/views/interview_results/_yes_no_question.html.haml +6 -0
  148. data/app/views/interview_results/index.html.haml +2 -0
  149. data/app/views/interview_results/new.html.haml +4 -0
  150. data/app/views/interview_results/numeric/_price.html.haml +2 -0
  151. data/app/views/interview_results/numeric/_simple_number.html.haml +2 -0
  152. data/app/views/interview_results/one_correct/_dropdown.html.haml +1 -0
  153. data/app/views/interview_results/one_correct/_radio.html.haml +2 -0
  154. data/app/views/interview_results/one_correct/_slider.html.haml +2 -0
  155. data/app/views/interview_results/show.html.haml +24 -0
  156. data/app/views/interview_templates/index.json.rabl +6 -0
  157. data/app/views/interview_templates/show.html.haml +1 -0
  158. data/app/views/layouts/_footer.haml +9 -0
  159. data/app/views/layouts/_header.haml +21 -0
  160. data/app/views/layouts/application.html.haml +29 -0
  161. data/app/views/pages/home.html.haml +10 -0
  162. data/app/views/questions/show.json.rabl +2 -0
  163. data/app/views/recommendations/new.html.haml +19 -0
  164. data/app/views/shared/_ask_facebook_friends.html.haml +11 -0
  165. data/app/views/shared/_ask_twitter_followers.html.haml +13 -0
  166. data/app/views/shared/_conditional_html_tags.html.haml +8 -0
  167. data/app/views/shared/_errors.html.haml +2 -0
  168. data/app/views/shared/_friends_recommendations.html.haml +12 -0
  169. data/app/views/shared/_import_contacts_links.html.haml +10 -0
  170. data/app/views/shared/_interview_widget.html.haml +1 -0
  171. data/app/views/shared/_login_social_buttons.html.haml +19 -0
  172. data/app/views/shared/_sign_in_modal.html.haml +22 -0
  173. data/app/views/shared/buttons/_create.html.haml +3 -0
  174. data/app/views/shared/buttons/_delete.html.haml +3 -0
  175. data/app/views/shared/buttons/_edit.html.haml +3 -0
  176. data/app/views/users/confirmations/new.html.haml +11 -0
  177. data/app/views/users/mailer/confirmation_instructions.html.haml +4 -0
  178. data/app/views/users/mailer/reset_password_instructions.html.haml +6 -0
  179. data/app/views/users/mailer/unlock_instructions.html.haml +5 -0
  180. data/app/views/users/passwords/edit.html.haml +16 -0
  181. data/app/views/users/passwords/new.html.haml +9 -0
  182. data/app/views/users/registrations/edit.html.haml +27 -0
  183. data/app/views/users/registrations/new.html.haml +17 -0
  184. data/app/views/users/sessions/new.html.haml +14 -0
  185. data/app/views/users/shared/_links.haml +14 -0
  186. data/app/views/users/unlocks/new.html.haml +11 -0
  187. data/config.ru +4 -0
  188. data/config/application.rb +86 -0
  189. data/config/boot.rb +6 -0
  190. data/config/bottom_navigation.rb +13 -0
  191. data/config/cucumber.yml +8 -0
  192. data/config/database.yml +20 -0
  193. data/config/environment.rb +5 -0
  194. data/config/environments/development.rb +38 -0
  195. data/config/environments/production.rb +71 -0
  196. data/config/environments/test.rb +39 -0
  197. data/config/exceptional.yml +7 -0
  198. data/config/initializers/active_admin.rb +129 -0
  199. data/config/initializers/backtrace_silencers.rb +7 -0
  200. data/config/initializers/contacts_monkey_patch.rb +8 -0
  201. data/config/initializers/core_extensions.rb +1 -0
  202. data/config/initializers/delayed_job_config.rb +6 -0
  203. data/config/initializers/devise.rb +236 -0
  204. data/config/initializers/formtastic.rb +1 -0
  205. data/config/initializers/generators.rb +2 -0
  206. data/config/initializers/inflections.rb +15 -0
  207. data/config/initializers/mime_types.rb +5 -0
  208. data/config/initializers/net_ssl_monkey_patch.rb +22 -0
  209. data/config/initializers/secret_token.rb +7 -0
  210. data/config/initializers/session_store.rb +8 -0
  211. data/config/initializers/settings.rb +20 -0
  212. data/config/initializers/setup_mailer.rb +1 -0
  213. data/config/initializers/wrap_parameters.rb +14 -0
  214. data/config/locales/devise.en.yml +57 -0
  215. data/config/locales/en.yml +131 -0
  216. data/config/navigation.rb +25 -0
  217. data/config/omniauth.yml +54 -0
  218. data/config/routes.rb +41 -0
  219. data/config/sendgrid.yml +18 -0
  220. data/config/sendgrid.yml.example +18 -0
  221. data/config/top_navigation.rb +28 -0
  222. data/data/.gitkeep +0 -0
  223. data/db/migrate/20120615102902_create_users.rb +10 -0
  224. data/db/migrate/20120615103611_add_devise_to_users.rb +53 -0
  225. data/db/migrate/20120615104044_add_facebook_id_to_users.rb +5 -0
  226. data/db/migrate/20120618051144_add_twitter_id_to_users.rb +5 -0
  227. data/db/migrate/20120618051522_add_google_id_to_users.rb +5 -0
  228. data/db/migrate/20120618083140_add_linkedin_id_to_users.rb +5 -0
  229. data/db/migrate/20120618094240_add_yahoo_id_to_users.rb +5 -0
  230. data/db/migrate/20120618102303_add_windowslive_id_to_users.rb +5 -0
  231. data/db/migrate/20120618121959_create_survey_templates.rb +9 -0
  232. data/db/migrate/20120618122120_create_survey_results.rb +10 -0
  233. data/db/migrate/20120618122346_create_questions.rb +12 -0
  234. data/db/migrate/20120618122442_create_answers.rb +11 -0
  235. data/db/migrate/20120618122551_create_question_results.rb +10 -0
  236. data/db/migrate/20120618123137_create_question_choices.rb +10 -0
  237. data/db/migrate/20120619142239_create_admin_notes.rb +17 -0
  238. data/db/migrate/20120619142255_move_admin_notes_to_comments.rb +25 -0
  239. data/db/migrate/20120619142315_add_fields_to_survey_template.rb +6 -0
  240. data/db/migrate/20120621124117_add_role_to_users.rb +5 -0
  241. data/db/migrate/20120625115344_rename_surveys_to_interviews.rb +5 -0
  242. data/db/migrate/20120625120613_rename_survey_relation_field.rb +7 -0
  243. data/db/migrate/20120625121230_rename_survey_results_to_interview_results.rb +5 -0
  244. data/db/migrate/20120625134119_add_type_field_to_interview_templates.rb +5 -0
  245. data/db/migrate/20120627104823_add_display_as_field_to_question.rb +5 -0
  246. data/db/migrate/20120628115724_rename_question_choices_to_answer_choices.rb +5 -0
  247. data/db/migrate/20120628124041_rename_answers_to_possible_answers.rb +5 -0
  248. data/db/migrate/20120628125515_rename_question_results_to_answers.rb +5 -0
  249. data/db/migrate/20120628125728_rename_questions_body_to_text.rb +5 -0
  250. data/db/migrate/20120628125839_rename_possible_answers_body_to_text.rb +5 -0
  251. data/db/migrate/20120628131944_fix_answer_choice_fields.rb +6 -0
  252. data/db/migrate/20120704144442_add_text_to_answer_choices.rb +5 -0
  253. data/db/migrate/20120706065743_add_body_from3rd_point_view_to_possible_answers.rb +5 -0
  254. data/db/migrate/20120706125136_change_facebook_id_and_twitter_id_type.rb +11 -0
  255. data/db/migrate/20120710070940_create_invitations.rb +10 -0
  256. data/db/migrate/20120710105054_create_delayed_jobs.rb +22 -0
  257. data/db/migrate/20120711084512_create_recommendations.rb +14 -0
  258. data/db/migrate/20120712092224_create_invitation_identifiers.rb +8 -0
  259. data/db/migrate/20120712130638_remove_user_id_from_recommendations.rb +9 -0
  260. data/db/migrate/20120712130711_remove_interview_template_id_from_recommendations.rb +9 -0
  261. data/db/migrate/20120712130744_add_invitation_id_to_recommendations.rb +5 -0
  262. data/db/migrate/20120716113646_create_contacts.rb +12 -0
  263. data/db/migrate/20120718135613_add_secret_to_interview_results.rb +5 -0
  264. data/db/migrate/20120718162312_fix_recommendation_relation.rb +5 -0
  265. data/db/migrate/20120724095308_add_state_to_interview_results.rb +5 -0
  266. data/db/migrate/20120724142439_create_carriers.rb +11 -0
  267. data/db/migrate/20120725071947_create_campaigns.rb +11 -0
  268. data/db/migrate/20120725083605_add_last_visited_path_to_users.rb +5 -0
  269. data/db/migrate/20120725085526_create_interesting_facts.rb +13 -0
  270. data/db/migrate/20120725131809_add_attachment_to_campaigns.rb +5 -0
  271. data/db/migrate/20120726115141_create_attachments.rb +10 -0
  272. data/db/migrate/20120726115644_extract_attachment_from_campaign.rb +11 -0
  273. data/db/migrate/20120726135706_create_buying_attempts.rb +11 -0
  274. data/db/migrate/20120727104402_add_campaign_id_to_interview_result.rb +5 -0
  275. data/db/migrate/20120730064404_change_interesting_facts.rb +6 -0
  276. data/db/migrate/20120730114402_add_attachment_id_to_interesting_facts.rb +5 -0
  277. data/db/migrate/20120730115758_remove_campaign_id_from_interesting_facts.rb +9 -0
  278. data/db/schema.rb +201 -0
  279. data/db/seeds.rb +86 -0
  280. data/doc/Ability.html +221 -0
  281. data/doc/Admin/InterviewHelper.html +292 -0
  282. data/doc/Answer.html +241 -0
  283. data/doc/AnswerChoice.html +296 -0
  284. data/doc/AnswersHelper.html +194 -0
  285. data/doc/ApplicationController.html +318 -0
  286. data/doc/ApplicationHelper.html +119 -0
  287. data/doc/CellPhoneInsuranceInterview.html +192 -0
  288. data/doc/Contact.html +186 -0
  289. data/doc/ContactsController.html +283 -0
  290. data/doc/CoreExtensions.html +129 -0
  291. data/doc/CoreExtensions/Object.html +210 -0
  292. data/doc/DefaultInterview.html +192 -0
  293. data/doc/DevelopmentMailInterceptor.html +203 -0
  294. data/doc/EmailValidator.html +210 -0
  295. data/doc/InterviewResult.html +251 -0
  296. data/doc/InterviewResultInvitationsController.html +218 -0
  297. data/doc/InterviewResultsController.html +280 -0
  298. data/doc/InterviewTemplate.html +330 -0
  299. data/doc/InterviewTemplatesController.html +145 -0
  300. data/doc/Invitation.html +362 -0
  301. data/doc/InvitationIdentifier.html +287 -0
  302. data/doc/InvitationMailer.html +218 -0
  303. data/doc/LayoutHelper.html +188 -0
  304. data/doc/NavLinksRenderer.html +214 -0
  305. data/doc/NumericQuestion.html +196 -0
  306. data/doc/OneCorrectQuestion.html +269 -0
  307. data/doc/PagesController.html +206 -0
  308. data/doc/PossibleAnswer.html +627 -0
  309. data/doc/Question.html +620 -0
  310. data/doc/Recommendation.html +186 -0
  311. data/doc/RecommendationHelper.html +292 -0
  312. data/doc/RecommendationsController.html +230 -0
  313. data/doc/ResourcesController.html +141 -0
  314. data/doc/ScaleQuestion.html +525 -0
  315. data/doc/SocialProvidersConfig.html +240 -0
  316. data/doc/User.html +677 -0
  317. data/doc/Users/OmniauthCallbacksController.html +542 -0
  318. data/doc/Wisemuv/Contacts.html +188 -0
  319. data/doc/Wisemuv/Contacts/Google/ControllerConcerns.html +204 -0
  320. data/doc/Wisemuv/Contacts/Google/ModelConcerns.html +128 -0
  321. data/doc/Wisemuv/Contacts/WindowsLive/ControllerConcerns.html +204 -0
  322. data/doc/Wisemuv/Contacts/WindowsLive/Grabber.html +307 -0
  323. data/doc/Wisemuv/Contacts/WindowsLive/ModelConcerns.html +128 -0
  324. data/doc/Wisemuv/Contacts/Yahoo/ControllerConcerns.html +206 -0
  325. data/doc/Wisemuv/Contacts/Yahoo/Grabber.html +526 -0
  326. data/doc/Wisemuv/Contacts/Yahoo/ModelConcerns.html +128 -0
  327. data/doc/YesNoQuestion.html +209 -0
  328. data/doc/_index.html +509 -0
  329. data/doc/carriers-campaigns-interviews-relationships.png +0 -0
  330. data/doc/class_list.html +61 -0
  331. data/doc/css/common.css +1 -0
  332. data/doc/css/cucumber.css +222 -0
  333. data/doc/css/full_list.css +57 -0
  334. data/doc/css/style.css +328 -0
  335. data/doc/feature_list.html +513 -0
  336. data/doc/file.README.html +152 -0
  337. data/doc/file_list.html +63 -0
  338. data/doc/frames.html +28 -0
  339. data/doc/index.html +152 -0
  340. data/doc/js/app.js +214 -0
  341. data/doc/js/cucumber.js +305 -0
  342. data/doc/js/full_list.js +173 -0
  343. data/doc/js/jquery.js +4 -0
  344. data/doc/method_list.html +740 -0
  345. data/doc/requirements.html +196 -0
  346. data/doc/requirements/features.html +180 -0
  347. data/doc/requirements/features/admin_manages_users.html +1260 -0
  348. data/doc/requirements/features/ask_friends_and_family.html +918 -0
  349. data/doc/requirements/features/create_interview.html +1734 -0
  350. data/doc/requirements/features/edit_interview.html +832 -0
  351. data/doc/requirements/features/pass_interview.html +757 -0
  352. data/doc/requirements/features/pulling_contacts.html +718 -0
  353. data/doc/requirements/features/questions_order_during_creating_interview.html +126 -0
  354. data/doc/requirements/features/sign_in.html +1035 -0
  355. data/doc/requirements/features/sign_up.html +1948 -0
  356. data/doc/requirements/step_transformers.html +10401 -0
  357. data/doc/requirements/tags.html +670 -0
  358. data/doc/requirements/tags/javascript.html +245 -0
  359. data/doc/requirements/tags/omniauth.html +165 -0
  360. data/doc/requirements/tags/users.html +227 -0
  361. data/doc/tag_list.html +82 -0
  362. data/doc/top-level-namespace.html +128 -0
  363. data/features/admin_manages_users.feature +57 -0
  364. data/features/ask_friends_and_family.feature +39 -0
  365. data/features/buying_tracking_code.feature +11 -0
  366. data/features/campaign_management.feature +42 -0
  367. data/features/create_interview.feature +74 -0
  368. data/features/edit_interview.feature +40 -0
  369. data/features/interesting_facts_parser.feature +11 -0
  370. data/features/interview_completion.feature +6 -0
  371. data/features/pass_interview.feature +31 -0
  372. data/features/pulling_contacts.feature +21 -0
  373. data/features/questions_order_during_creating_interview.feature +2 -0
  374. data/features/redirecting_after_signing_in.feature +19 -0
  375. data/features/sign_in.feature +51 -0
  376. data/features/sign_up.feature +43 -0
  377. data/features/step_definitions/admin_manages_users_steps.rb +91 -0
  378. data/features/step_definitions/ask_friends_and_family_steps.rb +41 -0
  379. data/features/step_definitions/buying_tracking_code_steps.rb +15 -0
  380. data/features/step_definitions/campaign_management_steps.rb +50 -0
  381. data/features/step_definitions/create_interview_steps.rb +130 -0
  382. data/features/step_definitions/edit_interview_steps.rb +35 -0
  383. data/features/step_definitions/interesting_facts_parser_steps.rb +34 -0
  384. data/features/step_definitions/interview_completion_steps.rb +8 -0
  385. data/features/step_definitions/interview_results_steps.rb +7 -0
  386. data/features/step_definitions/interview_steps.rb +11 -0
  387. data/features/step_definitions/pass_interview_steps.rb +52 -0
  388. data/features/step_definitions/pulling_contacts_steps.rb +24 -0
  389. data/features/step_definitions/redirecting_after_sign_in_steps.rb +19 -0
  390. data/features/step_definitions/sign_in_steps.rb +110 -0
  391. data/features/step_definitions/sign_up_steps.rb +56 -0
  392. data/features/support/env.rb +23 -0
  393. data/features/support/omniauth.rb +69 -0
  394. data/features/support/pickle.rb +26 -0
  395. data/features/support/uploading.rb +6 -0
  396. data/features/support/users.rb +18 -0
  397. data/features/upload-files/Life Insurance Facts-Final.xls +0 -0
  398. data/lib/assets/.gitkeep +0 -0
  399. data/lib/core_extensions/object.rb +9 -0
  400. data/lib/interceptors/development_mail_interceptor.rb +5 -0
  401. data/lib/social_providers_config.rb +10 -0
  402. data/lib/tasks/auto_annotate_models.rake +22 -0
  403. data/lib/tasks/cucumber.rake +65 -0
  404. data/lib/tasks/db/reseed.rake +12 -0
  405. data/lib/tasks/db/seed/interviews.rake +14 -0
  406. data/lib/tasks/db/truncate.rake +19 -0
  407. data/lib/tasks/yardoc.rake +19 -0
  408. data/lib/validators/email_validator.rb +7 -0
  409. data/lib/wisemuv/contacts.rb +5 -0
  410. data/lib/wisemuv/contacts/google/controller_concerns.rb +19 -0
  411. data/lib/wisemuv/contacts/google/model_concerns.rb +17 -0
  412. data/lib/wisemuv/contacts/windows_live/controller_concerns.rb +23 -0
  413. data/lib/wisemuv/contacts/windows_live/grabber.rb +22 -0
  414. data/lib/wisemuv/contacts/windows_live/model_concerns.rb +17 -0
  415. data/lib/wisemuv/contacts/yahoo/controller_concerns.rb +29 -0
  416. data/lib/wisemuv/contacts/yahoo/grabber.rb +55 -0
  417. data/lib/wisemuv/contacts/yahoo/model_concerns.rb +17 -0
  418. data/lib/wisemuv/interesting_facts_parser.rb +65 -0
  419. data/log/.gitkeep +0 -0
  420. data/public/403.html +26 -0
  421. data/public/404.html +26 -0
  422. data/public/422.html +26 -0
  423. data/public/500.html +25 -0
  424. data/public/ZeroClipboard10.swf +0 -0
  425. data/public/favicon.ico +0 -0
  426. data/public/robots.txt +5 -0
  427. data/script/cucumber +10 -0
  428. data/script/delayed_job +5 -0
  429. data/script/rails +6 -0
  430. data/spec/factories/answer.rb +6 -0
  431. data/spec/factories/answer_choice.rb +6 -0
  432. data/spec/factories/attachment.rb +11 -0
  433. data/spec/factories/buying_attempts.rb +8 -0
  434. data/spec/factories/campaign.rb +8 -0
  435. data/spec/factories/carrier.rb +6 -0
  436. data/spec/factories/contact.rb +8 -0
  437. data/spec/factories/interesting_facts.rb +10 -0
  438. data/spec/factories/interview_result.rb +27 -0
  439. data/spec/factories/interview_template.rb +46 -0
  440. data/spec/factories/invitation_identifier.rb +8 -0
  441. data/spec/factories/possible_answer.rb +23 -0
  442. data/spec/factories/question.rb +55 -0
  443. data/spec/factories/recommendation.rb +10 -0
  444. data/spec/factories/user.rb +21 -0
  445. data/spec/mailers/invitation_mailer_spec.rb +5 -0
  446. data/spec/models/answer_spec.rb +5 -0
  447. data/spec/models/attachment_spec.rb +5 -0
  448. data/spec/models/buying_attempt_spec.rb +5 -0
  449. data/spec/models/campaign_spec.rb +5 -0
  450. data/spec/models/carrier_spec.rb +5 -0
  451. data/spec/models/contact_spec.rb +5 -0
  452. data/spec/models/interesting_fact_spec.rb +5 -0
  453. data/spec/models/invitation_identifier_spec.rb +5 -0
  454. data/spec/models/question_choice_spec.rb +5 -0
  455. data/spec/models/question_result_spec.rb +5 -0
  456. data/spec/models/question_spec.rb +5 -0
  457. data/spec/models/recommendation_spec.rb +5 -0
  458. data/spec/models/survey_result_spec.rb +5 -0
  459. data/spec/models/survey_template_spec.rb +5 -0
  460. data/spec/spec_helper.rb +32 -0
  461. data/vendor/.rvmrc +53 -0
  462. data/vendor/Gemfile +60 -0
  463. data/vendor/Gemfile.lock +166 -0
  464. data/vendor/README.rdoc +261 -0
  465. data/vendor/Rakefile +7 -0
  466. data/vendor/assets/javascripts/ZeroClipboard.js +316 -0
  467. data/vendor/assets/javascripts/selectToUISlider.js +240 -0
  468. data/vendor/assets/javascripts/underscore.string.js +566 -0
  469. data/vendor/assets/stylesheets/.gitkeep +0 -0
  470. data/vendor/config.ru +4 -0
  471. data/vendor/plugins/.gitkeep +0 -0
  472. metadata +504 -55
  473. data/README.markdown +0 -44
  474. data/lib/shell-spinner.rb +0 -52
  475. data/lib/shell-spinner/version.rb +0 -3
  476. data/shell-spinner.gemspec +0 -18
@@ -0,0 +1,240 @@
1
+ /*
2
+ * --------------------------------------------------------------------
3
+ * jQuery-Plugin - selectToUISlider - creates a UI slider component from a select element(s)
4
+ * by Scott Jehl, scott@filamentgroup.com
5
+ * http://www.filamentgroup.com
6
+ * reference article: http://www.filamentgroup.com/lab/update_jquery_ui_16_slider_from_a_select_element/
7
+ * demo page: http://www.filamentgroup.com/examples/slider_v2/index.html
8
+ *
9
+ * Copyright (c) 2008 Filament Group, Inc
10
+ * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses.
11
+ *
12
+ * Usage Notes: please refer to our article above for documentation
13
+ *
14
+ * --------------------------------------------------------------------
15
+ */
16
+
17
+
18
+ jQuery.fn.selectToUISlider = function(settings){
19
+ var selects = jQuery(this);
20
+
21
+ //accessible slider options
22
+ var options = jQuery.extend({
23
+ labels: 3, //number of visible labels
24
+ tooltip: true, //show tooltips, boolean
25
+ tooltipSrc: 'text',//accepts 'value' as well
26
+ labelSrc: 'value',//accepts 'value' as well ,
27
+ sliderOptions: null
28
+ }, settings);
29
+
30
+
31
+ //handle ID attrs - selects each need IDs for handles to find them
32
+ var handleIds = (function(){
33
+ var tempArr = [];
34
+ selects.each(function(){
35
+ tempArr.push('handle_'+jQuery(this).attr('id'));
36
+ });
37
+ return tempArr;
38
+ })();
39
+
40
+ //array of all option elements in select element (ignores optgroups)
41
+ var selectOptions = (function(){
42
+ var opts = [];
43
+ selects.eq(0).find('option').each(function(){
44
+ opts.push({
45
+ value: jQuery(this).attr('value'),
46
+ text: jQuery(this).text()
47
+ });
48
+ });
49
+ return opts;
50
+ })();
51
+
52
+ //array of opt groups if present
53
+ var groups = (function(){
54
+ if(selects.eq(0).find('optgroup').size()>0){
55
+ var groupedData = [];
56
+ selects.eq(0).find('optgroup').each(function(i){
57
+ groupedData[i] = {};
58
+ groupedData[i].label = jQuery(this).attr('label');
59
+ groupedData[i].options = [];
60
+ jQuery(this).find('option').each(function(){
61
+ groupedData[i].options.push({text: jQuery(this).text(), value: jQuery(this).attr('value')});
62
+ });
63
+ });
64
+ return groupedData;
65
+ }
66
+ else return null;
67
+ })();
68
+
69
+ //check if obj is array
70
+ function isArray(obj) {
71
+ return obj.constructor == Array;
72
+ }
73
+ //return tooltip text from option index
74
+ function ttText(optIndex){
75
+ return (options.tooltipSrc == 'text') ? selectOptions[optIndex].text : selectOptions[optIndex].value;
76
+ }
77
+
78
+ //plugin-generated slider options (can be overridden)
79
+ var sliderOptions = {
80
+ step: 1,
81
+ min: 0,
82
+ orientation: 'horizontal',
83
+ max: selectOptions.length-1,
84
+ range: selects.length > 1,//multiple select elements = true
85
+ slide: function(e, ui) {//slide function
86
+ var thisHandle = jQuery(ui.handle);
87
+ //handle feedback
88
+ var textval = ttText(ui.value);
89
+ thisHandle
90
+ .attr('aria-valuetext', textval)
91
+ .attr('aria-valuenow', ui.value)
92
+ .find('.ui-slider-tooltip .ttContent')
93
+ .text( textval );
94
+
95
+ //control original select menu
96
+ var currSelect = jQuery('#' + thisHandle.attr('id').split('handle_')[1]);
97
+ currSelect.find('option').eq(ui.value).attr('selected', 'selected');
98
+ },
99
+ values: (function(){
100
+ var values = [];
101
+ selects.each(function(){
102
+ values.push( jQuery(this).get(0).selectedIndex );
103
+ });
104
+ return values;
105
+ })()
106
+ };
107
+
108
+ //slider options from settings
109
+ options.sliderOptions = (settings) ? jQuery.extend(sliderOptions, settings.sliderOptions) : sliderOptions;
110
+
111
+ //select element change event
112
+ selects.bind('change keyup click', function(){
113
+ var thisIndex = jQuery(this).get(0).selectedIndex;
114
+ var thisHandle = jQuery('#handle_'+ jQuery(this).attr('id'));
115
+ var handleIndex = thisHandle.data('handleNum');
116
+ thisHandle.parents('.ui-slider:eq(0)').slider("values", handleIndex, thisIndex);
117
+ });
118
+
119
+
120
+ //create slider component div
121
+ var sliderComponent = jQuery('<div></div>');
122
+
123
+ //CREATE HANDLES
124
+ selects.each(function(i){
125
+ var hidett = '';
126
+
127
+ //associate label for ARIA
128
+ var thisLabel = jQuery('label[for=' + jQuery(this).attr('id') +']');
129
+ //labelled by aria doesn't seem to work on slider handle. Using title attr as backup
130
+ var labelText = (thisLabel.size()>0) ? 'Slider control for '+ thisLabel.text()+'' : '';
131
+ var thisLabelId = thisLabel.attr('id') || thisLabel.attr('id', 'label_'+handleIds[i]).attr('id');
132
+
133
+
134
+ if( options.tooltip == false ){hidett = ' style="display: none;"';}
135
+ jQuery('<a '+
136
+ 'href="#" tabindex="0" '+
137
+ 'id="'+handleIds[i]+'" '+
138
+ 'class="ui-slider-handle" '+
139
+ 'role="slider" '+
140
+ 'aria-labelledby="'+thisLabelId+'" '+
141
+ 'aria-valuemin="'+options.sliderOptions.min+'" '+
142
+ 'aria-valuemax="'+options.sliderOptions.max+'" '+
143
+ 'aria-valuenow="'+options.sliderOptions.values[i]+'" '+
144
+ 'aria-valuetext="'+ttText(options.sliderOptions.values[i])+'" '+
145
+ '><span class="screenReaderContext">'+labelText+'</span>'+
146
+ '<span class="ui-slider-tooltip ui-widget-content ui-corner-all"'+ hidett +'><span class="ttContent"></span>'+
147
+ '<span class="ui-tooltip-pointer-down ui-widget-content"><span class="ui-tooltip-pointer-down-inner"></span></span>'+
148
+ '</span></a>')
149
+ .data('handleNum',i)
150
+ .appendTo(sliderComponent);
151
+ });
152
+
153
+ //CREATE SCALE AND TICS
154
+
155
+ //write dl if there are optgroups
156
+ if(groups) {
157
+ var inc = 0;
158
+ var scale = sliderComponent.append('<dl class="ui-slider-scale ui-helper-reset" role="presentation"></dl>').find('.ui-slider-scale:eq(0)');
159
+ jQuery(groups).each(function(h){
160
+ scale.append('<dt style="width: '+ (100/groups.length).toFixed(2) +'%' +'; left:'+ (h/(groups.length-1) * 100).toFixed(2) +'%' +'"><span>'+this.label+'</span></dt>');//class name becomes camelCased label
161
+ var groupOpts = this.options;
162
+ jQuery(this.options).each(function(i){
163
+ var style = (inc == selectOptions.length-1 || inc == 0) ? 'style="display: none;"' : '' ;
164
+ var labelText = (options.labelSrc == 'text') ? groupOpts[i].text : groupOpts[i].value;
165
+ scale.append('<dd style="left:'+ leftVal(inc) +'"><span class="ui-slider-label">'+ labelText +'</span><span class="ui-slider-tic ui-widget-content"'+ style +'></span></dd>');
166
+ inc++;
167
+ });
168
+ });
169
+ }
170
+ //write ol
171
+ else {
172
+ var scale = sliderComponent.append('<ol class="ui-slider-scale ui-helper-reset" role="presentation"></ol>').find('.ui-slider-scale:eq(0)');
173
+ jQuery(selectOptions).each(function(i){
174
+ var style = (i == selectOptions.length-1 || i == 0) ? 'style="display: none;"' : '' ;
175
+ var labelText = (options.labelSrc == 'text') ? this.text : this.value;
176
+ scale.append('<li style="left:'+ leftVal(i) +'"><span class="ui-slider-label">'+ labelText +'</span><span class="ui-slider-tic ui-widget-content"'+ style +'></span></li>');
177
+ });
178
+ }
179
+
180
+ function leftVal(i){
181
+ return (i/(selectOptions.length-1) * 100).toFixed(2) +'%';
182
+
183
+ }
184
+
185
+
186
+
187
+
188
+ //show and hide labels depending on labels pref
189
+ //show the last one if there are more than 1 specified
190
+ if(options.labels > 1) sliderComponent.find('.ui-slider-scale li:last span.ui-slider-label, .ui-slider-scale dd:last span.ui-slider-label').addClass('ui-slider-label-show');
191
+
192
+ //set increment
193
+ var increm = Math.max(1, Math.round(selectOptions.length / options.labels));
194
+ //show em based on inc
195
+ for(var j=0; j<selectOptions.length; j+=increm){
196
+ if((selectOptions.length - j) > increm){//don't show if it's too close to the end label
197
+ sliderComponent.find('.ui-slider-scale li:eq('+ j +') span.ui-slider-label, .ui-slider-scale dd:eq('+ j +') span.ui-slider-label').addClass('ui-slider-label-show');
198
+ }
199
+ }
200
+
201
+ //style the dt's
202
+ sliderComponent.find('.ui-slider-scale dt').each(function(i){
203
+ jQuery(this).css({
204
+ 'left': ((100 /( groups.length))*i).toFixed(2) + '%'
205
+ });
206
+ });
207
+
208
+
209
+ //inject and return
210
+ sliderComponent
211
+ .insertAfter(jQuery(this).eq(this.length-1))
212
+ .slider(options.sliderOptions)
213
+ .attr('role','application')
214
+ .find('.ui-slider-label')
215
+ .each(function(){
216
+ jQuery(this).css('marginLeft', -jQuery(this).width()/2);
217
+ });
218
+
219
+ //update tooltip arrow inner color
220
+ sliderComponent.find('.ui-tooltip-pointer-down-inner').each(function(){
221
+ var bWidth = jQuery('.ui-tooltip-pointer-down-inner').css('borderTopWidth');
222
+ var bColor = jQuery(this).parents('.ui-slider-tooltip').css('backgroundColor')
223
+ jQuery(this).css('border-top', bWidth+' solid '+bColor);
224
+ });
225
+
226
+ var values = sliderComponent.slider('values');
227
+
228
+ if(isArray(values)){
229
+ jQuery(values).each(function(i){
230
+ sliderComponent.find('.ui-slider-tooltip .ttContent').eq(i).text( ttText(this) );
231
+ });
232
+ }
233
+ else {
234
+ sliderComponent.find('.ui-slider-tooltip .ttContent').eq(0).text( ttText(values) );
235
+ }
236
+
237
+ return this;
238
+ }
239
+
240
+
@@ -0,0 +1,566 @@
1
+ // Underscore.string
2
+ // (c) 2010 Esa-Matti Suuronen <esa-matti aet suuronen dot org>
3
+ // Underscore.strings is freely distributable under the terms of the MIT license.
4
+ // Documentation: https://github.com/epeli/underscore.string
5
+ // Some code is borrowed from MooTools and Alexandru Marasteanu.
6
+
7
+ // Version 2.2.0rc
8
+
9
+ !function(root){
10
+ 'use strict';
11
+
12
+ // Defining helper functions.
13
+
14
+ var nativeTrim = String.prototype.trim;
15
+ var nativeTrimRight = String.prototype.trimRight;
16
+ var nativeTrimLeft = String.prototype.trimLeft;
17
+
18
+ var parseNumber = function(source) { return source * 1 || 0; };
19
+
20
+ var strRepeat = function(str, qty){
21
+ if (qty < 1) return '';
22
+ var result = '';
23
+ while (qty > 0) {
24
+ if (qty & 1) result += str;
25
+ qty >>= 1, str += str;
26
+ }
27
+ return result;
28
+ };
29
+
30
+ var slice = [].slice;
31
+
32
+ var replace = function(str, pattern, something){
33
+ return (''+str).replace(pattern, something);
34
+ }
35
+
36
+ var defaultToWhiteSpace = function(characters){
37
+ if (characters != null) {
38
+ return '[' + _s.escapeRegExp(characters) + ']';
39
+ }
40
+ return '\\s';
41
+ };
42
+
43
+ var levenshtein = function(str1, str2) {
44
+ str1 += ''; str2 += '';
45
+
46
+ var current = [], prev, value;
47
+
48
+ for (var i = 0; i <= str2.length; i++)
49
+ for (var j = 0; j <= str1.length; j++) {
50
+ if (i && j)
51
+ if (str1.charAt(j - 1) === str2.charAt(i - 1))
52
+ value = prev;
53
+ else
54
+ value = Math.min(current[j], current[j - 1], prev) + 1;
55
+ else
56
+ value = i + j;
57
+
58
+ prev = current[j];
59
+ current[j] = value;
60
+ }
61
+
62
+ return current.pop();
63
+ };
64
+
65
+ var escapeChars = {
66
+ lt: '<',
67
+ gt: '>',
68
+ quot: '"',
69
+ apos: "'",
70
+ amp: '&'
71
+ };
72
+
73
+ var reversedEscapeChars = {};
74
+ for(var key in escapeChars){ reversedEscapeChars[escapeChars[key]] = key; }
75
+
76
+ // sprintf() for JavaScript 0.7-beta1
77
+ // http://www.diveintojavascript.com/projects/javascript-sprintf
78
+ //
79
+ // Copyright (c) Alexandru Marasteanu <alexaholic [at) gmail (dot] com>
80
+ // All rights reserved.
81
+
82
+ var sprintf = (function() {
83
+ function get_type(variable) {
84
+ return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
85
+ }
86
+
87
+ var str_repeat = strRepeat;
88
+
89
+ var str_format = function() {
90
+ if (!str_format.cache.hasOwnProperty(arguments[0])) {
91
+ str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
92
+ }
93
+ return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
94
+ };
95
+
96
+ str_format.format = function(parse_tree, argv) {
97
+ var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
98
+ for (i = 0; i < tree_length; i++) {
99
+ node_type = get_type(parse_tree[i]);
100
+ if (node_type === 'string') {
101
+ output.push(parse_tree[i]);
102
+ }
103
+ else if (node_type === 'array') {
104
+ match = parse_tree[i]; // convenience purposes only
105
+ if (match[2]) { // keyword argument
106
+ arg = argv[cursor];
107
+ for (k = 0; k < match[2].length; k++) {
108
+ if (!arg.hasOwnProperty(match[2][k])) {
109
+ throw new Error(sprintf('[_.sprintf] property "%s" does not exist', match[2][k]));
110
+ }
111
+ arg = arg[match[2][k]];
112
+ }
113
+ } else if (match[1]) { // positional argument (explicit)
114
+ arg = argv[match[1]];
115
+ }
116
+ else { // positional argument (implicit)
117
+ arg = argv[cursor++];
118
+ }
119
+
120
+ if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) {
121
+ throw new Error(sprintf('[_.sprintf] expecting number but found %s', get_type(arg)));
122
+ }
123
+ switch (match[8]) {
124
+ case 'b': arg = arg.toString(2); break;
125
+ case 'c': arg = String.fromCharCode(arg); break;
126
+ case 'd': arg = parseInt(arg, 10); break;
127
+ case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break;
128
+ case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break;
129
+ case 'o': arg = arg.toString(8); break;
130
+ case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break;
131
+ case 'u': arg = Math.abs(arg); break;
132
+ case 'x': arg = arg.toString(16); break;
133
+ case 'X': arg = arg.toString(16).toUpperCase(); break;
134
+ }
135
+ arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg);
136
+ pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' ';
137
+ pad_length = match[6] - String(arg).length;
138
+ pad = match[6] ? str_repeat(pad_character, pad_length) : '';
139
+ output.push(match[5] ? arg + pad : pad + arg);
140
+ }
141
+ }
142
+ return output.join('');
143
+ };
144
+
145
+ str_format.cache = {};
146
+
147
+ str_format.parse = function(fmt) {
148
+ var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
149
+ while (_fmt) {
150
+ if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
151
+ parse_tree.push(match[0]);
152
+ }
153
+ else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
154
+ parse_tree.push('%');
155
+ }
156
+ else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) {
157
+ if (match[2]) {
158
+ arg_names |= 1;
159
+ var field_list = [], replacement_field = match[2], field_match = [];
160
+ if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
161
+ field_list.push(field_match[1]);
162
+ while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
163
+ if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
164
+ field_list.push(field_match[1]);
165
+ }
166
+ else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
167
+ field_list.push(field_match[1]);
168
+ }
169
+ else {
170
+ throw new Error('[_.sprintf] huh?');
171
+ }
172
+ }
173
+ }
174
+ else {
175
+ throw new Error('[_.sprintf] huh?');
176
+ }
177
+ match[2] = field_list;
178
+ }
179
+ else {
180
+ arg_names |= 2;
181
+ }
182
+ if (arg_names === 3) {
183
+ throw new Error('[_.sprintf] mixing positional and named placeholders is not (yet) supported');
184
+ }
185
+ parse_tree.push(match);
186
+ }
187
+ else {
188
+ throw new Error('[_.sprintf] huh?');
189
+ }
190
+ _fmt = _fmt.substring(match[0].length);
191
+ }
192
+ return parse_tree;
193
+ };
194
+
195
+ return str_format;
196
+ })();
197
+
198
+
199
+
200
+ // Defining underscore.string
201
+
202
+ var _s = {
203
+
204
+ VERSION: '2.2.0rc',
205
+
206
+ isBlank: function(str){
207
+ return (/^\s*$/).test(str);
208
+ },
209
+
210
+ stripTags: function(str){
211
+ return replace(str, /<\/?[^>]+>/g, '');
212
+ },
213
+
214
+ capitalize : function(str) {
215
+ str += '';
216
+ return str.charAt(0).toUpperCase() + str.slice(1);
217
+ },
218
+
219
+ chop: function(str, step){
220
+ str += ''; step = ~~step;
221
+ return step > 0 ? str.match(new RegExp('.{1,' + step + '}', 'g')) : [str];
222
+ },
223
+
224
+ clean: function(str){
225
+ return _s.strip(str).replace(/\s+/g, ' ');
226
+ },
227
+
228
+ count: function(str, substr){
229
+ str += ''; substr += '';
230
+ return str.split(substr).length - 1;
231
+ },
232
+
233
+ chars: function(str) {
234
+ return (''+str).split('');
235
+ },
236
+
237
+ swapCase: function(str) {
238
+ return replace(str, /\S/g, function(ch){
239
+ return ch === ch.toUpperCase() ? ch.toLowerCase() : ch.toUpperCase();
240
+ });
241
+ },
242
+
243
+ escapeHTML: function(str) {
244
+ return replace(str, /[&<>"']/g, function(match){ return '&' + reversedEscapeChars[match] + ';'; });
245
+ },
246
+
247
+ unescapeHTML: function(str) {
248
+ return replace(str, /\&([^;]+);/g, function(entity, entityCode){
249
+ var match;
250
+
251
+ if (entityCode in escapeChars) {
252
+ return escapeChars[entityCode];
253
+ } else if (match = entityCode.match(/^#x([\da-fA-F]+)$/)) {
254
+ return String.fromCharCode(parseInt(match[1], 16));
255
+ } else if (match = entityCode.match(/^#(\d+)$/)) {
256
+ return String.fromCharCode(~~match[1]);
257
+ } else {
258
+ return entity;
259
+ }
260
+ });
261
+ },
262
+
263
+ escapeRegExp: function(str){
264
+ // From MooTools core 1.2.4
265
+ return replace(str, /([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
266
+ },
267
+
268
+ insert: function(str, i, substr){
269
+ var arr = _s.chars(str);
270
+ arr.splice(~~i, 0, ''+substr);
271
+ return arr.join('');
272
+ },
273
+
274
+ include: function(str, needle){
275
+ return !!~(''+str).indexOf(needle);
276
+ },
277
+
278
+ join: function() {
279
+ var args = slice.call(arguments);
280
+ return args.join(args.shift());
281
+ },
282
+
283
+ lines: function(str) {
284
+ return (''+str).split("\n");
285
+ },
286
+
287
+ reverse: function(str){
288
+ return _s.chars(str).reverse().join('');
289
+ },
290
+
291
+ splice: function(str, i, howmany, substr){
292
+ var arr = _s.chars(str);
293
+ arr.splice(~~i, ~~howmany, substr);
294
+ return arr.join('');
295
+ },
296
+
297
+ startsWith: function(str, starts){
298
+ str += ''; starts += '';
299
+ return str.length >= starts.length && str.slice(0, starts.length) === starts;
300
+ },
301
+
302
+ endsWith: function(str, ends){
303
+ str += ''; ends += '';
304
+ return str.length >= ends.length && str.slice(str.length - ends.length) === ends;
305
+ },
306
+
307
+ succ: function(str){
308
+ str += '';
309
+ var arr = _s.chars(str);
310
+ arr.splice(str.length-1, 1, String.fromCharCode(str.charCodeAt(str.length-1) + 1));
311
+ return arr.join('');
312
+ },
313
+
314
+ titleize: function(str){
315
+ return replace(str, /(?:^|\s)\S/g, function(ch){ return ch.toUpperCase(); });
316
+ },
317
+
318
+ camelize: function(str){
319
+ return _s.trim(str).replace(/[-_\s]+(.)?/g, function(match, ch){ return ch.toUpperCase(); });
320
+ },
321
+
322
+ underscored: function(str){
323
+ return _s.trim(str).replace(/([a-z\d])([A-Z]+)/g, '$1_$2').replace(/[-\s]+/g, '_').toLowerCase();
324
+ },
325
+
326
+ dasherize: function(str){
327
+ return _s.trim(str).replace(/([A-Z])/g, '-$1').replace(/[-_\s]+/g, '-').toLowerCase();
328
+ },
329
+
330
+ classify: function(str){
331
+ return _s.titleize(replace(str, /_/g, ' ')).replace(/\s/g, '');
332
+ },
333
+
334
+ humanize: function(str){
335
+ return _s.capitalize(_s.underscored(str).replace(/_id$/,'').replace(/_/g, ' '));
336
+ },
337
+
338
+ trim: function(str, characters){
339
+ str += '';
340
+ if (!characters && nativeTrim) return nativeTrim.call(str);
341
+ characters = defaultToWhiteSpace(characters);
342
+ return str.replace(new RegExp('\^' + characters + '+|' + characters + '+$', 'g'), '');
343
+ },
344
+
345
+ ltrim: function(str, characters){
346
+ str += '';
347
+ if (!characters && nativeTrimLeft) {
348
+ return nativeTrimLeft.call(str);
349
+ }
350
+ characters = defaultToWhiteSpace(characters);
351
+ return str.replace(new RegExp('^' + characters + '+'), '');
352
+ },
353
+
354
+ rtrim: function(str, characters){
355
+ str += '';
356
+ if (!characters && nativeTrimRight) {
357
+ return nativeTrimRight.call(str);
358
+ }
359
+ characters = defaultToWhiteSpace(characters);
360
+ return str.replace(new RegExp(characters + '+$'), '');
361
+ },
362
+
363
+ truncate: function(str, length, truncateStr){
364
+ str += ''; truncateStr = truncateStr || '...';
365
+ length = ~~length;
366
+ return str.length > length ? str.slice(0, length) + truncateStr : str;
367
+ },
368
+
369
+ /**
370
+ * _s.prune: a more elegant version of truncate
371
+ * prune extra chars, never leaving a half-chopped word.
372
+ * @author github.com/rwz
373
+ */
374
+ prune: function(str, length, pruneStr){
375
+ str += ''; length = ~~length;
376
+ pruneStr = pruneStr != null ? ''+pruneStr : '...';
377
+
378
+ if (str.length <= length) return str;
379
+
380
+ var tmpl = function(c){ return c.toUpperCase() !== c.toLowerCase() ? 'A' : ' '; },
381
+ template = str.slice(0, length+1).replace(/.(?=\W*\w*$)/g, tmpl); // 'Hello, world' -> 'HellAA AAAAA'
382
+
383
+ if (template.slice(template.length-2).match(/\w\w/))
384
+ template = template.replace(/\s*\S+$/, '');
385
+ else
386
+ template = _s.rtrim(template.slice(0, template.length-1));
387
+
388
+ return (template+pruneStr).length > str.length ? str : str.slice(0, template.length)+pruneStr;
389
+ },
390
+
391
+ words: function(str, delimiter) {
392
+ return _s.trim(str, delimiter).split(delimiter || /\s+/);
393
+ },
394
+
395
+ pad: function(str, length, padStr, type) {
396
+ str += '';
397
+
398
+ var padlen = 0;
399
+
400
+ length = ~~length;
401
+
402
+ if (!padStr) {
403
+ padStr = ' ';
404
+ } else if (padStr.length > 1) {
405
+ padStr = padStr.charAt(0);
406
+ }
407
+
408
+ switch(type) {
409
+ case 'right':
410
+ padlen = (length - str.length);
411
+ return str + strRepeat(padStr, padlen);
412
+ case 'both':
413
+ padlen = (length - str.length);
414
+ return strRepeat(padStr, Math.ceil(padlen/2)) +
415
+ str +
416
+ strRepeat(padStr, Math.floor(padlen/2));
417
+ default: // 'left'
418
+ padlen = (length - str.length);
419
+ return strRepeat(padStr, padlen) + str;
420
+ }
421
+ },
422
+
423
+ lpad: function(str, length, padStr) {
424
+ return _s.pad(str, length, padStr);
425
+ },
426
+
427
+ rpad: function(str, length, padStr) {
428
+ return _s.pad(str, length, padStr, 'right');
429
+ },
430
+
431
+ lrpad: function(str, length, padStr) {
432
+ return _s.pad(str, length, padStr, 'both');
433
+ },
434
+
435
+ sprintf: sprintf,
436
+
437
+ vsprintf: function(fmt, argv){
438
+ argv.unshift(fmt);
439
+ return sprintf.apply(null, argv);
440
+ },
441
+
442
+ toNumber: function(str, decimals) {
443
+ str += '';
444
+ var num = parseNumber(parseNumber(str).toFixed(~~decimals));
445
+ return num === 0 && !str.match(/^0+$/) ? Number.NaN : num;
446
+ },
447
+
448
+ strRight: function(str, sep){
449
+ str += ''; sep = sep != null ? ''+sep : sep;
450
+ var pos = !sep ? -1 : str.indexOf(sep);
451
+ return ~pos ? str.slice(pos+sep.length, str.length) : str;
452
+ },
453
+
454
+ strRightBack: function(str, sep){
455
+ str += ''; sep = sep != null ? ''+sep : sep;
456
+ var pos = !sep ? -1 : str.lastIndexOf(sep);
457
+ return ~pos ? str.slice(pos+sep.length, str.length) : str;
458
+ },
459
+
460
+ strLeft: function(str, sep){
461
+ str += ''; sep = sep != null ? ''+sep : sep;
462
+ var pos = !sep ? -1 : str.indexOf(sep);
463
+ return ~pos ? str.slice(0, pos) : str;
464
+ },
465
+
466
+ strLeftBack: function(str, sep){
467
+ str += ''; sep = sep != null ? ''+sep : sep;
468
+ var pos = str.lastIndexOf(sep);
469
+ return ~pos ? str.slice(0, pos) : str;
470
+ },
471
+
472
+ toSentence: function(array, separator, lastSeparator) {
473
+ separator || (separator = ', ');
474
+ lastSeparator || (lastSeparator = ' and ');
475
+ var length = array.length, str = '';
476
+
477
+ for (var i = 0; i < length; i++) {
478
+ str += array[i];
479
+ if (i === (length - 2)) { str += lastSeparator; }
480
+ else if (i < (length - 1)) { str += separator; }
481
+ }
482
+
483
+ return str;
484
+ },
485
+
486
+ slugify: function(str) {
487
+ var from = "ąàáäâãćęèéëêìíïîłńòóöôõùúüûñçżź",
488
+ to = "aaaaaaceeeeeiiiilnooooouuuunczz",
489
+ regex = new RegExp(defaultToWhiteSpace(from), 'g');
490
+
491
+ str = (''+str).toLowerCase();
492
+
493
+ str = str.replace(regex, function(ch){
494
+ var index = from.indexOf(ch);
495
+ return to.charAt(index) || '-';
496
+ });
497
+
498
+ return _s.dasherize(str.replace(/[^\w\s-]/g, ''));
499
+ },
500
+
501
+ surround: function(str, wrapper) {
502
+ return [wrapper, str, wrapper].join('');
503
+ },
504
+
505
+ quote: function(str) {
506
+ return _s.surround(str, '"');
507
+ },
508
+
509
+ exports: function() {
510
+ var result = {};
511
+
512
+ for (var prop in this) {
513
+ if (!this.hasOwnProperty(prop) || prop.match(/^(?:include|contains|reverse)$/)) continue;
514
+ result[prop] = this[prop];
515
+ }
516
+
517
+ return result;
518
+ },
519
+
520
+ repeat: function(str, qty, separator){
521
+ qty = ~~qty;
522
+
523
+ // using faster implementation if separator is not needed;
524
+ if (separator == null) return strRepeat(str+'', qty);
525
+
526
+ // this one is about 300x slower in Google Chrome
527
+ for (var repeat = []; qty > 0; repeat[--qty] = str) {}
528
+ return repeat.join(separator);
529
+ },
530
+
531
+ levenshtein: levenshtein
532
+ };
533
+
534
+ // Aliases
535
+
536
+ _s.strip = _s.trim;
537
+ _s.lstrip = _s.ltrim;
538
+ _s.rstrip = _s.rtrim;
539
+ _s.center = _s.lrpad;
540
+ _s.rjust = _s.lpad;
541
+ _s.ljust = _s.rpad;
542
+ _s.contains = _s.include;
543
+ _s.q = _s.quote;
544
+
545
+ // CommonJS module is defined
546
+ if (typeof exports !== 'undefined') {
547
+ if (typeof module !== 'undefined' && module.exports) {
548
+ // Export module
549
+ module.exports = _s;
550
+ }
551
+ exports._s = _s;
552
+
553
+ } else if (typeof define === 'function' && define.amd) {
554
+ // Register as a named module with AMD.
555
+ define('underscore.string', [], function() {
556
+ return _s;
557
+ });
558
+
559
+ } else {
560
+ // Integrate with Underscore.js if defined
561
+ // or create our own underscore object.
562
+ root._ = root._ || {};
563
+ root._.string = root._.str = _s;
564
+ }
565
+
566
+ }(this);