referable 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +119 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/generators/referable/USAGE +10 -0
- data/lib/generators/referable/migrations.rb +15 -0
- data/lib/generators/referable/migrations/model_migrator.rb +48 -0
- data/lib/generators/referable/migrations/referral_migration.rb +28 -0
- data/lib/generators/referable/migrations/reward_migrator.rb +24 -0
- data/lib/generators/referable/referable_generator.rb +41 -0
- data/lib/generators/referable/templates/concerns/referable.rb +55 -0
- data/lib/generators/referable/templates/model/referable_reward.rb +39 -0
- data/lib/generators/referable/templates/model/referral.rb +6 -0
- data/lib/referable.rb +4 -0
- data/lib/referable/version.rb +3 -0
- data/referable.gemspec +27 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9918f1d6a54a3de5cb02eea2f3390206feb3ab39
|
4
|
+
data.tar.gz: e54e727bd83f1dfcc10803c51841c7524a50ceb8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: edf925ff93ca80029d7812650d9c04150f54425468bf9a36edb458b2839548ad3a57771b4e2488e4573c8176457395c1745f6127955cb13ecdda0b23b3f052d4
|
7
|
+
data.tar.gz: 50ba1849b82a66e6593219374baf429f783ca3c833192ba64fc8f6880b1c105e048f9791e61cd729c72b0dbf0bbf5103f87b69177d00602f513aee1b1e52e757
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting hello@eola.co.uk. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Eola Ltd.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
# Referable
|
2
|
+
|
3
|
+
Referable provides you with a generator that happily creates a multi-tenant referral
|
4
|
+
system for your app with rewards, in just two steps.
|
5
|
+
|
6
|
+
1.
|
7
|
+
```bash
|
8
|
+
rails g referable user && rails db:migrate
|
9
|
+
```
|
10
|
+
|
11
|
+
2.
|
12
|
+
```ruby
|
13
|
+
ReferableReward.create! reward: 'A new car',
|
14
|
+
referrals_required: 10,
|
15
|
+
acquireable_by: 'user'
|
16
|
+
```
|
17
|
+
|
18
|
+
aaand... you're done!
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
user = User.first
|
22
|
+
|
23
|
+
user.recruits
|
24
|
+
#=> #<ActiveRecord::Associations::CollectionProxy [...]>
|
25
|
+
|
26
|
+
user.recruits << User.create(name: 'Dan')
|
27
|
+
#=> #<ActiveRecord::Associations::CollectionProxy [...]>
|
28
|
+
|
29
|
+
user.referrals.count
|
30
|
+
#=> 1
|
31
|
+
|
32
|
+
user.distance_to_next_reward
|
33
|
+
#=> 9
|
34
|
+
|
35
|
+
user.percent_to_next_reward
|
36
|
+
#=> 10.0
|
37
|
+
|
38
|
+
user.last_acquired_reward.name
|
39
|
+
#=> 'nothing'
|
40
|
+
```
|
41
|
+
|
42
|
+
## Installation
|
43
|
+
|
44
|
+
Add this line to your application's Gemfile:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
gem 'referable'
|
48
|
+
```
|
49
|
+
|
50
|
+
And then execute:
|
51
|
+
|
52
|
+
$ bundle
|
53
|
+
|
54
|
+
Or install it yourself:
|
55
|
+
```bash
|
56
|
+
gem install referable
|
57
|
+
```
|
58
|
+
|
59
|
+
## Usage
|
60
|
+
|
61
|
+
The generator modifies an existing Rails model to allow referral functionality. The model
|
62
|
+
does not need to have any other dependencies.
|
63
|
+
|
64
|
+
To enable referrals for a specific model, run
|
65
|
+
```bash
|
66
|
+
rails generate referable name_of_model
|
67
|
+
```
|
68
|
+
|
69
|
+
This will create the necessary migration(s). Next, check the contents of the migrations.
|
70
|
+
Notably, the _add_referral_fields_to_XXX_ migration, as this updates each record for your
|
71
|
+
model with a referral slug.
|
72
|
+
|
73
|
+
Then,
|
74
|
+
```bash
|
75
|
+
rails db:migrate
|
76
|
+
```
|
77
|
+
|
78
|
+
This can be added for any number of models in your application.
|
79
|
+
|
80
|
+
### Creating rewards
|
81
|
+
|
82
|
+
Rewards are set for each model type individually. IE a President will have a different set
|
83
|
+
of rewards to a PrimeMinister.
|
84
|
+
|
85
|
+
Creating rewards is as simple as:
|
86
|
+
```ruby
|
87
|
+
ReferableReward.create! reward: 'A new car',
|
88
|
+
referrals_required: 10,
|
89
|
+
acquireable_by: 'user'
|
90
|
+
```
|
91
|
+
|
92
|
+
### Callback when model reaches a reward
|
93
|
+
|
94
|
+
Want to notify someone or do something when a user acquires a new reward?
|
95
|
+
Just hook in to `Referable#acquired_reward!`
|
96
|
+
|
97
|
+
### Adding a recruit in devise
|
98
|
+
|
99
|
+
At [eola](https://eola.co.uk), we hook in to the `Devise::RegistrationsController#post`
|
100
|
+
action, checking for the referral slug in the params. If it exists, the user is given
|
101
|
+
the new recruit.
|
102
|
+
|
103
|
+
## Development
|
104
|
+
|
105
|
+
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.
|
106
|
+
|
107
|
+
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
108
|
+
|
109
|
+
## Contributing
|
110
|
+
|
111
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/referable. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
112
|
+
|
113
|
+
## License
|
114
|
+
|
115
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
116
|
+
|
117
|
+
## Code of Conduct
|
118
|
+
|
119
|
+
Everyone interacting in the Referable project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/referable/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "referable"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Migrations
|
2
|
+
require_relative './migrations/model_migrator'
|
3
|
+
require_relative './migrations/reward_migrator'
|
4
|
+
|
5
|
+
include ModelMigrator
|
6
|
+
include RewardMigrator
|
7
|
+
|
8
|
+
def migration_created?(migration_name)
|
9
|
+
/#{migration_name}/ =~ last_migration
|
10
|
+
end
|
11
|
+
|
12
|
+
def last_migration
|
13
|
+
Dir['db/migrate/*'].last
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Migrations
|
2
|
+
module ModelMigrator
|
3
|
+
def create_model_migration
|
4
|
+
generate 'migration',
|
5
|
+
"add_referral_fields_to_#{file_name} \
|
6
|
+
last_reward_acquired_id:integer \
|
7
|
+
referral_slug \
|
8
|
+
referrals_count:integer"
|
9
|
+
add_model_migration_details
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def add_model_migration_details
|
15
|
+
return unless migration_created?("_add_referral_fields_to_#{file_name}")
|
16
|
+
constrain_count
|
17
|
+
write_slug_data
|
18
|
+
constrain_slug
|
19
|
+
end
|
20
|
+
|
21
|
+
def constrain_count
|
22
|
+
inject_into_file(last_migration, after: '_count, :integer') do
|
23
|
+
', default: 0, null: false'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def write_slug_data
|
28
|
+
inject_into_file(last_migration, after: 'null: false') do
|
29
|
+
<<~TEXT
|
30
|
+
\n
|
31
|
+
# Update each record with a slug
|
32
|
+
#{class_name}.find_each do |#{file_name}|
|
33
|
+
#{file_name}.valid?
|
34
|
+
#{file_name}.update_attribute(:slug, #{file_name}.slug)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Add constraint
|
38
|
+
TEXT
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def constrain_slug
|
43
|
+
inject_into_file(last_migration, after: 'Add constraint') do
|
44
|
+
"\n change_column_null :#{plural_name}, :referral_slug, false"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Migrations
|
2
|
+
module ReferralMigrator
|
3
|
+
|
4
|
+
def create_reward_migration
|
5
|
+
generate 'migration', "create_referrals"
|
6
|
+
add_referral_migration_details
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def add_referral_migration_details
|
12
|
+
return unless migration_created?('create_referrals')
|
13
|
+
inject_into_file(last_migration, after: 'do |t|') do
|
14
|
+
<<~TEXT
|
15
|
+
\n
|
16
|
+
t.integer "recruit_id"
|
17
|
+
t.datetime "created_at", null: false
|
18
|
+
t.datetime "updated_at", null: false
|
19
|
+
t.string "referrer_type"
|
20
|
+
t.bigint "referrer_id"
|
21
|
+
t.string "recruit_type"
|
22
|
+
t.index ["recruit_type", "recruit_id"], name: "index_referrals_on_recruit_type_and_recruit_id"
|
23
|
+
t.index ["referrer_type", "referrer_id"], name: "index_referrals_on_referrer_type_and_referrer_id"
|
24
|
+
TEXT
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Migrations
|
2
|
+
module RewardMigrator
|
3
|
+
|
4
|
+
def create_reward_migration
|
5
|
+
generate 'migration', "create_referable_rewards"
|
6
|
+
add_reward_migration_details
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def add_reward_migration_details
|
12
|
+
return unless migration_created?('create_referable_rewards')
|
13
|
+
inject_into_file(last_migration, after: 'do |t|') do
|
14
|
+
<<~TEXT
|
15
|
+
\n
|
16
|
+
t.string "reward", null: false
|
17
|
+
t.integer "referrals_required", null: false
|
18
|
+
t.integer "acquireable_by", null: false
|
19
|
+
t.timestamps
|
20
|
+
TEXT
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
class ReferableGenerator < Rails::Generators::NamedBase
|
4
|
+
require_relative './migrations'
|
5
|
+
|
6
|
+
include Migrations
|
7
|
+
|
8
|
+
source_root File.expand_path('../templates', __FILE__)
|
9
|
+
|
10
|
+
def copy_referral
|
11
|
+
copy_file "model/referal.rb", "app/models/referral.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
def copy_referable_concern
|
15
|
+
copy_file "concerns/referable.rb", "app/models/concerns/referable.rb"
|
16
|
+
copy_file "model/referable_reward.rb", "app/models/referable_reward.rb"
|
17
|
+
end
|
18
|
+
|
19
|
+
def setup_migrations
|
20
|
+
create_model_migration
|
21
|
+
create_reward_migration
|
22
|
+
end
|
23
|
+
|
24
|
+
def include_concern_in_class
|
25
|
+
inject_into_file "app/models/#{file_name}.rb", after: 'User < ApplicationRecord' do
|
26
|
+
"\n include Referable"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_class_to_referable_reward
|
31
|
+
symbol_in_array = acquireable_by_empty? ? ":#{file_name}" : ", :#{file_name}"
|
32
|
+
inject_into_file('app/models/referable_reward.rb',
|
33
|
+
before: '], _prefix: :acquireable_by') { symbol_in_array }
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def acquireable_by_empty?
|
39
|
+
File.read('app/models/referable_reward.rb').include? 'acquireable_by: []'
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Referable
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
has_many :referrals, as: :referrer
|
6
|
+
has_many :recruits, through: :referrals, source_type: name
|
7
|
+
belongs_to :last_reward_acquired,
|
8
|
+
class_name: 'ReferableReward',
|
9
|
+
default: -> { ReferableReward.zeroth_tier(self.class.name.downcase) }
|
10
|
+
|
11
|
+
before_save :add_referral_slug
|
12
|
+
end
|
13
|
+
|
14
|
+
def percent_to_next_reward
|
15
|
+
last_tier_count = last_reward_acquired.referrals_required
|
16
|
+
next_tier_count = last_reward_acquired
|
17
|
+
.next_reward(above: referrals.size)
|
18
|
+
.referrals_required - last_tier_count
|
19
|
+
current_count = referrals.size - last_tier_count
|
20
|
+
(current_count.to_f / next_tier_count) * 100
|
21
|
+
end
|
22
|
+
|
23
|
+
def distance_to_next_reward
|
24
|
+
last_reward_acquired
|
25
|
+
.next_reward(above: referrals.size)
|
26
|
+
.referrals_required - referrals.size
|
27
|
+
end
|
28
|
+
|
29
|
+
def acquired_reward!
|
30
|
+
update!(last_reward_acquired: last_reward_acquired.next_reward(above: referrals.size))
|
31
|
+
end
|
32
|
+
|
33
|
+
def increment!(attribute, by = 1)
|
34
|
+
super
|
35
|
+
check_for_new_reward
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def check_for_new_reward
|
41
|
+
count = referrals.size
|
42
|
+
if count >= last_reward_acquired.next_reward(above: count).referrals_required
|
43
|
+
acquired_reward!
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def add_referral_slug
|
48
|
+
self.referral_slug = create_referral_slug unless referral_slug
|
49
|
+
end
|
50
|
+
|
51
|
+
def create_referral_slug
|
52
|
+
slug = Utilities.generate_friendly_chars(3)
|
53
|
+
self.class.exists?(referral_slug: slug) ? create_referral_slug : slug
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class ReferableReward < ApplicationRecord
|
2
|
+
|
3
|
+
enum acquireable_by: [], _prefix: :acquireable_by
|
4
|
+
|
5
|
+
validates :referrals_required, uniqueness: {
|
6
|
+
scope: :acquireable_by, message: 'Target aleady present for this kind of reward'
|
7
|
+
}
|
8
|
+
|
9
|
+
def self.best_reward(acquireable_by)
|
10
|
+
where(acquireable_by: acquireable_by).order(referrals_required: :desc).first
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.zeroth_tier(acquireable_by)
|
14
|
+
zeroth = find_by(referrals_required: 0, acquireable_by: acquireable_by)
|
15
|
+
return zeroth if zeroth
|
16
|
+
create!(reward: 'none', referrals_required: 0, acquireable_by: acquireable_by)
|
17
|
+
end
|
18
|
+
|
19
|
+
def next_reward(above: 0)
|
20
|
+
query = self.class
|
21
|
+
.where(acquireable_by: acquireable_by)
|
22
|
+
.where('referrals_required > ?', referrals_required)
|
23
|
+
.where('referrals_required >= ?', above)
|
24
|
+
.order(referrals_required: :asc)
|
25
|
+
.limit(1)
|
26
|
+
query.any? ? query.first : self
|
27
|
+
end
|
28
|
+
|
29
|
+
def previous_reward(below: 10e5)
|
30
|
+
query = self.class
|
31
|
+
.where(acquireable_by: acquireable_by)
|
32
|
+
.where('referrals_required < ?', referrals_required)
|
33
|
+
.where('referrals_required <= ?', below)
|
34
|
+
.order(referrals_required: :desc)
|
35
|
+
.limit(1)
|
36
|
+
query.any? ? query.first : self
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/lib/referable.rb
ADDED
data/referable.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "referable/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'referable'
|
8
|
+
spec.version = Referable::VERSION
|
9
|
+
spec.authors = ['Daniel Steele']
|
10
|
+
spec.email = ['danielsteele@hotmail.co.uk']
|
11
|
+
|
12
|
+
spec.summary = 'Add a multi-tenant referral system to your app'
|
13
|
+
spec.description = 'Add a multi-tenant referral and rewards system to your app'
|
14
|
+
spec.homepage = 'https://github.com/eola/referable'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = 'exe'
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: referable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Steele
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Add a multi-tenant referral and rewards system to your app
|
56
|
+
email:
|
57
|
+
- danielsteele@hotmail.co.uk
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- CODE_OF_CONDUCT.md
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- lib/generators/referable/USAGE
|
73
|
+
- lib/generators/referable/migrations.rb
|
74
|
+
- lib/generators/referable/migrations/model_migrator.rb
|
75
|
+
- lib/generators/referable/migrations/referral_migration.rb
|
76
|
+
- lib/generators/referable/migrations/reward_migrator.rb
|
77
|
+
- lib/generators/referable/referable_generator.rb
|
78
|
+
- lib/generators/referable/templates/concerns/referable.rb
|
79
|
+
- lib/generators/referable/templates/model/referable_reward.rb
|
80
|
+
- lib/generators/referable/templates/model/referral.rb
|
81
|
+
- lib/referable.rb
|
82
|
+
- lib/referable/version.rb
|
83
|
+
- referable.gemspec
|
84
|
+
homepage: https://github.com/eola/referable
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.6.11
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Add a multi-tenant referral system to your app
|
108
|
+
test_files: []
|