blueberry_rails 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/README.md +12 -1
  4. data/blueberry_rails.gemspec +17 -18
  5. data/lib/blueberry_rails/action_helpers.rb +4 -0
  6. data/lib/blueberry_rails/app_builder.rb +151 -18
  7. data/lib/blueberry_rails/generators/app_generator.rb +60 -2
  8. data/lib/blueberry_rails/version.rb +1 -1
  9. data/spec/blueberry_rails_spec.rb +42 -1
  10. data/spec/support/blueberry_rails_helpers.rb +1 -1
  11. data/templates/Gemfile_custom.erb +20 -5
  12. data/templates/admin_assets/javascripts/admin.coffee +6 -0
  13. data/templates/admin_assets/javascripts/admin/.keep +0 -0
  14. data/templates/admin_assets/stylesheets/admin.sass +4 -0
  15. data/templates/admin_assets/stylesheets/admin/.keep +0 -0
  16. data/templates/admin_controllers/base_controller.rb +6 -0
  17. data/templates/admin_controllers/dashboard_controller.rb +6 -0
  18. data/templates/admin_views/dashboard/show.html.slim +12 -0
  19. data/templates/admin_views/partials/_menu.html.slim +13 -0
  20. data/templates/assets/icons/_font_icons.scss +18 -0
  21. data/templates/assets/images/blueberry-logo.png +0 -0
  22. data/templates/assets/javascripts/application.coffee +6 -0
  23. data/templates/assets/javascripts/common/.keep +0 -0
  24. data/templates/assets/javascripts/frontend/.keep +0 -0
  25. data/templates/assets/stylesheets/application.sass +17 -0
  26. data/templates/assets/stylesheets/frontend/base/buttons.sass +0 -0
  27. data/templates/assets/stylesheets/frontend/base/fonts.sass +0 -0
  28. data/templates/assets/stylesheets/frontend/base/typo.sass +0 -0
  29. data/templates/assets/stylesheets/frontend/common/bootstrap-ms.sass +128 -0
  30. data/templates/assets/stylesheets/frontend/common/bootstrap-override.sass +4 -0
  31. data/templates/assets/stylesheets/frontend/common/variables.sass +26 -0
  32. data/templates/assets/stylesheets/frontend/components/.keep +0 -0
  33. data/templates/assets/stylesheets/frontend/components/navigation.sass +0 -0
  34. data/templates/assets/stylesheets/frontend/layout/body.sass +0 -0
  35. data/templates/assets/stylesheets/frontend/layout/footer.sass +0 -0
  36. data/templates/assets/stylesheets/frontend/layout/header.sass +0 -0
  37. data/templates/assets/stylesheets/frontend/pages/.keep +0 -0
  38. data/templates/assets/stylesheets/frontend/third-party/includes.sass +1 -0
  39. data/templates/assets/stylesheets/frontend/utils/functions.sass +23 -0
  40. data/templates/assets/stylesheets/frontend/utils/make-columns.sass +67 -0
  41. data/templates/assets/stylesheets/frontend/utils/mixins.sass +24 -0
  42. data/templates/assets/stylesheets/frontend/utils/render-to.sass +27 -0
  43. data/templates/assets/stylesheets/frontend/utils/renderto-debug.sass +22 -0
  44. data/templates/assets/stylesheets/ie.sass +0 -0
  45. data/templates/assets/stylesheets/print.sass +0 -0
  46. data/templates/config/initializers/airbrake.rb +6 -0
  47. data/templates/config/initializers/simple_form_bootstrap.rb +151 -0
  48. data/templates/config/initializers/translation_engine.rb +23 -0
  49. data/templates/controllers/errors_controller.rb +13 -0
  50. data/templates/fontcustom.yml +22 -0
  51. data/templates/helpers/application_helper.rb +23 -0
  52. data/templates/helpers/body_class_helper.rb +16 -0
  53. data/templates/helpers/gtm_helper.rb +30 -0
  54. data/templates/helpers/images_helper.rb +13 -0
  55. data/templates/locales/cs/cs.devise.yml +69 -0
  56. data/templates/locales/cs/cs.meta.yml +5 -0
  57. data/templates/locales/cs/cs.rails.yml +211 -0
  58. data/templates/locales/cs/cs.yml +4 -0
  59. data/templates/locales/en/en.meta.yml +5 -0
  60. data/templates/locales/en/en.yml +4 -0
  61. data/templates/public/icons/android-icon-144x144.png +0 -0
  62. data/templates/public/icons/android-icon-192x192.png +0 -0
  63. data/templates/public/icons/android-icon-36x36.png +0 -0
  64. data/templates/public/icons/android-icon-48x48.png +0 -0
  65. data/templates/public/icons/android-icon-72x72.png +0 -0
  66. data/templates/public/icons/android-icon-96x96.png +0 -0
  67. data/templates/public/icons/apple-icon-114x114.png +0 -0
  68. data/templates/public/icons/apple-icon-120x120.png +0 -0
  69. data/templates/public/icons/apple-icon-144x144.png +0 -0
  70. data/templates/public/icons/apple-icon-152x152.png +0 -0
  71. data/templates/public/icons/apple-icon-180x180.png +0 -0
  72. data/templates/public/icons/apple-icon-57x57.png +0 -0
  73. data/templates/public/icons/apple-icon-60x60.png +0 -0
  74. data/templates/public/icons/apple-icon-72x72.png +0 -0
  75. data/templates/public/icons/apple-icon-76x76.png +0 -0
  76. data/templates/public/icons/apple-icon-precomposed.png +0 -0
  77. data/templates/public/icons/apple-icon.png +0 -0
  78. data/templates/public/icons/favicon-16x16.png +0 -0
  79. data/templates/public/icons/favicon-32x32.png +0 -0
  80. data/templates/public/icons/favicon-96x96.png +0 -0
  81. data/templates/public/icons/favicon.ico +0 -0
  82. data/templates/public/icons/ms-icon-144x144.png +0 -0
  83. data/templates/public/icons/ms-icon-150x150.png +0 -0
  84. data/templates/public/icons/ms-icon-310x310.png +0 -0
  85. data/templates/public/icons/ms-icon-70x70.png +0 -0
  86. data/templates/{root_controller_spec.rb → spec/controllers/root_controller_spec.rb} +0 -0
  87. data/templates/{database_cleaner_setup.rb → spec/database_cleaner_setup.rb} +0 -0
  88. data/templates/spec/factories/administrators.rb +6 -0
  89. data/templates/{users_factory.rb → spec/factories/users.rb} +0 -0
  90. data/templates/{factories_spec.rb → spec/factories_spec.rb} +0 -0
  91. data/templates/{factory_girl_syntax.rb → spec/factory_girl_syntax.rb} +0 -0
  92. data/templates/{mail_body_helpers.rb → spec/mail_body_helpers.rb} +0 -0
  93. data/templates/{spec_helper.rb → spec/spec_helper.rb} +5 -0
  94. data/templates/tasks/icons.rake +19 -0
  95. data/templates/tasks/images.rake +12 -0
  96. data/templates/travis.yml.erb +19 -18
  97. data/templates/views/application/_favicon.html.slim +16 -0
  98. data/templates/views/application/_flashes.html.slim +5 -0
  99. data/templates/views/application/_footer.html.slim +1 -0
  100. data/templates/views/application/_gtm.html.slim +7 -0
  101. data/templates/views/application/_header.html.slim +1 -0
  102. data/templates/views/layouts/admin.html.slim.erb +21 -0
  103. data/templates/views/layouts/application.html.slim.erb +26 -0
  104. metadata +95 -12
  105. data/templates/_flashes.html.slim +0 -5
  106. data/templates/layout.html.slim +0 -15
@@ -0,0 +1,23 @@
1
+ @function getNumber($string)
2
+ $strings: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9"
3
+ $numbers: 0 1 2 3 4 5 6 7 8 9
4
+ $result: 0
5
+
6
+ @for $i from 1 through str-length($string)
7
+ $character: str-slice($string, $i, $i)
8
+ $index: index($strings, $character)
9
+
10
+ @if $index
11
+ $number: nth($numbers, $index)
12
+ $result: $result * 10 + $number
13
+
14
+ @return $result
15
+
16
+ // calculate rem size from pixel size
17
+ @function rem($px)
18
+ $default: getNumber(inspect($font-size-base))
19
+ @return $px / $default * 1rem
20
+
21
+ // calculate em size from pixel size
22
+ @function em($px, $parent: getNumber(inspect($font-size-base)))
23
+ @return $px / $parent * 1em
@@ -0,0 +1,67 @@
1
+ $sizes: ("0": 0,"1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9, "10": 10, "11": 11, "12": 12)
2
+
3
+ @function to-number($value)
4
+ @if type-of($value) == 'number'
5
+ @return $value
6
+ @else if type-of($value) != 'string'
7
+ $_: log('Value for `to-number` should be a number or a string.')
8
+
9
+ $result: 0
10
+ $digits: 0
11
+ $minus: str-slice($value, 1, 1) == '-'
12
+ $numbers: ('0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9)
13
+
14
+ @for $i from if($minus, 2, 1) through str-length($value)
15
+ $character: str-slice($value, $i, $i)
16
+
17
+ @if not (index(map-keys($numbers), $character) or $character == '.')
18
+ @return to-length(if($minus, -$result, $result), str-slice($value, $i))
19
+
20
+ @if $character == '.'
21
+ $digits: 1
22
+ @else if $digits == 0
23
+ $result: $result * 10 + map-get($numbers, $character)
24
+ @else
25
+ $digits: $digits * 10
26
+ $result: $result + map-get($numbers, $character) / $digits
27
+
28
+ @return if($minus, -$result, $result)
29
+
30
+ @function getsize($args, $i)
31
+ $needle: str-slice(nth($args, $i), 3, str-length(nth($args, $i)))
32
+
33
+ @if map-has-key($sizes, $needle)
34
+ @return map-get($sizes, $needle)
35
+ @else
36
+ @return to-number($needle)
37
+
38
+ =make-columns($args...)
39
+ @for $i from 1 through length($args)
40
+ $type: str-slice(nth($args, $i), 1, 2)
41
+ $size: getsize($args, $i)
42
+
43
+ @if $type == 'xs'
44
+ +make-xs-column($size)
45
+ @if $type == 'ms'
46
+ +make-ms-column($size)
47
+ @if $type == 'sm'
48
+ +make-sm-column($size)
49
+ @if $type == 'md'
50
+ +make-md-column($size)
51
+ @if $type == 'lg'
52
+ +make-lg-column($size)
53
+
54
+ =make-offsets($args...)
55
+ @for $i from 1 through length($args)
56
+ $type: str-slice(nth($args, $i), 1, 2)
57
+ $size: map-get($sizes, str-slice(nth($args, $i), 3, str-length(nth($args, $i))))
58
+ @if $type == 'xs'
59
+ +make-xs-column-offset($size)
60
+ @if $type == 'ms'
61
+ +make-ms-column-offset($size)
62
+ @if $type == 'sm'
63
+ +make-sm-column-offset($size)
64
+ @if $type == 'md'
65
+ +make-md-column-offset($size)
66
+ @if $type == 'lg'
67
+ +make-lg-column-offset($size)
@@ -0,0 +1,24 @@
1
+ =centered($args...)
2
+ position: absolute
3
+ left: 50%
4
+ top: 50%
5
+ transform: translateX(-50%) translateY(-50%)
6
+
7
+ =antialiasing($type:antialiased)
8
+ -webkit-font-smoothing: $type
9
+ font-smoothing: $type
10
+ font-smooth: always
11
+
12
+ =pos($x, $y)
13
+ position: absolute
14
+ top: $x
15
+ left: $y
16
+
17
+ =display-flex
18
+ display: flex
19
+ flex-wrap: wrap
20
+ align-items: flex-end
21
+ justify-content: flex-start
22
+ &:after,
23
+ &:before
24
+ display: none
@@ -0,0 +1,27 @@
1
+ $xs: "(max-width: #{$screen-xs-max-new})"
2
+ $ms: "(min-width: #{$screen-ms-min}) and (max-width: #{$screen-ms-max})"
3
+ $sm: "(min-width: #{$screen-sm-min}) and (max-width: #{$screen-sm-max})"
4
+ $md: "(min-width: #{$screen-md-min}) and (max-width: #{$screen-md-max})"
5
+ $lg: "(min-width: #{$screen-lg-min})"
6
+
7
+ =render-to($type...)
8
+ @if $type == "xs"
9
+ @for $i from 1 through length($type)
10
+ @if nth($type, $i) == xs
11
+ @media #{$xs}
12
+ @content
13
+ @else if nth($type, $i) == sm
14
+ @media #{$sm}
15
+ @content
16
+ @else if nth($type, $i) == ms
17
+ @media #{$ms}
18
+ @content
19
+ @else if nth($type, $i) == md
20
+ @media #{$md}
21
+ @content
22
+ @else if nth($type, $i) == lg
23
+ @media #{$lg}
24
+ @content
25
+ @else
26
+ @media (max-width: $type)
27
+ @content
@@ -0,0 +1,22 @@
1
+ body.development:before
2
+ background-color: #FCF8E3
3
+ border-bottom: 1px solid #FBEED5
4
+ border-left: 1px solid #FBEED5
5
+ color: #C09853
6
+ font: small-caption
7
+ padding: 3px 6px
8
+ pointer-events: none
9
+ position: fixed
10
+ right: 0
11
+ top: 0
12
+ z-index: 1000001
13
+ +render-to(xs)
14
+ content: 'render to xs'
15
+ +render-to(ms)
16
+ content: 'render to ms'
17
+ +render-to(sm)
18
+ content: 'render to sm'
19
+ +render-to(md)
20
+ content: 'render to md'
21
+ +render-to(lg)
22
+ content: 'render to lg'
File without changes
File without changes
@@ -0,0 +1,6 @@
1
+ Airbrake.configure do |config|
2
+ config.host = 'http://errors.blueberry.cz'
3
+ config.project_id = true
4
+ config.project_key = 'APIKEY'
5
+ config.ignore_environments = %w(development test)
6
+ end
@@ -0,0 +1,151 @@
1
+ # Use this setup block to configure all options available in SimpleForm.
2
+ SimpleForm.setup do |config|
3
+ config.error_notification_class = 'alert alert-danger'
4
+ config.button_class = 'btn btn-default'
5
+ config.boolean_label_class = nil
6
+
7
+ config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
8
+ b.use :html5
9
+ b.use :placeholder
10
+ b.optional :maxlength
11
+ b.optional :pattern
12
+ b.optional :min_max
13
+ b.optional :readonly
14
+ b.use :label, class: 'control-label'
15
+
16
+ b.wrapper tag: 'div', class: 'form-control-wrapper' do |ba|
17
+ ba.use :input, class: 'form-control'
18
+ end
19
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
20
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
21
+ end
22
+
23
+ config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
24
+ b.use :html5
25
+ b.use :placeholder
26
+ b.optional :maxlength
27
+ b.optional :readonly
28
+ b.use :label, class: 'control-label'
29
+
30
+ b.use :input
31
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
32
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
33
+ end
34
+
35
+ config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
36
+ b.use :html5
37
+ b.optional :readonly
38
+
39
+ b.wrapper tag: 'div', class: 'checkbox' do |ba|
40
+ ba.use :label_input
41
+ end
42
+
43
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
44
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
45
+ end
46
+
47
+ config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
48
+ b.use :html5
49
+ b.optional :readonly
50
+ b.use :label, class: 'control-label'
51
+ b.use :input
52
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
53
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
54
+ end
55
+
56
+ config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
57
+ b.use :html5
58
+ b.use :placeholder
59
+ b.optional :maxlength
60
+ b.optional :pattern
61
+ b.optional :min_max
62
+ b.optional :readonly
63
+ b.use :label, class: 'col-sm-3 control-label'
64
+
65
+ b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
66
+ ba.use :input, class: 'form-control'
67
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
68
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
69
+ end
70
+ end
71
+
72
+ config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
73
+ b.use :html5
74
+ b.use :placeholder
75
+ b.optional :maxlength
76
+ b.optional :readonly
77
+ b.use :label, class: 'col-sm-3 control-label'
78
+
79
+ b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
80
+ ba.use :input
81
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
82
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
83
+ end
84
+ end
85
+
86
+ config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
87
+ b.use :html5
88
+ b.optional :readonly
89
+
90
+ b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr|
91
+ wr.wrapper tag: 'div', class: 'checkbox' do |ba|
92
+ ba.use :label_input
93
+ end
94
+
95
+ wr.use :error, wrap_with: { tag: 'span', class: 'help-block' }
96
+ wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
97
+ end
98
+ end
99
+
100
+ config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
101
+ b.use :html5
102
+ b.optional :readonly
103
+
104
+ b.use :label, class: 'col-sm-3 control-label'
105
+
106
+ b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
107
+ ba.use :input
108
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
109
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
110
+ end
111
+ end
112
+
113
+ config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
114
+ b.use :html5
115
+ b.use :placeholder
116
+ b.optional :maxlength
117
+ b.optional :pattern
118
+ b.optional :min_max
119
+ b.optional :readonly
120
+ b.use :label, class: 'sr-only'
121
+
122
+ b.use :input, class: 'form-control'
123
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
124
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
125
+ end
126
+
127
+ config.wrappers :multi_select, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
128
+ b.use :html5
129
+ b.optional :readonly
130
+ b.use :label, class: 'control-label'
131
+ b.wrapper tag: 'div', class: 'form-inline' do |ba|
132
+ ba.use :input, class: 'form-control'
133
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
134
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
135
+ end
136
+ end
137
+ # Wrappers for forms and inputs using the Bootstrap toolkit.
138
+ # Check the Bootstrap docs (http://getbootstrap.com)
139
+ # to learn about the different styles for forms and inputs,
140
+ # buttons and other elements.
141
+ config.default_wrapper = :vertical_form
142
+ config.wrapper_mappings = {
143
+ check_boxes: :vertical_radio_and_checkboxes,
144
+ radio_buttons: :vertical_radio_and_checkboxes,
145
+ file: :vertical_file_input,
146
+ boolean: :vertical_boolean,
147
+ datetime: :multi_select,
148
+ date: :multi_select,
149
+ time: :multi_select
150
+ }
151
+ end
@@ -0,0 +1,23 @@
1
+ if %w(production staging).include? Rails.env
2
+ TranslationEngine.config do |config|
3
+ # key for user
4
+ config.api_key = 'API_KEY'
5
+
6
+ # url to Translation Server
7
+ config.api_host = 'http://127.0.0.1:3000'
8
+
9
+ # enable screenshot functionality (default is false)
10
+ config.use_screenshots = true
11
+
12
+ # enable to send translation after every request and receive translations
13
+ # when something changed (default is false)
14
+ config.use_catcher = true
15
+
16
+ # Timeout for connecting to translation server
17
+ # config.timeout = 5
18
+
19
+ # If true TranslationEngine will throw exceptions on connection problems
20
+ # If false TranslationEngine will just log exception to Rails.logger
21
+ config.raise_exceptions = Rails.env.development?
22
+ end
23
+ end
@@ -0,0 +1,13 @@
1
+ class ErrorsController < ApplicationController
2
+
3
+ def show
4
+ render status_code.to_s, status: status_code
5
+ end
6
+
7
+ protected
8
+
9
+ def status_code
10
+ params[:code] || 500
11
+ end
12
+
13
+ end
@@ -0,0 +1,22 @@
1
+ font_name: icons
2
+ font_design_size: 16
3
+ font_em: 512
4
+ font_ascent: 448
5
+ font_descent: 64
6
+ css_selector: .icon-{{glyph}}
7
+ preprocessor_path: ""
8
+ autowidth: false
9
+ no_hash: true
10
+ force: true
11
+ debug: false
12
+ quiet: false
13
+
14
+ input:
15
+ vectors: app/assets/icons
16
+
17
+ output:
18
+ fonts: app/assets/fonts
19
+ css: app/assets/stylesheets/frontend/base
20
+
21
+ templates: [ _font_icons.scss ]
22
+
@@ -0,0 +1,23 @@
1
+ module ApplicationHelper
2
+ def t(_, options = {})
3
+ translation = super
4
+ return translation unless translation.is_a?(Array)
5
+
6
+ translations = translation.map do |str|
7
+ content_tag(options[:each_wrapper] || :span, str.html_safe)
8
+ end
9
+
10
+ translation = translations.join.html_safe
11
+
12
+ if options[:wrapper]
13
+ content_tag(options[:wrapper], translation)
14
+ else
15
+ translation
16
+ end
17
+ end
18
+
19
+ def meta_robots_tag
20
+ content = Rails.env.production? ? 'index,follow' : 'noindex,nofollow'
21
+ content_tag(:meta, nil, name: 'robots', content: content)
22
+ end
23
+ end
@@ -0,0 +1,16 @@
1
+ module BodyClassHelper
2
+ def body_class(options = {})
3
+ extra_body_classes_symbol = options[:extra_body_classes_symbol] || :extra_body_classes
4
+ qualified_controller_name = controller.controller_path.gsub('/','-')
5
+ basic_body_class = "#{qualified_controller_name} #{qualified_controller_name}-#{controller.action_name}"
6
+
7
+ basic_body_class << ' development' if Rails.env.development?
8
+ basic_body_class << ' show-cookie' if cookies['cookie_eu_consented'] != 'true'
9
+
10
+ if content_for?(extra_body_classes_symbol)
11
+ [basic_body_class, content_for(extra_body_classes_symbol)].join(' ')
12
+ else
13
+ basic_body_class
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,30 @@
1
+ module GtmHelper
2
+ def addEvent(options = {})
3
+ args = map_options options
4
+
5
+ content_for :javascript do
6
+ javascript_tag("dataLayer.push({ #{args} });")
7
+ end
8
+ end
9
+
10
+ def renderEvent(options = {})
11
+ args = map_options options
12
+ javascript_tag("dataLayer.push({ #{args} });")
13
+ end
14
+
15
+ def renderJsEvent(options = {})
16
+ args = map_options options
17
+ raw "dataLayer.push({ #{args} });"
18
+ end
19
+
20
+ private
21
+
22
+ def map_options(options)
23
+ default_options = { 'event': 'GAevent' }
24
+ merged_options = default_options.merge(options)
25
+ mappings = { 'category': 'eventCategory', 'action': 'eventAction', 'label': 'eventLabel', 'value': 'eventValue', 'event': 'event' }
26
+
27
+ args = merged_options.map { |key, value| [mappings[key], value] }
28
+ .map { |a| "'#{a[0]}': '#{a[1]}'" }.join(', ')
29
+ end
30
+ end