-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
95 lines (86 loc) · 3.38 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
require "immosquare-constants"
namespace :immosquare_constants do
namespace :sample do
##============================================================##
## bundle exec rake immosquare_constants:sample:ip:get_real_ip
##============================================================##
namespace :ip do
task :get_real_ip do
ip = ImmosquareConstants::Ip.get_real_ip
puts ip
end
end
##============================================================##
## bundle exec rake immosquare_constants:sample:locale:native_name_for_locale
##============================================================##
namespace :locale do
task :native_name_for_locale do
locale = :fr
locale_name = ImmosquareConstants::Locale.native_name_for_locale(locale)
puts locale_name
end
end
namespace :regex do
##============================================================##
## bundle exec rake immosquare_constants:sample:regex:email
##============================================================##
task :email do
valid_emails = [
"test@example.com",
"user.name+tag+sorting@example.co.uk",
"user_name@example-domain.com",
"user-name@sub.example.com"
]
invalid_emails = [
"plainaddress",
"@no-local-part.com",
"Outlook Contact <outlook-contact@domain.com>",
"no-at.domain.com",
"a test@test.com",
"test@test.com extra",
"test@@example.com"
]
(valid_emails + invalid_emails).each do |email|
tester = ImmosquareConstants::Regex.email.match?(email)
puts "Email: #{email} => #{tester}"
end
end
##============================================================##
## bundle exec rake immosquare_constants:sample:regex:email_in_string
##============================================================##
task :email_in_string do
text = "Veuillez contacter support@example.com ou sales@example.org pour plus d'informations."
emails = text.scan(ImmosquareConstants::Regex.email_in_string)
puts "Adresses email trouvées : #{emails.join(", ")}" if emails.any?
end
##============================================================##
## bundle exec rake immosquare_constants:sample:regex:email_raw
##============================================================##
task :email_raw do
texts = [
"Contact: support@example.com pour plus d'infos.",
"Voici un email: user@domain.com.",
"Il n'y a pas d'email ici !"
]
texts.each do |text|
email_found = text.scan(ImmosquareConstants::Regex.email_raw)
if email_found.any?
puts "Email brut trouvé dans '#{text}' : #{email_found.join(", ")}"
else
puts "Aucun email trouvé dans '#{text}'."
end
end
end
end
##============================================================##
## bundle exec rake immosquare_constants:sample:color:color_name_to_hex
##============================================================##
namespace :color do
task :color_name_to_hex do
color = "red"
color_hex = ImmosquareConstants::Color.color_name_to_hex(color)
puts "#{color} => #{color_hex}"
end
end
end
end