summarylogtreecommitdiffstats
path: root/devendor.diff
blob: 876b77534902265638731ced7233b6f95f791626 (plain)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
diff --git a/weatherspect b/weatherspect
index 5a8716c..774c9e8 100755
--- a/weatherspect
+++ b/weatherspect
@@ -44,6 +44,8 @@
 #############################################################################
 
 use Term::Animation 2.5;
+use Compass::Points;
+use JSON;
 
 use Curses;
 use Data::Dumper;
@@ -5289,636 +5291,3 @@ Copyright (C) 2018 Edgar (Edgar@AnotherFoxGuy).  All rights reserved.  Use is su
     1;
 
 }
-
-
-# From http://search.cpan.org/~janus/Compass-Points-0.02/lib/Compass/Points.pm
-BEGIN{
-    package Compass::Points;
-
-    use strict;
-    use warnings;
-
-    our $VERSION = "0.02";
-
-    our @FIELDS = qw(abbr name);
-    our @NAMES = (
-        [ N => "North" ],
-        [ NbE => "North by east" ],
-        [ NNE => "North-northeast" ],
-        [ NEbN => "Northeast by north" ],
-        [ NE => "Northeast" ],
-        [ NEbE => "Northeast by east" ],
-        [ ENE => "East-northeast" ],
-        [ EbN => "East by north" ],
-        [ E => "East" ],
-        [ EbS => "East by south" ],
-        [ ESE => "East-southeast" ],
-        [ SEbE => "Southeast by east" ],
-        [ SE => "Southeast" ],
-        [ SEbS => "Southeast by south" ],
-        [ SSE => "South-southeast" ],
-        [ SbE => "South by east" ],
-        [ S => "South" ],
-        [ SbW => "South by west" ],
-        [ SSW => "South-southwest" ],
-        [ SWbS => "Southwest by south" ],
-        [ SW => "Southwest" ],
-        [ SWbW => "Southwest by west" ],
-        [ WSW => "West-southwest" ],
-        [ WbS => "West by south" ],
-        [ W => "West" ],
-        [ WbN => "West by north" ],
-        [ WNW => "West-northwest" ],
-        [ NWbW => "Northwest by west" ],
-        [ NW => "Northwest" ],
-        [ NWbN => "Northwest by north" ],
-        [ NNW => "North-northwest" ],
-        [ NbW => "North by west" ],
-    );
-    our @GROUP; # separate groups to assign different degree values
-    our @INDEX; # index per group
-    our @MAP;   # mapping for easy access
-
-    for my $n (0 .. 3) {
-        my $slice = 360 / (2 ** (2 + $n));            # 90, 45, 22.5, 11.25
-        my $mod = 2 ** (3 - $n);                      # 8, 4, 2, 1
-        my @offs = grep $_ % $mod == 0, 0 .. $#NAMES; # 0,8,16,24 0,4,8,12,...
-
-        $GROUP[ $n ] = bless([], __PACKAGE__);
-
-        for my $m (0 .. $#offs) {
-            my @entry = @{$NAMES[ $offs[ $m ] ]};
-
-            for my $key (map lc, @entry) {
-                $key =~ s![^a-z]!!g;
-
-                $INDEX[ $n ]{ $key } = \@entry;
-            }
-
-            $entry[ 2 ] = $m * $slice;
-
-            $GROUP[ $n ][ $m ] = \@entry;
-        }
-
-        $MAP[ $_ ] = $n for @MAP .. $#offs;
-    }
-
-    sub new {
-        my $class = shift;
-        my $number = shift || 16;
-
-        $number = @{$GROUP[ $#GROUP ]}
-            if $number > @{$GROUP[ $#GROUP ]};
-
-        return $GROUP[ $MAP[ $number - 1 ] ];
-    }
-
-    for my $offset (0 .. $#FIELDS) {
-        my $deg2sub = "deg2$FIELDS[ $offset ]";
-        my $sub2deg = "$FIELDS[ $offset ]2deg";
-
-        no strict qw(refs);
-
-        *$deg2sub = sub {
-            my $self = shift;
-            my $deg = abs(shift || 0);
-
-            $deg -= 360 while $deg > 360;
-
-            my $slice = 360 / @$self;
-            my $index = ($deg + $slice / 2) / $slice;
-
-            return $self->[ $index ][ $offset ];
-        };
-
-        *$sub2deg = sub {
-            my $self = shift;
-            my $key = lc(shift || "");
-            my $index = $INDEX[ $MAP[ @$self - 1 ] ];
-
-            $key =~ s![^a-z]!!g;
-
-            return exists($index->{ $key })
-                ? $index->{ $key }[ 2 ]
-                : undef
-            ;
-        };
-    }
-
-    1;
-
-=head1 NAME
-
-Compass::Points - Convert between compass point names, abbreviations and values
-
-=head1 SYNOPSIS
-
-  use Compass::Points;
-  my $points = Compass::Points->new();
-  my $deg = $points->abbr2deg( "NNE" );
-
-=head1 DESCRIPTION
-
-This module converts compass point names and abbreviations to degrees
-and vice versa.
-It supports four different compass point systems: 4, 8, 16 and 32.
-The default is 16 and can be used for wind compass usage.
-
-=head1 METHODS
-
-=head2 new( [ $points ] )
-
-Returns a Compass::Points object for the number of points (defaults to 16).
-
-=head2 deg2abbr( $degree )
-
-Takes a degree value and returns the corresponding abbreviation for the
-matching wind name.
-
-=head2 deg2name( $degree )
-
-Same as deg2abbr() but returns the full wind name.
-
-=head2 abbr2deg( $abbreviation )
-
-Given a wind name abbreviation returns the degree of the points object.
-
-=head2 name2deg( $name )
-
-Same as abbr2deg() but takes full wind names.
-
-=head1 SEE ALSO
-
-L<http://en.wikipedia.org/wiki/Points_of_the_compass>
-
-=head1 AUTHOR
-
-Simon Bertrang, E<lt>janus@cpan.orgE<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright (C) 2014 by Simon Bertrang
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
-}
-
-
-BEGIN{
-    package JSON;
-
-
-    use strict;
-    use Carp ();
-    use Exporter;
-    BEGIN {@JSON::ISA = 'Exporter'}
-
-    @JSON::EXPORT = qw(from_json to_json jsonToObj objToJson encode_json decode_json);
-
-    BEGIN {
-        $JSON::VERSION = '4.02';
-        $JSON::DEBUG = 0 unless (defined $JSON::DEBUG);
-        $JSON::DEBUG = $ENV{ PERL_JSON_DEBUG } if exists $ENV{ PERL_JSON_DEBUG };
-    }
-
-    my %RequiredVersion = (
-        'JSON::PP' => '2.27203',
-        'JSON::XS' => '2.34',
-    );
-
-    # XS and PP common methods
-
-    my @PublicMethods = qw/
-        ascii latin1 utf8 pretty indent space_before space_after relaxed canonical allow_nonref
-        allow_blessed convert_blessed filter_json_object filter_json_single_key_object
-        shrink max_depth max_size encode decode decode_prefix allow_unknown
-    /;
-
-    my @Properties = qw/
-        ascii latin1 utf8 indent space_before space_after relaxed canonical allow_nonref
-        allow_blessed convert_blessed shrink max_depth max_size allow_unknown
-    /;
-
-    my @XSOnlyMethods = qw//; # Currently nothing
-
-    my @PublicMethodsSince4_0 = qw/allow_tags/;
-    my @PropertiesSince4_0 = qw/allow_tags/;
-
-    my @PPOnlyMethods = qw/
-        indent_length sort_by
-        allow_singlequote allow_bignum loose allow_barekey escape_slash as_nonblessed
-    /; # JSON::PP specific
-
-
-    # used in _load_xs and _load_pp ($INSTALL_ONLY is not used currently)
-    my $_INSTALL_DONT_DIE = 1; # When _load_xs fails to load XS, don't die.
-    my $_ALLOW_UNSUPPORTED = 0;
-    my $_UNIV_CONV_BLESSED = 0;
-
-
-    # Check the environment variable to decide worker module.
-
-    unless ($JSON::Backend) {
-        $JSON::DEBUG and Carp::carp("Check used worker module...");
-
-        my $backend = exists $ENV{PERL_JSON_BACKEND} ? $ENV{PERL_JSON_BACKEND} : 1;
-
-        if ($backend eq '1') {
-            $backend = 'JSON::XS,JSON::PP';
-        }
-        elsif ($backend eq '0') {
-            $backend = 'JSON::PP';
-        }
-        elsif ($backend eq '2') {
-            $backend = 'JSON::XS';
-        }
-        $backend =~ s/\s+//g;
-
-        my @backend_modules = split /,/, $backend;
-        while (my $module = shift @backend_modules) {
-            if ($module =~ /JSON::XS/) {
-                _load_xs($module, @backend_modules ? $_INSTALL_DONT_DIE : 0);
-            }
-            elsif ($module =~ /JSON::PP/) {
-                _load_pp($module);
-            }
-            elsif ($module =~ /JSON::backportPP/) {
-                _load_pp($module);
-            }
-            else {
-                Carp::croak "The value of environmental variable 'PERL_JSON_BACKEND' is invalid.";
-            }
-            last if $JSON::Backend;
-        }
-    }
-
-
-    sub import {
-        my $pkg = shift;
-        my @what_to_export;
-        my $no_export;
-
-        for my $tag (@_) {
-            if ($tag eq '-support_by_pp') {
-                if (!$_ALLOW_UNSUPPORTED++) {
-                    JSON::Backend::XS
-                        ->support_by_pp(@PPOnlyMethods) if ($JSON::Backend->is_xs);
-                }
-                next;
-            }
-            elsif ($tag eq '-no_export') {
-                $no_export++, next;
-            }
-            elsif ($tag eq '-convert_blessed_universally') {
-                my $org_encode = $JSON::Backend->can('encode');
-                eval q|
-                require B;
-                local $^W;
-                no strict 'refs';
-                *{"${JSON::Backend}\::encode"} = sub {
-                    # only works with Perl 5.18+
-                    local *UNIVERSAL::TO_JSON = sub {
-                        my $b_obj = B::svref_2object( $_[0] );
-                        return    $b_obj->isa('B::HV') ? { %{ $_[0] } }
-                                : $b_obj->isa('B::AV') ? [ @{ $_[0] } ]
-                                : undef
-                                ;
-                    };
-                    $org_encode->(@_);
-                };
-            | if (!$_UNIV_CONV_BLESSED++);
-                next;
-            }
-            push @what_to_export, $tag;
-        }
-
-        return if ($no_export);
-
-        __PACKAGE__->export_to_level(1, $pkg, @what_to_export);
-    }
-
-
-    # OBSOLETED
-
-    sub jsonToObj {
-        my $alternative = 'from_json';
-        if (defined $_[0] and UNIVERSAL::isa($_[0], 'JSON')) {
-            shift @_;
-            $alternative = 'decode';
-        }
-        Carp::carp "'jsonToObj' will be obsoleted. Please use '$alternative' instead.";
-        return JSON::from_json(@_);
-    };
-
-    sub objToJson {
-        my $alternative = 'to_json';
-        if (defined $_[0] and UNIVERSAL::isa($_[0], 'JSON')) {
-            shift @_;
-            $alternative = 'encode';
-        }
-        Carp::carp "'objToJson' will be obsoleted. Please use '$alternative' instead.";
-        JSON::to_json(@_);
-    };
-
-
-    # INTERFACES
-
-    sub to_json($@) {
-        if (
-            ref($_[0]) eq 'JSON'
-                or (@_ > 2 and $_[0] eq 'JSON')
-        ) {
-            Carp::croak "to_json should not be called as a method.";
-        }
-        my $json = JSON->new;
-
-        if (@_ == 2 and ref $_[1] eq 'HASH') {
-            my $opt = $_[1];
-            for my $method (keys %$opt) {
-                $json->$method($opt->{$method});
-            }
-        }
-
-        $json->encode($_[0]);
-    }
-
-
-    sub from_json($@) {
-        if (ref($_[0]) eq 'JSON' or $_[0] eq 'JSON') {
-            Carp::croak "from_json should not be called as a method.";
-        }
-        my $json = JSON->new;
-
-        if (@_ == 2 and ref $_[1] eq 'HASH') {
-            my $opt = $_[1];
-            for my $method (keys %$opt) {
-                $json->$method($opt->{$method});
-            }
-        }
-
-        return $json->decode($_[0]);
-    }
-
-
-
-    sub true {$JSON::true}
-
-    sub false {$JSON::false}
-
-    sub boolean {
-        # might be called as method or as function, so pop() to get the last arg instead of shift() to get the first
-        pop() ? $JSON::true : $JSON::false
-    }
-
-    sub null {undef;}
-
-
-    sub require_xs_version {$RequiredVersion{'JSON::XS'};}
-
-    sub backend {
-        my $proto = shift;
-        $JSON::Backend;
-    }
-
-    #*module = *backend;
-
-
-    sub is_xs {
-        return $_[0]->backend->is_xs;
-    }
-
-
-    sub is_pp {
-        return $_[0]->backend->is_pp;
-    }
-
-
-    sub pureperl_only_methods {@PPOnlyMethods;}
-
-
-    sub property {
-        my ($self, $name, $value) = @_;
-
-        if (@_ == 1) {
-            my %props;
-            for $name (@Properties) {
-                my $method = 'get_' . $name;
-                if ($name eq 'max_size') {
-                    my $value = $self->$method();
-                    $props{$name} = $value == 1 ? 0 : $value;
-                    next;
-                }
-                $props{$name} = $self->$method();
-            }
-            return \%props;
-        }
-        elsif (@_ > 3) {
-            Carp::croak('property() can take only the option within 2 arguments.');
-        }
-        elsif (@_ == 2) {
-            if (my $method = $self->can('get_' . $name)) {
-                if ($name eq 'max_size') {
-                    my $value = $self->$method();
-                    return $value == 1 ? 0 : $value;
-                }
-                $self->$method();
-            }
-        }
-        else {
-            $self->$name($value);
-        }
-
-    }
-
-
-    # INTERNAL
-
-    sub __load_xs {
-        my ($module, $opt) = @_;
-
-        $JSON::DEBUG and Carp::carp "Load $module.";
-        my $required_version = $RequiredVersion{$module} || '';
-
-        eval qq|
-        use $module $required_version ();
-    |;
-
-        if ($@) {
-            if (defined $opt and $opt & $_INSTALL_DONT_DIE) {
-                $JSON::DEBUG and Carp::carp "Can't load $module...($@)";
-                return 0;
-            }
-            Carp::croak $@;
-        }
-        $JSON::BackendModuleXS = $module;
-        return 1;
-    }
-
-    sub _load_xs {
-        my ($module, $opt) = @_;
-        __load_xs($module, $opt) or return;
-
-        my $data = join("", <DATA>); # this code is from Jcode 2.xx.
-        close(DATA);
-        eval $data;
-        JSON::Backend::XS->init($module);
-
-        return 1;
-    };
-
-
-    sub __load_pp {
-        my ($module, $opt) = @_;
-
-        $JSON::DEBUG and Carp::carp "Load $module.";
-        my $required_version = $RequiredVersion{$module} || '';
-
-        eval qq| use $module $required_version () |;
-
-        if ($@) {
-            if ($module eq 'JSON::PP') {
-                $JSON::DEBUG and Carp::carp "Can't load $module ($@), so try to load JSON::backportPP";
-                $module = 'JSON::backportPP';
-                local $^W; # if PP installed but invalid version, backportPP redefines methods.
-                eval qq| require $module |;
-            }
-            Carp::croak $@ if $@;
-        }
-        $JSON::BackendModulePP = $module;
-        return 1;
-    }
-
-    sub _load_pp {
-        my ($module, $opt) = @_;
-        __load_pp($module, $opt);
-
-        JSON::Backend::PP->init($module);
-    };
-
-    #
-    # Helper classes for Backend Module (PP)
-    #
-
-    package JSON::Backend::PP;
-
-    sub init {
-        my ($class, $module) = @_;
-
-        # name may vary, but the module should (always) be a JSON::PP
-
-        local $^W;
-        no strict qw(refs); # this routine may be called after JSON::Backend::XS init was called.
-        *{"JSON::decode_json"} = \&{"JSON::PP::decode_json"};
-        *{"JSON::encode_json"} = \&{"JSON::PP::encode_json"};
-        *{"JSON::is_bool"} = \&{"JSON::PP::is_bool"};
-
-        $JSON::true = ${"JSON::PP::true"};
-        $JSON::false = ${"JSON::PP::false"};
-
-        push @JSON::Backend::PP::ISA, 'JSON::PP';
-        push @JSON::ISA, $class;
-        $JSON::Backend = $class;
-        $JSON::BackendModule = $module;
-        my $version = ${"$class\::VERSION"} = $module->VERSION;
-        $version =~ s/_//;
-        if ($version < 3.99) {
-            push @XSOnlyMethods, qw/allow_tags get_allow_tags/;
-        }
-        else {
-            push @Properties, 'allow_tags';
-        }
-
-        for my $method (@XSOnlyMethods) {
-            *{"JSON::$method"} = sub {
-                Carp::carp("$method is not supported by $module $version.");
-                $_[0];
-            };
-        }
-
-        return 1;
-    }
-
-    sub is_xs {0};
-    sub is_pp {1};
-
-    #
-    # To save memory, the below lines are read only when XS backend is used.
-    #
-
-    package JSON;
-
-    1;
-
-    #
-    # Helper classes for Backend Module (XS)
-    #
-
-    package JSON::Backend::XS;
-
-    sub init {
-        my ($class, $module) = @_;
-
-        local $^W;
-        no strict qw(refs);
-        *{"JSON::decode_json"} = \&{"$module\::decode_json"};
-        *{"JSON::encode_json"} = \&{"$module\::encode_json"};
-        *{"JSON::is_bool"} = \&{"$module\::is_bool"};
-
-        $JSON::true = ${"$module\::true"};
-        $JSON::false = ${"$module\::false"};
-
-        push @JSON::Backend::XS::ISA, $module;
-        push @JSON::ISA, $class;
-        $JSON::Backend = $class;
-        $JSON::BackendModule = $module;
-        ${"$class\::VERSION"} = $module->VERSION;
-
-        if ($module->VERSION < 3) {
-            eval 'package JSON::PP::Boolean';
-            push @{"$module\::Boolean::ISA"}, qw(JSON::PP::Boolean);
-        }
-
-        for my $method (@PPOnlyMethods) {
-            *{"JSON::$method"} = sub {
-                Carp::carp("$method is not supported by $module.");
-                $_[0];
-            };
-        }
-
-        return 1;
-    }
-
-    sub is_xs {1};
-    sub is_pp {0};
-
-    sub support_by_pp {
-        my ($class, @methods) = @_;
-
-        JSON::__load_pp('JSON::PP');
-
-        local $^W;
-        no strict qw(refs);
-
-        for my $method (@methods) {
-            my $pp_method = JSON::PP->can($method) or next;
-            *{"JSON::$method"} = sub {
-                if (!$_[0]->isa('JSON::PP')) {
-                    my $xs_self = $_[0];
-                    my $pp_self = JSON::PP->new;
-                    for (@Properties) {
-                        my $getter = "get_$_";
-                        $pp_self->$_($xs_self->$getter);
-                    }
-                    $_[0] = $pp_self;
-                }
-                $pp_method->(@_);
-            };
-        }
-
-        $JSON::DEBUG and Carp::carp("set -support_by_pp mode.");
-    }
-
-    1;
-}
\ No newline at end of file