andy_rails_toolbox 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d490a832956c4287797e3213abfba7ecb66e5179
4
- data.tar.gz: 858db06595597e257a290054b5e4afb3251ae4f5
3
+ metadata.gz: 290b2eef6daf36498d9d7bb54ec8c3667ac23454
4
+ data.tar.gz: c3ead3f7c84415d4ccac7f4bcb020defeb8213f2
5
5
  SHA512:
6
- metadata.gz: 5a42df778e012a8f4bf7866b0eace5d8be5ed433608120b6dd126e16a8acdfd703016a553d393af75c8ef35d5f394ed91a423bbc9073a4b32d5928c6fa1dfbc1
7
- data.tar.gz: d6babe40c2412f7439352160ca9b9d748a6ff30dd61bb5d485941e39fa9e4f583b1def9e35f26a8c88425f0bec651760f3a0ca31157646ce1c203b76597b1bd7
6
+ metadata.gz: 619d0caa1528cee00e98b1fba0af73026aecb296e414145444e22ed01168b6334ebff3729bba87c31a62eac8a4eef35560d1bd1de64b413625d10f17f7d4884c
7
+ data.tar.gz: 7c62f301586d085391ce8cc6e2733a437a6cc1446a0a3dc17d243d313240e756555ea71e7a4b14d8a45ff9d31494ea746281ac8b71bd2a6f463a82a3b17d55d1
data/README.md CHANGED
@@ -47,24 +47,30 @@ bs_icon 'user'
47
47
  BUTTONS
48
48
 
49
49
  ``` ruby
50
- html_button 'button'
50
+ link_button 'link_label', '/'
51
+ # => <a class="btn btn-default" href="/">link_label</a>
52
+ link_button 'link_label', '/', color: 'primary'
53
+ # => <a class="btn btn-primary" href="/">link_label</a>
54
+ link_button 'link_label', '/', size: 'sm'
55
+ # => <a class="btn btn-default btn-sm" href="/">link_label</a>
56
+ link_button 'link_label', '/', block: true
57
+ # => <a class="btn btn-default btn-block" href="/">link_label</a>
58
+ link_button 'link_label', '/', active: true
59
+ # => <a class="btn btn-default active" href="/">link_label</a>
60
+ link_button 'link_label', '/', disabled: true
61
+ # => <a class="btn btn-default disabled" href="/">link_label</a>
62
+ link_button 'link-button', '/', class: 'preset-class'
63
+ # => <a class="btn btn-default preset-class" href="/">link_label</a>
64
+ link_button 'link-button', '/', label_hidden: 'xs'
65
+ # => <a class="btn btn-default" href="/"><span class="hidden-xs">link_label</span></a>
66
+ link_button 'link_label', '/', icon: 'user'
67
+ # => <a class="btn btn-default" href="/"><i class="fa fa-user"></i> link_label</a>
68
+ button 'button'
51
69
  # => <button name="button" type="button" class="btn btn-default">button</button>
52
- html_button 'button', color: 'primary'
53
- # => <button name="button" type="button" class="btn btn-primary">button</button>
54
- html_button 'button', size: 'sm'
55
- # => <button name="button" type="button" class="btn btn-default btn-sm">button</button>
56
- html_button 'button', block: true
57
- # => <button name="button" type="button" class="btn btn-default btn-block">button</button>
58
- html_button 'button', icon: 'user'
59
- # => <button name="button" type="button" class="btn btn-default"><i class="fa fa-user"></i> button</button>
60
- html_button 'button', active: true
61
- # => <button name="button" type="button" class="btn btn-default active">button</button>
62
70
  submit_button 'submit'
63
71
  # => <button name="submit" type="submit" class="btn btn-primary"><i class="fa fa-check"></i> submit</button>
64
72
  reset_button 'reset'
65
73
  # => <button name="reset" type="reset" class="btn btn-default"><i class="fa fa-eraser"></i> reset</button>
66
- link_button 'link', '/'
67
- # => <a class="btn btn-default" href="/">link</a>
68
74
  ```
69
75
 
70
76
  IMAGES
@@ -155,28 +161,6 @@ fa_icon "user 4x"
155
161
  # => <i class="fa fa-user fa-4x"></i>
156
162
  ```
157
163
 
158
- #### HashHelper Examples
159
-
160
- ``` ruby
161
- options = { a: '1', b: '2', c: '3' }
162
-
163
- get_value :a, options
164
- # => '1'
165
- get_value :d, options
166
- # => nil
167
- get_value :d, options, '4'
168
- # => '4'
169
-
170
- pop_value :a, options
171
- # => '1'
172
- # options = { b: '2', c: '3' }
173
- pop_value :d, options
174
- # => nil
175
- pop_value :d, options, '4'
176
- # => '4'
177
- # options = { a: '1', b: '2', c: '3' }
178
- ```
179
-
180
164
  #### TimeagoHelper
181
165
 
182
166
  Add below codes to file `app/assets/javascripts/application.js`
@@ -6,13 +6,13 @@ module BootstrapHelper
6
6
 
7
7
  # Generates an icon.
8
8
  def bs_icon(icon, html_options = {})
9
- html_options = html_options.stringify_keys
9
+ html_options = html_options.symbolize_keys
10
10
  classes = ['glyphicon']
11
11
  classes << "glyphicon-#{icon}"
12
- if preset_class = html_options.delete('class')
13
- classes << preset_class
12
+ if html_options[:class]
13
+ classes << html_options[:class]
14
14
  end
15
- html_options['class'] = classes * ' '
15
+ html_options[:class] = classes * ' '
16
16
 
17
17
  content_tag(:span, nil, html_options)
18
18
  end
@@ -26,76 +26,70 @@ module BootstrapHelper
26
26
  html_options, options, label = options, label, capture(&block) if block_given?
27
27
 
28
28
  html_options ||= {}
29
- html_options = html_options.stringify_keys
29
+ html_options = html_options.symbolize_keys
30
30
  html_options = normalize_button_options_for_bootstrap(html_options)
31
31
 
32
- if (label_hidden = html_options.delete('label_hidden')) && !block_given?
32
+ if (label_hidden = html_options.delete(:label_hidden)) && !block_given?
33
33
  label = content_tag :span, label, class: "hidden-#{label_hidden}"
34
34
  end
35
35
 
36
- if (icon = html_options.delete('icon')) && !block_given?
36
+ if (icon = html_options.delete(:icon)) && !block_given?
37
37
  label = fa_icon(icon, text: label)
38
38
  end
39
39
 
40
- if html_options['confirm']
41
- html_options['data-confirm'] = html_options.delete('confirm')
40
+ if html_options[:confirm]
41
+ html_options[:'data-confirm'] = html_options.delete(:confirm)
42
42
  end
43
43
 
44
- if html_options['disable_with']
45
- html_options['data-disable-with'] = html_options.delete('disable_with')
44
+ if html_options[:disable_with]
45
+ html_options[:'data-disable-with'] = html_options.delete(:disable_with)
46
46
  end
47
47
 
48
48
  link_to(label, options, html_options)
49
49
  end
50
50
 
51
- def new_button(label = nil, options = nil, html_options = nil)
51
+ def new_button(label = nil, options = nil, html_options = {})
52
52
  button_options = { icon: 'plus', color: 'primary' }
53
- html_options ||= {}
54
53
  html_options.update button_options
55
54
 
56
55
  link_button(label, options, html_options)
57
56
  end
58
57
 
59
58
  # Generates a link show button.
60
- def show_button(label = nil, options = nil, html_options = nil)
59
+ def show_button(label = nil, options = nil, html_options = {})
61
60
  button_options = { icon: 'search', color: 'info' }
62
- html_options ||= {}
63
61
  html_options.update button_options
64
62
 
65
63
  link_button(label, options, html_options)
66
64
  end
67
65
 
68
66
  # Generates a link edit button.
69
- def edit_button(label = nil, options = nil, html_options = nil)
67
+ def edit_button(label = nil, options = nil, html_options = {})
70
68
  button_options = { icon: 'edit', color: 'warning' }
71
- html_options ||= {}
72
69
  html_options.update button_options
73
70
 
74
71
  link_button(label, options, html_options)
75
72
  end
76
73
 
77
74
  # Generates a link destroy button.
78
- def destroy_button(label = nil, options = nil, html_options = nil)
75
+ def destroy_button(label = nil, options = nil, html_options = {})
79
76
  button_options = { icon: 'trash', color: 'danger', method: :delete, confirm: 'Are you sure?' }
80
- html_options ||= {}
81
77
  html_options.update button_options
82
78
 
83
79
  link_button(label, options, html_options)
84
80
  end
85
81
 
86
82
  # Generates a link back button.
87
- def back_button(label = nil, options = nil, html_options = nil)
83
+ def back_button(label = nil, options = nil, html_options = {})
88
84
  button_options = { icon: 'reply' }
89
- html_options ||= {}
90
85
  html_options.update button_options
91
86
 
92
87
  link_button(label, options, html_options)
93
88
  end
94
89
 
95
90
  # Generates a link cancel button.
96
- def cancel_button(label = nil, options = nil, html_options = nil)
91
+ def cancel_button(label = nil, options = nil, html_options = {})
97
92
  button_options = { icon: 'ban' }
98
- html_options ||= {}
99
93
  html_options.update button_options
100
94
 
101
95
  link_button(label, options, html_options)
@@ -110,43 +104,41 @@ module BootstrapHelper
110
104
  html_options, label = label, capture(&block) if block_given?
111
105
 
112
106
  html_options ||= {}
113
- html_options = html_options.stringify_keys
107
+ html_options = html_options.symbolize_keys
114
108
  html_options = normalize_button_options_for_bootstrap(html_options, :button)
115
109
 
116
- html_options['type'] ||= 'button'
110
+ html_options[:type] ||= 'button'
117
111
 
118
- if (label_hidden = html_options.delete('label_hidden')) && !block_given?
112
+ if (label_hidden = html_options.delete(:label_hidden)) && !block_given?
119
113
  label = content_tag :span, label, class: "hidden-#{label_hidden}"
120
114
  end
121
115
 
122
- if (icon = html_options.delete('icon')) && !block_given?
116
+ if (icon = html_options.delete(:icon)) && !block_given?
123
117
  label = fa_icon(icon, text: label)
124
118
  end
125
119
 
126
- if html_options['confirm']
127
- html_options['data-confirm'] = html_options.delete('confirm')
120
+ if html_options[:confirm]
121
+ html_options[:'data-confirm'] = html_options.delete(:confirm)
128
122
  end
129
123
 
130
- if html_options['disable_with']
131
- html_options['data-disable-with'] = html_options.delete('disable_with')
124
+ if html_options[:disable_with]
125
+ html_options[:'data-disable-with'] = html_options.delete(:disable_with)
132
126
  end
133
127
 
134
128
  button_tag(label, html_options)
135
129
  end
136
130
 
137
131
  # Generates a submit button.
138
- def submit_button(label = nil, html_options = nil)
132
+ def submit_button(label = nil, html_options = {})
139
133
  button_options = { icon: 'check', color: 'primary', name: 'submit', type: 'submit' }
140
- html_options ||= {}
141
134
  html_options.update button_options
142
135
 
143
136
  button(label, html_options)
144
137
  end
145
138
 
146
139
  # Generates a reset button.
147
- def reset_button(label = nil, html_options = nil)
140
+ def reset_button(label = nil, html_options = {})
148
141
  button_options = { icon: 'eraser', name: 'reset', type: 'reset' }
149
- html_options ||= {}
150
142
  html_options.update button_options
151
143
 
152
144
  button(label, html_options)
@@ -157,134 +149,125 @@ module BootstrapHelper
157
149
  # ---------- #
158
150
 
159
151
  # Generates a responsive-friendly image tag
160
- def image_responsive(source, options = {})
161
- add_css_class 'img-responsive', options
162
- image_tag source, options
163
- end
152
+ def image_responsive(source, html_options = {})
153
+ html_options = html_options.symbolize_keys
164
154
 
165
- # Generates an image tag with rounded corners.
166
- def image_rounded(source, options = {})
167
- add_css_class 'img-rounded', options
168
- image_tag source, options
169
- end
155
+ classes = ['img-responsive']
156
+ if html_options[:class]
157
+ classes << html_options[:class]
158
+ end
170
159
 
171
- # Generates an image tag with circle.
172
- def image_circle(source, options = {})
173
- add_css_class 'img-circle', options
174
- image_tag source, options
175
- end
160
+ html_options[:class] = classes * ' '
176
161
 
177
- # Generates an image tag within thumbnail.
178
- def image_thumbnail(source, options = {})
179
- add_css_class 'img-thumbnail', options
180
- image_tag source, options
162
+ image_tag(source, html_options)
181
163
  end
182
164
 
183
- # ------------ #
184
- # - OVERRIDE - #
185
- # ------------ #
165
+ # Generates an image tag with rounded corners.
166
+ def image_rounded(source, html_options = {})
167
+ html_options = html_options.symbolize_keys
186
168
 
187
- # override rails helper: content_tag
188
- def content_tag(name, content_or_options_with_block = nil, options = nil, escape = true, &block)
189
- if block_given?
190
- options = content_or_options_with_block if content_or_options_with_block.is_a? Hash
191
- normalize_typography_options(options) if options
192
- content_tag_string name, capture(&block), options, escape
193
- else
194
- normalize_typography_options(options) if options
195
- content_tag_string name, content_or_options_with_block, options, escape
169
+ classes = ['img-rounded']
170
+ if html_options[:class]
171
+ classes << html_options[:class]
196
172
  end
173
+
174
+ html_options[:class] = classes * ' '
175
+
176
+ image_tag(source, html_options)
197
177
  end
198
178
 
199
- private
179
+ # Generates an image tag with circle.
180
+ def image_circle(source, html_options = {})
181
+ html_options = html_options.symbolize_keys
200
182
 
201
- def normalize_button_options_for_bootstrap(html_options = {}, type = :link)
202
- classes = ['btn']
203
- if color = html_options.delete('color')
204
- classes << "btn-#{color}"
205
- else
206
- classes << 'btn-default'
207
- end
208
- if size = html_options.delete('size')
209
- classes << "btn-#{size}"
210
- end
211
- if block = html_options.delete('block')
212
- classes << 'btn-block'
213
- end
214
- if active = html_options.delete('active')
215
- classes << 'active'
216
- end
217
- if type == :link && html_options['disabled']
218
- html_options.delete('disabled')
219
- classes << 'disabled'
220
- end
221
- if preset_class = html_options.delete('class')
222
- classes << preset_class
183
+ classes = ['img-circle']
184
+ if html_options[:class]
185
+ classes << html_options[:class]
223
186
  end
224
187
 
225
- html_options['class'] = classes * ' '
226
- html_options
188
+ html_options[:class] = classes * ' '
189
+
190
+ image_tag(source, html_options)
227
191
  end
228
192
 
229
- # ------------- #
230
- # - UTILITIES - #
231
- # ------------- #
232
-
233
- # Appends new class names to the given options.
234
- def add_css_class(class_names, options)
235
- class_names = class_names.to_s if class_names.is_a? Symbol
236
- class_names = class_names.split if class_names.is_a? String
237
- if symbolize_keys(options).key? :class
238
- options_class_names = options[:class].split
239
- class_names.each do |value|
240
- options_class_names << %(#{value.strip}) unless options_class_names.include? value
241
- end
242
- class_names = options_class_names
193
+ # Generates an image tag within thumbnail.
194
+ def image_thumbnail(source, html_options = {})
195
+ html_options = html_options.symbolize_keys
196
+
197
+ classes = ['img-thumbnail']
198
+ if html_options[:class]
199
+ classes << html_options[:class]
243
200
  end
244
- options[:class] = %(#{class_names * ' '})
245
- end
246
201
 
247
- # Adds the pull class to the given options is applicable.
248
- def add_pull_class(options)
249
- pull = pop_value :pull, options
250
- add_css_class(%(pull-#{pull}), options) if pull
251
- end
202
+ html_options[:class] = classes * ' '
252
203
 
253
- # Adds the text align class to the given options if applicable.
254
- def add_align_class(options)
255
- align = pop_value :align, options
256
- add_css_class(%(text-#{align}), options) if align
204
+ image_tag(source, html_options)
257
205
  end
258
206
 
259
- # Adds the text transform class to the given options if applicable.
260
- def add_transform_class(options)
261
- transform = pop_value :transform, options
262
- add_css_class(%(text-#{transform}), options) if transform
263
- end
207
+ # ------------ #
208
+ # - OVERRIDE - #
209
+ # ------------ #
264
210
 
265
- # Adds the color to the given options if applicable.
266
- def add_color_class(options)
267
- color = pop_value :color, options
268
- add_css_class(%(text-#{color}), options) if color
269
- end
211
+ def content_tag(name, content = nil, options = nil, escape = true, &block)
212
+ options, content = content, capture(&block) if block_given?
270
213
 
271
- # Adds the bgcolor to the given options if applicable.
272
- def add_bgcolor_class(options)
273
- bgcolor = pop_value :bgcolor, options
274
- add_css_class(%(bg-#{bgcolor}), options) if bgcolor
275
- end
214
+ options ||= {}
215
+ options = options.symbolize_keys
216
+ options = normalize_options_for_typography(options)
276
217
 
277
- # Adds the active to the given options if applicable.
278
- def add_active_class(options)
279
- active = pop_value :active, options
280
- add_css_class('active', options) if active
218
+ content_tag_string(name, content, options, escape)
281
219
  end
282
220
 
283
- def normalize_typography_options(options)
284
- add_pull_class options
285
- add_align_class options
286
- add_transform_class options
287
- add_color_class options
288
- add_bgcolor_class options
289
- end
221
+ private
222
+
223
+ def normalize_button_options_for_bootstrap(html_options = {}, type = :link)
224
+ classes = ['btn']
225
+ if color = html_options.delete(:color) { 'default' }
226
+ classes << "btn-#{color}"
227
+ end
228
+ if size = html_options.delete(:size)
229
+ classes << "btn-#{size}"
230
+ end
231
+ if block = html_options.delete(:block)
232
+ classes << 'btn-block'
233
+ end
234
+ if active = html_options.delete(:active)
235
+ classes << 'active'
236
+ end
237
+ if type == :link && html_options[:disabled]
238
+ html_options.delete(:disabled)
239
+ classes << 'disabled'
240
+ end
241
+ if html_options[:class]
242
+ classes << html_options[:class]
243
+ end
244
+
245
+ html_options[:class] = classes * ' '
246
+ html_options
247
+ end
248
+
249
+ def normalize_options_for_typography(html_options = {})
250
+ classes = []
251
+ if pull = html_options.delete(:pull)
252
+ classes << "pull-#{pull}"
253
+ end
254
+ if align = html_options.delete(:align)
255
+ classes << "text-#{align}"
256
+ end
257
+ if transform = html_options.delete(:transform)
258
+ classes << "text-#{transform}"
259
+ end
260
+ if color = html_options.delete(:color)
261
+ classes << "text-#{color}"
262
+ end
263
+ if bgcolor = html_options.delete(:bgcolor)
264
+ classes << "text-#{bgcolor}"
265
+ end
266
+ if html_options[:class]
267
+ classes << html_options[:class]
268
+ end
269
+
270
+ html_options[:class] = classes * ' '
271
+ html_options
272
+ end
290
273
  end
@@ -1,21 +1,21 @@
1
1
  module QrcodeHelper
2
2
  def qrcode(data = '', options = {})
3
3
  # Google API: https://google-developers.appspot.com/chart/infographics/docs/qr_codes
4
- width = pop_value :width, options, '200'
5
- output_encoding = pop_value :output_encoding, options
6
- error_correction_level = pop_value :error_correction_level, options
7
- margin = pop_value :margin, options
4
+ width = options.delete(:width) { '200' }
5
+ output_encoding = options.delete(:output_encoding)
6
+ error_correction_level = options.delete(:error_correction_level)
7
+ margin = options.delete(:margin)
8
8
 
9
9
  qrcode_url = 'https://chart.googleapis.com/chart?cht=qr'
10
10
  qrcode_url += "&chl=#{data}"
11
11
  qrcode_url += "&chs=#{width}x#{width}"
12
- qrcode_url += "&choe=#{output_encoding}" unless output_encoding.nil?
13
- if error_correction_level.nil? or margin.nil?
14
- qrcode_url += "&chld=#{error_correction_level}" unless error_correction_level.nil?
15
- qrcode_url += "&chld=|#{margin}" unless margin.nil?
16
- else
12
+ qrcode_url += "&choe=#{output_encoding}" if output_encoding
13
+ if error_correction_level && margin
17
14
  qrcode_url += "&chld=#{error_correction_level}|#{margin}"
15
+ else
16
+ qrcode_url += "&chld=#{error_correction_level}" if error_correction_level
17
+ qrcode_url += "&chld=|#{margin}" if margin
18
18
  end
19
- image_tag qrcode_url, alt: data
19
+ image_tag(qrcode_url, alt: data)
20
20
  end
21
21
  end
@@ -1,7 +1,12 @@
1
1
  module TimeagoHelper
2
- def timeago(time, options = {})
2
+ def timeago(time = nil, html_options = {})
3
3
  time = time.to_time if time.is_a? String
4
- options[:class] ||= 'timeago'
5
- content_tag(:abbr, time.to_s, options.merge(title: time.getutc.iso8601)) if time
4
+ classes = ['timeago']
5
+ if html_options[:class]
6
+ classes << html_options[:class]
7
+ end
8
+ html_options[:class] = classes * ' '
9
+ html_options[:title] = time.getutc.iso8601
10
+ content_tag(:abbr, time.try(:to_s), html_options)
6
11
  end
7
12
  end
@@ -1,3 +1,3 @@
1
1
  module AndyRailsToolbox
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
metadata CHANGED
@@ -1,27 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: andy_rails_toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ChouAndy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-30 00:00:00.000000000 Z
11
+ date: 2015-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.10
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.3.10
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.2.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 3.2.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: capybara
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 2.4.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 2.4.4
13
69
  - !ruby/object:Gem::Dependency
14
70
  name: bootstrap-sass
15
71
  requirement: !ruby/object:Gem::Requirement
16
72
  requirements:
17
- - - "~>"
73
+ - - ">="
18
74
  - !ruby/object:Gem::Version
19
75
  version: 3.3.4
20
76
  type: :runtime
21
77
  prerelease: false
22
78
  version_requirements: !ruby/object:Gem::Requirement
23
79
  requirements:
24
- - - "~>"
80
+ - - ">="
25
81
  - !ruby/object:Gem::Version
26
82
  version: 3.3.4
27
83
  - !ruby/object:Gem::Dependency
@@ -94,7 +150,6 @@ files:
94
150
  - app/assets/javascripts/jquery.timeago.load.coffee
95
151
  - app/assets/javascripts/jquery.timeago.zh-TW.js
96
152
  - app/helpers/bootstrap_helper.rb
97
- - app/helpers/hash_helper.rb
98
153
  - app/helpers/markdown_helper.rb
99
154
  - app/helpers/qrcode_helper.rb
100
155
  - app/helpers/timeago_helper.rb
@@ -1,26 +0,0 @@
1
- module HashHelper
2
-
3
- # -------- #
4
- # - Hash - #
5
- # -------- #
6
-
7
- # Returns a specific value from the given hash (or the default value if not set).
8
- def get_value(key, hash, default_value = nil)
9
- value = hash.delete key
10
- value = default_value if value.nil? and !default_value.nil?
11
- value
12
- end
13
-
14
- # Removes and returns a specific value from the given hash (or the default value if not set).
15
- def pop_value(key, hash, default_value = nil)
16
- symbolize_keys hash unless hash.empty?
17
- get_value key.to_sym, hash, default_value
18
- end
19
-
20
- # all keys of the given hash symbolize.
21
- def symbolize_keys(hash)
22
- result = {}
23
- hash.each { |key, value| result[key.to_sym] = value }
24
- hash.replace result
25
- end
26
- end