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