inqlude 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +23 -0
- data/{README → README.md} +0 -0
- data/TODO +24 -9
- data/accessing-inqlude-data.md +55 -0
- data/inqlude.gemspec +2 -1
- data/lib/cli.rb +36 -4
- data/lib/creator.rb +17 -32
- data/lib/distros/suse.rb +2 -2
- data/lib/downloader.rb +37 -0
- data/lib/exceptions.rb +2 -0
- data/lib/inqlude.rb +21 -15
- data/lib/json_object.rb +104 -0
- data/lib/kde_frameworks_creator.rb +14 -10
- data/lib/kde_frameworks_release.rb +14 -13
- data/lib/library.rb +4 -4
- data/lib/manifest.rb +165 -28
- data/lib/manifest_handler.rb +14 -16
- data/lib/verifier.rb +23 -48
- data/lib/version.rb +1 -1
- data/lib/view.rb +29 -26
- data/manifest-format.md +15 -0
- data/spec/data/inqlude-all-karchive.json +31 -0
- data/spec/data/inqlude-all.json +120 -0
- data/spec/data/invalid-schema.manifest +4 -0
- data/spec/data/karchive-release-5.4.manifest +29 -0
- data/spec/data/karchive-release.manifest +7 -7
- data/spec/data/karchive.readme +0 -6
- data/spec/data/newlib/newlib.manifest +11 -4
- data/spec/data/rendertest-generic.manifest +4 -1
- data/spec/integration/cli_create_spec.rb +24 -0
- data/spec/integration/cli_general_spec.rb +19 -0
- data/spec/integration/cli_get_involved_spec.rb +14 -0
- data/spec/integration/cli_help_spec.rb +21 -0
- data/spec/integration/cli_list_spec.rb +23 -0
- data/spec/integration/cli_verify_spec.rb +37 -0
- data/spec/integration/cli_view_spec.rb +28 -0
- data/spec/integration/spec_helper.rb +2 -0
- data/spec/{creator_spec.rb → unit/creator_spec.rb} +8 -41
- data/spec/unit/downloader_spec.rb +32 -0
- data/spec/unit/json_object_spec.rb +273 -0
- data/spec/{kde_frameworks_creator_spec.rb → unit/kde_frameworks_creator_spec.rb} +13 -14
- data/spec/{kde_frameworks_release_spec.rb → unit/kde_frameworks_release_spec.rb} +14 -10
- data/spec/{library_spec.rb → unit/library_spec.rb} +7 -7
- data/spec/{manifest_handler_spec.rb → unit/manifest_handler_spec.rb} +21 -17
- data/spec/unit/manifest_spec.rb +301 -0
- data/spec/{rpm_manifestizer_spec.rb → unit/rpm_manifestizer_spec.rb} +0 -0
- data/spec/{settings_spec.rb → unit/settings_spec.rb} +0 -0
- data/spec/{spec_helper.rb → unit/spec_helper.rb} +10 -12
- data/spec/{verifier_spec.rb → unit/verifier_spec.rb} +24 -15
- data/spec/{view_spec.rb → unit/view_spec.rb} +38 -7
- data/view/all.html.haml +4 -4
- data/view/commercial.html.haml +1 -1
- data/view/development.html.haml +3 -3
- data/view/get.html.haml +11 -2
- data/view/group.html.haml +4 -4
- data/view/index.html.haml +1 -1
- data/view/library.html.haml +8 -9
- data/view/unreleased.html.haml +1 -1
- data/yes_ship_it.conf +3 -0
- metadata +67 -51
- data/spec/manifest_spec.rb +0 -63
data/lib/json_object.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
class JsonObject
|
2
|
+
|
3
|
+
def self.attribute(name, &block)
|
4
|
+
define_method("#{name}=") do |value|
|
5
|
+
@values[name] = value
|
6
|
+
@valid[name] = true
|
7
|
+
end
|
8
|
+
|
9
|
+
@keys ||= Hash.new
|
10
|
+
|
11
|
+
if block_given?
|
12
|
+
define_method("#{name}") do
|
13
|
+
return @values[name]
|
14
|
+
end
|
15
|
+
|
16
|
+
nested_class = self.const_set(name.to_s.capitalize, Class.new(JsonObject))
|
17
|
+
nested_class.class_exec(&block)
|
18
|
+
type = nested_class
|
19
|
+
else
|
20
|
+
define_method("#{name}") do
|
21
|
+
if @valid[name]
|
22
|
+
return @values[name]
|
23
|
+
else
|
24
|
+
return nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
type = nil
|
29
|
+
end
|
30
|
+
@keys[name] = type
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.keys
|
34
|
+
@keys
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.all_keys
|
38
|
+
keys = Hash.new
|
39
|
+
klass = self
|
40
|
+
while(klass != JsonObject) do
|
41
|
+
if klass.keys
|
42
|
+
keys.merge!(klass.keys)
|
43
|
+
end
|
44
|
+
klass = klass.superclass
|
45
|
+
end
|
46
|
+
keys
|
47
|
+
end
|
48
|
+
|
49
|
+
attr_accessor :schema_id
|
50
|
+
|
51
|
+
def initialize
|
52
|
+
@values = Hash.new
|
53
|
+
self.class.all_keys.each do |key,value|
|
54
|
+
if value
|
55
|
+
@values[key] = value.new
|
56
|
+
end
|
57
|
+
end
|
58
|
+
@valid = Hash.new
|
59
|
+
end
|
60
|
+
|
61
|
+
def valid?
|
62
|
+
!@valid.empty?
|
63
|
+
end
|
64
|
+
|
65
|
+
def from_hash(hash)
|
66
|
+
hash.each do |key, value|
|
67
|
+
next if key == "$schema"
|
68
|
+
type = self.class.all_keys[key.to_sym]
|
69
|
+
value = hash[key]
|
70
|
+
if type
|
71
|
+
nested_object = send("#{key}")
|
72
|
+
nested_object.from_hash(value)
|
73
|
+
else
|
74
|
+
send("#{key}=", value)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
self
|
78
|
+
end
|
79
|
+
|
80
|
+
def from_json(json_string)
|
81
|
+
from_hash(JSON(json_string))
|
82
|
+
end
|
83
|
+
|
84
|
+
def to_hash
|
85
|
+
hash = Hash.new
|
86
|
+
if schema_id
|
87
|
+
hash["$schema"] = schema_id
|
88
|
+
end
|
89
|
+
self.class.all_keys.each do |attribute,type|
|
90
|
+
value = @values[attribute]
|
91
|
+
if type && value.valid?
|
92
|
+
hash[attribute] = value.to_hash
|
93
|
+
elsif @valid[attribute]
|
94
|
+
hash[attribute] = value
|
95
|
+
end
|
96
|
+
end
|
97
|
+
hash
|
98
|
+
end
|
99
|
+
|
100
|
+
def to_json
|
101
|
+
JSON.pretty_generate(to_hash)
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
@@ -42,7 +42,7 @@ class KdeFrameworksCreator
|
|
42
42
|
|
43
43
|
def framework name
|
44
44
|
f = @frameworks[name]
|
45
|
-
raise "Unable to read '#{name}'" if !f
|
45
|
+
raise InqludeError.new("Unable to read '#{name}'") if !f
|
46
46
|
f
|
47
47
|
end
|
48
48
|
|
@@ -52,6 +52,10 @@ class KdeFrameworksCreator
|
|
52
52
|
name = extract_name( path )
|
53
53
|
framework = @frameworks[name] || {}
|
54
54
|
|
55
|
+
framework["link_home_page"] = "https://projects.kde.org/projects/frameworks/#{name}"
|
56
|
+
framework["link_mailing_list"] = "https://mail.kde.org/mailman/listinfo/kde-frameworks-devel"
|
57
|
+
framework["link_git_repository"] = "https://projects.kde.org/projects/frameworks/#{name}/repository"
|
58
|
+
|
55
59
|
state = nil
|
56
60
|
File.open(File.join(path,"README.md")).each_line do |line|
|
57
61
|
if line =~ /^# (.*)/
|
@@ -160,14 +164,14 @@ class KdeFrameworksCreator
|
|
160
164
|
end
|
161
165
|
|
162
166
|
def fill_in_data framework, manifest
|
163
|
-
manifest
|
164
|
-
manifest
|
165
|
-
manifest
|
166
|
-
manifest
|
167
|
-
manifest
|
168
|
-
manifest
|
169
|
-
manifest
|
170
|
-
manifest
|
171
|
-
manifest
|
167
|
+
manifest.display_name = framework["title"]
|
168
|
+
manifest.summary = framework["summary"]
|
169
|
+
manifest.description = framework["introduction"]
|
170
|
+
manifest.urls.vcs = framework["link_git_repository"]
|
171
|
+
manifest.urls.homepage = framework["link_home_page"]
|
172
|
+
manifest.urls.mailing_list = framework["link_mailing_list"]
|
173
|
+
manifest.licenses = [ "LGPLv2.1+" ]
|
174
|
+
manifest.authors = [ "The KDE Community" ]
|
175
|
+
manifest.group = "kde-frameworks"
|
172
176
|
end
|
173
177
|
end
|
@@ -22,19 +22,20 @@ class KdeFrameworksRelease
|
|
22
22
|
@handler = handler
|
23
23
|
end
|
24
24
|
|
25
|
+
def self.strip_patch_release(version)
|
26
|
+
version =~ /^(\d+\.\d+)\./
|
27
|
+
$1
|
28
|
+
end
|
29
|
+
|
25
30
|
def self.create_release_manifest generic_manifest, release_date, version
|
26
|
-
m = generic_manifest
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
m
|
32
|
-
m
|
33
|
-
m
|
34
|
-
m["version"] = version
|
35
|
-
m["packages"] = {
|
36
|
-
"source" => "#{download_url}#{name}-#{version}.tar.xz"
|
37
|
-
}
|
31
|
+
m = generic_manifest.create_release_manifest(release_date, version)
|
32
|
+
|
33
|
+
version_dir = strip_patch_release(version)
|
34
|
+
|
35
|
+
download_url = "http://download.kde.org/stable/frameworks/#{version_dir}/"
|
36
|
+
m.urls.download = download_url
|
37
|
+
m.maturity = "stable"
|
38
|
+
m.packages.source = "#{download_url}#{m.name}-#{version}.tar.xz"
|
38
39
|
m
|
39
40
|
end
|
40
41
|
|
@@ -53,7 +54,7 @@ class KdeFrameworksRelease
|
|
53
54
|
generic_manifest, release_date, version )
|
54
55
|
path = @handler.manifest_path( release_manifest )
|
55
56
|
File.open( path, "w" ) do |file|
|
56
|
-
file.write
|
57
|
+
file.write release_manifest.to_json
|
57
58
|
end
|
58
59
|
end
|
59
60
|
end
|
data/lib/library.rb
CHANGED
@@ -4,12 +4,12 @@ class Library
|
|
4
4
|
attr_accessor :manifests
|
5
5
|
|
6
6
|
def versions
|
7
|
-
versions = release_manifests.map { |m| m
|
7
|
+
versions = release_manifests.map { |m| m.version }
|
8
8
|
end
|
9
9
|
|
10
10
|
def generic_manifest
|
11
11
|
@manifests.each do |m|
|
12
|
-
if m
|
12
|
+
if m.is_a?(ManifestGeneric)
|
13
13
|
return m
|
14
14
|
end
|
15
15
|
end
|
@@ -17,9 +17,9 @@ class Library
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def release_manifests
|
20
|
-
result = @manifests.reject { |m| m
|
20
|
+
result = @manifests.reject { |m| m.is_a?(ManifestGeneric) }
|
21
21
|
result.sort! do |m1,m2|
|
22
|
-
m1
|
22
|
+
m1.release_date <=> m2.release_date
|
23
23
|
end
|
24
24
|
result
|
25
25
|
end
|
data/lib/manifest.rb
CHANGED
@@ -1,43 +1,180 @@
|
|
1
|
-
class Manifest
|
1
|
+
class Manifest < JsonObject
|
2
2
|
|
3
|
-
def self.
|
3
|
+
def self.descendants
|
4
|
+
ObjectSpace.each_object(::Class).select { |klass| klass < self }
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.for_schema_id schema_id
|
8
|
+
descendants.each do |manifest_class|
|
9
|
+
if schema_id == manifest_class.schema_id
|
10
|
+
return manifest_class.new
|
11
|
+
end
|
12
|
+
end
|
13
|
+
raise VerificationError.new("Unknown schema id '#{schema_id}'")
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.parse_file path
|
17
|
+
json = JSON File.read path
|
18
|
+
manifest = Manifest.for_schema_id(json["$schema"])
|
19
|
+
manifest.filename = File.basename path
|
20
|
+
manifest.filename =~ /^(.*?)\./
|
21
|
+
manifest.libraryname = $1
|
22
|
+
|
23
|
+
manifest.from_hash(json)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.parse_schema_version schema_id
|
27
|
+
schema_id =~ /^http:\/\/inqlude\.org\/schema\/(.*)-manifest-v(.*)\#$/
|
28
|
+
type = $1
|
29
|
+
version = $2.to_i
|
30
|
+
if !type || !version
|
31
|
+
raise InqludeError.new("Unable to parse schema id '{schema_id}'")
|
32
|
+
end
|
33
|
+
version
|
34
|
+
end
|
35
|
+
|
36
|
+
attribute :name
|
37
|
+
attribute :display_name
|
38
|
+
attribute :release_date
|
39
|
+
attribute :version
|
40
|
+
attribute :summary
|
41
|
+
attribute :urls do
|
42
|
+
attribute :homepage
|
43
|
+
attribute :api_docs
|
44
|
+
attribute :download
|
45
|
+
attribute :tutorial
|
46
|
+
attribute :vcs
|
47
|
+
attribute :description_source
|
48
|
+
attribute :announcement
|
49
|
+
attribute :mailing_list
|
50
|
+
attribute :contact
|
51
|
+
attribute :custom
|
52
|
+
end
|
53
|
+
attribute :licenses
|
54
|
+
attribute :description
|
55
|
+
attribute :authors
|
56
|
+
attribute :maturity
|
57
|
+
attribute :platforms
|
58
|
+
attribute :packages do
|
59
|
+
attribute :source
|
60
|
+
attribute :openSUSE
|
61
|
+
attribute :windows
|
62
|
+
attribute :ubuntu
|
63
|
+
end
|
64
|
+
attribute :group
|
65
|
+
|
66
|
+
attr_reader :schema_version
|
67
|
+
|
68
|
+
attr_accessor :filename, :libraryname
|
69
|
+
|
70
|
+
def initialize(schema_id)
|
71
|
+
@schema_id = schema_id
|
72
|
+
@schema_version = Manifest.parse_schema_version(schema_id)
|
73
|
+
super()
|
74
|
+
end
|
75
|
+
|
76
|
+
def schema_name
|
77
|
+
regexp = /Manifest([A-Z][a-z]*)([A-Z][a-z]*)?/
|
78
|
+
match = regexp.match(self.class.to_s)
|
79
|
+
if !match
|
80
|
+
raise "Class '#{self.class} is not a Manifest sub class"
|
81
|
+
end
|
82
|
+
schema_type = match[1].downcase
|
83
|
+
if match[2]
|
84
|
+
schema_type += "-" + match[2].downcase
|
85
|
+
end
|
86
|
+
"#{schema_type}-manifest-v#{schema_version}"
|
87
|
+
end
|
88
|
+
|
89
|
+
def path
|
90
|
+
File.join( name, expected_filename )
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
class ManifestGeneric < Manifest
|
95
|
+
def self.schema_id
|
4
96
|
"http://inqlude.org/schema/generic-manifest-v1#"
|
5
97
|
end
|
6
98
|
|
7
|
-
def
|
99
|
+
def initialize
|
100
|
+
super(ManifestGeneric.schema_id)
|
101
|
+
end
|
102
|
+
|
103
|
+
def expected_filename
|
104
|
+
"#{name}.manifest"
|
105
|
+
end
|
106
|
+
|
107
|
+
def is_released?
|
108
|
+
# Purely commercial libraries often don't have release information publicly
|
109
|
+
# available, so we treat them as released, even, if the manifest only has
|
110
|
+
# generic data.
|
111
|
+
if licenses == ["Commercial"]
|
112
|
+
return true
|
113
|
+
else
|
114
|
+
return false
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def has_version?
|
119
|
+
false
|
120
|
+
end
|
121
|
+
|
122
|
+
def create_release_manifest(release_date, version)
|
123
|
+
m = ManifestRelease.new
|
124
|
+
ManifestGeneric.all_keys.each do |key, type|
|
125
|
+
value = send("#{key}")
|
126
|
+
if value
|
127
|
+
m.send("#{key}=", value)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
m.release_date = release_date
|
132
|
+
m.version = version
|
133
|
+
m
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
class ManifestRelease < Manifest
|
138
|
+
def self.schema_id
|
8
139
|
"http://inqlude.org/schema/release-manifest-v1#"
|
9
140
|
end
|
10
141
|
|
11
|
-
def
|
142
|
+
def initialize
|
143
|
+
super(ManifestRelease.schema_id)
|
144
|
+
end
|
145
|
+
|
146
|
+
def expected_filename
|
147
|
+
"#{name}.#{release_date}.manifest"
|
148
|
+
end
|
149
|
+
|
150
|
+
def is_released?
|
151
|
+
return true
|
152
|
+
end
|
153
|
+
|
154
|
+
def has_version?
|
155
|
+
true
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
class ManifestProprietaryRelease < Manifest
|
160
|
+
def self.schema_id
|
12
161
|
"http://inqlude.org/schema/proprietary-release-manifest-v1#"
|
13
162
|
end
|
14
163
|
|
15
|
-
def
|
16
|
-
|
17
|
-
filename = File.basename path
|
18
|
-
manifest["filename"] = filename
|
19
|
-
filename =~ /^(.*?)\./
|
20
|
-
manifest["libraryname"] = $1
|
21
|
-
manifest["schema_type"],manifest["schema_version"] =
|
22
|
-
Manifest.parse_schema_id manifest["$schema"]
|
23
|
-
manifest
|
164
|
+
def initialize
|
165
|
+
super(ManifestProprietaryRelease.schema_id)
|
24
166
|
end
|
25
|
-
|
26
|
-
def
|
27
|
-
|
28
|
-
m.delete "filename"
|
29
|
-
m.delete "libraryname"
|
30
|
-
m.delete "schema_type"
|
31
|
-
m.delete "schema_version"
|
32
|
-
JSON.pretty_generate m
|
167
|
+
|
168
|
+
def expected_filename
|
169
|
+
"#{name}.#{release_date}.manifest"
|
33
170
|
end
|
34
|
-
|
35
|
-
def
|
36
|
-
|
37
|
-
type = $1
|
38
|
-
version = $2.to_i
|
39
|
-
raise "Unable to parse schema id '{schema_id}'" if !type || !version
|
40
|
-
return type, version
|
171
|
+
|
172
|
+
def is_released?
|
173
|
+
return true
|
41
174
|
end
|
42
175
|
|
176
|
+
def has_version?
|
177
|
+
true
|
178
|
+
end
|
43
179
|
end
|
180
|
+
|
data/lib/manifest_handler.rb
CHANGED
@@ -26,13 +26,7 @@ class ManifestHandler
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def manifest_path manifest
|
29
|
-
|
30
|
-
return File.join( @settings.manifest_path, manifest["name"],
|
31
|
-
"#{manifest["name"]}.#{manifest["release_date"]}.manifest" )
|
32
|
-
else
|
33
|
-
return File.join( @settings.manifest_path, manifest["name"],
|
34
|
-
"#{manifest["name"]}.manifest" )
|
35
|
-
end
|
29
|
+
File.join(@settings.manifest_path, manifest.path)
|
36
30
|
end
|
37
31
|
|
38
32
|
def libraries maturity = nil
|
@@ -41,31 +35,29 @@ class ManifestHandler
|
|
41
35
|
else
|
42
36
|
return @libraries.select do |l|
|
43
37
|
manifest = l.latest_manifest
|
44
|
-
manifest
|
45
|
-
|
38
|
+
manifest.maturity == maturity.to_s &&
|
39
|
+
manifest.licenses != [ "Commercial" ]
|
46
40
|
end
|
47
41
|
end
|
48
42
|
end
|
49
43
|
|
50
44
|
def unreleased_libraries
|
51
45
|
return @libraries.select do |l|
|
52
|
-
|
53
|
-
manifest["schema_type"] == "generic" &&
|
54
|
-
manifest["licenses"] != [ "Commercial" ]
|
46
|
+
!l.latest_manifest.is_released?
|
55
47
|
end
|
56
48
|
end
|
57
49
|
|
58
50
|
def commercial_libraries
|
59
51
|
return @libraries.select do |l|
|
60
52
|
manifest = l.latest_manifest
|
61
|
-
manifest
|
53
|
+
manifest.licenses.include? "Commercial"
|
62
54
|
end
|
63
55
|
end
|
64
56
|
|
65
57
|
def group name
|
66
58
|
return @libraries.select do |l|
|
67
59
|
manifest = l.latest_manifest
|
68
|
-
manifest
|
60
|
+
manifest.group == name
|
69
61
|
end
|
70
62
|
end
|
71
63
|
|
@@ -79,13 +71,12 @@ class ManifestHandler
|
|
79
71
|
end
|
80
72
|
|
81
73
|
def manifest name
|
82
|
-
read_remote
|
83
74
|
@libraries.each do |library|
|
84
75
|
if library.name == name
|
85
76
|
return library.latest_manifest
|
86
77
|
end
|
87
78
|
end
|
88
|
-
raise "Unable to find manifest '#{name}'"
|
79
|
+
raise InqludeError.new("Unable to find manifest '#{name}'")
|
89
80
|
end
|
90
81
|
|
91
82
|
def read_remote
|
@@ -125,4 +116,11 @@ class ManifestHandler
|
|
125
116
|
end
|
126
117
|
end
|
127
118
|
|
119
|
+
def generate_inqlude_all
|
120
|
+
all = []
|
121
|
+
libraries.each do |l|
|
122
|
+
all.push(l.latest_manifest.to_hash)
|
123
|
+
end
|
124
|
+
JSON.pretty_generate(all)
|
125
|
+
end
|
128
126
|
end
|