File Coverage

blib/lib/BlankOnDev/Form.pm
Criterion Covered Total %
statement 15 137 10.9
branch 0 40 0.0
condition 0 6 0.0
subroutine 5 11 45.4
pod 0 6 0.0
total 20 200 10.0


line stmt bran cond sub pod time code
1             package BlankOnDev::Form;
2 1     1   6 use strict;
  1         1  
  1         26  
3 1     1   4 use warnings FATAL => 'all';
  1         2  
  1         24  
4              
5             # Import :
6 1     1   423 use Term::ReadKey;
  1         1568  
  1         63  
7 1     1   6 use BlankOnDev::Rilis;
  1         2  
  1         16  
8 1     1   406 use BlankOnDev::DateTime;
  1         3  
  1         769  
9              
10             # Version :
11             our $VERSION = '0.1005';
12              
13             # Subroutine for form time zone :
14             # ------------------------------------------------------------------------
15             sub form_timezone {
16 0     0 0   my ($self, $time_zone) = @_;
17             # Prepare From TimeZone :
18 0           my $form_timezone;
19 0 0         my $timezone = $time_zone ? $time_zone : 'Asia/Makassar';
20 0           my $data_timezone = '';
21 0           my $id_timezone = BlankOnDev::DateTime::id_timezone();
22 0           my $tz_long_short = $id_timezone->{'long-short'};
23 0           my $tz_num_short = $id_timezone->{'num-short'};
24 0           my $tz_num_long = $id_timezone->{'num-long'};
25 0 0         if (exists $tz_long_short->{$timezone}) {
26 0           $timezone = uc $tz_long_short->{$timezone}
27             } else {
28 0           $timezone = $timezone;
29             }
30              
31 0           print "\n";
32 0           print "List TimeZone : \n";
33 0           print "1. WIB \n";
34 0           print "2. WITA \n";
35 0           print "3. WIT \n";
36 0 0         if ($timezone ne '') {
37 0           print "Enter your time zone [$timezone] : ";
38             } else {
39 0           print "Enter your time zone : ";
40             }
41 0           chomp($form_timezone = <STDIN>);
42 0 0         if ($form_timezone ne '') {
43 0 0         if ($form_timezone =~ m/^[0-9]$/) {
44 0           $data_timezone = $tz_num_long->{$form_timezone};
45             } else {
46 0           $data_timezone = $tz_num_long->{'1'};
47             }
48             } else {
49 0           $data_timezone = 'Asia/Makassar';
50             }
51 0           print "\n";
52 0           print "Active TimeZone : $data_timezone\n";
53 0           return $data_timezone;
54             }
55             # Subroutine for form blankon release :
56             # ------------------------------------------------------------------------
57             sub form_boi_rilis {
58 0     0 0   my ($self) = @_;
59             # Prepare Form Rilis :
60 0           my $num_data_rilis;
61 0           my %data = ();
62 0           my $data_rilis = BlankOnDev::Rilis::data();
63 0           my $latest_rilis = $data_rilis->{'latest'}->{'name'};
64 0           my $boi_rilis = $latest_rilis;
65 0           my $status = 0;
66              
67 0           print "\n";
68 0           print "Choose rilis \n";
69 0           print "---" x 15 . "\n";
70             # my $daftar_rilis = list_rilis();
71             # my $num = 0;
72             # my %choose_rilis = ();
73             # while (my ($key, $value) = each %{$daftar_rilis}) {
74             # my $num_rilis = $num + 1;
75             # $choose_rilis{$num_rilis} = $key;
76             # print "$num_rilis. $key\n";
77             # $num++;
78             # }
79 0           print "1. $data_rilis->{'10'}->{'name'}\n";
80 0           print "2. $data_rilis->{'11'}->{'name'}\n";
81 0           print "Enter number choice : ";
82 0           chomp($num_data_rilis = <STDIN>);
83 0 0 0       if ($num_data_rilis ne '' and $num_data_rilis eq '1') {
    0          
84 0           $boi_rilis = 'tambora';
85 0           $status = 1;
86             } elsif ($num_data_rilis eq 2) {
87 0           $boi_rilis = 'uluwatu';
88 0           $status = 1;
89             }
90             else {
91 0           $boi_rilis = 'tambora';
92 0           $status = 1;
93             }
94              
95 0           print "\n";
96 0           print "Rilis Activated : $boi_rilis\n\n";
97              
98 0           $data{'result'} = $status;
99 0           $data{'data'} = $boi_rilis;
100              
101 0           return \%data;
102             }
103             # Subroutine for form Name : :
104             # ------------------------------------------------------------------------
105             sub form_name {
106 0     0 0   my ($self, $name) = @_;
107             # Prepare Form :
108 0           my $name_form;
109             my $data_name;
110 0           my %data = ();
111              
112             # Form_name ;
113 0           print "\n";
114 0 0         if ($name ne '') {
115 0           print "Enter your name [$name] : ";
116             } else {
117 0           print "Enter your name : ";
118             }
119 0           chomp($name_form = <STDIN>);
120 0 0         if ($name_form ne '') {
121 0           $data_name = $name_form;
122             } else {
123 0 0         if ($name eq '') {
124 0           print "your name is empty !!! \n";
125 0           form_name();
126             } else {
127 0           $data_name = $name;
128             }
129             }
130              
131 0           return $data_name;
132             }
133             # Subroutine for Email Github :
134             # ------------------------------------------------------------------------
135             sub form_email_git {
136 0     0 0   my ($self, $email) = @_;
137             # Prepare Form :
138 0           my $emailGit_form;
139             my $data_emailGit;
140              
141             # Form Email Git :
142 0           print "\n";
143 0 0         if ($email ne '') {
144 0           print "Enter your email address Github Account [$email] : ";
145             } else {
146 0           print "Enter your email address Github Account : ";
147             }
148 0           chomp($emailGit_form = <STDIN>);
149 0 0         if ($emailGit_form ne '') {
150 0 0         if ($emailGit_form =~ m/(.*)\@(.*).(.*)/) {
151 0           $data_emailGit = $emailGit_form;
152             } else {
153 0           print "Please enter valid email address !!! \n";
154 0           form_email_git();
155             }
156             } else {
157 0 0         if ($email eq '') {
158 0           print "your E-mail Github Account is empty !!! \n";
159 0           form_email_git();
160             } else {
161 0           $data_emailGit = $email;
162             }
163             }
164 0           return $data_emailGit;
165             }
166             # Subroutine for Email GnuPG :
167             # ------------------------------------------------------------------------
168             sub form_email_gpg {
169 0     0 0   my ($self, $email) = @_;
170             # Prepare Form :
171 0           my $emailGnuPG_form;
172             my $data_emailGnuPG;
173              
174             # Form Email GnuPG :
175 0           print "\n";
176 0 0         if ($email ne '') {
177 0           print "Enter your email address for GnuPG Generate Key [$email] : ";
178             } else {
179 0           print "Enter your email address for GnuPG Generate Key : ";
180             }
181 0           chomp($emailGnuPG_form = <STDIN>);
182 0 0         if ($emailGnuPG_form ne '') {
183 0 0         if ($emailGnuPG_form =~ m/(.*)\@(.*).(.*)/) {
184 0           $data_emailGnuPG = $emailGnuPG_form;
185             } else {
186 0           print "Please enter valid email address !!! \n";
187 0           form_email_gpg();
188             }
189             } else {
190 0 0         if ($email eq '') {
191 0           print "your enter email is empty !!! \n";
192 0           form_email_gpg();
193             } else {
194 0           $data_emailGnuPG = $email;
195             }
196             }
197 0           return $data_emailGnuPG;
198             }
199             # Subroutine for Passphrase GnuPG :
200             # ------------------------------------------------------------------------
201             sub form_passphrase_gpg {
202 0     0 0   my ($self) = @_;
203             # Prepare Form :
204 0           my $passph_form = '';
205 0           my $confirm_again;
206             my $data_passph;
207              
208             # From Passhphrase :
209 0           print "\n";
210 0           print "Enter Passphrase gpg : ";
211 0           ReadMode('noecho');
212 0           $passph_form = ReadLine(0);
213 0           ReadMode 1;
214 0 0         if ($passph_form ne '') {
215 0           $data_passph = $passph_form;
216             } else {
217 0           print "your enter passphrase gpg is empty !!! \n";
218 0           print "You want to try again ? [y or n] : ";
219 0           chomp($confirm_again = <STDIN>);
220 0 0 0       if ($confirm_again eq 'y' or $confirm_again eq 'Y') {
221 0           print "Enter Passphrase gpg : ";
222 0           ReadMode('noecho');
223 0           $passph_form = ReadLine(0);
224 0           ReadMode 1;
225             }
226             }
227 0           return $passph_form;
228             }
229             1;