core_merchant 0.1.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: 6d92b65405d20766e71e2510e5bc3c79dcbd1a0821721f83262c28c4ecb3e5f6
4
- data.tar.gz: 1da82246e7b5145805e4c31d24b42fd7acf77d7ab541166ae5cc450a008c2b45
3
+ metadata.gz: 186950538bdef9e0bebf514212e20953f34f2eb2a3d2513d97a616b66744c3f3
4
+ data.tar.gz: 3509ceb3b0d12b66ab0cbe5715ca7e8852be461319694075ea9976e1fb5b1d4f
5
5
  SHA512:
6
- metadata.gz: ec3490ecc9fd035a910657eea62a2326cf87bccd8dc4b578c44850b3eba8e0478d3f2a6174b398a0cb0b1b4821147c87f8d7cf7e2422740d0e90340becb3c975
7
- data.tar.gz: 879406bcfb5e904c51c502b2fb5cd91540487993dcb5c33fa0ef8b0104c78ca8a6ba6aa37e0e577a8fd2effbb167b233d5497820849eaef9050b8774a6f3974d
6
+ metadata.gz: ff86052965a4ae8d5e535bae668176888879de0080a5fe5cbf0e753323aab071d64912085fd52a360b9b6db8e1eb9380d44bc4ab89b751ab531803ddbe2a38e1
7
+ data.tar.gz: 289f60e89c495762fa2d547cc6abc8cf1f600d6b4b8ee221449bd7e80ed52f21f794841c57d84d96c340cc53065e2ef2de003f16c5a3c388b463d13fda207ec2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- core_merchant (0.1.0)
4
+ core_merchant (0.2.0)
5
5
  activesupport (~> 7.0)
6
6
  rails (~> 7.0)
7
7
 
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2024 Seyithan
3
+ Copyright (c) 2024 Seyithan Teymur (https://seyithan.me)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,39 +1,87 @@
1
1
  # CoreMerchant
2
2
 
3
- ## This gem is under development at pre-release stage
3
+ > [!CAUTION]
4
+ > This gem is under development at pre-release stage
4
5
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/core_merchant`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+ CoreMerchant is a library for customer, product, and subscription management in Rails applications. It's meant to be a starting point for building e-commerce and SaaS applications. It provides essential functionality for handling customers, products, and subscriptions. Does not include payment integrations.
6
7
 
7
- TODO: Delete this and the text above, and describe your gem
8
+ ## To-dos until 1.0.0 release
9
+ - [X] Add customer behavior
10
+ - [X] Add initializer generator
11
+ - [X] Add SubscriptionPlan model
12
+ - [ ] Add Subscription model
13
+ - [ ] Add subscription management service
14
+ - [ ] Add sidekiq jobs for subscription management
15
+ - [ ] Add Invoice model
16
+ - [ ] Add billing and invoicing service
8
17
 
9
18
  ## Installation
19
+ Add this line to your application's Gemfile:
20
+ ```
21
+ gem 'core_merchant', '~> 0.1.0'
22
+ ```
23
+ and run `bundle install`.
10
24
 
11
- Install the gem and add to the application's Gemfile by executing:
12
-
13
- $ bundle add core_merchant
14
-
15
- If bundler is not being used to manage dependencies, install the gem by executing:
16
-
17
- $ gem install core_merchant
25
+ Alternatively, you can install the gem manually:
26
+ ```
27
+ $ gem install core_merchant
28
+ ```
18
29
 
19
30
  ## Usage
20
-
21
- TODO: Write usage instructions here
22
-
23
- ## Development
24
-
25
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
-
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
31
+ ### Initialization
32
+ Run the generator to create the initializer file and the migrations:
33
+ ```
34
+ $ rails generate core_merchant:install
35
+ ```
36
+ This will create the following files:
37
+ - `config/initializers/core_merchant.rb` - Configuration file
38
+ - `db/migrate/xxxxxx_create_core_merchant_subscription_plans.rb` - Migration for subscription plans
39
+
40
+ You can then run the migrations:
41
+ ```
42
+ $ rails db:migrate
43
+ ```
44
+
45
+ ### Configuration
46
+ The initializer file `config/initializers/core_merchant.rb` contains the following configuration options:
47
+ ```ruby
48
+ config.customer_class
49
+ ```
50
+
51
+ ### The cusomer class
52
+ The customer class is the model that represents the customer in your application. For example, if you already have a `User` model that represents the users of your application, you can use it as the customer class in CoreMerchant. To do this, you need to set the `customer_class` configuration option in the initializer file:
53
+ ```ruby
54
+ # config/initializers/core_merchant.rb
55
+ CoreMerchant.configure do |config|
56
+ config.customer_class = 'User'
57
+ end
58
+ ```
59
+
60
+ You need to then include the `CoreMerchant::Customer` module in the customer class:
61
+ ```ruby
62
+ # app/models/user.rb
63
+ class User < ApplicationRecord
64
+ include CoreMerchant::Customer
65
+
66
+ # ... the rest of your model code
67
+ end
68
+ ```
69
+
70
+ ## Models
71
+ ### SubscriptionPlan
72
+ The `SubscriptionPlan` model represents a subscription plan in your application. It has the following attributes:
73
+ - `name_key`: A unique key for the subscription plan.
74
+ This key is used to identify the plan in the application,
75
+ as well as the translation key for the plan name through `core_merchant.subscription_plans`.
76
+ - `price_cents`: The price of the subscription plan in cents.
77
+ - `duration`: The duration of the subscription plan.
78
+ Consists of a number and a letter representing the time unit as day, week, month, or year.
79
+ For example, `1w` for 1 week, `3m` for 3 months, `1y` for 1 year.
80
+ - `introductory_price_cents`: The introductory price of the subscription plan in cents.
81
+ - `introductory_duration`: The duration of the introductory price of the subscription plan.
82
+
83
+ > [!NOTE]
84
+ > Other models and features are being developed and will be added in future releases.
28
85
 
29
86
  ## Contributing
30
-
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/core_merchant. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/core_merchant/blob/main/CODE_OF_CONDUCT.md).
32
-
33
- ## License
34
-
35
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
36
-
37
- ## Code of Conduct
38
-
39
- Everyone interacting in the CoreMerchant project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/core_merchant/blob/main/CODE_OF_CONDUCT.md).
87
+ Bug reports and pull requests are welcome on GitHub at https://github.com/theseyithan/core_merchant
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CoreMerchant
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.1"
5
5
  end
@@ -19,9 +19,8 @@ module CoreMerchant
19
19
  end
20
20
 
21
21
  def create_migration_file
22
- timestamp = self.class.next_migration_number(nil)
23
- migration_template "create_core_merchant_subscription_plans.rb",
24
- "db/migrate/#{timestamp}_create_core_merchant_subscription_plans.rb"
22
+ migration_template "create_core_merchant_subscription_plans.erb",
23
+ "db/migrate/create_core_merchant_subscription_plans.rb"
25
24
  end
26
25
  end
27
26
  end
@@ -1,5 +1,5 @@
1
1
  # Created by: rails generate core_merchant:install
2
- class CreateCoreMerchantSubscriptionPlans < ActiveRecord::Migration
2
+ class CreateCoreMerchantSubscriptionPlans < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
3
3
  def change
4
4
  create_table :core_merchant_subscription_plans do |t|
5
5
  t.string :name_key, null: false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: core_merchant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seyithan Teymur
@@ -135,7 +135,7 @@ files:
135
135
  - lib/core_merchant/version.rb
136
136
  - lib/generators/core_merchant/install_generator.rb
137
137
  - lib/generators/core_merchant/templates/core_merchant.rb
138
- - lib/generators/core_merchant/templates/create_core_merchant_subscription_plans.rb
138
+ - lib/generators/core_merchant/templates/create_core_merchant_subscription_plans.erb
139
139
  - sig/core_merchant.rbs
140
140
  homepage: https://github.com/theseyithan/core_merchant
141
141
  licenses: