catarse_moip 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -6
  3. data/.rspec +2 -0
  4. data/.travis.yml +17 -0
  5. data/Gemfile +2 -109
  6. data/Gemfile.lock +73 -476
  7. data/README.md +2 -26
  8. data/Rakefile +7 -2
  9. data/app/assets/javascripts/catarse_moip/moip_form.js +80 -0
  10. data/app/assets/javascripts/catarse_moip/payment_account.js +37 -0
  11. data/app/assets/javascripts/catarse_moip/payment_card.js +89 -0
  12. data/app/assets/javascripts/catarse_moip/payment_choice.js +19 -0
  13. data/app/assets/javascripts/catarse_moip/payment_slip.js +35 -0
  14. data/app/assets/javascripts/catarse_moip/user_document.js +111 -0
  15. data/app/assets/javascripts/catarse_moip.js +7 -0
  16. data/app/controllers/catarse_moip/moip_controller.rb +126 -0
  17. data/app/views/catarse_moip/moip/review.html.slim +105 -0
  18. data/catarse_moip.gemspec +5 -5
  19. data/config/initializers/moip.rb +4 -7
  20. data/config/initializers/register.rb +5 -0
  21. data/config/locales/en.yml +2 -0
  22. data/config/locales/pt.yml +19 -0
  23. data/config/routes.rb +9 -5
  24. data/lib/catarse_moip/engine.rb +7 -0
  25. data/lib/catarse_moip/version.rb +1 -1
  26. data/lib/catarse_moip.rb +1 -1
  27. data/lib/moip_transparente/checkout.rb +218 -0
  28. data/lib/moip_transparente/version.rb +3 -0
  29. data/lib/moip_transparente.rb +32 -0
  30. data/spec/controllers/catarse_moip/moip_controller_spec.rb +230 -0
  31. data/spec/fixtures/ipn_data.txt +1 -0
  32. data/spec/javascripts/moip_form_spec.js +25 -0
  33. data/spec/javascripts/support/app.js +1 -0
  34. data/spec/javascripts/support/backbone.js +1571 -0
  35. data/spec/javascripts/support/jquery.js +8829 -0
  36. data/spec/javascripts/support/skull.js +64 -0
  37. data/spec/javascripts/support/underscore.js +1227 -0
  38. data/spec/spec_helper.rb +2 -23
  39. data/spec/support/payment_engines.rb +3 -0
  40. data/test/dummy/README.rdoc +261 -0
  41. data/test/dummy/Rakefile +7 -0
  42. data/test/dummy/app/assets/javascripts/application.js +15 -0
  43. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  44. data/test/dummy/app/controllers/application_controller.rb +3 -0
  45. data/test/dummy/app/helpers/application_helper.rb +2 -0
  46. data/test/dummy/app/mailers/.gitkeep +0 -0
  47. data/test/dummy/app/models/.gitkeep +0 -0
  48. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  49. data/test/dummy/config/application.rb +59 -0
  50. data/test/dummy/config/boot.rb +10 -0
  51. data/test/dummy/config/database.yml +50 -0
  52. data/test/dummy/config/environment.rb +5 -0
  53. data/test/dummy/config/environments/development.rb +37 -0
  54. data/test/dummy/config/environments/production.rb +67 -0
  55. data/test/dummy/config/environments/test.rb +37 -0
  56. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  57. data/test/dummy/config/initializers/inflections.rb +15 -0
  58. data/test/dummy/config/initializers/mime_types.rb +5 -0
  59. data/test/dummy/config/initializers/secret_token.rb +7 -0
  60. data/test/dummy/config/initializers/session_store.rb +8 -0
  61. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  62. data/test/dummy/config/locales/en.yml +5 -0
  63. data/test/dummy/config/routes.rb +4 -0
  64. data/test/dummy/config.ru +4 -0
  65. data/test/dummy/lib/assets/.gitkeep +0 -0
  66. data/test/dummy/log/.gitkeep +0 -0
  67. data/test/dummy/public/404.html +26 -0
  68. data/test/dummy/public/422.html +26 -0
  69. data/test/dummy/public/500.html +25 -0
  70. data/test/dummy/public/favicon.ico +0 -0
  71. data/test/dummy/script/rails +6 -0
  72. metadata +120 -35
  73. data/.gitmodules +0 -3
  74. data/app/controllers/catarse_moip/payment/moip_controller.rb +0 -49
  75. data/spec/controllers/catarse_moip/payment/moip_controller_spec.rb +0 -81
@@ -0,0 +1,64 @@
1
+ var Skull = { View: undefined };
2
+ if (typeof exports !== 'undefined') {
3
+ Skull = exports;
4
+ }
5
+
6
+ Skull.View = Backbone.View.extend({
7
+ addView: function(name, view){
8
+ if(!this['_' + name]){
9
+ this['_' + name] = new view({name: name, parent: this});
10
+ }
11
+ return this['_' + name];
12
+ },
13
+
14
+ initialize: function(options){
15
+ _.bindAll(this);
16
+ if(options){
17
+ this.name = options.name;
18
+ this.parent = options.parent;
19
+ }
20
+
21
+ if(_.isFunction(this.beforeActivate)){
22
+ this.beforeActivate();
23
+ }
24
+
25
+ this.createViewGetters();
26
+
27
+ if(_.isFunction(this.activate)){
28
+ this.activate();
29
+ }
30
+ },
31
+
32
+ navigate: function(url){
33
+ window.location.href = url;
34
+ },
35
+
36
+ // Create a getter to initilize each view defined in the constructor when needed
37
+ createViewGetters: function(){
38
+ _.each(Object.getPrototypeOf(this).constructor.views, function(val, key){
39
+ var name = key[0].toLowerCase() + key.substring(1);
40
+ Object.defineProperty(this, name, {
41
+ configurable: true,
42
+ enumerable: true,
43
+ get: function(){
44
+ return this.addView(name, val);
45
+ }
46
+ });
47
+ // Initialize the view if the el is present in the parent's DOM subtree
48
+ if(this.$(val.el).length > 0) this[name];
49
+ }, this);
50
+ }
51
+ },
52
+ // Static methods
53
+ {
54
+ // We just overwrite the extend to extract the el property and store it in the constructor
55
+ // That's how we look for the view's el before initializing it
56
+ views: {},
57
+ addChild: function(name, protoProps, staticProps){
58
+ var child = Skull.View.extend(protoProps, _.extend({views: {}}, staticProps));
59
+ child.el = protoProps.el;
60
+ this.views[name] = child;
61
+ return this;
62
+ }
63
+ });
64
+