susply 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +8 -0
  4. data/Rakefile +30 -0
  5. data/app/assets/javascripts/susply/application.js +13 -0
  6. data/app/assets/stylesheets/susply/application.css +15 -0
  7. data/app/controllers/susply/application_controller.rb +4 -0
  8. data/app/helpers/susply/application_helper.rb +4 -0
  9. data/app/models/susply/payment.rb +19 -0
  10. data/app/models/susply/plan.rb +16 -0
  11. data/app/models/susply/subscription.rb +23 -0
  12. data/app/services/susply/calculations.rb +15 -0
  13. data/app/services/susply/cancel_subscription.rb +11 -0
  14. data/app/services/susply/change_subscription.rb +14 -0
  15. data/app/services/susply/close_subscription.rb +10 -0
  16. data/app/services/susply/create_payment.rb +30 -0
  17. data/app/services/susply/create_subscription.rb +21 -0
  18. data/app/services/susply/owner_methods.rb +28 -0
  19. data/app/services/susply/prorate.rb +22 -0
  20. data/app/services/susply/renews_subscription.rb +25 -0
  21. data/app/views/layouts/susply/application.html.erb +14 -0
  22. data/config/initializers/susply.rb +3 -0
  23. data/config/routes.rb +2 -0
  24. data/db/migrate/20150513155547_create_susply_plans.rb +14 -0
  25. data/db/migrate/20150513161513_add_status_to_plans.rb +6 -0
  26. data/db/migrate/20150513180124_create_susply_subscriptions.rb +17 -0
  27. data/db/migrate/20150521222634_create_susply_payments.rb +19 -0
  28. data/lib/generators/susply/install_generator.rb +20 -0
  29. data/lib/generators/templates/config/initializers/susply.rb +3 -0
  30. data/lib/susply/engine.rb +24 -0
  31. data/lib/susply/version.rb +3 -0
  32. data/lib/susply.rb +10 -0
  33. data/lib/tasks/susply_tasks.rake +4 -0
  34. data/spec/dummy/README.rdoc +28 -0
  35. data/spec/dummy/Rakefile +6 -0
  36. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  37. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  38. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  39. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  40. data/spec/dummy/app/models/organization.rb +5 -0
  41. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  42. data/spec/dummy/bin/bundle +3 -0
  43. data/spec/dummy/bin/rails +4 -0
  44. data/spec/dummy/bin/rake +4 -0
  45. data/spec/dummy/bin/setup +29 -0
  46. data/spec/dummy/config/application.rb +32 -0
  47. data/spec/dummy/config/boot.rb +5 -0
  48. data/spec/dummy/config/database.yml +25 -0
  49. data/spec/dummy/config/environment.rb +5 -0
  50. data/spec/dummy/config/environments/development.rb +41 -0
  51. data/spec/dummy/config/environments/production.rb +79 -0
  52. data/spec/dummy/config/environments/test.rb +42 -0
  53. data/spec/dummy/config/initializers/assets.rb +11 -0
  54. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  55. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  56. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  57. data/spec/dummy/config/initializers/inflections.rb +16 -0
  58. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  59. data/spec/dummy/config/initializers/session_store.rb +3 -0
  60. data/spec/dummy/config/initializers/susply.rb +3 -0
  61. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  62. data/spec/dummy/config/locales/en.yml +23 -0
  63. data/spec/dummy/config/routes.rb +4 -0
  64. data/spec/dummy/config/secrets.yml +22 -0
  65. data/spec/dummy/config.ru +4 -0
  66. data/spec/dummy/db/development.sqlite3 +0 -0
  67. data/spec/dummy/db/migrate/20150513183555_create_organizations.rb +11 -0
  68. data/spec/dummy/db/production.sqlite3 +0 -0
  69. data/spec/dummy/db/schema.rb +67 -0
  70. data/spec/dummy/db/test.sqlite3 +0 -0
  71. data/spec/dummy/log/development.log +950 -0
  72. data/spec/dummy/log/test.log +40824 -0
  73. data/spec/dummy/public/404.html +67 -0
  74. data/spec/dummy/public/422.html +67 -0
  75. data/spec/dummy/public/500.html +66 -0
  76. data/spec/dummy/public/favicon.ico +0 -0
  77. data/spec/dummy/spec/factories/organizations.rb +8 -0
  78. data/spec/dummy/spec/models/organization_spec.rb +4 -0
  79. data/spec/factories/susply_payments.rb +13 -0
  80. data/spec/factories/susply_plans.rb +15 -0
  81. data/spec/factories/susply_subscriptions.rb +19 -0
  82. data/spec/models/susply/payment_spec.rb +135 -0
  83. data/spec/models/susply/plan_spec.rb +106 -0
  84. data/spec/models/susply/subscription_spec.rb +102 -0
  85. data/spec/services/susply/calculations_spec.rb +29 -0
  86. data/spec/services/susply/cancel_subscription_spec.rb +20 -0
  87. data/spec/services/susply/change_subscription_spec.rb +68 -0
  88. data/spec/services/susply/close_subscription_spec.rb +36 -0
  89. data/spec/services/susply/create_payment_spec.rb +84 -0
  90. data/spec/services/susply/create_subscription_spec.rb +22 -0
  91. data/spec/services/susply/owner_methods_spec.rb +99 -0
  92. data/spec/services/susply/prorate_spec.rb +92 -0
  93. data/spec/services/susply/renews_subscription_spec.rb +98 -0
  94. data/spec/spec_helper.rb +19 -0
  95. metadata +282 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7b3829fb3458ce9daf9f83a8155fc4c2f0410385
4
+ data.tar.gz: 244df39807a39516b83e48c70ecf8d502f61a2c3
5
+ SHA512:
6
+ metadata.gz: f5f794f190d0a7f75efb993fed32272b4dd132f07a3ff8f2747326384e5c9aaf1208bbf9e9578f6786e83bded40c25d75a6fa1c3e1abd8df1c5996b1f038c197
7
+ data.tar.gz: 7958f7464dcfc9efd7a0e1b075f57a9994c6a5f5872f6d51785337f3c464911d055f4e077533c3a846d62718971ebcee2f680bfdf56a2f7283d6cf7d6438a6cc
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 Wenceslao Paez Chavez
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/README.rdoc ADDED
@@ -0,0 +1,8 @@
1
+ = Susply
2
+
3
+ {<img alt="Status?branch=master" src="https://codeship.com/projects/9749e880-e313-0132-4e7b-0e8782f5ebb8/status?branch=master" />}[https://codeship.com/projects/81636]
4
+ {<img src="https://codeclimate.com/github/wcpaez/susply/badges/gpa.svg" />}[https://codeclimate.com/github/wcpaez/susply]
5
+ {<img src="https://codeclimate.com/github/wcpaez/susply/badges/coverage.svg" />}[https://codeclimate.com/github/wcpaez/susply/coverage]
6
+
7
+ This project rocks and uses MIT-LICENSE.
8
+
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Susply'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
22
+ Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
23
+
24
+ require 'rspec/core'
25
+ require 'rspec/core/rake_task'
26
+
27
+ desc "Run all specs in spec directory (excluding plugin specs)"
28
+ RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
29
+
30
+ task :default => :spec
@@ -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 any plugin's vendor/assets/javascripts directory 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/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
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 any plugin's vendor/assets/stylesheets directory 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 bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ module Susply
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Susply
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,19 @@
1
+ module Susply
2
+ class Payment < ActiveRecord::Base
3
+ belongs_to :owner, class_name: Susply.subscription_owner_class
4
+ belongs_to :plan, class_name: 'Susply::Plan'
5
+ belongs_to :subscription, class_name: 'Susply::Subscription'
6
+
7
+ validates_presence_of :owner_id, :plan_id, :subscription_id,
8
+ :period_start, :period_end, :amount, :status
9
+
10
+ validates :amount, numericality: { only_integer: true,
11
+ greater_than_or_equal_to: 0 }
12
+
13
+ validates_inclusion_of :generated_type,
14
+ in: %w(plan_renovation plan_change plan_close)
15
+
16
+ validates_inclusion_of :status,
17
+ in: %w(generated paid exonerated refunded)
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ module Susply
2
+ class Plan < ActiveRecord::Base
3
+ validates_presence_of :sku, :name, :description
4
+ validates_uniqueness_of :sku, case_sensitive: false
5
+ validates :price, numericality: { only_integer: true,
6
+ greater_than_or_equal_to: 0 }
7
+
8
+ validates :interval, inclusion: { in: ['monthly', 'yearly'] }
9
+ validates :highlight, inclusion: { in: [true, false] }
10
+ validates :active, inclusion: { in: [true, false] }
11
+ validates :published, inclusion: { in: [true, false] }
12
+
13
+ scope :actives, -> { where(active: true)}
14
+ scope :published, -> { where(published: true)}
15
+ end
16
+ end
@@ -0,0 +1,23 @@
1
+ module Susply
2
+ class Subscription < ActiveRecord::Base
3
+ belongs_to :owner, class_name: Susply.subscription_owner_class
4
+ belongs_to :plan, class_name: 'Susply::Plan'
5
+
6
+ validates_presence_of :owner_id, :plan_id, :start,
7
+ :current_period_start, :current_period_end
8
+
9
+ validates :quantity, numericality: { only_integer: true, greater_than: 0 }
10
+
11
+ def name
12
+ plan.name
13
+ end
14
+
15
+ def price
16
+ plan.price
17
+ end
18
+
19
+ def active?
20
+ deactivated_at.nil?
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ module Susply
2
+ module Calculations
3
+ def end_period_calculation(start, interval)
4
+ case interval
5
+ when 'yearly'
6
+ start + 1.year
7
+ when 'monthly'
8
+ start + 1.month
9
+ else
10
+ start + 1.month
11
+ end
12
+ end
13
+ module_function :end_period_calculation
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ module Susply
2
+ class CancelSubscription
3
+ def self.call(subscription)
4
+ if subscription.active?
5
+ subscription.update_attributes(deactivated_at: Time.zone.now)
6
+ end
7
+
8
+ subscription
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ module Susply
2
+ class ChangeSubscription
3
+ def self.call(owner, new_plan)
4
+ if owner.has_active_subscription?
5
+ Susply::CreatePayment.call(owner.active_subscription, "plan_change")
6
+ Susply::CancelSubscription.call(owner.active_subscription)
7
+ end
8
+
9
+ new_subscription = Susply::CreateSubscription.call(owner, new_plan)
10
+
11
+ new_subscription
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ module Susply
2
+ class CloseSubscription
3
+ def self.call(owner)
4
+ if owner.has_active_subscription?
5
+ Susply::CreatePayment.call(owner.active_subscription, "plan_close")
6
+ Susply::CancelSubscription.call(owner.active_subscription)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,30 @@
1
+ module Susply
2
+ module CreatePayment
3
+ def self.call(subscription, generated_type)
4
+ if subscription.active?
5
+ amount = calculate_amount(subscription, generated_type)
6
+ payment = Susply::Payment.new do |payment|
7
+ payment.owner = subscription.owner
8
+ payment.plan = subscription.plan
9
+ payment.subscription = subscription
10
+ payment.amount = amount
11
+ payment.generated_type = generated_type
12
+ payment.period_start = subscription.current_period_start
13
+ payment.period_end = subscription.current_period_end
14
+ payment.status = 'generated'
15
+ end
16
+ payment.save!
17
+ payment
18
+ end
19
+ end
20
+
21
+ private
22
+ def self.calculate_amount(subscription, generated_type)
23
+ if generated_type == "plan_renovation"
24
+ subscription.plan.price
25
+ else
26
+ Susply::Prorate.call(subscription)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,21 @@
1
+ module Susply
2
+ class CreateSubscription
3
+ def self.call(owner, plan)
4
+ now = Time.zone.now
5
+
6
+ subscription = Susply::Subscription.new do |s|
7
+ s.owner = owner
8
+ s.plan = plan
9
+ s.quantity = 1
10
+ s.start = now
11
+ s.current_period_start = now
12
+ s.current_period_end = Susply::Calculations.
13
+ end_period_calculation(s.current_period_start, plan.interval)
14
+ end
15
+
16
+ subscription.save!
17
+
18
+ subscription
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,28 @@
1
+ module Susply
2
+ module OwnerMethods
3
+ def self.included(base)
4
+ base.extend ClassMethods
5
+ base.class_eval do
6
+ has_many :subscriptions, class_name: 'Susply::Subscription',
7
+ foreign_key: 'owner_id'
8
+ has_many :payments, class_name: 'Susply::Payment',
9
+ foreign_key: 'owner_id'
10
+ end
11
+ end
12
+
13
+ module ClassMethods
14
+ end
15
+
16
+ def has_active_subscription?
17
+ active_subscription.present?
18
+ end
19
+
20
+ def active_subscription
21
+ subscriptions.detect(&:active?)
22
+ end
23
+
24
+ def most_recently_deactivated_subscription
25
+ subscriptions.reject(&:active?).max_by(&:deactivated_at)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,22 @@
1
+ module Susply
2
+ module Prorate
3
+ def self.call(subscription)
4
+ return 0 unless subscription.active?
5
+ plan = subscription.plan
6
+ days = used_days(subscription)
7
+ calculate_used_amount(plan, days)
8
+ end
9
+
10
+ def self.used_days(subscription)
11
+ (Time.zone.today.to_date - subscription.current_period_start.to_date).to_i
12
+ end
13
+
14
+ def self.calculate_used_amount(plan, used_days)
15
+ if plan.interval == "yearly"
16
+ (plan.price * 1.2 * used_days / 365).ceil
17
+ else
18
+ (plan.price * used_days / 30.0).ceil
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ module Susply
2
+ class RenewsSubscription
3
+ def self.call(owner)
4
+ if owner.has_active_subscription?
5
+ subscription = owner.active_subscription
6
+ Susply::CreatePayment.call(subscription, "plan_renovation")
7
+ calculate_renewed_subscription(subscription)
8
+ else
9
+ nil
10
+ end
11
+ end
12
+
13
+ private
14
+ def self.calculate_renewed_subscription(subscription)
15
+ new_period_start = subscription.current_period_end
16
+ new_period_end = Susply::Calculations.
17
+ end_period_calculation(new_period_start, subscription.plan.interval)
18
+ subscription.quantity = subscription.quantity + 1
19
+ subscription.current_period_start = new_period_start
20
+ subscription.current_period_end = new_period_end
21
+ subscription.save
22
+ subscription
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Susply</title>
5
+ <%= stylesheet_link_tag "susply/application", media: "all" %>
6
+ <%= javascript_include_tag "susply/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ Susply.setup do |config|
2
+ config.subscription_owner_class = "Organization"
3
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ Susply::Engine.routes.draw do
2
+ end
@@ -0,0 +1,14 @@
1
+ class CreateSusplyPlans < ActiveRecord::Migration
2
+ def change
3
+ create_table :susply_plans do |t|
4
+ t.string :sku
5
+ t.string :name
6
+ t.string :description
7
+ t.integer :price
8
+ t.string :interval
9
+ t.boolean :highlight
10
+
11
+ t.timestamps null: false
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,6 @@
1
+ class AddStatusToPlans < ActiveRecord::Migration
2
+ def change
3
+ add_column :susply_plans, :active, :boolean
4
+ add_column :susply_plans, :published, :boolean
5
+ end
6
+ end
@@ -0,0 +1,17 @@
1
+ class CreateSusplySubscriptions < ActiveRecord::Migration
2
+ def change
3
+ create_table :susply_subscriptions do |t|
4
+ t.integer :owner_id
5
+ t.integer :plan_id
6
+ t.timestamp :start
7
+ t.timestamp :current_period_start
8
+ t.timestamp :current_period_end
9
+ t.integer :quantity
10
+ t.timestamp :deactivated_at
11
+
12
+ t.timestamps null: false
13
+ end
14
+
15
+ add_index :susply_subscriptions, :owner_id
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ class CreateSusplyPayments < ActiveRecord::Migration
2
+ def change
3
+ create_table :susply_payments do |t|
4
+ t.integer :owner_id
5
+ t.integer :plan_id
6
+ t.integer :subscription_id
7
+ t.integer :amount
8
+ t.datetime :period_start
9
+ t.datetime :period_end
10
+ t.string :status
11
+ t.string :invoice
12
+ t.string :generated_type
13
+
14
+ t.timestamps null: false
15
+ end
16
+
17
+ add_index :susply_payments, :owner_id
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ module Susply
2
+ class InstallGenerator < Rails::Generators::Base
3
+ source_root File.expand_path("../../templates", __FILE__)
4
+
5
+ argument :subscription_owner_model, :type => :string, :required => true,
6
+ :desc => "Owner of the subscription"
7
+
8
+ def subscription_owner_model
9
+ @subscription_owner_model.capitalize
10
+ end
11
+
12
+ def install
13
+ template "config/initializers/susply.rb"
14
+
15
+ inject_into_class "app/models/#{subscription_owner_model.downcase}.rb",
16
+ subscription_owner_model.downcase.camelize.constantize,
17
+ "# Added by Susply\n include Susply::OwnerMethods \n\n"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ Susply.setup do |config|
2
+ config.subscription_owner_class = "<%= subscription_owner_model %>"
3
+ end
@@ -0,0 +1,24 @@
1
+ module Susply
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Susply
4
+
5
+ config.to_prepare do
6
+ Decorators.register! Engine.root, Rails.root
7
+ end
8
+
9
+ config.generators do |g|
10
+ g.test_framework :rspec, :fixture => false
11
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
12
+ g.assets false
13
+ g.helper false
14
+ end
15
+
16
+ initializer :append_migrations do |app|
17
+ unless app.root.to_s.match(root.to_s)
18
+ config.paths["db/migrate"].expanded.each do |p|
19
+ app.config.paths["db/migrate"] << p
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module Susply
2
+ VERSION = "0.0.1"
3
+ end
data/lib/susply.rb ADDED
@@ -0,0 +1,10 @@
1
+ require "susply/engine"
2
+ require "decorators"
3
+
4
+ module Susply
5
+ mattr_accessor :subscription_owner_class
6
+
7
+ def self.setup(&block)
8
+ yield self
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :susply do
3
+ # # Task goes here
4
+ # 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,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.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 any plugin's vendor/assets/javascripts directory 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/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
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 any plugin's vendor/assets/stylesheets directory 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 bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -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,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,5 @@
1
+ class Organization < ActiveRecord::Base
2
+ # Added by Susply
3
+ include Susply::OwnerMethods
4
+
5
+ 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>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run