stripe_saas 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11d33c83f274930a298978620639a355a8c74e0f
4
- data.tar.gz: 115508a935fc8fe389b89bb57f20adc5c412d88d
3
+ metadata.gz: e683d926b99d47e967cde412ccf290153f5cac08
4
+ data.tar.gz: 9caf9845349a7b64dcb429c86676853cf53447fa
5
5
  SHA512:
6
- metadata.gz: 2e76f158eb245eafce9c67c07eee561272b8d952d43ecce13e6d7eb0b82144cf7ee58fe8f7ce7acb79e96a548a5a4551cb9e8976b950788b7b3b631712112f4d
7
- data.tar.gz: 3d8bff7dc13eae924e75df86389811295a0952974ae71c35fc753671d1b2d199ade53a742392ca58326e9268c65b4f3fd44ea44eec2d7ace6e126bf0487edd03
6
+ metadata.gz: bcfed1599303739ebb5e09a1e2641abe568a7d5eeb1979d401d975c306d9ea90fa18794478280d81c518c59c2038463a285c4287f31b8ffa236b5776f9d9a284
7
+ data.tar.gz: 26811659cdf3b5d511680f963e70485a32b9eee4f4e0b2fd0d90b1e3b0e0c4b8014108244b797112bf9a0f742c452f9d2aaa9789764f28232c2f848313981c6d
@@ -6,7 +6,7 @@ module StripeSaas::Plan
6
6
  end
7
7
 
8
8
  def is_upgrade_from?(plan)
9
- (price || 0) >= (plan.price || 0)
9
+ (price_cents || 0) >= (plan.price_cents || 0)
10
10
  end
11
11
 
12
12
  def is_downgrade_from?(plan)
@@ -14,7 +14,7 @@ module StripeSaas::Plan
14
14
  end
15
15
 
16
16
  def free?
17
- price == 0.0
17
+ price_cents.zero?
18
18
  end
19
19
 
20
20
  def add_feature(feature, value, display_value=nil)
@@ -2,8 +2,12 @@ class Plan < ActiveRecord::Base
2
2
  has_many :subscriptions
3
3
  has_many :plan_features
4
4
  has_many :features, through: :plan_features
5
-
5
+
6
6
  default_scope { order(:display_order) }
7
7
 
8
+ self.all.each do |plan|
9
+ scope plan.to_sym, -> { find_by(stripe_id: plan.stripe_id) }
10
+ end
11
+
8
12
  include StripeSaas::Plan
9
13
  end
@@ -1,3 +1,3 @@
1
1
  module StripeSaas
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
Binary file
@@ -3426,3 +3426,107 @@ Migrating to CreatePlanFeatures (20151220161817)
3426
3426
   (2.0ms) INSERT INTO "schema_migrations" (version) VALUES ('20150102001930')
3427
3427
   (1.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20151220161809')
3428
3428
  ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
3429
+ ActiveRecord::SchemaMigration Load (1.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
3430
+  (4.8ms) CREATE TABLE "features" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "description" varchar, "feature_type" varchar, "unit" varchar, "display_order" integer, "use_unit" boolean, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
3431
+  (1.9ms) CREATE TABLE "plan_features" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "value" varchar, "display_value" varchar, "plan_id" integer, "feature_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
3432
+  (1.8ms) CREATE TABLE "plans" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "stripe_id" varchar, "name" varchar, "price_cents" integer, "interval" varchar, "interval_count" integer, "trial_period_days" integer, "metadata_as_json" text, "statement_descriptor" text, "highlight" boolean, "display_order" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
3433
+  (1.7ms) CREATE TABLE "subscriptions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "stripe_id" varchar, "plan_id" integer, "last_four" varchar, "card_type" varchar, "current_price_cents" integer, "user_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
3434
+  (2.3ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar DEFAULT '' NOT NULL, "encrypted_password" varchar DEFAULT '' NOT NULL, "reset_password_token" varchar, "reset_password_sent_at" datetime, "remember_created_at" datetime, "sign_in_count" integer DEFAULT 0 NOT NULL, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar, "last_sign_in_ip" varchar, "created_at" datetime, "updated_at" datetime) 
3435
+  (0.1ms) select sqlite_version(*)
3436
+  (3.7ms) CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")
3437
+  (0.2ms) SELECT sql
3438
+ FROM sqlite_master
3439
+ WHERE name='index_users_on_email' AND type='index'
3440
+ UNION ALL
3441
+ SELECT sql
3442
+ FROM sqlite_temp_master
3443
+ WHERE name='index_users_on_email' AND type='index'
3444
+
3445
+  (2.2ms) CREATE UNIQUE INDEX "index_users_on_reset_password_token" ON "users" ("reset_password_token")
3446
+  (2.1ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
3447
+  (1.5ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3448
+  (0.4ms) SELECT version FROM "schema_migrations"
3449
+  (2.8ms) INSERT INTO "schema_migrations" (version) VALUES ('20151220161817')
3450
+  (2.1ms) INSERT INTO "schema_migrations" (version) VALUES ('20150101233243')
3451
+  (3.1ms) INSERT INTO "schema_migrations" (version) VALUES ('20150102001921')
3452
+  (2.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20150102001930')
3453
+  (2.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20151220161809')
3454
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
3455
+ ActiveRecord::SchemaMigration Load (1.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
3456
+  (1.0ms) CREATE TABLE "features" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "description" varchar, "feature_type" varchar, "unit" varchar, "display_order" integer, "use_unit" boolean, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
3457
+  (1.0ms) CREATE TABLE "plan_features" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "value" varchar, "display_value" varchar, "plan_id" integer, "feature_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
3458
+  (1.8ms) CREATE TABLE "plans" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "stripe_id" varchar, "name" varchar, "price_cents" integer, "interval" varchar, "interval_count" integer, "trial_period_days" integer, "metadata_as_json" text, "statement_descriptor" text, "highlight" boolean, "display_order" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
3459
+  (1.5ms) CREATE TABLE "subscriptions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "stripe_id" varchar, "plan_id" integer, "last_four" varchar, "card_type" varchar, "current_price_cents" integer, "user_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
3460
+  (2.0ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar DEFAULT '' NOT NULL, "encrypted_password" varchar DEFAULT '' NOT NULL, "reset_password_token" varchar, "reset_password_sent_at" datetime, "remember_created_at" datetime, "sign_in_count" integer DEFAULT 0 NOT NULL, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar, "last_sign_in_ip" varchar, "created_at" datetime, "updated_at" datetime) 
3461
+  (0.1ms) select sqlite_version(*)
3462
+  (1.5ms) CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")
3463
+  (0.1ms) SELECT sql
3464
+ FROM sqlite_master
3465
+ WHERE name='index_users_on_email' AND type='index'
3466
+ UNION ALL
3467
+ SELECT sql
3468
+ FROM sqlite_temp_master
3469
+ WHERE name='index_users_on_email' AND type='index'
3470
+
3471
+  (1.2ms) CREATE UNIQUE INDEX "index_users_on_reset_password_token" ON "users" ("reset_password_token")
3472
+  (1.4ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
3473
+  (2.4ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3474
+  (0.2ms) SELECT version FROM "schema_migrations"
3475
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20151220161817')
3476
+  (0.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20150101233243')
3477
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20150102001921')
3478
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20150102001930')
3479
+  (1.2ms) INSERT INTO "schema_migrations" (version) VALUES ('20151220161809')
3480
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
3481
+ ActiveRecord::SchemaMigration Load (1.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
3482
+  (2.3ms) CREATE TABLE "features" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "description" varchar, "feature_type" varchar, "unit" varchar, "display_order" integer, "use_unit" boolean, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
3483
+  (2.0ms) CREATE TABLE "plan_features" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "value" varchar, "display_value" varchar, "plan_id" integer, "feature_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
3484
+  (3.4ms) CREATE TABLE "plans" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "stripe_id" varchar, "name" varchar, "price_cents" integer, "interval" varchar, "interval_count" integer, "trial_period_days" integer, "metadata_as_json" text, "statement_descriptor" text, "highlight" boolean, "display_order" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
3485
+  (3.6ms) CREATE TABLE "subscriptions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "stripe_id" varchar, "plan_id" integer, "last_four" varchar, "card_type" varchar, "current_price_cents" integer, "user_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
3486
+  (2.9ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar DEFAULT '' NOT NULL, "encrypted_password" varchar DEFAULT '' NOT NULL, "reset_password_token" varchar, "reset_password_sent_at" datetime, "remember_created_at" datetime, "sign_in_count" integer DEFAULT 0 NOT NULL, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar, "last_sign_in_ip" varchar, "created_at" datetime, "updated_at" datetime) 
3487
+  (0.2ms) select sqlite_version(*)
3488
+  (2.4ms) CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")
3489
+  (1.7ms) SELECT sql
3490
+ FROM sqlite_master
3491
+ WHERE name='index_users_on_email' AND type='index'
3492
+ UNION ALL
3493
+ SELECT sql
3494
+ FROM sqlite_temp_master
3495
+ WHERE name='index_users_on_email' AND type='index'
3496
+
3497
+  (3.3ms) CREATE UNIQUE INDEX "index_users_on_reset_password_token" ON "users" ("reset_password_token")
3498
+  (1.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
3499
+  (5.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3500
+  (0.2ms) SELECT version FROM "schema_migrations"
3501
+  (1.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20151220161817')
3502
+  (2.5ms) INSERT INTO "schema_migrations" (version) VALUES ('20150101233243')
3503
+  (4.0ms) INSERT INTO "schema_migrations" (version) VALUES ('20150102001921')
3504
+  (2.2ms) INSERT INTO "schema_migrations" (version) VALUES ('20150102001930')
3505
+  (2.8ms) INSERT INTO "schema_migrations" (version) VALUES ('20151220161809')
3506
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
3507
+ ActiveRecord::SchemaMigration Load (1.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
3508
+  (4.8ms) CREATE TABLE "features" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "description" varchar, "feature_type" varchar, "unit" varchar, "display_order" integer, "use_unit" boolean, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
3509
+  (1.7ms) CREATE TABLE "plan_features" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "value" varchar, "display_value" varchar, "plan_id" integer, "feature_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
3510
+  (1.6ms) CREATE TABLE "plans" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "stripe_id" varchar, "name" varchar, "price_cents" integer, "interval" varchar, "interval_count" integer, "trial_period_days" integer, "metadata_as_json" text, "statement_descriptor" text, "highlight" boolean, "display_order" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
3511
+  (1.5ms) CREATE TABLE "subscriptions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "stripe_id" varchar, "plan_id" integer, "last_four" varchar, "card_type" varchar, "current_price_cents" integer, "user_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
3512
+  (2.0ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar DEFAULT '' NOT NULL, "encrypted_password" varchar DEFAULT '' NOT NULL, "reset_password_token" varchar, "reset_password_sent_at" datetime, "remember_created_at" datetime, "sign_in_count" integer DEFAULT 0 NOT NULL, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar, "last_sign_in_ip" varchar, "created_at" datetime, "updated_at" datetime) 
3513
+  (0.1ms) select sqlite_version(*)
3514
+  (2.4ms) CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")
3515
+  (0.1ms) SELECT sql
3516
+ FROM sqlite_master
3517
+ WHERE name='index_users_on_email' AND type='index'
3518
+ UNION ALL
3519
+ SELECT sql
3520
+ FROM sqlite_temp_master
3521
+ WHERE name='index_users_on_email' AND type='index'
3522
+
3523
+  (2.0ms) CREATE UNIQUE INDEX "index_users_on_reset_password_token" ON "users" ("reset_password_token")
3524
+  (1.8ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
3525
+  (1.6ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3526
+  (0.1ms) SELECT version FROM "schema_migrations"
3527
+  (1.5ms) INSERT INTO "schema_migrations" (version) VALUES ('20151220161817')
3528
+  (1.8ms) INSERT INTO "schema_migrations" (version) VALUES ('20150101233243')
3529
+  (1.8ms) INSERT INTO "schema_migrations" (version) VALUES ('20150102001921')
3530
+  (1.1ms) INSERT INTO "schema_migrations" (version) VALUES ('20150102001930')
3531
+  (1.3ms) INSERT INTO "schema_migrations" (version) VALUES ('20151220161809')
3532
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe_saas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Sam-Bodden