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.
Files changed (61) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +494 -0
  3. data/Rakefile +19 -22
  4. data/exe/simp-install +1 -1
  5. data/exe/simp-media +1 -1
  6. data/exe/simp-metadata +1 -1
  7. data/lib/simp/install/command.rb +34 -35
  8. data/lib/simp/media.rb +0 -1
  9. data/lib/simp/media/command.rb +34 -35
  10. data/lib/simp/media/engine.rb +29 -35
  11. data/lib/simp/media/type.rb +1 -2
  12. data/lib/simp/media/type/base.rb +12 -4
  13. data/lib/simp/media/type/control-repo.rb +96 -107
  14. data/lib/simp/media/type/internet.rb +8 -8
  15. data/lib/simp/media/type/iso.rb +0 -1
  16. data/lib/simp/media/type/local.rb +18 -19
  17. data/lib/simp/media/type/tar.rb +37 -37
  18. data/lib/simp/metadata.rb +240 -258
  19. data/lib/simp/metadata/bootstrap_source.rb +93 -89
  20. data/lib/simp/metadata/buildinfo.rb +23 -23
  21. data/lib/simp/metadata/command.rb +60 -58
  22. data/lib/simp/metadata/commands.rb +1 -1
  23. data/lib/simp/metadata/commands/base.rb +28 -25
  24. data/lib/simp/metadata/commands/clone.rb +3 -5
  25. data/lib/simp/metadata/commands/component.rb +128 -90
  26. data/lib/simp/metadata/commands/delete.rb +4 -5
  27. data/lib/simp/metadata/commands/pry.rb +1 -3
  28. data/lib/simp/metadata/commands/release.rb +22 -23
  29. data/lib/simp/metadata/commands/releases.rb +1 -3
  30. data/lib/simp/metadata/commands/save.rb +10 -13
  31. data/lib/simp/metadata/commands/script.rb +11 -14
  32. data/lib/simp/metadata/commands/search.rb +15 -20
  33. data/lib/simp/metadata/commands/set-write-url.rb +1 -3
  34. data/lib/simp/metadata/commands/set-write.rb +1 -3
  35. data/lib/simp/metadata/commands/update.rb +9 -10
  36. data/lib/simp/metadata/component.rb +310 -154
  37. data/lib/simp/metadata/components.rb +15 -16
  38. data/lib/simp/metadata/engine.rb +31 -39
  39. data/lib/simp/metadata/fake_uri.rb +2 -0
  40. data/lib/simp/metadata/location.rb +99 -105
  41. data/lib/simp/metadata/locations.rb +19 -21
  42. data/lib/simp/metadata/release.rb +30 -39
  43. data/lib/simp/metadata/releases.rb +14 -15
  44. data/lib/simp/metadata/source.rb +69 -79
  45. data/lib/simp/metadata/version.rb +9 -0
  46. data/spec/simp/media/command_spec.rb +4 -5
  47. data/spec/simp/media/engine_spec.rb +14 -14
  48. data/spec/simp/media/type/control_repo_spec.rb +10 -12
  49. data/spec/simp/media/type/internet_spec.rb +11 -11
  50. data/spec/simp/media/type/iso_spec.rb +6 -7
  51. data/spec/simp/media/type/local_spec.rb +6 -8
  52. data/spec/simp/media/type/tar_spec.rb +6 -8
  53. data/spec/simp/metadata/buildinfo_spec.rb +19 -17
  54. data/spec/simp/metadata/commands/clone_spec.rb +4 -3
  55. data/spec/simp/metadata/component_spec.rb +43 -54
  56. data/spec/simp/metadata/engine_spec.rb +38 -41
  57. data/spec/simp/metadata/release_spec.rb +72 -79
  58. data/spec/simp/metadata/source_spec.rb +8 -6
  59. data/spec/simp/metadata_spec.rb +95 -98
  60. data/spec/spec_helper.rb +33 -21
  61. metadata +5 -3
@@ -12,16 +12,16 @@ module Simp
12
12
  @type = type
13
13
  end
14
14
 
15
- def to_s()
16
- self.keys.to_s
15
+ def to_s
16
+ keys.to_s
17
17
  end
18
18
 
19
- def size()
20
- self.keys.size
19
+ def size
20
+ keys.size
21
21
  end
22
22
 
23
- def each(&block)
24
- self.keys.each do |version|
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
- self.keys.include?(name)
34
+ keys.include?(name)
35
35
  end
36
36
 
37
- def keys()
37
+ def keys
38
38
  result = {}
39
- if (version == nil)
40
- engine.sources.each do |name, source|
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 |name, source|
47
- if (source.releases.key?(version))
48
- source.releases[version].each do |component, data|
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, data|
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 (self.key?(name))
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
-
@@ -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 = "community", options = {})
11
-
11
+ def initialize(cachepath = nil, metadatarepos = nil, edition = 'community', options = {})
12
12
  ENV['GIT_SSH'] = "#{File.dirname(__FILE__)}/git_ssh_wrapper.sh"
13
- if (options["ssh_key"] != nil)
14
- ENV['SIMP_METADATA_SSHKEY'] = "#{options["ssh_key"]}"
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 = "simp-metadata"
18
+ @writable_source = 'simp-metadata'
18
19
  priority = 0
19
20
  bootstrap_source = Simp::Metadata::Bootstrap_source.new(edition)
20
- if (metadatarepos.class.to_s == "Hash")
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
- if (bootstrap_source.components.key?(reponame))
25
- bootstrap_source.components[reponame]["locations"][0]["url"] = url
26
- bootstrap_source.components[reponame]["locations"][0]["method"] = "git"
27
- bootstrap_source.components[reponame]["locations"][0]["extract"] = false
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
- self.components.keys.each do |key|
33
- component = self.components[key]
34
- @sources[key] = Simp::Metadata::Source.new({:name => key, :component => component}.merge({cachepath: cachepath, edition: edition, engine: self}))
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
- return Simp::Metadata::Components.new(self)
38
+ def components
39
+ Simp::Metadata::Components.new(self)
40
40
  end
41
41
 
42
- def releases()
43
- return Simp::Metadata::Releases.new(self)
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 |name, source|
49
- if (source.dirty? == true)
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 = "Auto-saving using simp-metadata")
74
- Simp::Metadata.debug2("Saving metadata")
75
- @sources.each do |name, source|
76
- if (source.dirty? == true)
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
- def ssh_key
86
- @ssh_key
87
- end
82
+ attr_reader :ssh_key
88
83
 
89
- def ssh_key= (value)
90
- @ssh_key = value
91
- end
84
+ attr_writer :ssh_key
92
85
 
93
- def cleanup()
94
- @sources.each do |name, source|
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
-
@@ -8,9 +8,11 @@ module Simp
8
8
  attr_accessor :port
9
9
  attr_accessor :path
10
10
  attr_accessor :user
11
+
11
12
  def initialize(uri)
12
13
  @uri = uri
13
14
  end
15
+
14
16
  def to_s
15
17
  @uri
16
18
  end
@@ -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
- self.url
16
+ url
18
17
  end
19
18
 
20
19
  def primary
21
- if (location.key?("primary"))
22
- location["primary"]
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
- ["extract", "primary", "method", "type", "url"]
27
+ def keys
28
+ %w(extract primary method type url)
30
29
  end
31
30
 
32
- def [] (index)
33
- self.send index.to_sym
31
+ def [](index)
32
+ send index.to_sym
34
33
  end
35
34
 
36
- def each(&block)
37
- self.keys.each do |key|
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 (location.key?("extract"))
44
- location["extract"]
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 (@local_method)
54
+ if @local_method
56
55
  @local_method
57
56
  else
58
- if (location.key?("type"))
59
- if (location["type"] == "git")
60
- method = "git"
57
+ if location.key?('type')
58
+ if location['type'] == 'git'
59
+ 'git'
61
60
  else
62
- method = "file"
61
+ 'file'
63
62
  end
64
63
  else
65
- if (location.key?("method"))
66
- location["method"]
64
+ if location.key?('method')
65
+ location['method']
67
66
  else
68
- method = "file"
67
+ 'file'
69
68
  end
70
69
  end
71
70
  end
72
71
  end
73
72
 
74
73
  def type
75
- location["binary"]
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 (@local_url)
82
+ if @local_url
84
83
  @local_url
85
84
  else
86
- base = self.real_url
85
+ base = real_url
87
86
  uri = Simp::Metadata.uri(base)
88
87
  case uri.scheme
89
- when "simp-enterprise"
90
- if (uri.query.class == String)
91
- query_elements = uri.query.split("&")
92
- newquery = []
93
- found_version = false
94
- found_filetype = false
95
- query_elements.each do |element|
96
- elements = element.split("=")
97
- if (elements.size > 1)
98
- if (elements[0] == "version")
99
- found_version = true
100
- elements[1] = component.version
101
- newquery << elements.join("=")
102
- elsif (elements[0] == "filetype")
103
- found_filetype = true
104
- elements[1] = component.extension
105
- newquery << elements.join("=")
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
- uri.to_s
122
-
123
- when "simp"
124
- if (uri.query.class == String)
125
- query_elements = uri.query.split("&")
126
- newquery = []
127
- found_version = false
128
- found_filetype = false
129
- query_elements.each do |element|
130
- elements = element.split("=")
131
- if (elements.size > 1)
132
- if (elements[0] == "version")
133
- found_version = true
134
- elements[1] = component.version
135
- newquery << elements.join("=")
136
- elsif (elements[0] == "filetype")
137
- found_filetype = true
138
- elements[1] = component.extension
139
- newquery << elements.join("=")
140
- else
141
- newquery << element
142
- end
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
- uri.to_s
156
- else
157
- case component.component_type
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
- base
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 (component.compiled? == true)
167
+ if component.compiled?
172
168
  case component.component_type
173
- when "rubygem"
174
- case component.release_source.to_s
175
- when "simp-metadata"
176
- return "simp:///#{component.name}/#{component.binaryname}"
177
- when "enterprise-metadata"
178
- return "simp-enterprise:///#{component.name}/#{component.binaryname}"
179
- end
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 (location.key?("url"))
183
- location["url"]
178
+ if location.key?('url')
179
+ location['url']
184
180
  else
185
- if (location.key?("host"))
186
- if (location.key?("path"))
187
- if (location.key?("type"))
188
- "https://#{location["host"]}/#{location["path"]}"
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