line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BusyBird::Input::Generator; |
2
|
1
|
|
|
1
|
|
143834
|
use v5.8.0; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
3
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
4
|
use DateTime; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
13
|
|
6
|
1
|
|
|
1
|
|
3
|
use BusyBird::DateTime::Format; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
7
|
1
|
|
|
1
|
|
487
|
use Data::UUID; |
|
1
|
|
|
|
|
708
|
|
|
1
|
|
|
|
|
407
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
2
|
|
|
2
|
1
|
685
|
my ($class, %args) = @_; |
11
|
2
|
100
|
|
|
|
344
|
my $self = bless { |
12
|
|
|
|
|
|
|
screen_name => defined($args{screen_name}) ? $args{screen_name} : "", |
13
|
|
|
|
|
|
|
id_gen => Data::UUID->new, |
14
|
|
|
|
|
|
|
}, $class; |
15
|
2
|
|
|
|
|
17
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub generate { |
19
|
23
|
|
|
23
|
1
|
77221
|
my ($self, %args) = @_; |
20
|
23
|
50
|
|
|
|
53
|
my $text = defined($args{text}) ? $args{text} : ""; |
21
|
23
|
100
|
|
|
|
40
|
my $level = defined($args{level}) ? $args{level} : 0; |
22
|
23
|
|
|
|
|
73
|
my $cur_time = DateTime->now; |
23
|
23
|
|
|
|
|
4548
|
my $status = +{ |
24
|
|
|
|
|
|
|
id => $self->_generate_id(), |
25
|
|
|
|
|
|
|
text => $text, |
26
|
|
|
|
|
|
|
created_at => BusyBird::DateTime::Format->format_datetime($cur_time), |
27
|
|
|
|
|
|
|
user => { |
28
|
|
|
|
|
|
|
screen_name => $self->{screen_name}, |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
busybird => { |
31
|
|
|
|
|
|
|
status_permalink => "" |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
}; |
34
|
23
|
50
|
|
|
|
5708
|
if(defined $level) { |
35
|
23
|
|
|
|
|
56
|
$status->{busybird}{level} = $level + 0; |
36
|
|
|
|
|
|
|
} |
37
|
23
|
|
|
|
|
129
|
return $status; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _generate_id { |
41
|
23
|
|
|
23
|
|
36
|
my ($self) = @_; |
42
|
23
|
|
|
|
|
35
|
my $namespace = $self->{screen_name}; |
43
|
23
|
|
|
|
|
495
|
my $uuid = $self->{id_gen}->create_str; |
44
|
23
|
|
|
|
|
134
|
return qq{busybird://$namespace/$uuid}; |
45
|
|
|
|
|
|
|
## $cur_time = DateTime->now if not defined($cur_time); |
46
|
|
|
|
|
|
|
## my $cur_epoch = $cur_time->epoch; |
47
|
|
|
|
|
|
|
## if($self->{last_epoch} != $cur_epoch) { |
48
|
|
|
|
|
|
|
## $self->{next_sequence_number} = 0; |
49
|
|
|
|
|
|
|
## } |
50
|
|
|
|
|
|
|
## my $id = qq{busybird://$namespace/$cur_epoch/$self->{next_sequence_number}}; |
51
|
|
|
|
|
|
|
## $self->{next_sequence_number}++; |
52
|
|
|
|
|
|
|
## $self->{last_epoch} = $cur_epoch; |
53
|
|
|
|
|
|
|
## return $id; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
__END__ |