simp-metadata 0.4.4 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +494 -0
- data/Rakefile +19 -22
- data/exe/simp-install +1 -1
- data/exe/simp-media +1 -1
- data/exe/simp-metadata +1 -1
- data/lib/simp/install/command.rb +34 -35
- data/lib/simp/media.rb +0 -1
- data/lib/simp/media/command.rb +34 -35
- data/lib/simp/media/engine.rb +29 -35
- data/lib/simp/media/type.rb +1 -2
- data/lib/simp/media/type/base.rb +12 -4
- data/lib/simp/media/type/control-repo.rb +96 -107
- data/lib/simp/media/type/internet.rb +8 -8
- data/lib/simp/media/type/iso.rb +0 -1
- data/lib/simp/media/type/local.rb +18 -19
- data/lib/simp/media/type/tar.rb +37 -37
- data/lib/simp/metadata.rb +240 -258
- data/lib/simp/metadata/bootstrap_source.rb +93 -89
- data/lib/simp/metadata/buildinfo.rb +23 -23
- data/lib/simp/metadata/command.rb +60 -58
- data/lib/simp/metadata/commands.rb +1 -1
- data/lib/simp/metadata/commands/base.rb +28 -25
- data/lib/simp/metadata/commands/clone.rb +3 -5
- data/lib/simp/metadata/commands/component.rb +128 -90
- data/lib/simp/metadata/commands/delete.rb +4 -5
- data/lib/simp/metadata/commands/pry.rb +1 -3
- data/lib/simp/metadata/commands/release.rb +22 -23
- data/lib/simp/metadata/commands/releases.rb +1 -3
- data/lib/simp/metadata/commands/save.rb +10 -13
- data/lib/simp/metadata/commands/script.rb +11 -14
- data/lib/simp/metadata/commands/search.rb +15 -20
- data/lib/simp/metadata/commands/set-write-url.rb +1 -3
- data/lib/simp/metadata/commands/set-write.rb +1 -3
- data/lib/simp/metadata/commands/update.rb +9 -10
- data/lib/simp/metadata/component.rb +310 -154
- data/lib/simp/metadata/components.rb +15 -16
- data/lib/simp/metadata/engine.rb +31 -39
- data/lib/simp/metadata/fake_uri.rb +2 -0
- data/lib/simp/metadata/location.rb +99 -105
- data/lib/simp/metadata/locations.rb +19 -21
- data/lib/simp/metadata/release.rb +30 -39
- data/lib/simp/metadata/releases.rb +14 -15
- data/lib/simp/metadata/source.rb +69 -79
- data/lib/simp/metadata/version.rb +9 -0
- data/spec/simp/media/command_spec.rb +4 -5
- data/spec/simp/media/engine_spec.rb +14 -14
- data/spec/simp/media/type/control_repo_spec.rb +10 -12
- data/spec/simp/media/type/internet_spec.rb +11 -11
- data/spec/simp/media/type/iso_spec.rb +6 -7
- data/spec/simp/media/type/local_spec.rb +6 -8
- data/spec/simp/media/type/tar_spec.rb +6 -8
- data/spec/simp/metadata/buildinfo_spec.rb +19 -17
- data/spec/simp/metadata/commands/clone_spec.rb +4 -3
- data/spec/simp/metadata/component_spec.rb +43 -54
- data/spec/simp/metadata/engine_spec.rb +38 -41
- data/spec/simp/metadata/release_spec.rb +72 -79
- data/spec/simp/metadata/source_spec.rb +8 -6
- data/spec/simp/metadata_spec.rb +95 -98
- data/spec/spec_helper.rb +33 -21
- metadata +5 -3
@@ -12,16 +12,16 @@ module Simp
|
|
12
12
|
@type = type
|
13
13
|
end
|
14
14
|
|
15
|
-
def to_s
|
16
|
-
|
15
|
+
def to_s
|
16
|
+
keys.to_s
|
17
17
|
end
|
18
18
|
|
19
|
-
def size
|
20
|
-
|
19
|
+
def size
|
20
|
+
keys.size
|
21
21
|
end
|
22
22
|
|
23
|
-
def each
|
24
|
-
|
23
|
+
def each
|
24
|
+
keys.each do |version|
|
25
25
|
yield self[version]
|
26
26
|
end
|
27
27
|
end
|
@@ -31,25 +31,25 @@ module Simp
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def key?(name)
|
34
|
-
|
34
|
+
keys.include?(name)
|
35
35
|
end
|
36
36
|
|
37
|
-
def keys
|
37
|
+
def keys
|
38
38
|
result = {}
|
39
|
-
if
|
40
|
-
engine.sources.each do |
|
39
|
+
if version.nil?
|
40
|
+
engine.sources.each do |_name, source|
|
41
41
|
source.components.keys.each do |name|
|
42
42
|
result[name] = true
|
43
43
|
end
|
44
44
|
end
|
45
45
|
else
|
46
|
-
engine.sources.each do |
|
47
|
-
if
|
48
|
-
source.releases[version].each do |component,
|
46
|
+
engine.sources.each do |_name, source|
|
47
|
+
if source.releases.key?(version)
|
48
|
+
source.releases[version].each do |component, _data|
|
49
49
|
result[component] = true
|
50
50
|
end
|
51
51
|
else
|
52
|
-
source.release(version).each do |component,
|
52
|
+
source.release(version).each do |component, _data|
|
53
53
|
result[component] = true
|
54
54
|
end
|
55
55
|
end
|
@@ -59,7 +59,7 @@ module Simp
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def create(name, settings = {})
|
62
|
-
unless
|
62
|
+
unless key?(name)
|
63
63
|
engine.writable_source.components[name] = settings
|
64
64
|
engine.writable_source.dirty = true
|
65
65
|
end
|
@@ -67,4 +67,3 @@ module Simp
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
70
|
-
|
data/lib/simp/metadata/engine.rb
CHANGED
@@ -5,50 +5,48 @@ require 'simp/metadata'
|
|
5
5
|
module Simp
|
6
6
|
module Metadata
|
7
7
|
class Engine
|
8
|
+
attr_accessor :options
|
8
9
|
attr_accessor :sources
|
9
10
|
|
10
|
-
def initialize(cachepath = nil, metadatarepos = nil, edition =
|
11
|
-
|
11
|
+
def initialize(cachepath = nil, metadatarepos = nil, edition = 'community', options = {})
|
12
12
|
ENV['GIT_SSH'] = "#{File.dirname(__FILE__)}/git_ssh_wrapper.sh"
|
13
|
-
|
14
|
-
ENV['SIMP_METADATA_SSHKEY'] =
|
13
|
+
unless options['ssh_key'].nil?
|
14
|
+
ENV['SIMP_METADATA_SSHKEY'] = (options['ssh_key']).to_s
|
15
15
|
end
|
16
|
+
@options = options
|
16
17
|
@sources = {}
|
17
|
-
@writable_source =
|
18
|
+
@writable_source = 'simp-metadata'
|
18
19
|
priority = 0
|
19
20
|
bootstrap_source = Simp::Metadata::Bootstrap_source.new(edition)
|
20
|
-
if
|
21
|
+
if metadatarepos.class.to_s == 'Hash'
|
21
22
|
metadatarepos.each do |reponame, url|
|
22
23
|
# XXX: ToDo replace with better logic once Simp::Metadata.download_component gets refactored.
|
23
24
|
# MUCH LAYERING VIOLATIONS
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
25
|
+
next unless bootstrap_source.components.key?(reponame)
|
26
|
+
bootstrap_source.components[reponame]['locations'][0]['url'] = url
|
27
|
+
bootstrap_source.components[reponame]['locations'][0]['method'] = 'git'
|
28
|
+
bootstrap_source.components[reponame]['locations'][0]['extract'] = false
|
29
29
|
end
|
30
30
|
end
|
31
31
|
@sources[bootstrap_source.name] = bootstrap_source
|
32
|
-
|
33
|
-
component =
|
34
|
-
@sources[key] = Simp::Metadata::Source.new({:
|
32
|
+
components.keys.each do |key|
|
33
|
+
component = components[key]
|
34
|
+
@sources[key] = Simp::Metadata::Source.new({ name: key, component: component }.merge(cachepath: cachepath, edition: edition, engine: self))
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
def components
|
39
|
-
|
38
|
+
def components
|
39
|
+
Simp::Metadata::Components.new(self)
|
40
40
|
end
|
41
41
|
|
42
|
-
def releases
|
43
|
-
|
42
|
+
def releases
|
43
|
+
Simp::Metadata::Releases.new(self)
|
44
44
|
end
|
45
45
|
|
46
|
-
def dirty?
|
46
|
+
def dirty?
|
47
47
|
dirty = false
|
48
|
-
@sources.each do |
|
49
|
-
if
|
50
|
-
dirty = true
|
51
|
-
end
|
48
|
+
@sources.each do |_name, source|
|
49
|
+
dirty = true if source.dirty?
|
52
50
|
end
|
53
51
|
dirty
|
54
52
|
end
|
@@ -57,12 +55,11 @@ module Simp
|
|
57
55
|
@writable_source = source
|
58
56
|
end
|
59
57
|
|
60
|
-
def writable_source_name
|
58
|
+
def writable_source_name
|
61
59
|
@writable_source
|
62
60
|
end
|
63
61
|
|
64
|
-
|
65
|
-
def writable_source()
|
62
|
+
def writable_source
|
66
63
|
@sources[@writable_source]
|
67
64
|
end
|
68
65
|
|
@@ -70,10 +67,10 @@ module Simp
|
|
70
67
|
@sources[metadata_name].write_url = url
|
71
68
|
end
|
72
69
|
|
73
|
-
def save(message =
|
74
|
-
Simp::Metadata.debug2(
|
75
|
-
@sources.each do |
|
76
|
-
if
|
70
|
+
def save(message = 'Auto-saving using simp-metadata')
|
71
|
+
Simp::Metadata.debug2('Saving metadata')
|
72
|
+
@sources.each do |_name, source|
|
73
|
+
if source.dirty?
|
77
74
|
Simp::Metadata.debug1("#{source} - dirty, saving")
|
78
75
|
source.save(message)
|
79
76
|
else
|
@@ -82,20 +79,15 @@ module Simp
|
|
82
79
|
end
|
83
80
|
end
|
84
81
|
|
85
|
-
|
86
|
-
@ssh_key
|
87
|
-
end
|
82
|
+
attr_reader :ssh_key
|
88
83
|
|
89
|
-
|
90
|
-
@ssh_key = value
|
91
|
-
end
|
84
|
+
attr_writer :ssh_key
|
92
85
|
|
93
|
-
def cleanup
|
94
|
-
@sources.each do |
|
86
|
+
def cleanup
|
87
|
+
@sources.each do |_name, source|
|
95
88
|
source.cleanup
|
96
89
|
end
|
97
90
|
end
|
98
91
|
end
|
99
92
|
end
|
100
93
|
end
|
101
|
-
|
@@ -2,7 +2,6 @@ require 'uri'
|
|
2
2
|
module Simp
|
3
3
|
module Metadata
|
4
4
|
class Location
|
5
|
-
|
6
5
|
attr_accessor :locationinfo
|
7
6
|
attr_accessor :location
|
8
7
|
attr_accessor :component
|
@@ -14,34 +13,34 @@ module Simp
|
|
14
13
|
end
|
15
14
|
|
16
15
|
def to_s
|
17
|
-
|
16
|
+
url
|
18
17
|
end
|
19
18
|
|
20
19
|
def primary
|
21
|
-
if
|
22
|
-
location[
|
20
|
+
if location.key?('primary')
|
21
|
+
location['primary']
|
23
22
|
else
|
24
23
|
false
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
28
|
-
def keys
|
29
|
-
|
27
|
+
def keys
|
28
|
+
%w(extract primary method type url)
|
30
29
|
end
|
31
30
|
|
32
|
-
def []
|
33
|
-
|
31
|
+
def [](index)
|
32
|
+
send index.to_sym
|
34
33
|
end
|
35
34
|
|
36
|
-
def each
|
37
|
-
|
35
|
+
def each
|
36
|
+
keys.each do |key|
|
38
37
|
yield key, self[key]
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
42
41
|
def extract
|
43
|
-
if
|
44
|
-
location[
|
42
|
+
if location.key?('extract')
|
43
|
+
location['extract']
|
45
44
|
else
|
46
45
|
false
|
47
46
|
end
|
@@ -52,27 +51,27 @@ module Simp
|
|
52
51
|
end
|
53
52
|
|
54
53
|
def method
|
55
|
-
if
|
54
|
+
if @local_method
|
56
55
|
@local_method
|
57
56
|
else
|
58
|
-
if
|
59
|
-
if
|
60
|
-
|
57
|
+
if location.key?('type')
|
58
|
+
if location['type'] == 'git'
|
59
|
+
'git'
|
61
60
|
else
|
62
|
-
|
61
|
+
'file'
|
63
62
|
end
|
64
63
|
else
|
65
|
-
if
|
66
|
-
location[
|
64
|
+
if location.key?('method')
|
65
|
+
location['method']
|
67
66
|
else
|
68
|
-
|
67
|
+
'file'
|
69
68
|
end
|
70
69
|
end
|
71
70
|
end
|
72
71
|
end
|
73
72
|
|
74
73
|
def type
|
75
|
-
location[
|
74
|
+
location['binary']
|
76
75
|
end
|
77
76
|
|
78
77
|
def url=(value)
|
@@ -80,119 +79,114 @@ module Simp
|
|
80
79
|
end
|
81
80
|
|
82
81
|
def url
|
83
|
-
if
|
82
|
+
if @local_url
|
84
83
|
@local_url
|
85
84
|
else
|
86
|
-
base =
|
85
|
+
base = real_url
|
87
86
|
uri = Simp::Metadata.uri(base)
|
88
87
|
case uri.scheme
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
else
|
107
|
-
newquery << element
|
108
|
-
end
|
88
|
+
when 'simp-enterprise'
|
89
|
+
if uri.query.class == String
|
90
|
+
query_elements = uri.query.split('&')
|
91
|
+
newquery = []
|
92
|
+
found_version = false
|
93
|
+
found_filetype = false
|
94
|
+
query_elements.each do |element|
|
95
|
+
elements = element.split('=')
|
96
|
+
if elements.size > 1
|
97
|
+
if elements[0] == 'version'
|
98
|
+
found_version = true
|
99
|
+
elements[1] = component.version
|
100
|
+
newquery << elements.join('=')
|
101
|
+
elsif elements[0] == 'filetype'
|
102
|
+
found_filetype = true
|
103
|
+
elements[1] = component.extension
|
104
|
+
newquery << elements.join('=')
|
109
105
|
else
|
110
106
|
newquery << element
|
111
107
|
end
|
108
|
+
else
|
109
|
+
newquery << element
|
112
110
|
end
|
113
|
-
if (found_version == false)
|
114
|
-
newquery << "version=#{component.version}"
|
115
|
-
end
|
116
|
-
if (found_filetype == false)
|
117
|
-
newquery << "filetype=#{component.extension}"
|
118
|
-
end
|
119
|
-
uri.query = newquery.join("&")
|
120
111
|
end
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
112
|
+
newquery << "version=#{component.version}" unless found_version
|
113
|
+
|
114
|
+
unless found_filetype
|
115
|
+
newquery << "filetype=#{component.extension}"
|
116
|
+
end
|
117
|
+
|
118
|
+
uri.query = newquery.join('&')
|
119
|
+
end
|
120
|
+
uri.to_s
|
121
|
+
|
122
|
+
when 'simp'
|
123
|
+
if uri.query.class == String
|
124
|
+
query_elements = uri.query.split('&')
|
125
|
+
newquery = []
|
126
|
+
found_version = false
|
127
|
+
found_filetype = false
|
128
|
+
query_elements.each do |element|
|
129
|
+
elements = element.split('=')
|
130
|
+
if elements.size > 1
|
131
|
+
if elements[0] == 'version'
|
132
|
+
found_version = true
|
133
|
+
elements[1] = component.version
|
134
|
+
newquery << elements.join('=')
|
135
|
+
elsif elements[0] == 'filetype'
|
136
|
+
found_filetype = true
|
137
|
+
elements[1] = component.extension
|
138
|
+
newquery << elements.join('=')
|
143
139
|
else
|
144
140
|
newquery << element
|
145
141
|
end
|
142
|
+
else
|
143
|
+
newquery << element
|
146
144
|
end
|
147
|
-
if (found_version == false)
|
148
|
-
newquery << "version=#{component.version}"
|
149
|
-
end
|
150
|
-
if (found_filetype == false)
|
151
|
-
newquery << "filetype=#{component.extension}"
|
152
|
-
end
|
153
|
-
uri.query = newquery.join("&")
|
154
145
|
end
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
when "rubygem"
|
159
|
-
if (base =~ /.*\.gem/)
|
160
|
-
else
|
161
|
-
"#{base}/#{component.asset_name}-#{component.version}.gem"
|
162
|
-
end
|
146
|
+
newquery << "version=#{component.version}" unless found_version
|
147
|
+
unless found_filetype
|
148
|
+
newquery << "filetype=#{component.extension}"
|
163
149
|
end
|
164
|
-
|
150
|
+
uri.query = newquery.join('&')
|
151
|
+
end
|
152
|
+
uri.to_s
|
153
|
+
else
|
154
|
+
case component.component_type
|
155
|
+
when 'rubygem'
|
156
|
+
if base =~ /.*\.gem/
|
157
|
+
else
|
158
|
+
"#{base}/#{component.asset_name}-#{component.version}.gem"
|
159
|
+
end
|
160
|
+
end
|
161
|
+
base
|
165
162
|
end
|
166
163
|
end
|
167
|
-
|
168
164
|
end
|
169
165
|
|
170
166
|
def real_url
|
171
|
-
if
|
167
|
+
if component.compiled?
|
172
168
|
case component.component_type
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
169
|
+
when 'rubygem'
|
170
|
+
case component.release_source.to_s
|
171
|
+
when 'simp-metadata'
|
172
|
+
return "simp:///#{component.name}/#{component.binaryname}"
|
173
|
+
when 'enterprise-metadata'
|
174
|
+
return "simp-enterprise:///#{component.name}/#{component.binaryname}"
|
175
|
+
end
|
180
176
|
end
|
181
177
|
end
|
182
|
-
if
|
183
|
-
location[
|
178
|
+
if location.key?('url')
|
179
|
+
location['url']
|
184
180
|
else
|
185
|
-
if
|
186
|
-
if
|
187
|
-
if
|
188
|
-
"https://#{location[
|
181
|
+
if location.key?('host')
|
182
|
+
if location.key?('path')
|
183
|
+
if location.key?('type')
|
184
|
+
"https://#{location['host']}/#{location['path']}"
|
189
185
|
end
|
190
186
|
end
|
191
187
|
end
|
192
188
|
end
|
193
189
|
end
|
194
|
-
|
195
|
-
|
196
190
|
end
|
197
191
|
end
|
198
192
|
end
|