interage-helpers 0.0.1 → 0.0.2

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
  SHA256:
3
- metadata.gz: 27b972d490cd2db68dc116b22cdaa81c78553722ed5247d83de4057161fbb832
4
- data.tar.gz: 47caf7f7dd96d6cb2e12461eb6f261d336b343167fc37aae460545953f177beb
3
+ metadata.gz: b8da433c746d4cf678a2ee5f5c5bb11f1903b9d0bd2c1e0490a3d0c6b2885ca5
4
+ data.tar.gz: 9ad869ca4510da6ead8fedb93fb13627644b0c57812c94570177f5d20cc8c0ab
5
5
  SHA512:
6
- metadata.gz: da669f0b9ef5f770feea456e440fde1500434a08fe2e5f83ae2c66ac0daa1c130cbec490028a09bff74863e028bf1ef0a895cbe3d80241eada8345b92ee46acc
7
- data.tar.gz: 943f27c894e0343717296a67205ba6caacc1145368018b1adf4ac4efd7578f266836f19dbe8e77d9291002e71973abbc152a75f894c8c77be2361d55c385c9b1
6
+ metadata.gz: 80cc54300af75ccfd07d45899b332fa9b89c7f0542ff462612ccb947348a2adff8cc8498f9c0b4751fcb1af46f1f27efd24b0a9521a8d89fce9de1fef9d913df
7
+ data.tar.gz: b216e2f856fab3657b0e6d9b1ff52f3fb0561692770c6bdd1a604aa63c689021db414d0edb7ae3ce04f6e5c58b46fd31d54d731185bd18cc7cc34ae658814498
data/.rubocop.yml CHANGED
@@ -14,6 +14,11 @@ Style/SymbolArray:
14
14
  Style/WordArray:
15
15
  Enabled: false
16
16
 
17
+ Metrics/BlockLength:
18
+ Exclude:
19
+ - spec/**/*
20
+ - interage-helpers.gemspec
21
+
17
22
  AllCops:
18
23
  TargetRubyVersion: 2.6
19
24
  Exclude:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- interage-helpers (0.0.1)
4
+ interage-helpers (0.0.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -201,12 +201,12 @@ FAVICON_FILE_NAME='icons/apple-touch-icon'
201
201
  #### Interage::BootstrapHelper
202
202
 
203
203
  ```erb
204
- <%= bootstrap_alert_info('Info message') %>
205
- <%= bootstrap_alert_warning('Warning message') %>
206
- <%= bootstrap_alert_success('Success message') %>
207
- <%= bootstrap_alert_danger('Danger message') %>
208
- <%= bootstrap_alert_not_found_male(User) %>
209
- <%= bootstrap_alert_not_found_female(User) %>
204
+ <%= bs_alert_info('Info message') %>
205
+ <%= bs_alert_warning('Warning message') %>
206
+ <%= bs_alert_success('Success message') %>
207
+ <%= bs_alert_danger('Danger message') %>
208
+ <%= bs_alert_not_found_male(User) %>
209
+ <%= bs_alert_not_found_female(User) %>
210
210
  <%= text_not_found_male(User) %>
211
211
  <%= text_not_found_female(User) %>
212
212
  ```
Binary file
@@ -3,7 +3,9 @@
3
3
  module Interage
4
4
  module ApplicationHelper
5
5
  include ::Interage::ApplicationIconHelper
6
- include ::Interage::BootstrapHelper
6
+ include ::Interage::BootstrapAlertHelper
7
+ include ::Interage::BootstrapBadgeHelper
8
+ include ::Interage::BootstrapButtonHelper
7
9
  include ::Interage::CEPHelper
8
10
  include ::Interage::CNPJHelper
9
11
  include ::Interage::CocoonHelper
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Interage
4
+ module BootstrapAlertHelper
5
+ def bootstrap_alert(type, message)
6
+ icon = t("bootstrap.alert.icons.#{type}", default: type)
7
+
8
+ content_tag :div, class: "no-margin alert alert-#{type}" do
9
+ app_icon_text(icon, message)
10
+ end
11
+ end
12
+ alias bs_alert bootstrap_alert
13
+
14
+ def bootstrap_alert_default(message)
15
+ bs_alert(:default, message)
16
+ end
17
+ alias bs_alert_default bootstrap_alert_default
18
+
19
+ def bootstrap_alert_info(message)
20
+ bs_alert(:info, message)
21
+ end
22
+ alias bs_alert_info bootstrap_alert_info
23
+
24
+ def bootstrap_alert_warning(message)
25
+ bs_alert(:warning, message)
26
+ end
27
+ alias bs_alert_warning bootstrap_alert_warning
28
+
29
+ def bootstrap_alert_success(message)
30
+ bs_alert(:success, message)
31
+ end
32
+ alias bs_alert_success bootstrap_alert_success
33
+
34
+ def bootstrap_alert_danger(message)
35
+ bs_alert(:danger, message)
36
+ end
37
+ alias bs_alert_danger bootstrap_alert_danger
38
+
39
+ def bootstrap_alert_not_found(gender, model)
40
+ bs_alert_info(text_404(gender, model))
41
+ end
42
+ alias bs_text_404 bootstrap_alert_not_found
43
+
44
+ def bootstrap_alert_not_found_male(model)
45
+ bs_text_404(:male, model)
46
+ end
47
+ alias bs_male_404 bootstrap_alert_not_found_male
48
+
49
+ def bootstrap_alert_not_found_female(model)
50
+ bs_text_404(:female, model)
51
+ end
52
+ alias bs_female_404 bootstrap_alert_not_found_female
53
+
54
+ def text_not_found(gender, model)
55
+ attributes = { model: tm(model).downcase, default: default_404 }
56
+
57
+ t("bootstrap.alert.#{gender}.not_found", attributes)
58
+ end
59
+ alias text_404 text_not_found
60
+
61
+ def default_not_found
62
+ t('bootstrap.alert.not_found', default: '')
63
+ end
64
+ alias default_404 default_not_found
65
+
66
+ def text_not_found_male(model)
67
+ text_404(:male, model)
68
+ end
69
+ alias male_404 text_not_found_male
70
+
71
+ def text_not_found_female(model)
72
+ text_404(:female, model)
73
+ end
74
+ alias female_404 text_not_found_female
75
+ end
76
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Interage
4
+ module BootstrapBadgeHelper
5
+ def bootstrap_badge(type, message, options = {})
6
+ options[:class] = "badge badge-pill badge-#{type} #{options[:class]}"
7
+
8
+ content_tag :span, message, options
9
+ end
10
+ alias bs_badge bootstrap_badge
11
+
12
+ def bs_badge_default(message, options = {})
13
+ bs_badge(:default, message, options)
14
+ end
15
+
16
+ def bs_badge_primary(message, options = {})
17
+ bs_badge(:primary, message, options)
18
+ end
19
+
20
+ def bs_badge_secondary(message, options = {})
21
+ bs_badge(:secondary, message, options)
22
+ end
23
+
24
+ def bs_badge_success(message, options = {})
25
+ bs_badge(:success, message, options)
26
+ end
27
+
28
+ def bs_badge_danger(message, options = {})
29
+ bs_badge(:danger, message, options)
30
+ end
31
+
32
+ def bs_badge_warning(message, options = {})
33
+ bs_badge(:warning, message, options)
34
+ end
35
+
36
+ def bs_badge_info(message, options = {})
37
+ bs_badge(:info, message, options)
38
+ end
39
+
40
+ def bs_badge_light(message, options = {})
41
+ bs_badge(:light, message, options)
42
+ end
43
+
44
+ def bs_badge_dark(message, options = {})
45
+ bs_badge(:dark, message, options)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Interage
4
+ module BootstrapButtonHelper
5
+ DEFAULT_BTN_CLASS = 'btn btn-sm btn-outline-'
6
+
7
+ def bootstrap_default_btn_class(type)
8
+ default_btn_class = ENV.fetch('DEFAULT_BTN_TYPE_CLASS', DEFAULT_BTN_CLASS)
9
+
10
+ "#{default_btn_class}#{type} text-truncate"
11
+ end
12
+ alias bs_default_btn_class bootstrap_default_btn_class
13
+ end
14
+ end
@@ -4,8 +4,7 @@ module Interage
4
4
  module CocoonHelper
5
5
  def cocoon_link_to_add_association(form, association, options = {})
6
6
  label = options[:label] || t('buttons.cocoon.add.text')
7
- html_class =
8
- options[:html_class] || bootstrap_default_btn_class('success')
7
+ html_class = options[:html_class] || bs_default_btn_class('success')
9
8
 
10
9
  link_to_add_association(form, association, class: html_class) do
11
10
  app_icon_text(t('buttons.cocoon.add.icon'), label)
@@ -14,7 +13,7 @@ module Interage
14
13
 
15
14
  def cocoon_link_to_remove_association(form, label = nil)
16
15
  label ||= t('buttons.cocoon.remove.text')
17
- html_class = bootstrap_default_btn_class('danger')
16
+ html_class = bs_default_btn_class('danger')
18
17
 
19
18
  content_tag :div, class: 'cocoon-link-to-remove' do
20
19
  link_to_remove_association(form, class: html_class, title: label) do
@@ -15,13 +15,37 @@ module Interage
15
15
  end
16
16
 
17
17
  def format_date(date, date_format = :date_time)
18
+ return if date.blank?
19
+
18
20
  l(date, format: date_format)
19
21
  end
20
22
 
21
23
  def format_time(time)
22
- return if time.blank?
24
+ time.strftime('%H:%M') if time.present?
25
+ end
26
+
27
+ def format_datetime(date, date_format = '%d/%m/%Y %H:%M')
28
+ format_date(date, format: date_format)
29
+ end
30
+
31
+ def current_day_name
32
+ l(Date.current, format: '%A')
33
+ end
34
+
35
+ def current_day
36
+ Date.current.day
37
+ end
38
+
39
+ def current_month_year
40
+ "#{current_month} / #{current_year}"
41
+ end
42
+
43
+ def current_month
44
+ Date.current.strftime('%b')
45
+ end
23
46
 
24
- time.strftime('%H:%M')
47
+ def current_year
48
+ Date.current.year
25
49
  end
26
50
  end
27
51
  end
@@ -11,7 +11,9 @@ module Interage
11
11
 
12
12
  autoload :ApplicationHelper, 'interage/application_helper'
13
13
  autoload :ApplicationIconHelper, 'interage/application_icon_helper'
14
- autoload :BootstrapHelper, 'interage/bootstrap_helper'
14
+ autoload :BootstrapAlertHelper, 'interage/bootstrap_alert_helper'
15
+ autoload :BootstrapBadgeHelper, 'interage/bootstrap_badge_helper'
16
+ autoload :BootstrapButtonHelper, 'interage/bootstrap_button_helper'
15
17
  autoload :CEPHelper, 'interage/cep_helper'
16
18
  autoload :CNPJHelper, 'interage/cnpj_helper'
17
19
  autoload :CocoonHelper, 'interage/cocoon_helper'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Interage
4
4
  module Helper
5
- VERSION = '0.0.1'
5
+ VERSION = '0.0.2'
6
6
  end
7
7
  end
@@ -7,11 +7,13 @@ module Interage
7
7
  DESTROY_CONFIRM_MESSAGE = 'Tem certeza que deseja apagar?'
8
8
  NEW_BUTTON_CLASS = 'btn text-truncate btn-outline-application'
9
9
 
10
- def aside_link_to(text, url = '#', html_options = {})
11
- html_options[:class] = "#{ASIDE_DEFAULT_CLASS} #{html_options[:class]}"
12
- html_options[:title] = strip_tags(text)
10
+ def aside_link_to(*args, &block)
11
+ options = args.last.is_a?(Hash) ? args.pop : {}
12
+ options[:class] = "#{ASIDE_DEFAULT_CLASS} #{options[:class]}"
13
+ options[:title] = strip_tags(args.first) if block.blank?
14
+ args.push(options)
13
15
 
14
- link_to text, url, html_options
16
+ link_to(*args, &block)
15
17
  end
16
18
 
17
19
  def link_to_modal(text, url = '#', html_options = {})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interage-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Walmir Neto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-12 00:00:00.000000000 Z
11
+ date: 2020-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -74,6 +74,7 @@ files:
74
74
  - bin/rspec
75
75
  - bin/rubocop
76
76
  - bin/setup
77
+ - interage-helpers-0.0.1.gem
77
78
  - interage-helpers.gemspec
78
79
  - lib/generators/interage/helper/install/USAGE
79
80
  - lib/generators/interage/helper/install/install_generator.rb
@@ -81,7 +82,9 @@ files:
81
82
  - lib/generators/interage/helper/install/templates/application_helper.yml
82
83
  - lib/interage/application_helper.rb
83
84
  - lib/interage/application_icon_helper.rb
84
- - lib/interage/bootstrap_helper.rb
85
+ - lib/interage/bootstrap_alert_helper.rb
86
+ - lib/interage/bootstrap_badge_helper.rb
87
+ - lib/interage/bootstrap_button_helper.rb
85
88
  - lib/interage/cep_helper.rb
86
89
  - lib/interage/cnpj_helper.rb
87
90
  - lib/interage/cocoon_helper.rb
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Interage
4
- module BootstrapHelper
5
- DEFAULT_BTN_CLASS = 'btn btn-sm btn-outline-'
6
-
7
- def bootstrap_alert(type, message)
8
- icon = t("bootstrap.alert.icons.#{type}", default: type)
9
-
10
- content_tag :div, class: "no-margin alert alert-#{type}" do
11
- app_icon_text(icon, message)
12
- end
13
- end
14
-
15
- def bootstrap_alert_default(message)
16
- bootstrap_alert(:default, message)
17
- end
18
-
19
- def bootstrap_alert_info(message)
20
- bootstrap_alert(:info, message)
21
- end
22
-
23
- def bootstrap_alert_warning(message)
24
- bootstrap_alert(:warning, message)
25
- end
26
-
27
- def bootstrap_alert_success(message)
28
- bootstrap_alert(:success, message)
29
- end
30
-
31
- def bootstrap_alert_danger(message)
32
- bootstrap_alert(:danger, message)
33
- end
34
-
35
- def bootstrap_alert_not_found(gender, model)
36
- bootstrap_alert_info(text_not_found(gender, model))
37
- end
38
-
39
- def bootstrap_alert_not_found_male(model)
40
- bootstrap_alert_not_found(:male, model)
41
- end
42
-
43
- def bootstrap_alert_not_found_female(model)
44
- bootstrap_alert_not_found(:female, model)
45
- end
46
-
47
- def text_not_found(gender, model)
48
- default_not_found = t('bootstrap.alert.not_found', default: '')
49
-
50
- t("bootstrap.alert.#{gender}.not_found", model: tm(model).downcase,
51
- default: default_not_found)
52
- end
53
-
54
- def text_not_found_male(model)
55
- text_not_found(:male, model)
56
- end
57
-
58
- def text_not_found_female(model)
59
- text_not_found(:female, model)
60
- end
61
-
62
- def bootstrap_default_btn_class(type)
63
- default_btn_class = ENV.fetch('DEFAULT_BTN_TYPE_CLASS', DEFAULT_BTN_CLASS)
64
-
65
- "#{default_btn_class}#{type} text-truncate"
66
- end
67
- end
68
- end