interage-helper 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +69 -49
- data/interage-helper-0.1.3.gem +0 -0
- data/lib/interage/application_helper.rb +3 -2
- data/lib/interage/cep_helper.rb +3 -3
- data/lib/interage/cnpj_helper.rb +11 -0
- data/lib/interage/cpf_helper.rb +11 -0
- data/lib/interage/helper.rb +2 -1
- data/lib/interage/helper/version.rb +1 -1
- data/lib/interage/number_helper.rb +4 -0
- data/lib/interage/parsers/parser_cep.rb +29 -0
- data/lib/interage/parsers/parser_cnpj.rb +37 -0
- data/lib/interage/parsers/parser_cpf.rb +37 -0
- data/lib/interage/parsers/parser_phone.rb +49 -0
- data/lib/interage/phone_helper.rb +3 -5
- metadata +8 -2
- data/lib/interage/cpf_cnpj_helper.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fa12c957f6264600a7e63ce1ed2f0751e90f3ff65d7dbef08a0b86f39c94629
|
4
|
+
data.tar.gz: 032dbb521e9ec10c5343519bf35f80fb388a31da366b89e13ef4769617896c2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 338b8d2ed326c26637fe024b523bc78928ccdd3c78540fc0a3ae939dff319993bc9d9581fda30963737189ca8c6faeedb10c55e30a70665aa84bdc3a36bd4ca3
|
7
|
+
data.tar.gz: a8ca9edde891c33aff13e29c04275fdba60816a77cedaa60decc4526daf26202789d8f759e4a9770157da013b972e8c822786d8cd9b3f261b16aa8d0f1566550
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
Add this line to your application's Gemfile:
|
7
7
|
|
8
8
|
```ruby
|
9
|
-
gem 'interage-helper', '~> 0.1.
|
9
|
+
gem 'interage-helper', '~> 0.1.4'
|
10
10
|
```
|
11
11
|
|
12
12
|
And then execute:
|
@@ -65,130 +65,150 @@ FAVICON_FILE_NAME='icons/apple-touch-icon'
|
|
65
65
|
#### Interage::LinkToHelper
|
66
66
|
|
67
67
|
```erb
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
<%= link_to_edit edit_user_path(user) %>
|
69
|
+
<%= link_to_back :back %>
|
70
|
+
<%= link_to_show user_path(user) %>
|
71
|
+
<%= link_to_destroy user_path(user) %>
|
72
|
+
<%= link_to_new User, users_path %>
|
73
73
|
```
|
74
74
|
|
75
75
|
#### Interage::ApplicationIconHelper
|
76
76
|
|
77
77
|
```erb
|
78
|
-
|
79
|
-
|
78
|
+
<%= app_icon('user', class: 'text-muted') %>
|
79
|
+
<%= app_icon_text('users', 'Usuários', class: 'text-muted') %>
|
80
80
|
```
|
81
81
|
|
82
82
|
#### Interage::FontAwesomeHelper
|
83
83
|
|
84
84
|
```erb
|
85
|
-
|
86
|
-
|
85
|
+
<%= fa_icon('user', class: 'text-muted') %>
|
86
|
+
<%= fa_icon_text('users', 'Usuários', class: 'text-muted') %>
|
87
87
|
```
|
88
88
|
|
89
89
|
#### Interage::MaterialDesignIconsHelper
|
90
90
|
|
91
91
|
```erb
|
92
|
-
|
93
|
-
|
92
|
+
<%= md_icon('user', class: 'text-muted') %>
|
93
|
+
<%= md_icon_text('users', 'Usuários', class: 'text-muted') %>
|
94
94
|
```
|
95
95
|
|
96
96
|
#### Interage::VersionHelper
|
97
97
|
|
98
98
|
```erb
|
99
|
-
|
100
|
-
|
99
|
+
<%= app_version %>
|
100
|
+
<%= app_text_version %>
|
101
101
|
```
|
102
102
|
|
103
103
|
#### Interage::TranslationHelper
|
104
104
|
|
105
105
|
```erb
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
106
|
+
<%= tm(User) %>
|
107
|
+
<%= tmp(User) %>
|
108
|
+
<%= ta(User, :name) %>
|
109
|
+
<%= tb(false) %>
|
110
|
+
<%= tb(true) %>
|
111
|
+
<%= tbi(false) %>
|
112
|
+
<%= tbi(true) %>
|
113
|
+
<%= tbci(false) %>
|
114
|
+
<%= tbci(true) %>
|
115
115
|
```
|
116
116
|
|
117
117
|
#### Interage::TextHelper
|
118
118
|
|
119
119
|
```erb
|
120
|
-
|
120
|
+
<%= nl2br("Hello\nWorld") %>
|
121
121
|
```
|
122
122
|
|
123
123
|
#### Interage::PhoneHelper
|
124
124
|
|
125
125
|
```erb
|
126
|
-
|
126
|
+
<%= format_phone('+5581987654321') %>
|
127
|
+
<%= format_phone('5581987654321') %>
|
128
|
+
<%= format_phone('081987654321') %>
|
129
|
+
<%= format_phone('81987654321') %>
|
130
|
+
<%= format_phone('8187654321') %>
|
131
|
+
<%= format_phone('987654321') %>
|
132
|
+
<%= format_phone('98765432') %>
|
127
133
|
```
|
128
134
|
|
129
135
|
#### Interage::PaginationHelper
|
130
136
|
|
131
137
|
```erb
|
132
|
-
|
138
|
+
<%= pagination_links(@users) %>
|
133
139
|
```
|
134
140
|
|
135
141
|
#### Interage::NumberHelper
|
136
142
|
|
137
143
|
```erb
|
138
|
-
|
144
|
+
<%= default_currency_format(10.57) %>
|
145
|
+
<%= default_currency_format(100.17) %>
|
146
|
+
<%= default_currency_format(1_000) %>
|
147
|
+
<%= default_currency_format(10_000) %>
|
148
|
+
<%= default_currency_format(1_000_000) %>
|
139
149
|
```
|
140
150
|
|
141
151
|
#### Interage::GravatarHelper
|
142
152
|
|
143
153
|
```erb
|
144
|
-
|
154
|
+
<%= gravatar_image_tag(user.email) %>
|
145
155
|
```
|
146
156
|
|
147
157
|
#### Interage::ControllerActiveHelper
|
148
158
|
|
149
159
|
```erb
|
150
|
-
|
151
|
-
|
160
|
+
<%= current_controller?('home') %>
|
161
|
+
<%= current_controller?('docs') %>
|
162
|
+
<%= menu_class_show('docs') %>
|
163
|
+
<%= menu_active('docs') %>
|
164
|
+
<%= current_controller?('home', 'docs') %>
|
165
|
+
<%= menu_class_show('home', 'docs') %>
|
166
|
+
<%= menu_active('home', 'docs') %>
|
152
167
|
```
|
153
168
|
|
154
169
|
#### Interage::CEPHelper
|
155
170
|
|
156
171
|
```erb
|
157
|
-
|
172
|
+
<%= format_cep('54754-195') %>
|
173
|
+
<%= format_cep('54754195') %>
|
158
174
|
```
|
159
175
|
|
160
|
-
#### Interage::
|
176
|
+
#### Interage::CNPJHelper
|
161
177
|
|
162
178
|
```erb
|
163
|
-
|
164
|
-
|
179
|
+
<%= format_cnpj('08.475.876/0001-04') %>
|
180
|
+
<%= format_cnpj('08475876000104') %>
|
181
|
+
```
|
182
|
+
|
183
|
+
#### Interage::CPFHelper
|
184
|
+
|
185
|
+
```erb
|
186
|
+
<%= format_cpf('320.871.430-05') %>
|
187
|
+
<%= format_cpf('32087143005') %>
|
165
188
|
```
|
166
189
|
|
167
190
|
#### Interage::ApplicationHelper
|
168
191
|
|
169
192
|
```erb
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
<p><%= env_name_upcase %></p>
|
193
|
+
<%= format_seconds(20) %>
|
194
|
+
<%= admin_page_title %>
|
195
|
+
<%= devise_page_title %>
|
196
|
+
<%= page_title %>
|
197
|
+
<%= app_name %>
|
198
|
+
<%= env_name_upcase %>
|
177
199
|
```
|
178
200
|
|
179
201
|
#### Interage::BootstrapHelper
|
180
202
|
|
181
203
|
```erb
|
182
|
-
<%=
|
183
|
-
<%=
|
184
|
-
<%=
|
185
|
-
<%=
|
186
|
-
<%= bootstrap_alert_success('users') %>
|
187
|
-
<%= bootstrap_alert_danger('users') %>
|
204
|
+
<%= bootstrap_alert_info('Info message') %>
|
205
|
+
<%= bootstrap_alert_warning('Warning message') %>
|
206
|
+
<%= bootstrap_alert_success('Success message') %>
|
207
|
+
<%= bootstrap_alert_danger('Danger message') %>
|
188
208
|
<%= bootstrap_alert_not_found_male(User) %>
|
189
209
|
<%= bootstrap_alert_not_found_female(User) %>
|
190
|
-
|
191
|
-
|
210
|
+
<%= text_not_found_male(User) %>
|
211
|
+
<%= text_not_found_female(User) %>
|
192
212
|
```
|
193
213
|
|
194
214
|
## Contributing
|
Binary file
|
@@ -5,9 +5,10 @@ module Interage
|
|
5
5
|
include ::Interage::ApplicationIconHelper
|
6
6
|
include ::Interage::BootstrapHelper
|
7
7
|
include ::Interage::CEPHelper
|
8
|
+
include ::Interage::CNPJHelper
|
8
9
|
include ::Interage::CocoonHelper
|
9
10
|
include ::Interage::ControllerActiveHelper
|
10
|
-
include ::Interage::
|
11
|
+
include ::Interage::CPFHelper
|
11
12
|
include ::Interage::DateTimeHelper
|
12
13
|
include ::Interage::FaviconHelper
|
13
14
|
include ::Interage::FlashMessageHelper
|
@@ -27,7 +28,7 @@ module Interage
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def app_page_title(area = '')
|
30
|
-
"#{env_name_upcase}#{page_title}#{area}#{app_name}"
|
31
|
+
strip_tags "#{env_name_upcase}#{page_title}#{area}#{app_name}"
|
31
32
|
end
|
32
33
|
|
33
34
|
def admin_page_title
|
data/lib/interage/cep_helper.rb
CHANGED
data/lib/interage/helper.rb
CHANGED
@@ -13,9 +13,10 @@ module Interage
|
|
13
13
|
autoload :ApplicationIconHelper, 'interage/application_icon_helper'
|
14
14
|
autoload :BootstrapHelper, 'interage/bootstrap_helper'
|
15
15
|
autoload :CEPHelper, 'interage/cep_helper'
|
16
|
+
autoload :CNPJHelper, 'interage/cnpj_helper'
|
16
17
|
autoload :CocoonHelper, 'interage/cocoon_helper'
|
17
18
|
autoload :ControllerActiveHelper, 'interage/controller_active_helper'
|
18
|
-
autoload :
|
19
|
+
autoload :CPFHelper, 'interage/cpf_helper'
|
19
20
|
autoload :DateTimeHelper, 'interage/date_time_helper'
|
20
21
|
autoload :FaviconHelper, 'interage/favicon_helper'
|
21
22
|
autoload :FlashMessageHelper, 'interage/flash_message_helper'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Interage
|
4
|
+
class ParserCep
|
5
|
+
include Interage::NumberHelper
|
6
|
+
|
7
|
+
ALLOWED_SIZE = 8
|
8
|
+
|
9
|
+
def self.call(cep)
|
10
|
+
new(cep).perform
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(cep)
|
14
|
+
@cep = only_numbers(cep).to_i
|
15
|
+
end
|
16
|
+
|
17
|
+
def perform
|
18
|
+
"#{digits[-8..-4]}-#{digits[-3..-1]}" if cep.positive?
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_reader :cep
|
24
|
+
|
25
|
+
def digits
|
26
|
+
@digits ||= cep.to_s.rjust(ALLOWED_SIZE, '0')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Interage
|
4
|
+
class ParserCNPJ
|
5
|
+
include Interage::NumberHelper
|
6
|
+
|
7
|
+
ALLOWED_SIZE = 14
|
8
|
+
|
9
|
+
def self.call(cnpj)
|
10
|
+
new(cnpj).perform
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(cnpj)
|
14
|
+
@cnpj = only_numbers(cnpj).to_i
|
15
|
+
end
|
16
|
+
|
17
|
+
def perform
|
18
|
+
"#{prefix_cnpj}/#{sufix_cnpj}".strip if cnpj.positive?
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_reader :cnpj
|
24
|
+
|
25
|
+
def prefix_cnpj
|
26
|
+
[digits[-14..-13], digits[-12..-10], digits[-9..-7]].join('.')
|
27
|
+
end
|
28
|
+
|
29
|
+
def sufix_cnpj
|
30
|
+
[digits[-6..-3], digits[-2..-1]].join('-')
|
31
|
+
end
|
32
|
+
|
33
|
+
def digits
|
34
|
+
@digits ||= cnpj.to_s.rjust(ALLOWED_SIZE, '0')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Interage
|
4
|
+
class ParserCPF
|
5
|
+
include Interage::NumberHelper
|
6
|
+
|
7
|
+
ALLOWED_SIZE = 11
|
8
|
+
|
9
|
+
def self.call(cpf)
|
10
|
+
new(cpf).perform
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(cpf)
|
14
|
+
@cpf = only_numbers(cpf).to_i
|
15
|
+
end
|
16
|
+
|
17
|
+
def perform
|
18
|
+
"#{prefix_cpf}-#{sufix_cpf}".strip if cpf.positive?
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_reader :cpf
|
24
|
+
|
25
|
+
def prefix_cpf
|
26
|
+
[digits[-11..-9], digits[-8..-6], digits[-5..-3]].join('.')
|
27
|
+
end
|
28
|
+
|
29
|
+
def sufix_cpf
|
30
|
+
digits[-2..-1]
|
31
|
+
end
|
32
|
+
|
33
|
+
def digits
|
34
|
+
@digits ||= cpf.to_s.rjust(ALLOWED_SIZE, '0')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Interage
|
4
|
+
class ParserPhone
|
5
|
+
include Interage::NumberHelper
|
6
|
+
|
7
|
+
ALLOWED_SIZES = [13, 11, 9, 8].freeze
|
8
|
+
|
9
|
+
def self.call(phone)
|
10
|
+
new(phone).perform
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(phone)
|
14
|
+
@phone = only_numbers(phone).to_i.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
def perform
|
18
|
+
formatted_phone
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_reader :phone
|
24
|
+
|
25
|
+
def formatted_phone
|
26
|
+
"#{country_code} #{ddd} #{prefix_phone}-#{sufix_phone}".strip
|
27
|
+
end
|
28
|
+
|
29
|
+
def country_code
|
30
|
+
"+#{phone[-13..-12]}" if phone[-13..-12].present?
|
31
|
+
end
|
32
|
+
|
33
|
+
def ddd
|
34
|
+
"(#{phone[-11..-10]})" if phone[-13..-12].present?
|
35
|
+
end
|
36
|
+
|
37
|
+
def prefix_phone
|
38
|
+
phone.size == 8 ? phone[-8..-5] : phone[-9..-5]
|
39
|
+
end
|
40
|
+
|
41
|
+
def sufix_phone
|
42
|
+
phone[-4..-1]
|
43
|
+
end
|
44
|
+
|
45
|
+
def valid?
|
46
|
+
ALLOWED_SIZES.include?(phone.size)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'parsers/parser_phone'
|
4
|
+
|
3
5
|
module Interage
|
4
6
|
module PhoneHelper
|
5
7
|
def format_phone(phone)
|
6
|
-
|
7
|
-
|
8
|
-
phone.to_s.gsub!(/[^0-9]/, '')
|
9
|
-
|
10
|
-
"(#{phone[0, 2]}) #{phone[3, 5]}-#{phone[8, 4]}".strip
|
8
|
+
ParserPhone.call(phone)
|
11
9
|
end
|
12
10
|
end
|
13
11
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interage-helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Walmir Neto
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- interage-helper-0.1.0.gem
|
78
78
|
- interage-helper-0.1.1.gem
|
79
79
|
- interage-helper-0.1.2.gem
|
80
|
+
- interage-helper-0.1.3.gem
|
80
81
|
- interage-helper.gemspec
|
81
82
|
- lib/generators/interage/helper/install/USAGE
|
82
83
|
- lib/generators/interage/helper/install/install_generator.rb
|
@@ -86,9 +87,10 @@ files:
|
|
86
87
|
- lib/interage/application_icon_helper.rb
|
87
88
|
- lib/interage/bootstrap_helper.rb
|
88
89
|
- lib/interage/cep_helper.rb
|
90
|
+
- lib/interage/cnpj_helper.rb
|
89
91
|
- lib/interage/cocoon_helper.rb
|
90
92
|
- lib/interage/controller_active_helper.rb
|
91
|
-
- lib/interage/
|
93
|
+
- lib/interage/cpf_helper.rb
|
92
94
|
- lib/interage/date_time_helper.rb
|
93
95
|
- lib/interage/favicon_helper.rb
|
94
96
|
- lib/interage/flash_message_helper.rb
|
@@ -100,6 +102,10 @@ files:
|
|
100
102
|
- lib/interage/material_design_icons_helper.rb
|
101
103
|
- lib/interage/number_helper.rb
|
102
104
|
- lib/interage/pagination_helper.rb
|
105
|
+
- lib/interage/parsers/parser_cep.rb
|
106
|
+
- lib/interage/parsers/parser_cnpj.rb
|
107
|
+
- lib/interage/parsers/parser_cpf.rb
|
108
|
+
- lib/interage/parsers/parser_phone.rb
|
103
109
|
- lib/interage/phone_helper.rb
|
104
110
|
- lib/interage/text_helper.rb
|
105
111
|
- lib/interage/translation_helper.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Interage
|
4
|
-
module CPFCNPJHelper
|
5
|
-
def format_cnpj(cnpj)
|
6
|
-
return if cnpj.blank?
|
7
|
-
|
8
|
-
cnpj.to_s.gsub!(/[^0-9]/, '')
|
9
|
-
|
10
|
-
formatted_cnpj = ["#{cnpj[0, 2]}.#{cnpj[2, 3]}.#{cnpj[5, 3]}",
|
11
|
-
"#{cnpj[8, 4]}-#{cnpj[12, 2]}"]
|
12
|
-
formatted_cnpj.join('/').strip
|
13
|
-
end
|
14
|
-
|
15
|
-
def format_cpf(cpf)
|
16
|
-
return if cpf.blank?
|
17
|
-
|
18
|
-
cpf.to_s.gsub!(/[^0-9]/, '')
|
19
|
-
|
20
|
-
"#{cpf[0, 3]}.#{cpf[3, 3]}.#{cpf[6, 3]}-#{cpf[9, 2]}".strip
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|