package-info 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/package-info.rb +20 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95476db1bb9ad5391cdb40d0158088549c718eac
|
4
|
+
data.tar.gz: 488def1ae103fd13eb293b3e8fc7a1170094ffc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47bf4ada1a6b247e9f7329a26388116d5c92a12ee699d66a864f9dc883304e95b927ea0379fd39e7d26ab201056100591f17076692a10478dcdb89942b3d5e03
|
7
|
+
data.tar.gz: 8fd1a272866dc9c1c6991aa7aad90a42c9faf41de2acc48e2c6aa017030c0c6772740df7c301a62bc67b1d70cb0ae83d6f33e53785670a2245758692dbfc585f
|
data/lib/package-info.rb
CHANGED
@@ -2,12 +2,19 @@
|
|
2
2
|
require 'csv'
|
3
3
|
|
4
4
|
class PackageInfo
|
5
|
-
COPYRIGHT_FIELDS = ["Format", "Upstream-Name", "Upstream-Contact",
|
5
|
+
COPYRIGHT_FIELDS = ["License-Title", "Format", "Upstream-Name", "Upstream-Contact",
|
6
6
|
"Source", "Disclaimer", "Comment", "License",
|
7
7
|
"Copyright", "Files"]
|
8
8
|
|
9
9
|
LICENSE_TAGS = ["gpl", "mit", "license", "license"]
|
10
10
|
|
11
|
+
LICENSE_TITLE_TAGS = ["GPL", "GNU General Public License", "LGPL-2+",
|
12
|
+
"LGPL-2.1+", "LGPL-2", "LGPL-3", "LGPL-3+",
|
13
|
+
"MPL-1.1", "BSD-2", "zlib", "MIT", "MPL", "ISC",
|
14
|
+
"BSD", "Boost", "Apache", "BSD-3", "Cisco",
|
15
|
+
"Apache 2.0", "Apache 1.0", "Apache 1.1", "LGPL",
|
16
|
+
"ASL", "Artistic", "OFL", "CC-BY-SA", "CPL", ]
|
17
|
+
|
11
18
|
COPYRIGHT_TAGS = ["copyright"]
|
12
19
|
|
13
20
|
UPSTREAM_NAME_TAGS = ["author", "developer", "upstream"]
|
@@ -59,7 +66,9 @@ class PackageInfo
|
|
59
66
|
end
|
60
67
|
|
61
68
|
def parse_dep_5_compatible text
|
62
|
-
fields, lines = {}, text
|
69
|
+
fields, lines = {}, text
|
70
|
+
.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
|
71
|
+
.split(/\n/)
|
63
72
|
field_name, field_content = "", ""
|
64
73
|
|
65
74
|
lines.each do |line|
|
@@ -76,6 +85,9 @@ class PackageInfo
|
|
76
85
|
|
77
86
|
paragraphs.each do |paragraph|
|
78
87
|
case
|
88
|
+
when match_tags(LICENSE_TAGS, paragraph)
|
89
|
+
fields["License-Title"] += add_license_titles(LICENSE_TITLE_TAGS, paragraph)
|
90
|
+
fields["License"] += paragraph
|
79
91
|
when match_tags(LICENSE_TAGS, paragraph)
|
80
92
|
fields["License"] += paragraph
|
81
93
|
when match_tags(COPYRIGHT_TAGS, paragraph)
|
@@ -110,6 +122,12 @@ class PackageInfo
|
|
110
122
|
fields
|
111
123
|
end
|
112
124
|
|
125
|
+
def add_license_titles tags, paragraph
|
126
|
+
titles = ""
|
127
|
+
tags.each {|tag| titles += tag + ", " if paragraph.include?(tag)}
|
128
|
+
titles
|
129
|
+
end
|
130
|
+
|
113
131
|
def match_tags tags, paragraph
|
114
132
|
tags.each {|tag| return true if paragraph.downcase.include?(tag)}
|
115
133
|
false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: package-info
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Angelos Kapsimanis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
Retrieves information for all installed packages
|