File: utils.t

package info (click to toggle)
libsoftware-license-perl 0.103004-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 908 kB
  • sloc: perl: 6,173; makefile: 2
file content (166 lines) | stat: -rw-r--r-- 3,495 bytes parent folder | download | duplicates (2)
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
use strict;
use warnings;
use Test::More tests => 4;
use Software::LicenseUtils;

{
    my $fake_pm = <<'END_PM';

"magic true value";
__END__

=head1 LICENSE

This is released under the same terms as perl itself.

=cut

END_PM

    my @guesses = Software::LicenseUtils->guess_license_from_pod($fake_pm);

    is_deeply(
      \@guesses,
      [ 'Software::License::Perl_5' ],
      "guessed okay"
    );
}

{
    my $fake_yaml = <<'END_YAML';
---
abstract: 'packages that provide templated software licenses'
author:
  - 'Ricardo Signes <rjbs@cpan.org>'
distribution_type: module
generated_by: 'Module::Install version 0.71'
license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.3.html
  version: 1.3
name: Software-License
no_index:
  directory:
    - inc
    - t
requires:
  Class::ISA: 0.000
  Sub::Install: 0.000
  Text::Template: 0.000
  perl: 5.6.0
tests: 't/*.t xt/*.t'
version: 0.002
END_YAML

    my @guesses = Software::LicenseUtils->guess_license_from_meta_yml(
      $fake_yaml
    );

    is_deeply(
      \@guesses,
      [ 'Software::License::Perl_5' ],
      "guessed okay"
    );
}

{
    my $fake_yaml = <<'END_YAML';
---
abstract: 'packages that provide templated software licenses'
author:
  - 'Ricardo Signes <rjbs@cpan.org>'
distribution_type: module
generated_by: 'Module::Install version 0.71'
license: gpl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.3.html
  version: 1.3
name: Software-License
no_index:
  directory:
    - inc
    - t
requires:
  Class::ISA: 0.000
  Sub::Install: 0.000
  Text::Template: 0.000
  perl: 5.6.0
tests: 't/*.t xt/*.t'
version: 0.002
END_YAML

    my @guesses = Software::LicenseUtils->guess_license_from_meta(
      $fake_yaml
    );

    is_deeply(
      \@guesses,
      [ qw(
        Software::License::GPL_1
        Software::License::GPL_2
        Software::License::GPL_3
      ) ],
      "guessed okay"
    );
}

{
    my $fake_json = <<'END_JSON';
{
   "resources" : {
      "repository" : "http://github.com/rjbs/dist-zilla"
   },
   "generated_by" : "Dist::Zilla::Plugin::MetaJSON version 1.091370",
   "version" : "1.091370",
   "name" : "Dist-Zilla",
   "requires" : {
      "DateTime" : "0.44",
      "Config::INI::MVP::Reader" : "0.018",
      "Pod::Eventual" : "0",
      "App::Cmd" : "0.200",
      "String::RewritePrefix" : "0.002",
      "Data::Section" : "0.004",
      "File::chdir" : "0",
      "YAML::XS" : "0",
      "String::Formatter" : "0",
      "Perl::Version" : "0",
      "autobox" : "2.53",
      "Software::License" : "0",
      "Archive::Tar" : "0",
      "MooseX::ClassAttribute" : "0",
      "List::MoreUtils" : "0",
      "Moose" : "0.65",
      "ExtUtils::Manifest" : "1.54",
      "String::Flogger" : "1",
      "File::Find::Rule" : "0",
      "Mixin::ExtraFields::Param" : "0",
      "File::HomeDir" : "0",
      "ExtUtils::MakeMaker" : "0",
      "CPAN::Uploader" : "0",
      "Moose::Autobox" : "0.09",
      "Test::More" : "0",
      "MooseX::Types::Path::Class" : "0",
      "Hash::Merge::Simple" : "0",
      "File::Temp" : "0",
      "Path::Class" : "0",
      "Text::Template" : "0"
   },
   "abstract" : "distribution builder; installer not included!",
   "author" : [
      "Ricardo SIGNES <rjbs@cpan.org>"
   ],
   "license" : "perl"
}
END_JSON

    my @guesses = Software::LicenseUtils->guess_license_from_meta(
      $fake_json
    );

    is_deeply(
      \@guesses,
      [ 'Software::License::Perl_5' ],
      "guessed okay"
    );
}