Module: Heya
- Extended by:
- Heya
- Included in:
- Heya
- Defined in:
- lib/heya/license/boundary.rb,
lib/heya.rb,
lib/heya/config.rb,
lib/heya/engine.rb,
lib/heya/license.rb,
lib/heya/version.rb,
lib/heya/campaigns/base.rb,
lib/heya/campaigns/step.rb,
lib/heya/campaigns/action.rb,
lib/heya/campaigns/queries.rb,
lib/heya/license/encryptor.rb,
lib/heya/campaigns/scheduler.rb,
app/jobs/heya/application_job.rb,
app/mailers/heya/campaign_mailer.rb,
app/models/heya/campaign_receipt.rb,
lib/heya/campaigns/actions/block.rb,
lib/heya/campaigns/actions/email.rb,
app/models/heya/application_record.rb,
lib/heya/campaigns/step_action_job.rb,
app/helpers/heya/application_helper.rb,
app/mailers/heya/application_mailer.rb,
app/models/heya/campaign_membership.rb,
app/controllers/heya/application_controller.rb
Overview
The MIT License (MIT)
Copyright © 2015 GitLab B.V.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Defined Under Namespace
Modules: ApplicationHelper, Campaigns Classes: ApplicationController, ApplicationJob, ApplicationMailer, ApplicationRecord, CampaignGenerator, CampaignMailer, CampaignMembership, CampaignReceipt, Config, Engine, InstallGenerator, License
Constant Summary collapse
- VERSION =
"0.2.0"
Instance Attribute Summary collapse
-
#campaigns ⇒ Object
Returns the value of attribute campaigns.
Instance Method Summary collapse
- #config ⇒ Object
- #configure {|config| ... } ⇒ Object
- #in_segment?(user, segment) ⇒ Boolean
- #in_segments?(user, *segments) ⇒ Boolean
- #register_campaign(klass) ⇒ Object
- #unregister_campaign(klass) ⇒ Object
- #verify_license! ⇒ Object
Instance Attribute Details
#campaigns ⇒ Object
Returns the value of attribute campaigns.
19 20 21 |
# File 'lib/heya.rb', line 19 def campaigns @campaigns end |
Instance Method Details
#configure {|config| ... } ⇒ Object
30 31 32 33 |
# File 'lib/heya.rb', line 30 def configure yield(config) if block_given? config end |
#in_segment?(user, segment) ⇒ Boolean
44 45 46 47 48 |
# File 'lib/heya.rb', line 44 def in_segment?(user, segment) return true if segment.nil? return user.send(segment) if segment.is_a?(Symbol) segment.call(user) end |
#in_segments?(user, *segments) ⇒ Boolean
39 40 41 42 |
# File 'lib/heya.rb', line 39 def in_segments?(user, *segments) return false if segments.any? { |s| !in_segment?(user, s) } true end |
#register_campaign(klass) ⇒ Object
22 23 24 |
# File 'lib/heya.rb', line 22 def register_campaign(klass) campaigns.push(klass) unless campaigns.include?(klass) end |
#unregister_campaign(klass) ⇒ Object
26 27 28 |
# File 'lib/heya.rb', line 26 def unregister_campaign(klass) campaigns.delete(klass) end |
#verify_license! ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/heya.rb', line 50 def verify_license! unless File.file?(config.license_file) puts(<<-NOTICE.strip_heredoc) This copy of Heya is licensed for non-commercial non-profit, or 30-day trial usage only. For a commercial use license, please visit https://www.heya.email NOTICE return end begin license = License.import(File.read(config.license_file)) rescue License::ImportError warn(<<-NOTICE.strip_heredoc) Your Heya license is invalid. If you need support, please visit https://www.heya.email NOTICE return end if license.expired? warn(<<-NOTICE.strip_heredoc) Your Heya license has expired. To update your license, please visit https://www.heya.email NOTICE return end if (max_user_count = license.restrictions[:user_count]&.to_i) user_count = config.user_type.constantize.count if user_count > max_user_count warn(<<-NOTICE.strip_heredoc) Your app exceeds the number of users for your Heya license. To upgrade your license, please visit https://www.heya.email NOTICE end return # rubocop:disable Style/RedundantReturn end # Valid license end |