Module: Testimonials

Defined in:
lib/testimonials.rb,
lib/testimonials/engine.rb,
lib/testimonials/widget.rb,
lib/testimonials/version.rb,
lib/testimonials/configuration.rb,
lib/testimonials/prompt_helper.rb,
app/models/testimonials/testimonial.rb,
app/models/testimonials/nps_response.rb,
app/models/testimonials/prompt_event.rb,
app/helpers/testimonials/widget_helper.rb,
app/models/testimonials/application_record.rb,
app/controllers/testimonials/nps_controller.rb,
app/controllers/testimonials/media_controller.rb,
app/controllers/testimonials/events_controller.rb,
app/controllers/testimonials/widgets_controller.rb,
app/controllers/testimonials/api/base_controller.rb,
app/controllers/testimonials/api/stats_controller.rb,
app/controllers/testimonials/collection_controller.rb,
app/controllers/testimonials/application_controller.rb,
app/controllers/testimonials/testimonials_controller.rb,
app/controllers/testimonials/nps_responses_controller.rb,
lib/generators/testimonials/install/install_generator.rb,
app/controllers/testimonials/api/testimonials_controller.rb

Overview

Testimonials, reviews and NPS for Rails. An iOS-style in-app widget collects star ratings and testimonials (text or video) at moments your code chooses; a public page collects them from shareable links; NPS promoters are routed straight into the testimonial ask. Everything lands in your own database with a minimal dashboard to approve, feature, and pick best lines — and a read API to render approved testimonials wherever you like.

Defined Under Namespace

Modules: Api, Generators, PromptHelper, Widget, WidgetHelper Classes: ApplicationController, ApplicationRecord, CollectionController, Configuration, Engine, EventsController, MediaController, NpsController, NpsResponse, NpsResponsesController, PromptEvent, Testimonial, TestimonialsController, WidgetsController

Constant Summary collapse

VERSION =
'0.1.1'

Class Method Summary collapse

Class Method Details

.admin?(request) ⇒ Boolean

Can this request browse and triage submissions? Checked by every dashboard action.

Returns:

  • (Boolean)


33
34
35
# File 'lib/testimonials.rb', line 33

def admin?(request)
  !!config.authorize_admin.call(request)
end

.app_nameObject



37
38
39
# File 'lib/testimonials.rb', line 37

def app_name
  config.app_name.presence || rails_app_name
end

.configObject



17
18
19
# File 'lib/testimonials.rb', line 17

def config
  @config ||= Configuration.new
end

.configure {|config| ... } ⇒ Object

Yields:



21
22
23
# File 'lib/testimonials.rb', line 21

def configure
  yield config
end


52
53
54
55
56
57
# File 'lib/testimonials.rb', line 52

def consent_text
  config.consent_text.presence ||
    I18n.t('testimonials.consent',
           default: 'I give permission to use this testimonial across social channels ' \
                    'and other marketing efforts.')
end

.enabled?(request) ⇒ Boolean

Can this request see the widget and submit? Checked on the server for every public endpoint and by the helper before rendering.

Returns:

  • (Boolean)


27
28
29
# File 'lib/testimonials.rb', line 27

def enabled?(request)
  !!config.enabled.call(request)
end

.questionsObject

The guiding questions for the current locale, with %app filled in. I18n leaves the token alone when no interpolation values are passed, so a plain gsub covers built-in, literal, and lambda-provided strings alike.



45
46
47
48
49
50
# File 'lib/testimonials.rb', line 45

def questions
  list = config.questions
  list = list.call if list.respond_to?(:call)
  list = I18n.t('testimonials.questions', default: []) if list.nil?
  Array(list).map { |q| q.to_s.gsub('%{app}', app_name) }
end