workarea-product_badges 1.3.2

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 (83) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +16 -0
  3. data/.eslintrc +25 -0
  4. data/.gitignore +19 -0
  5. data/.markdownlint.json +10 -0
  6. data/.rails-rubocop.yml +119 -0
  7. data/.rubocop.yml +8 -0
  8. data/.scss-lint.yml +192 -0
  9. data/CHANGELOG.md +101 -0
  10. data/Gemfile +16 -0
  11. data/README.md +167 -0
  12. data/Rakefile +63 -0
  13. data/app/assets/stylesheets/workarea/product_badges/components/_badges.scss +47 -0
  14. data/app/models/workarea/catalog/product.decorator +11 -0
  15. data/app/view_models/workarea/storefront/product_view_model.decorator +52 -0
  16. data/app/views/workarea/admin/catalog_products/_badge_fields.html.haml +40 -0
  17. data/app/views/workarea/storefront/products/_badges.haml +5 -0
  18. data/bin/rails +20 -0
  19. data/config/initializers/appends.rb +21 -0
  20. data/config/initializers/workarea.rb +9 -0
  21. data/config/locales/en.yml +19 -0
  22. data/lib/workarea/product_badges/engine.rb +8 -0
  23. data/lib/workarea/product_badges/version.rb +5 -0
  24. data/lib/workarea/product_badges.rb +30 -0
  25. data/script/admin_ci +9 -0
  26. data/script/ci +11 -0
  27. data/script/core_ci +9 -0
  28. data/script/plugins_ci +9 -0
  29. data/script/storefront_ci +9 -0
  30. data/test/dummy/Rakefile +6 -0
  31. data/test/dummy/app/assets/config/manifest.js +4 -0
  32. data/test/dummy/app/assets/images/.keep +0 -0
  33. data/test/dummy/app/assets/javascripts/application.js +13 -0
  34. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  35. data/test/dummy/app/controllers/application_controller.rb +3 -0
  36. data/test/dummy/app/controllers/concerns/.keep +0 -0
  37. data/test/dummy/app/helpers/application_helper.rb +2 -0
  38. data/test/dummy/app/jobs/application_job.rb +2 -0
  39. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  40. data/test/dummy/app/models/concerns/.keep +0 -0
  41. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  42. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  43. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  44. data/test/dummy/bin/bundle +3 -0
  45. data/test/dummy/bin/rails +4 -0
  46. data/test/dummy/bin/rake +4 -0
  47. data/test/dummy/bin/setup +38 -0
  48. data/test/dummy/bin/update +29 -0
  49. data/test/dummy/bin/yarn +11 -0
  50. data/test/dummy/config/application.rb +26 -0
  51. data/test/dummy/config/boot.rb +5 -0
  52. data/test/dummy/config/cable.yml +10 -0
  53. data/test/dummy/config/environment.rb +5 -0
  54. data/test/dummy/config/environments/development.rb +54 -0
  55. data/test/dummy/config/environments/production.rb +91 -0
  56. data/test/dummy/config/environments/test.rb +44 -0
  57. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  58. data/test/dummy/config/initializers/assets.rb +14 -0
  59. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  60. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  61. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  62. data/test/dummy/config/initializers/inflections.rb +16 -0
  63. data/test/dummy/config/initializers/mime_types.rb +4 -0
  64. data/test/dummy/config/initializers/workarea.rb +5 -0
  65. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  66. data/test/dummy/config/locales/en.yml +33 -0
  67. data/test/dummy/config/puma.rb +56 -0
  68. data/test/dummy/config/routes.rb +5 -0
  69. data/test/dummy/config/secrets.yml +32 -0
  70. data/test/dummy/config/spring.rb +6 -0
  71. data/test/dummy/config.ru +5 -0
  72. data/test/dummy/db/seeds.rb +2 -0
  73. data/test/dummy/lib/assets/.keep +0 -0
  74. data/test/dummy/log/.keep +0 -0
  75. data/test/dummy/package.json +5 -0
  76. data/test/integration/workarea/admin/products_badging_integration_test.rb +15 -0
  77. data/test/system/workarea/admin/product_badges_system_test.rb +29 -0
  78. data/test/system/workarea/storefront/product_badges_system_test.rb +62 -0
  79. data/test/teaspoon_env.rb +6 -0
  80. data/test/test_helper.rb +10 -0
  81. data/test/view_models/workarea/storefront/product_view_model_badging_test.rb +81 -0
  82. data/workarea-product_badges.gemspec +17 -0
  83. metadata +143 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e3632e4f228e57a2fc9484b0c8cdc4e65f9b42c562768e987481e1a93ae5c7c8
4
+ data.tar.gz: 70dacdddb4287037759a4a90263cc2ef602b47ac542f3110497bc8aec8cd9e35
5
+ SHA512:
6
+ metadata.gz: 28fe68b38b069e53fc71a386e0408763e23b94e37803855ce23a933cb1ac938c1ec2870a8be1036b2b03738b882f15c165ef92e6aff900f9dc07f0dbcce18d9b
7
+ data.tar.gz: fd4b8439d1f4a8e89221df01fe6da7bf9167cbc650b06949df7291b179f48fdfb9da42e31d7f541706a191fbc2e2ff5f194f5f4724f9565e30f48992624a5fba
data/.editorconfig ADDED
@@ -0,0 +1,16 @@
1
+ # editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_style = space
7
+ end_of_line = lf
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [{*.rb,*.haml,*.decorator}]
12
+ indent_size = 2
13
+ indent_style = space
14
+
15
+ [{*.js,*.jst,*.ejs,*.scss}]
16
+ indent_size = 4
data/.eslintrc ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "extends": "eslint:recommended",
3
+ "rules": {
4
+ "semi": ["error", "always"],
5
+ "eqeqeq": ["error", "always"]
6
+ },
7
+ "globals": {
8
+ "window": true,
9
+ "document": true,
10
+ "WORKAREA": true,
11
+ "$": true,
12
+ "jQuery": true,
13
+ "_": true,
14
+ "feature": true,
15
+ "JST": true,
16
+ "Turbolinks": true,
17
+ "I18n": true,
18
+ "Chart": true,
19
+ "Dropzone": true,
20
+ "strftime": true,
21
+ "Waypoint": true,
22
+ "wysihtml": true,
23
+ "LocalTime": true
24
+ }
25
+ }
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/db/*.sqlite3
5
+ test/dummy/db/*.sqlite3-journal
6
+ test/dummy/log/*.log
7
+ test/dummy/tmp/
8
+ .DS_Store
9
+ .byebug_history
10
+ .bundle/
11
+ .sass-cache/
12
+ Gemfile.lock
13
+ pkg/
14
+ test/dummy/tmp/
15
+ test/dummy/public/
16
+ log/*.log
17
+ test/dummy/log/*.log
18
+ test/dummy/db/*.sqlite3
19
+ test/dummy/db/*.sqlite3-journal
@@ -0,0 +1,10 @@
1
+ {
2
+ "default": true,
3
+ "MD003": {
4
+ "style": "setext_with_atx"
5
+ },
6
+ "MD007": {
7
+ "indent": 4
8
+ },
9
+ "no-hard-tabs": false
10
+ }
@@ -0,0 +1,119 @@
1
+ AllCops:
2
+ # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
3
+ # to ignore them, so only the ones explicitly set in this file are enabled.
4
+ DisabledByDefault: true
5
+
6
+ # Prefer &&/|| over and/or.
7
+ Style/AndOr:
8
+ Enabled: true
9
+
10
+ # Do not use braces for hash literals when they are the last argument of a
11
+ # method call.
12
+ Style/BracesAroundHashParameters:
13
+ Enabled: true
14
+
15
+ # Align `when` with `case`.
16
+ Layout/CaseIndentation:
17
+ Enabled: true
18
+
19
+ # Align comments with method definitions.
20
+ Layout/CommentIndentation:
21
+ Enabled: true
22
+
23
+ # No extra empty lines.
24
+ Layout/EmptyLines:
25
+ Enabled: true
26
+
27
+ # In a regular class definition, no empty lines around the body.
28
+ Layout/EmptyLinesAroundClassBody:
29
+ Enabled: true
30
+
31
+ # In a regular method definition, no empty lines around the body.
32
+ Layout/EmptyLinesAroundMethodBody:
33
+ Enabled: true
34
+
35
+ # In a regular module definition, no empty lines around the body.
36
+ Layout/EmptyLinesAroundModuleBody:
37
+ Enabled: true
38
+
39
+ # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
40
+ Style/HashSyntax:
41
+ Enabled: true
42
+
43
+ # Method definitions after `private` or `protected` isolated calls need one
44
+ # extra level of indentation.
45
+ Layout/IndentationConsistency:
46
+ Enabled: true
47
+ EnforcedStyle: rails
48
+
49
+ # Two spaces, no tabs (for indentation).
50
+ Layout/IndentationWidth:
51
+ Enabled: true
52
+
53
+ Layout/SpaceAfterColon:
54
+ Enabled: true
55
+
56
+ Layout/SpaceAfterComma:
57
+ Enabled: true
58
+
59
+ Layout/SpaceAroundEqualsInParameterDefault:
60
+ Enabled: true
61
+
62
+ Layout/SpaceAroundKeyword:
63
+ Enabled: true
64
+
65
+ Layout/SpaceAroundOperators:
66
+ Enabled: true
67
+
68
+ Layout/SpaceBeforeFirstArg:
69
+ Enabled: true
70
+
71
+ # Defining a method with parameters needs parentheses.
72
+ Style/MethodDefParentheses:
73
+ Enabled: true
74
+
75
+ # Use `foo {}` not `foo{}`.
76
+ Layout/SpaceBeforeBlockBraces:
77
+ Enabled: true
78
+
79
+ # Use `foo { bar }` not `foo {bar}`.
80
+ Layout/SpaceInsideBlockBraces:
81
+ Enabled: true
82
+
83
+ # Use `{ a: 1 }` not `{a:1}`.
84
+ Layout/SpaceInsideHashLiteralBraces:
85
+ Enabled: true
86
+
87
+ Layout/SpaceInsideParens:
88
+ Enabled: true
89
+
90
+ # Check quotes usage according to lint rule below.
91
+ Style/StringLiterals:
92
+ Enabled: true
93
+ EnforcedStyle: double_quotes
94
+
95
+ # Detect hard tabs, no hard tabs.
96
+ Layout/Tab:
97
+ Enabled: true
98
+
99
+ # Blank lines should not have any spaces.
100
+ Layout/TrailingBlankLines:
101
+ Enabled: true
102
+
103
+ # No trailing whitespace.
104
+ Layout/TrailingWhitespace:
105
+ Enabled: true
106
+
107
+ # Use quotes for string literals when they are enough.
108
+ Style/UnneededPercentQ:
109
+ Enabled: true
110
+
111
+ # Align `end` with the matching keyword or starting expression except for
112
+ # assignments, where it should be aligned with the LHS.
113
+ Lint/EndAlignment:
114
+ Enabled: true
115
+ EnforcedStyleAlignWith: variable
116
+
117
+ # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
118
+ Lint/RequireParentheses:
119
+ Enabled: true
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ inherit_from: .rails-rubocop.yml
2
+
3
+ AllCops:
4
+ Exclude:
5
+ - 'Rakefile'
6
+ - 'test/dummy/**/*'
7
+ - 'lib/badges.rb'
8
+ - 'lib/badges/**/*'
data/.scss-lint.yml ADDED
@@ -0,0 +1,192 @@
1
+ # Extension of the default configuration:
2
+ # https://github.com/causes/scss-lint/blob/master/config/default.yml
3
+
4
+ exclude: 'docs/**'
5
+
6
+ linters:
7
+ Comment:
8
+ enabled: false
9
+
10
+ DeclarationOrder:
11
+ enabled: true
12
+
13
+ ElsePlacement:
14
+ enabled: true
15
+
16
+ EmptyRule:
17
+ enabled: false
18
+
19
+ HexLength:
20
+ enabled: true
21
+ style: long
22
+
23
+ Indentation:
24
+ enabled: true
25
+ allow_non_nested_indentation: true
26
+ character: space
27
+ width: 4
28
+
29
+ LeadingZero:
30
+ enabled: true
31
+ style: include_zero
32
+
33
+ MergeableSelector:
34
+ enabled: true
35
+ force_nesting: false
36
+
37
+ PropertySortOrder:
38
+ enabled: true
39
+ ignore_unspecified: false
40
+ separate_groups: false
41
+ order:
42
+ - display
43
+ -
44
+ - position
45
+ - top
46
+ - right
47
+ - bottom
48
+ - left
49
+ - z-index
50
+ -
51
+ - margin
52
+ - margin-top
53
+ - margin-right
54
+ - margin-bottom
55
+ - margin-left
56
+ -
57
+ - margin-collapse
58
+ - margin-top-collapse
59
+ - margin-right-collapse
60
+ - margin-bottom-collapse
61
+ - margin-left-collapse
62
+ -
63
+ - padding
64
+ - padding-top
65
+ - padding-right
66
+ - padding-bottom
67
+ - padding-left
68
+ -
69
+ - width
70
+ - height
71
+ - max-width
72
+ - max-height
73
+ - min-width
74
+ - min-height
75
+ -
76
+ - float
77
+ - clear
78
+ -
79
+ - color
80
+ -
81
+ - font
82
+ - font-size
83
+ - font-style
84
+ - font-family
85
+ - font-weight
86
+ - font-variant
87
+ - font-smoothing
88
+ -
89
+ - line-height
90
+ - letter-spacing
91
+ - word-spacing
92
+ -
93
+ - text-align
94
+ - text-indent
95
+ - text-shadow
96
+ - text-overflow
97
+ - text-rendering
98
+ - text-transform
99
+ - text-decoration
100
+ - text-size-adjust
101
+ -
102
+ - word-break
103
+ - word-wrap
104
+ -
105
+ - white-space
106
+ -
107
+ - background
108
+ - background-size
109
+ - background-color
110
+ - background-image
111
+ - background-repeat
112
+ - background-position
113
+ - background-attachment
114
+ -
115
+ - border
116
+ - border-top
117
+ - border-right
118
+ - border-bottom
119
+ - border-left
120
+ -
121
+ - border-image
122
+ - border-spacing
123
+ - border-collapse
124
+ -
125
+ - border-color
126
+ - border-top-color
127
+ - border-right-color
128
+ - border-bottom-color
129
+ - border-left-color
130
+ -
131
+ - border-style
132
+ - border-top-style
133
+ - border-right-style
134
+ - border-bottom-style
135
+ - border-left-style
136
+ -
137
+ - border-width
138
+ - border-top-width
139
+ - border-right-width
140
+ - border-bottom-width
141
+ - border-left-width
142
+ -
143
+ - border-radius
144
+ - border-top-right-radius
145
+ - border-bottom-right-radius
146
+ - border-bottom-left-radius
147
+ - border-top-left-radius
148
+ - border-radius-topright
149
+ - border-radius-bottomright
150
+ - border-radius-bottomleft
151
+ - border-radius-topleft
152
+ -
153
+ - box-shadow
154
+
155
+ SelectorFormat:
156
+ enabled: true
157
+ convention: hyphenated_BEM
158
+
159
+ SingleLinePerSelector:
160
+ enabled: false
161
+
162
+ SpaceAfterPropertyColon:
163
+ enabled: true
164
+ style: at_least_one_space
165
+
166
+ SpaceBeforeBrace:
167
+ enabled: true
168
+ style: space
169
+ allow_single_line_padding: true
170
+
171
+ VariableForProperty:
172
+ enabled: true
173
+ properties:
174
+ - color
175
+ - font-family
176
+ - background-color
177
+
178
+ PseudoElement:
179
+ enabled: false
180
+
181
+ # These default settings may be problematic to implementors. They are not
182
+ # ommitted so that they may be adjusted as needed during an implementation.
183
+ #
184
+ # For documentation:
185
+ # https://github.com/causes/scss-lint/blob/master/lib/scss_lint/linter/README.md
186
+
187
+ DuplicateProperty:
188
+ enabled: true
189
+
190
+ PropertySpelling:
191
+ enabled: true
192
+ extra_properties: [] # Add experimental CSS to this array, if needed
data/CHANGELOG.md ADDED
@@ -0,0 +1,101 @@
1
+ Workarea Product Badges 1.3.2 (2019-08-21)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Open Source!
5
+
6
+
7
+
8
+ Workarea Product Badges 1.3.1 (2019-06-11)
9
+ --------------------------------------------------------------------------------
10
+
11
+ * Add minimum version requirement for Workarea v3.4
12
+
13
+ * As of v1.3.0 product badges requries workarea v3.4.0 or higher
14
+
15
+ PRODBADGE-10
16
+ Jake Beresford
17
+
18
+
19
+
20
+ Workarea Product Badges 1.3.0 (2019-03-19)
21
+ --------------------------------------------------------------------------------
22
+
23
+ * Update for v3.4 compatibility
24
+
25
+ * Update implementation of top_sellers badge to use new Insights properly
26
+ * Update gemfile format
27
+ * Use integration tests instead of system tests for speed and to prevent weirdness.
28
+ * Set test/dummy to use 5.2
29
+ * Fix engine_path in bin/rails
30
+ * Remove require workarea from bin/rails
31
+ * rubocop fixes
32
+
33
+ PRODBADGE-8
34
+ Jake Beresford
35
+
36
+ * Update for v3.4 compatibility
37
+
38
+ * Use Insights instead of deprecated Analytics when determining best sellers
39
+ * Update CI scripts
40
+
41
+ PRODBADGE-8
42
+ Matt Dunphy
43
+
44
+
45
+
46
+ Workarea Product Badges 1.2.0 (2018-10-30)
47
+ --------------------------------------------------------------------------------
48
+
49
+ * Allow field used for new badge to be configured
50
+
51
+ PRODBADGE-4
52
+ Jake Beresford
53
+
54
+
55
+
56
+ Workarea Product Badges 1.1.0 (2018-09-19)
57
+ --------------------------------------------------------------------------------
58
+
59
+ * Add badges to product detail page
60
+
61
+ * Append badges partial to storefront.product_description
62
+ * Add scoped styles for badges on PDP
63
+
64
+ PRODBADGE-7
65
+ Jake Beresford
66
+
67
+ * Prevent pointer events on badges
68
+
69
+ * Allow user to click link behind a badge component, like a linked product_summary image
70
+
71
+ PRODBADGE-6
72
+ Jake Beresford
73
+
74
+
75
+
76
+ Workarea Product Badges 1.0.0 (2018-04-11 10:58:26 -0400)
77
+ --------------------------------------------------------------------------------
78
+
79
+ * Workarea Product Badges Plugin
80
+
81
+ Allows products to be 'badged' either manually via the admin/product import or
82
+ via logic-based automatic badges. Admins can add badges via a CSV of
83
+ values or toggle rule-based badges like 'sale' or 'new'. Badges are
84
+ displayed on product summary.
85
+
86
+ PRODBADGE-1
87
+ Jake Beresford
88
+
89
+
90
+ Workarea Product Badges 1.0.0 (2018-04-10 15:14:42 -0400)
91
+ --------------------------------------------------------------------------------
92
+
93
+ * Workarea Product Badges Plugin
94
+
95
+ Allows products to be 'badged' either manually via the admin/product import or
96
+ via logic-based automatic badges. Admins can add badges via a CSV of
97
+ values or toggle rule-based badges like 'sale' or 'new'. Badges are
98
+ displayed on product summary.
99
+
100
+ PRODBADGE-1
101
+ Jake Beresford
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Declare your gem"s dependencies in accordions.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # Declare any dependencies that are still in development here instead of in
9
+ # your gemspec. These might include edge Rails or gems from your path or
10
+ # Git. Remember to move these dependencies to your gemspec before releasing
11
+ # your gem to rubygems.org.
12
+
13
+ # To use a debugger
14
+ # gem "byebug", group: [:development, :test]
15
+
16
+ gem "workarea", source: "https://gems.weblinc.com"
data/README.md ADDED
@@ -0,0 +1,167 @@
1
+ Workarea Badges
2
+ ================================================================================
3
+
4
+ Badges plugin for the Workarea platform.
5
+ Adds badges to product summary and product detail views.
6
+
7
+ Badges can be added to products manually, or via a product import by specifying
8
+ a comma-separated list in the product[:badges] field.
9
+
10
+ In addition to custom badges via the product[:badges] field this plugin provides
11
+ automatic badging for products. Out of the box automatic badges are:
12
+
13
+ * New
14
+ * Sale
15
+ * Best Seller
16
+
17
+ Configuration
18
+ --------------------------------------------------------------------------------
19
+
20
+ The following configuration can be added to your host app and adjusted as necessary:
21
+
22
+ ```ruby
23
+ Workarea.configure do |config|
24
+ config.product_badges = {
25
+ new_threshold: 30,
26
+ new_date_field: :created_at,
27
+ number_of_top_sellers: 10,
28
+ max_badges: nil,
29
+ sort: ->(badges) { badges.sort_by{ |b| ["New", "Sale", "Best Seller"].find_index(b) || 999 } }
30
+ }
31
+ end
32
+ ```
33
+
34
+ ### new_threshold
35
+
36
+ * type: integer
37
+ * default: 30
38
+ * products created in this time will receive a 'New' badge
39
+
40
+ ### new_date_field
41
+
42
+ * type: symbol
43
+ * default: :created_at
44
+ * Specify which field will be used to calculate whether a product should display
45
+ the 'new' badge.
46
+
47
+ ### number_of_top_sellers
48
+
49
+ * type: integer
50
+ * default: 10
51
+ * Description: Number of products from top sellers to apply a badge to
52
+
53
+ ### max_badges
54
+
55
+ * type: integer
56
+ * default: nil
57
+ * Description: limits the number of badges that can be applied to any product
58
+
59
+ ### sort
60
+
61
+ * type: Lambda
62
+ * default: ->(badges) { badges.sort_by{ |b| ["New", "Sale", "Best Seller"].find_index(b) || 999 } }
63
+ * Description: Specify the order in which badges should appear, this lambda can
64
+ be updated to sort badges according to any business logic without decoration.
65
+ By default the plugin will sort automatic badges first followed by custom badges.
66
+ Custom badges will display in the order they appear in the admin.
67
+
68
+ #### Implementing a custom sort class
69
+
70
+ For more complicated sorting logic, a sorting class can be implemented as long as
71
+ it responds to .call example
72
+
73
+ ```ruby
74
+ class MyBadgeSort
75
+ def self.call(badges)
76
+ new(badges).results
77
+ end
78
+
79
+ def initialize(badges)
80
+ @badges = badges
81
+ end
82
+
83
+ def results
84
+ # do all sorts of crazy complex stuff
85
+ end
86
+ end
87
+ ```
88
+
89
+ Then update your configuration to:
90
+
91
+ ```ruby
92
+ Workarea.config.product_badges[:sort] = MyBadgeSort
93
+ ```
94
+
95
+ Adding new automatic badges
96
+ --------------------------------------------------------------------------------
97
+
98
+ To add a new automatic badge in your host application you should decorate the
99
+ product_view_model automatic_badges method, calling super and injecting your badge
100
+ to the array.
101
+
102
+ Example:
103
+
104
+ ```ruby
105
+ module Workarea
106
+ decorate Storefront::ProductViewModel, with: :your_app_name do
107
+ def automatic_badges
108
+ super << custom_badge_method
109
+ end
110
+
111
+ private
112
+
113
+ def custom_badge_method
114
+ if logic_for_automatic_badge
115
+ t('workarea.storefront.products.badges.[custom_badge_key]')
116
+ end
117
+ end
118
+ end
119
+ end
120
+ ```
121
+
122
+ Getting Started
123
+ --------------------------------------------------------------------------------
124
+
125
+ This gem contains a rails engine that must be mounted onto a host Rails application.
126
+
127
+ To access Workarea gems and source code, you must be an employee of WebLinc or a licensed retailer or partner.
128
+
129
+ Workarea gems are hosted privately at https://gems.weblinc.com/.
130
+ You must have individual or team credentials to install gems from this server. Add your gems server credentials to Bundler:
131
+
132
+ bundle config gems.weblinc.com my_username:my_password
133
+
134
+ Or set the appropriate environment variable in a shell startup file:
135
+
136
+ export BUNDLE_GEMS__WEBLINC__COM='my_username:my_password'
137
+
138
+ Then add the gem to your application's Gemfile specifying the source:
139
+
140
+ # ...
141
+ gem 'workarea-badges', source: 'https://gems.weblinc.com'
142
+ # ...
143
+
144
+ Or use a source block:
145
+
146
+ # ...
147
+ source 'https://gems.weblinc.com' do
148
+ gem 'workarea-badges'
149
+ end
150
+ # ...
151
+
152
+ Update your application's bundle.
153
+
154
+ cd path/to/application
155
+ bundle
156
+
157
+ Workarea Platform Documentation
158
+ --------------------------------------------------------------------------------
159
+
160
+ See [http://developer.weblinc.com](http://developer.weblinc.com) for Workarea platform documentation.
161
+
162
+ Copyright & Licensing
163
+ --------------------------------------------------------------------------------
164
+
165
+ Copyright WebLinc 2018. All rights reserved.
166
+
167
+ For licensing, contact sales@workarea.com.