europeana-feedback-button 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +5 -5
  2. data/.codeclimate.yml +5 -0
  3. data/.rubocop.yml +2 -8
  4. data/.travis.yml +1 -2
  5. data/Gemfile +11 -6
  6. data/README.md +17 -7
  7. data/Rakefile +1 -0
  8. data/app/controllers/europeana/feedback_button/application_controller.rb +28 -0
  9. data/app/controllers/europeana/feedback_button/feedback_controller.rb +20 -12
  10. data/app/mailers/europeana/feedback_button/feedback_mailer.rb +9 -6
  11. data/app/models/europeana/feedback_button/feedback.rb +21 -0
  12. data/app/validators/europeana/feedback_button/word_count_validator.rb +26 -0
  13. data/app/views/concerns/europeana/feedback_button/feedbackable_view.rb +5 -5
  14. data/app/views/europeana/feedback_button/feedback_mailer/post.text.erb +2 -0
  15. data/bin/rails +19 -5
  16. data/config/routes.rb +1 -0
  17. data/europeana-feedback-button.gemspec +7 -10
  18. data/lib/europeana/feedback_button.rb +32 -1
  19. data/lib/europeana/feedback_button/engine.rb +2 -1
  20. data/lib/europeana/feedback_button/version.rb +2 -1
  21. data/lib/generators/europeana/feedback_button/install_generator.rb +15 -0
  22. data/lib/generators/europeana/feedback_button/templates/europeana_feedback_button.rb +8 -0
  23. data/spec/controllers/feedback_controller_spec.rb +82 -19
  24. data/spec/dummy/Rakefile +2 -1
  25. data/spec/dummy/app/assets/config/manifest.js +3 -0
  26. data/spec/dummy/app/assets/javascripts/application.js +2 -1
  27. data/spec/dummy/app/assets/stylesheets/application.css +3 -3
  28. data/spec/dummy/app/controllers/application_controller.rb +1 -3
  29. data/spec/dummy/app/controllers/welcome_controller.rb +3 -5
  30. data/spec/dummy/app/helpers/application_helper.rb +1 -0
  31. data/spec/dummy/app/jobs/application_job.rb +4 -0
  32. data/spec/dummy/app/mailers/application_mailer.rb +2 -1
  33. data/spec/dummy/app/views/layouts/application.html.erb +9 -9
  34. data/spec/dummy/app/views/layouts/mailer.html.erb +10 -6
  35. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  36. data/spec/dummy/bin/bundle +2 -1
  37. data/spec/dummy/bin/rails +2 -1
  38. data/spec/dummy/bin/rake +1 -0
  39. data/spec/dummy/bin/setup +16 -16
  40. data/spec/dummy/bin/update +30 -0
  41. data/spec/dummy/bin/yarn +11 -0
  42. data/spec/dummy/config.ru +3 -1
  43. data/spec/dummy/config/application.rb +12 -18
  44. data/spec/dummy/config/boot.rb +3 -2
  45. data/spec/dummy/config/environment.rb +2 -1
  46. data/spec/dummy/config/environments/development.rb +24 -20
  47. data/spec/dummy/config/environments/production.rb +22 -26
  48. data/spec/dummy/config/environments/test.rb +10 -6
  49. data/spec/dummy/config/initializers/application_controller_renderer.rb +9 -0
  50. data/spec/dummy/config/initializers/content_security_policy.rb +26 -0
  51. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  52. data/spec/dummy/config/initializers/europeana_feedback_button.rb +5 -0
  53. data/spec/dummy/config/initializers/filter_parameter_logging.rb +1 -0
  54. data/spec/dummy/config/initializers/wrap_parameters.rb +2 -6
  55. data/spec/dummy/config/locales/en.yml +10 -0
  56. data/spec/dummy/config/puma.rb +36 -0
  57. data/spec/dummy/config/routes.rb +2 -57
  58. data/spec/dummy/config/spring.rb +8 -0
  59. data/spec/dummy/package.json +5 -0
  60. data/spec/dummy/public/404.html +6 -6
  61. data/spec/dummy/public/422.html +6 -6
  62. data/spec/dummy/public/500.html +6 -6
  63. data/{app/assets/images/europeana_feedback_button/.keep → spec/dummy/public/apple-touch-icon-precomposed.png} +0 -0
  64. data/{app/models/.keep → spec/dummy/public/apple-touch-icon.png} +0 -0
  65. data/spec/lib/europeana/feedback_button_spec.rb +21 -0
  66. data/spec/mailers/feedback_mailer_spec.rb +54 -0
  67. data/spec/models/feedback_spec.rb +25 -0
  68. data/spec/spec_helper.rb +11 -1
  69. metadata +52 -53
  70. data/QUICKSTART.md +0 -30
  71. data/app/assets/javascripts/europeana_feedback_button/application.js +0 -13
  72. data/app/assets/stylesheets/europeana_feedback_button/application.css +0 -15
  73. data/app/helpers/europeana/feedback_button/application_helper.rb +0 -7
  74. data/app/helpers/europeana/feedback_button/feedback_helper.rb +0 -12
  75. data/app/views/layouts/europeana/feedback_button/application.html.erb +0 -14
  76. data/config/initializers/action_mailer.rb +0 -2
  77. data/lib/tasks/europeana_feedback_button_tasks.rake +0 -5
  78. data/spec/dummy/README.rdoc +0 -28
  79. data/spec/dummy/app/mailers/.keep +0 -0
  80. data/spec/dummy/app/models/.keep +0 -0
  81. data/spec/dummy/config/database.yml +0 -25
  82. data/spec/dummy/config/initializers/assets.rb +0 -12
  83. data/spec/dummy/config/initializers/session_store.rb +0 -4
  84. data/spec/dummy/config/secrets.yml +0 -22
  85. data/spec/helpers/feedback_helper_spec.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 113b65138abc0cf99712cea95a0e75f29c7be998
4
- data.tar.gz: 3f940b87272c66151d47e5a0aaa78a28dbe62d8f
2
+ SHA256:
3
+ metadata.gz: b94361c1bc78192b1cc1457df6b77407ed3ad5435a3e0538031ef958f426934b
4
+ data.tar.gz: 43d3ffbf8b53ba737b4f4aa7beebea7d3bfcccbeb33432b7a662566722cfe8d2
5
5
  SHA512:
6
- metadata.gz: 32d4bc1d1cb4d428e9ef0a884be44abbfbebc4feee682336df84e4cb3c6d06c139acb0f57d5f348840429d8389b14b6e7d4c511c4ba4732c04ad37415471385d
7
- data.tar.gz: ce1250b90c213203a3293a13814d6d2082ed67b70ce182a4ab047cef8d50a0b7f2bf69d72f820c8f4e7a712e7d6987fc6a4473c5fbd68749802054c481624bf1
6
+ metadata.gz: 9d2c5f733f9baa166193392c8d5b3c2413202c633c3bbb4ae56e62306a9673fa6c78c81c8c3c5be1133a863c3b0066ab9a5d8abd51378457aa477f3defe8bd3f
7
+ data.tar.gz: 158dcc448e4cac5fbcaa3d8e814d5d3012bcc57b8641bdc85b942eeb43dd123e3fe03613dce0283fcfc43a87a7d4efc8256a56307fc50fe6719c9713b254147f
@@ -0,0 +1,5 @@
1
+ plugins:
2
+ brakeman:
3
+ enabled: true
4
+ rubocop:
5
+ enabled: true
@@ -3,7 +3,7 @@ AllCops:
3
3
  - "vendor/**/*"
4
4
  - "db/schema.rb"
5
5
  UseCache: false
6
- TargetRubyVersion: 2.4
6
+ TargetRubyVersion: 2.5
7
7
  Style/CollectionMethods:
8
8
  Description: Preferred collection methods.
9
9
  StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
@@ -41,7 +41,6 @@ Style/IfUnlessModifier:
41
41
  Description: Favor modifier if/unless usage when you have a single-line body.
42
42
  StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
43
43
  Enabled: false
44
- MaxLineLength: 80
45
44
  Style/OptionHash:
46
45
  Description: Don't use option hashes when you can use keyword arguments.
47
46
  Enabled: false
@@ -125,11 +124,6 @@ Style/TrailingCommaInArguments:
125
124
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
126
125
  Enabled: false
127
126
  EnforcedStyleForMultiline: no_comma
128
- Style/TrailingCommaInLiteral:
129
- Description: 'Checks for trailing comma in array and hash literals.'
130
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
131
- Enabled: false
132
- EnforcedStyleForMultiline: no_comma
133
127
  Metrics/AbcSize:
134
128
  Description: A calculated magnitude based on number of assignments, branches, and
135
129
  conditions.
@@ -241,7 +235,7 @@ Lint/HandleExceptions:
241
235
  Description: Don't suppress exception.
242
236
  StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
243
237
  Enabled: false
244
- Lint/LiteralInCondition:
238
+ Lint/LiteralAsCondition:
245
239
  Description: Checks of literals used in conditions.
246
240
  Enabled: false
247
241
  Lint/LiteralInInterpolation:
@@ -1,7 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.1
4
- - 2.3.1
3
+ - 2.5.1
5
4
  notifications:
6
5
  email: false
7
6
  sudo: false
data/Gemfile CHANGED
@@ -1,14 +1,19 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  source 'https://rubygems.org'
3
4
 
4
- # Specify your gem's dependencies in europeana-blacklight.gemspec
5
+ # Specify your gem's dependencies in europeana-feedback-button.gemspec
5
6
  gemspec
6
7
 
7
- group :test do
8
- gem 'simplecov', require: false
8
+ group :test, :develop do
9
+ gem 'rails', '> 5.2', '< 6'
10
+ gem 'rubocop', '0.53', require: false
9
11
  end
10
12
 
11
- group :test, :develop do
12
- gem 'sqlite3'
13
- gem 'rubocop', require: false
13
+ group :develop do
14
+ gem 'brakeman'
15
+ end
16
+
17
+ group :test do
18
+ gem 'simplecov', require: false
14
19
  end
data/README.md CHANGED
@@ -1,21 +1,31 @@
1
1
  # Europeana::FeedbackButton
2
2
 
3
- [![Build Status](https://travis-ci.org/europeana/europeana-feedback-button.svg?branch=develop)](https://travis-ci.org/europeana/europeana-feedback-button) [![Coverage Status](https://coveralls.io/repos/github/europeana/europeana-feedback-button/badge.svg?branch=develop)](https://coveralls.io/github/europeana/europeana-feedback-button?branch=develop) [![security](https://hakiri.io/github/europeana/europeana-feedback-button/develop.svg)](https://hakiri.io/github/europeana/europeana-feedback-button/develop) [![Dependency Status](https://gemnasium.com/europeana/europeana-feedback-button.svg)](https://gemnasium.com/europeana/europeana-feedback-button)
3
+ [![Build Status](https://travis-ci.org/europeana/europeana-feedback-button.svg?branch=develop)](https://travis-ci.org/europeana/europeana-feedback-button) [![Security](https://hakiri.io/github/europeana/europeana-feedback-button/develop.svg)](https://hakiri.io/github/europeana/europeana-feedback-button/develop) [![Maintainability](https://api.codeclimate.com/v1/badges/326e7cf35738e64c36d6/maintainability)](https://codeclimate.com/github/europeana/europeana-feedback-button/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/326e7cf35738e64c36d6/test_coverage)](https://codeclimate.com/github/europeana/europeana-feedback-button/test_coverage)
4
4
 
5
- Ruby gem providing feedback buttons for europeana pages.
5
+ Rails engine providing feedback functionality for various Europeana websites.
6
6
 
7
7
  ## Usage
8
8
 
9
- See the [Quick Start Guide](QUICKSTART.md).
9
+ ### Include gem
10
10
 
11
- ## Configurations
11
+ * ``gem 'europeana-feedback-button', require: 'europeana/feedback_button'``
12
+ * Run ``bundle install``
12
13
 
13
- The following options can be configured in your .env file
14
+ ### Generate an initializer
14
15
 
15
- - FEEDBACK_MAIL_TO=example@example.org
16
+ * Run ``bundle exec rails g europeana:feedback_button:install``
17
+ * Edit config/initializers/europeana_feedback_button.rb to configure the engine
16
18
 
19
+ ### Mount the engine
17
20
 
21
+ * In config/routes.rb add: ``mount Europeana::FeedbackButton::Engine, at: '/'``
22
+
23
+ ### Add FeedbackableView to your views
24
+
25
+ * Add ``include Europeana::FeedbackButton::FeedbackableView`` to any view you want to have a feedback button. Add it to app/views/application_view.rb for feedback buttons on all pages.
18
26
 
19
27
  ## License
20
28
 
21
- See the [License](License.md).
29
+ Licensed under the EUPL V.1.1.
30
+
31
+ For full details, see [LICENSE.md](LICENSE.md).
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'bundler/gem_tasks'
3
4
  require 'rspec/core/rake_task'
4
5
  task default: :spec
@@ -1,8 +1,36 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Europeana
3
4
  module FeedbackButton
4
5
  class ApplicationController < ActionController::Base
5
6
  protect_from_forgery with: :exception
7
+
8
+ before_action :fail_unless_feedback_enabled
9
+
10
+ rescue_from ApplicationError do |exception|
11
+ respond_to do |format|
12
+ format.json do
13
+ response = { success: false, message: exception.message }
14
+ response[:errors] = exception.errors if exception.errors.present?
15
+ render json: response, status: 400
16
+ end
17
+ end
18
+ end
19
+
20
+ rescue_from NoRecipientError do |exception|
21
+ respond_to do |format|
22
+ format.json do
23
+ response = { success: false, message: exception.message }
24
+ render json: response, status: 500
25
+ end
26
+ end
27
+ end
28
+
29
+ protected
30
+
31
+ def fail_unless_feedback_enabled
32
+ fail NoRecipientError, 'Feedback is not enabled' unless Europeana::FeedbackButton.enabled?
33
+ end
6
34
  end
7
35
  end
8
36
  end
@@ -1,25 +1,33 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Europeana
3
4
  module FeedbackButton
4
- class FeedbackController < ApplicationController
5
- include FeedbackHelper
6
-
5
+ class FeedbackController < Europeana::FeedbackButton::ApplicationController
7
6
  def create
8
- if feedback_enabled? && FeedbackMailer.post(mailer_post_args).deliver_later
9
- respond_to do |format|
10
- format.json { render json: { success: true } }
11
- end
12
- else
13
- respond_to do |format|
14
- format.json { render json: { success: false }, status: 500 }
15
- end
7
+ feedback = Feedback.new(feedback_params)
8
+
9
+ feedback.validate
10
+
11
+ unless feedback.valid?
12
+ fail ApplicationError.new('Feedback is invalid. See "errors" for details.',
13
+ errors: feedback.errors.messages)
14
+ end
15
+
16
+ FeedbackMailer.post(**mailer_post_args).deliver_later
17
+
18
+ respond_to do |format|
19
+ format.json { render json: { success: true } }
16
20
  end
17
21
  end
18
22
 
19
23
  private
20
24
 
25
+ def feedback_params
26
+ @feedback_params ||= params.permit(:text, :type, :page, :email, :privacy_policy)
27
+ end
28
+
21
29
  def mailer_post_args
22
- { text: params[:text], type: params[:type], page: params[:page], ip: request.remote_ip }
30
+ feedback_params.to_h.symbolize_keys.slice(:text, :type, :page, :email)
23
31
  end
24
32
  end
25
33
  end
@@ -1,18 +1,21 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Europeana
3
4
  module FeedbackButton
4
5
  class FeedbackMailer < ApplicationMailer
5
- include FeedbackHelper
6
-
7
- def post(text:, type:, page:, ip:)
8
- fail Errors::NoRecipient unless feedback_enabled?
6
+ def post(text:, type:, page:, email: nil)
7
+ fail NoRecipientError unless Europeana::FeedbackButton.enabled?
9
8
 
10
9
  @text = text
11
10
  @type = type
12
11
  @page = page
13
- @ip = ip
12
+ @email = email
14
13
 
15
- mail(to: Rails.application.config.x.feedback_mail_to, subject: text.truncate(100, separator: ' '))
14
+ mail_options = {
15
+ to: Europeana::FeedbackButton.mail_to,
16
+ subject: text.truncate(100, separator: ' ')
17
+ }
18
+ mail(mail_options)
16
19
  end
17
20
  end
18
21
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Europeana
4
+ module FeedbackButton
5
+ class Feedback
6
+ include ActiveModel::Model
7
+
8
+ MAX_LENGTH = 400
9
+ MIN_WORDS = 5
10
+ TYPES = %w(comment correction bug).freeze
11
+
12
+ attr_accessor :text, :type, :page, :email, :privacy_policy
13
+
14
+ validates :text, :type, :page, presence: true
15
+ validates :type, inclusion: { in: TYPES }
16
+ validates :privacy_policy, acceptance: true, allow_nil: false, allow_blank: false
17
+ validates :text, length: { maximum: MAX_LENGTH }
18
+ validates :text, word_count: { minimum: MIN_WORDS }, allow_nil: true, allow_blank: true
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Europeana
4
+ module FeedbackButton
5
+ class WordCountValidator < ActiveModel::EachValidator
6
+ def validate_each(record, attribute, value)
7
+ return if options[:allow_nil] && value.nil?
8
+ return if options[:allow_blank] && value.blank?
9
+
10
+ minimum = options[:minimum] || 5
11
+ validate_minimum_words(record, attribute, value, minimum)
12
+ end
13
+
14
+ def validate_minimum_words(record, attribute, value, minimum)
15
+ word_count = count_words(value)
16
+ unless word_count >= minimum
17
+ record.errors[attribute] << (options[:message] || "has too few words (#{word_count} < #{minimum})")
18
+ end
19
+ end
20
+
21
+ def count_words(value)
22
+ value&.strip&.scan(/\w+/)&.size || 0
23
+ end
24
+ end
25
+ end
26
+ end
@@ -2,18 +2,18 @@
2
2
 
3
3
  module Europeana
4
4
  module FeedbackButton
5
- ##
6
5
  # Feedback form display methods
7
6
  module FeedbackableView
8
7
  extend ActiveSupport::Concern
9
- include FeedbackHelper
10
8
 
11
9
  def feedback
12
- return nil unless feedback_enabled?
10
+ return nil unless Europeana::FeedbackButton.enabled?
11
+
13
12
  {
14
13
  form_action: europeana_feedback_button.feedback_path,
15
- maxlength: 400,
16
- minwords: 5
14
+ maxlength: Europeana::FeedbackButton::Feedback::MAX_LENGTH,
15
+ minwords: Europeana::FeedbackButton::Feedback::MIN_WORDS,
16
+ privacy_policy_url: Europeana::FeedbackButton.privacy_policy_url
17
17
  }
18
18
  end
19
19
  end
@@ -1,4 +1,6 @@
1
1
  Type: <%= @type %>
2
2
  URL: <%= @page %>
3
+ Email: <%= @email %>
4
+
3
5
  Text:
4
6
  <%= @text %>
data/bin/rails CHANGED
@@ -1,13 +1,27 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
- # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
4
3
 
5
- ENGINE_ROOT = File.expand_path('../..', __FILE__)
6
- ENGINE_PATH = File.expand_path('../../lib/europeana/feedback_button/engine', __FILE__)
4
+ # This command will automatically be run when you run "rails" with Rails gems
5
+ # installed from the root of your application.
6
+
7
+ ENGINE_ROOT = File.expand_path('..', __dir__)
8
+ ENGINE_PATH = File.expand_path('../lib/europeana/feedback_button/engine', __dir__)
9
+ APP_PATH = File.expand_path('../spec/dummy/config/application', __dir__)
7
10
 
8
11
  # Set up gems listed in the Gemfile.
9
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
12
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
10
13
  require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
11
14
 
12
- require 'rails/all'
15
+ require 'rails'
16
+ # Pick the frameworks you want:
17
+ require 'active_model/railtie'
18
+ require 'active_job/railtie'
19
+ # require "active_record/railtie"
20
+ # require "active_storage/engine"
21
+ require 'action_controller/railtie'
22
+ require 'action_mailer/railtie'
23
+ require 'action_view/railtie'
24
+ # require "action_cable/engine"
25
+ # require "sprockets/railtie"
26
+ # require "rails/test_unit/railtie"
13
27
  require 'rails/engine/commands'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Europeana::FeedbackButton::Engine.routes.draw do
3
4
  post 'feedback', to: 'feedback#create', defaults: { format: 'json' }
4
5
  end
@@ -1,16 +1,14 @@
1
1
  # frozen_string_literal: true
2
- # lib = File.expand_path('../lib', __FILE__)
3
- # $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
2
 
5
- $:.push File.expand_path('../lib', __FILE__)
3
+ $:.push File.expand_path('lib', __dir__)
6
4
 
7
5
  require 'europeana/feedback_button/version'
8
6
 
9
7
  Gem::Specification.new do |s|
10
8
  s.name = 'europeana-feedback-button'
11
9
  s.version = Europeana::FeedbackButton::VERSION
12
- s.authors = ['Lutz Biedinger']
13
- s.email = ['lutz.biedinger@gmail.com']
10
+ s.authors = ['Lutz Biedinger', 'Richard Doe']
11
+ s.email = %w(lutz.biedinger@europeana.eu richard.doe@europeana.eu)
14
12
  s.homepage = 'http://github.org/europeana/europeana-feedback-button'
15
13
  s.summary = 'Europeana Feedback Button.'
16
14
  s.description = 'An engine which allows the Europeana Feedback Button to be displayed.'
@@ -18,15 +16,14 @@ Gem::Specification.new do |s|
18
16
 
19
17
  s.files = `git ls-files -z`.split("\x0")
20
18
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
21
- s.require_paths = ['lib']
19
+ s.require_paths = %w(lib)
22
20
 
23
- s.required_ruby_version = '>= 2.0.0'
21
+ s.required_ruby_version = '>= 2.5'
24
22
 
25
- s.add_dependency 'rails', '~> 4.2', '>= 4.2.7.1'
23
+ s.add_dependency 'rails', '>= 4.2.7.1', '< 6'
26
24
 
27
25
  s.add_development_dependency 'bundler', '~> 1.8'
28
26
  s.add_development_dependency 'rake', '~> 11.0'
29
27
  s.add_development_dependency 'rspec-rails', '~> 3.0'
30
- s.add_development_dependency 'dotenv-rails', '~> 2.1'
31
- s.add_development_dependency 'shoulda-matchers', '~> 2.8'
28
+ s.add_development_dependency 'shoulda-matchers', '~> 3'
32
29
  end
@@ -1,8 +1,39 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'europeana/feedback_button/engine'
3
4
 
4
5
  module Europeana
5
6
  module FeedbackButton
6
- autoload :FeedbackableView, 'europeana/feedback_button/feedbackable_view'
7
+ PRIVACY_POLICY_URL = 'https://www.europeana.eu/portal/rights/privacy.html'
8
+
9
+ class << self
10
+ # @return [String] Email recipient of feedback submissions
11
+ attr_accessor :mail_to
12
+
13
+ # @return [String] URL to the privacy policy users must accept
14
+ attr_accessor :privacy_policy_url
15
+
16
+ # Is feedback enabled?
17
+ #
18
+ # Feedback will be enabled if +mail_to+ is set.
19
+ #
20
+ # @return [Boolean]
21
+ def enabled?
22
+ mail_to.present?
23
+ end
24
+ end
25
+
26
+ self.privacy_policy_url = PRIVACY_POLICY_URL
27
+
28
+ class ApplicationError < StandardError
29
+ attr_reader :errors
30
+
31
+ def initialize(message, **options)
32
+ super(message)
33
+ @errors = options[:errors]
34
+ end
35
+ end
36
+
37
+ class NoRecipientError < StandardError; end
7
38
  end
8
39
  end