fig 0.1.51 → 0.1.52

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,16 +1,21 @@
1
1
  require 'fig/logging'
2
2
  require 'fig/packageerror'
3
- require 'fig/package/archive'
4
- require 'fig/package/configuration'
5
- require 'fig/package/resource'
6
- require 'fig/package/retrieve'
3
+ require 'fig/statement/archive'
4
+ require 'fig/statement/configuration'
5
+ require 'fig/statement/resource'
6
+ require 'fig/statement/retrieve'
7
7
 
8
8
  module Fig; end
9
9
 
10
10
  # The parsed representation of a configuration file. Contains the statement
11
11
  # objects.
12
12
  class Fig::Package
13
- attr_reader :package_name, :version_name, :directory, :statements
13
+ include Comparable
14
+
15
+ UNPUBLISHED = '<unpublished>'
16
+ DEFAULT_CONFIG = 'default'
17
+
18
+ attr_reader :package_name, :version_name, :directory, :statements
14
19
  attr_accessor :backtrace
15
20
 
16
21
  def initialize(package_name, version_name, directory, statements)
@@ -18,59 +23,170 @@ class Fig::Package
18
23
  @version_name = version_name
19
24
  @directory = directory
20
25
  @statements = statements
26
+ @applied_config_names = []
21
27
  @backtrace = nil
22
28
  end
23
29
 
24
30
  def [](config_name)
25
31
  @statements.each do |stmt|
26
- return stmt if stmt.is_a?(Configuration) && stmt.name == config_name
32
+ return stmt if stmt.is_a?(Fig::Statement::Configuration) && stmt.name == config_name
27
33
  end
28
- message = "Configuration not found: #{@package_name}/#{@version_name}:#{config_name}"
29
- raise Fig::PackageError.new message
34
+
35
+ message =
36
+ 'Configuration not found: ' +
37
+ (@package_name || '<empty>') +
38
+ '/' +
39
+ (@version_name || '<empty>') +
40
+ ':' +
41
+ (config_name || '<empty>')
42
+
43
+ raise Fig::PackageError.new(message)
44
+ end
45
+
46
+ def <=>(other)
47
+ compared = compare_components(package_name, other.package_name)
48
+ return compared if compared != 0
49
+
50
+ return compare_components(version_name, other.version_name)
30
51
  end
31
52
 
32
53
  def configs
33
- @statements.select { |statement| statement.is_a?(Configuration) }
54
+ return @statements.select { |statement| statement.is_a?(Fig::Statement::Configuration) }
55
+ end
56
+
57
+ def config_names
58
+ return configs.collect { |statement| statement.name }
34
59
  end
35
60
 
36
61
  def retrieves
37
62
  retrieves = {}
38
- statements.each { |statement| retrieves[statement.var] = statement.path if statement.is_a?(Retrieve) }
39
- retrieves
63
+
64
+ statements.each do
65
+ |statement|
66
+
67
+ retrieves[statement.var] = statement.path if statement.is_a?(Fig::Statement::Retrieve)
68
+ end
69
+
70
+ return retrieves
40
71
  end
41
72
 
42
73
  def archive_urls
43
- @statements.select{|s| s.is_a?(Archive)}.map{|s|s.url}
74
+ return @statements.select{|s| s.is_a?(Fig::Statement::Archive)}.map{|s| s.url}
44
75
  end
45
76
 
46
77
  def resource_urls
47
- @statements.select{|s| s.is_a?(Resource)}.map{|s|s.url}
78
+ return @statements.select{|s| s.is_a?(Fig::Statement::Resource)}.map{|s|s.url}
79
+ end
80
+
81
+ def applied_config_names()
82
+ return @applied_config_names.clone
83
+ end
84
+
85
+ def add_applied_config_name(name)
86
+ @applied_config_names << name
87
+ end
88
+
89
+ def primary_config_name()
90
+ return @applied_config_names.first
91
+ end
92
+
93
+ # Returns an array of PackageDescriptors
94
+ def package_dependencies(config_name)
95
+ descriptors = []
96
+
97
+ self[config_name || DEFAULT_CONFIG].walk_statements do
98
+ |statement|
99
+
100
+ if statement.is_a?(Fig::Statement::Include)
101
+ descriptors << statement.resolved_dependency_descriptor(self)
102
+ end
103
+ end
104
+
105
+ return descriptors
48
106
  end
49
107
 
108
+ # Block will receive a Statement.
50
109
  def walk_statements(&block)
51
110
  @statements.each do |statement|
52
111
  yield statement
53
112
  statement.walk_statements &block
54
113
  end
114
+
115
+ return
116
+ end
117
+
118
+ # Block will receive a Package and a Statement.
119
+ def walk_statements_following_package_dependencies(repository, &block)
120
+ @statements.each do |statement|
121
+ yield self, statement
122
+ statement.walk_statements_following_package_dependencies(
123
+ repository, self, &block
124
+ )
125
+ end
126
+
127
+ return
55
128
  end
56
129
 
57
130
  def unparse
58
- @statements.map { |statement| statement.unparse('') }.join("\n")
131
+ return @statements.map { |statement| statement.unparse('') }.join("\n")
59
132
  end
60
133
 
61
134
  def ==(other)
62
135
  return false if other.nil?
63
- @package_name == other.package_name && @version_name == other.version_name && @statements.to_yaml == other.statements.to_yaml
136
+
137
+ return @package_name == other.package_name &&
138
+ @version_name == other.version_name &&
139
+ @statements.to_yaml == other.statements.to_yaml
64
140
  end
65
141
 
66
142
  def to_s
67
- package_name ||= 'uninitialized'
68
- version_name ||= 'uninitialized'
69
- package_name + '/' + version_name
143
+ package_name = @package_name || '<empty>'
144
+ version_name = @version_name || '<empty>'
145
+ return package_name + '/' + version_name
146
+ end
147
+
148
+ def to_s_with_config(config_name)
149
+ string = nil
150
+
151
+ if package_name.nil?
152
+ string = UNPUBLISHED
153
+ else
154
+ string = to_s
155
+ end
156
+
157
+ if not config_name.nil? and config_name != DEFAULT_CONFIG
158
+ string += ":#{config_name}"
159
+ end
160
+
161
+ return string
162
+ end
163
+
164
+ def to_s_with_primary_config()
165
+ return to_s_with_config(primary_config_name)
166
+ end
167
+
168
+ private
169
+
170
+ def compare_components(mine, others)
171
+ if mine.nil?
172
+ if others.nil?
173
+ return 0
174
+ end
175
+
176
+ return 1
177
+ end
178
+
179
+ if others.nil?
180
+ return -1
181
+ end
182
+
183
+ return mine <=> others
70
184
  end
71
185
  end
72
186
 
187
+ # TODO: get this out of the global namespace
73
188
  def unparse_statements(indent, prefix, statements, suffix)
74
189
  body = @statements.map { |statement| statement.unparse(indent+' ') }.join("\n")
190
+
75
191
  return ["\n#{indent}#{prefix}", body, "#{indent}#{suffix}"].join("\n")
76
192
  end
@@ -0,0 +1,36 @@
1
+ module Fig; end
2
+
3
+ # Simple double-level cache of Packages.
4
+ class Fig::PackageCache
5
+ def initialize()
6
+ @packages = {}
7
+ end
8
+
9
+ def add_package(package)
10
+ versions = @packages[package.package_name]
11
+ if not versions
12
+ versions = {}
13
+ @packages[package.package_name] = versions
14
+ end
15
+
16
+ versions[package.version_name] = package
17
+
18
+ return
19
+ end
20
+
21
+ def get_package(name, version)
22
+ versions = @packages[name]
23
+ return if not versions
24
+
25
+ return versions[version]
26
+ end
27
+
28
+ def remove_package(name, version)
29
+ versions = @packages[name]
30
+ return if not versions
31
+
32
+ versions.delete(version)
33
+
34
+ return
35
+ end
36
+ end
@@ -0,0 +1,46 @@
1
+ module Fig; end
2
+
3
+ # Parsed representation of a package name:config/version.
4
+ class Fig::PackageDescriptor
5
+ include Comparable
6
+
7
+ DEFAULT_CONFIG = 'default'
8
+
9
+ attr_reader :name, :version, :config
10
+
11
+ def self.parse(raw_string)
12
+ self.new(
13
+ raw_string =~ %r< ^ ( [^:/]+ ) >x ? $1 : nil,
14
+ raw_string =~ %r< / ( [^:/]+ ) >x ? $1 : nil,
15
+ raw_string =~ %r< : ( [^:/]+ ) >x ? $1 : nil
16
+ )
17
+ end
18
+
19
+ def initialize(name, version, config)
20
+ @name = name
21
+ @version = version
22
+ @config = config
23
+ end
24
+
25
+ def to_string(use_default_config = false)
26
+ string = @name || ''
27
+
28
+ if @version
29
+ string += '/'
30
+ string += @version
31
+ end
32
+
33
+ if @config
34
+ string += ':'
35
+ string += @config
36
+ elsif use_default_config
37
+ string += ':default'
38
+ end
39
+
40
+ return string
41
+ end
42
+
43
+ def <=>(other)
44
+ return to_string() <=> other.to_string()
45
+ end
46
+ end
@@ -32,12 +32,12 @@ module Fig
32
32
  def find_multiple_command_statements(package)
33
33
  command_processed = false
34
34
  package.walk_statements do |statement|
35
- if statement.is_a?(Package::Command)
35
+ if statement.is_a?(Statement::Command)
36
36
  if command_processed == true
37
37
  raise UserInputError.new("Multiple command statements cannot be processed.")
38
38
  end
39
39
  command_processed = true
40
- elsif statement.is_a?(Package::Configuration)
40
+ elsif statement.is_a?(Statement::Configuration)
41
41
  command_processed = false
42
42
  end
43
43
  end
@@ -1,9 +1,10 @@
1
1
  require 'fig/logging'
2
2
  require 'fig/notfounderror'
3
- require 'fig/package/archive'
4
- require 'fig/package/resource'
3
+ require 'fig/packagecache'
5
4
  require 'fig/parser'
6
5
  require 'fig/repositoryerror'
6
+ require 'fig/statement/archive'
7
+ require 'fig/statement/resource'
7
8
  require 'fig/urlaccesserror'
8
9
 
9
10
  module Fig
@@ -14,36 +15,31 @@ module Fig
14
15
  not (/ftp:\/\/|http:\/\/|file:\/\/|ssh:\/\// =~ url).nil?
15
16
  end
16
17
 
17
- def initialize(os, local_repository_dir, remote_repository_url, application_config, remote_repository_user=nil, update=false, update_if_missing=true)
18
- @os = os
18
+ def initialize(
19
+ os,
20
+ local_repository_dir,
21
+ remote_repository_url,
22
+ application_config,
23
+ remote_repository_user = nil,
24
+ update = false,
25
+ update_if_missing = true
26
+ )
27
+ @operating_system = os
19
28
  @local_repository_dir = local_repository_dir
20
29
  @remote_repository_url = remote_repository_url
21
30
  @remote_repository_user = remote_repository_user
22
- @application_config = application_config
23
31
  @update = update
24
32
  @update_if_missing = update_if_missing
25
- @parser = Parser.new(@application_config)
26
-
27
- @overrides = {}
28
- if File.exist?('fig.properties')
29
- File.readlines('fig.properties').each do |line|
30
- descriptor, path = line.strip.split('=')
31
- @overrides[descriptor] = path
32
- end
33
- end
34
- end
35
33
 
36
- def clean(package_name, version_name)
37
- dir = File.join(@local_repository_dir, package_name)
38
- dir = File.join(dir, version_name) if version_name
39
- FileUtils.rm_rf(dir)
34
+ @parser = Parser.new(@application_config)
35
+ @packages = PackageCache.new()
40
36
  end
41
37
 
42
38
  def list_packages
43
39
  results = []
44
40
  if File.exist?(@local_repository_dir)
45
- @os.list(@local_repository_dir).each do |package_name|
46
- @os.list(File.join(@local_repository_dir, package_name)).each do |version_name|
41
+ @operating_system.list(@local_repository_dir).each do |package_name|
42
+ @operating_system.list(File.join(@local_repository_dir, package_name)).each do |version_name|
47
43
  results << "#{package_name}/#{version_name}"
48
44
  end
49
45
  end
@@ -52,84 +48,142 @@ module Fig
52
48
  end
53
49
 
54
50
  def list_remote_packages
55
- @os.download_list(@remote_repository_url)
51
+ @operating_system.download_list(@remote_repository_url)
52
+ end
53
+
54
+ def get_package(package_name, version_name, disable_updating = false)
55
+ package = @packages.get_package(package_name, version_name)
56
+ return package if package
57
+
58
+ Logging.debug "Considering #{package_name}/#{version_name}."
59
+
60
+ if should_update?(package_name, version_name, disable_updating)
61
+ update_package(package_name, version_name)
62
+ end
63
+
64
+ return read_local_package(package_name, version_name)
65
+ end
66
+
67
+ def clean(package_name, version_name)
68
+ @packages.remove_package(package_name, version_name)
69
+
70
+ dir = File.join(@local_repository_dir, package_name)
71
+ dir = File.join(dir, version_name) if version_name
72
+
73
+ FileUtils.rm_rf(dir)
74
+
75
+ return
56
76
  end
57
77
 
58
- def publish_package(package_statements, package_name, version_name, local_only)
78
+ def publish_package(
79
+ package_statements, package_name, version_name, local_only
80
+ )
59
81
  temp_dir = temp_dir_for_package(package_name, version_name)
60
- @os.clear_directory(temp_dir)
82
+ @operating_system.clear_directory(temp_dir)
61
83
  local_dir = local_dir_for_package(package_name, version_name)
62
- @os.clear_directory(local_dir)
84
+ @operating_system.clear_directory(local_dir)
63
85
  fig_file = File.join(temp_dir, '.fig')
64
- content = bundle_resources(package_statements).map do |statement|
65
- if statement.is_a?(Package::Publish)
66
- nil
67
- elsif statement.is_a?(Package::Archive) || statement.is_a?(Package::Resource)
68
- if statement.is_a?(Package::Resource) && !Repository.is_url?(statement.url)
69
- archive_name = statement.url
70
- archive_remote = "#{remote_dir_for_package(package_name, version_name)}/#{statement.url}"
71
- else
72
- archive_name = statement.url.split('/').last
73
- archive_remote = "#{remote_dir_for_package(package_name, version_name)}/#{archive_name}"
74
- end
75
- if Repository.is_url?(statement.url)
76
- archive_local = File.join(temp_dir, archive_name)
77
- @os.download(statement.url, archive_local)
78
- else
79
- archive_local = statement.url
80
- end
81
- @os.upload(archive_local, archive_remote, @remote_repository_user) unless local_only
82
- @os.copy(archive_local, local_dir + '/' + archive_name)
83
- if statement.is_a?(Package::Archive)
84
- @os.unpack_archive(local_dir, archive_name)
85
- end
86
- statement.class.new(archive_name).unparse('')
87
- else
88
- statement.unparse('')
89
- end
90
- end.select {|s|not s.nil?}
91
- @os.write(fig_file, content.join("\n").strip)
92
- @os.upload(fig_file, remote_fig_file_for_package(package_name, version_name), @remote_repository_user) unless local_only
93
- @os.copy(fig_file, local_fig_file_for_package(package_name, version_name))
86
+ content = derive_package_content(
87
+ package_statements, package_name, version_name, local_dir, local_only
88
+ )
89
+ @operating_system.write(fig_file, content.join("\n").strip)
90
+ @operating_system.upload(
91
+ fig_file,
92
+ remote_fig_file_for_package(package_name, version_name),
93
+ @remote_repository_user
94
+ ) unless local_only
95
+ @operating_system.copy(
96
+ fig_file, local_fig_file_for_package(package_name, version_name)
97
+ )
98
+
99
+ FileUtils.rm_rf(temp_dir)
100
+ end
101
+
102
+ def updating?
103
+ return @update || @update_if_missing
104
+ end
105
+
106
+ private
107
+
108
+ def should_update?(package_name, version_name, disable_updating)
109
+ return false if disable_updating
110
+
111
+ return true if @update
112
+
113
+ return @update_if_missing &&
114
+ package_missing?(package_name, version_name)
115
+ end
116
+
117
+ def read_local_package(package_name, version_name)
118
+ dir = local_dir_for_package(package_name, version_name)
119
+ return read_package_from_directory(dir, package_name, version_name)
94
120
  end
95
121
 
96
122
  def bundle_resources(package_statements)
97
123
  resources = []
98
124
  new_package_statements = package_statements.reject do |statement|
99
- if statement.is_a?(Package::Resource) && !Repository.is_url?(statement.url)
125
+ if (
126
+ statement.is_a?(Statement::Resource) &&
127
+ ! Repository.is_url?(statement.url)
128
+ )
100
129
  resources << statement.url
101
130
  true
102
131
  else
103
132
  false
104
133
  end
105
134
  end
135
+
106
136
  if resources.size > 0
107
137
  resources = expand_globs_from(resources)
108
138
  file = 'resources.tar.gz'
109
- @os.create_archive(file, resources)
110
- new_package_statements.unshift(Package::Archive.new(file))
139
+ @operating_system.create_archive(file, resources)
140
+ new_package_statements.unshift(Statement::Archive.new(file))
111
141
  at_exit { File.delete(file) }
112
142
  end
113
- new_package_statements
114
- end
115
143
 
116
- def load_package(package_name, version_name)
117
- Logging.debug "Considering #{package_name}/#{version_name}."
118
- if @update || (@update_if_missing && package_missing?(package_name, version_name))
119
- update_package(package_name, version_name)
120
- end
121
- read_local_package(package_name, version_name)
144
+ return new_package_statements
122
145
  end
123
146
 
124
- def updating?
125
- return @update || @update_if_missing
147
+ def install_package(package_name, version_name)
148
+ temp_dir = nil
149
+
150
+ begin
151
+ package = read_local_package(package_name, version_name)
152
+ temp_dir = temp_dir_for_package(package_name, version_name)
153
+ @operating_system.clear_directory(temp_dir)
154
+ package.archive_urls.each do |archive_url|
155
+ if not Repository.is_url?(archive_url)
156
+ archive_url = remote_dir_for_package(package_name, version_name) + '/' + archive_url
157
+ end
158
+ @operating_system.download_archive(archive_url, File.join(temp_dir))
159
+ end
160
+ package.resource_urls.each do |resource_url|
161
+ if not Repository.is_url?(resource_url)
162
+ resource_url = remote_dir_for_package(package_name, version_name) + '/' + resource_url
163
+ end
164
+ @operating_system.download_resource(resource_url, File.join(temp_dir))
165
+ end
166
+ local_dir = local_dir_for_package(package_name, version_name)
167
+ @operating_system.clear_directory(local_dir)
168
+ # some packages contain no files, only a fig file.
169
+ if not (package.archive_urls.empty? && package.resource_urls.empty?)
170
+ FileUtils.mv(Dir.glob(File.join(temp_dir, '*')), local_dir)
171
+ end
172
+ write_local_package(package_name, version_name, package)
173
+ rescue
174
+ Logging.fatal 'Install failed, cleaning up.'
175
+ delete_local_package(package_name, version_name)
176
+ raise RepositoryError.new
177
+ ensure
178
+ FileUtils.rm_rf(temp_dir)
179
+ end
126
180
  end
127
181
 
128
182
  def update_package(package_name, version_name)
129
183
  remote_fig_file = remote_fig_file_for_package(package_name, version_name)
130
184
  local_fig_file = local_fig_file_for_package(package_name, version_name)
131
185
  begin
132
- if @os.download(remote_fig_file, local_fig_file)
186
+ if @operating_system.download(remote_fig_file, local_fig_file)
133
187
  install_package(package_name, version_name)
134
188
  end
135
189
  rescue NotFoundError
@@ -139,9 +193,11 @@ module Fig
139
193
  end
140
194
  end
141
195
 
142
- def read_local_package(package_name, version_name)
143
- dir = local_dir_for_package(package_name, version_name)
144
- read_package_from_directory(dir, package_name, version_name)
196
+ # 'resources' is an Array of filenames: ['tmp/foo/file1', 'tmp/foo/*.jar']
197
+ def expand_globs_from(resources)
198
+ expanded_files = []
199
+ resources.each {|f| expanded_files.concat(Dir.glob(f))}
200
+ expanded_files
145
201
  end
146
202
 
147
203
  def read_package_from_directory(dir, package_name, version_name)
@@ -150,10 +206,11 @@ module Fig
150
206
  file = File.join(dir, 'package.fig')
151
207
  end
152
208
  if not File.exist?(file)
153
- Logging.fatal "Fig file not found for package: #{file}"
209
+ Logging.fatal %Q<Fig file not found for package "#{package_name || '<unnamed>'}": #{file}>
154
210
  raise RepositoryError.new
155
211
  end
156
- read_package_from_file(file, package_name, version_name)
212
+
213
+ return read_package_from_file(file, package_name, version_name)
157
214
  end
158
215
 
159
216
  def read_package_from_file(file_name, package_name, version_name)
@@ -162,58 +219,14 @@ module Fig
162
219
  raise RepositoryError.new
163
220
  end
164
221
  content = File.read(file_name)
165
- return @parser.parse_package(package_name, version_name, File.dirname(file_name), content)
166
- end
167
-
168
- def local_dir_for_package(package_name, version_name)
169
- descriptor = "#{package_name}/#{version_name}"
170
- dir = @overrides[descriptor]
171
- if dir
172
- Logging.info "override: #{descriptor}=#{dir}"
173
- else
174
- dir = File.join(@local_repository_dir, package_name, version_name)
175
- end
176
- dir
177
- end
178
222
 
179
- private
223
+ package = @parser.parse_package(
224
+ package_name, version_name, File.dirname(file_name), content
225
+ )
180
226
 
181
- def install_package(package_name, version_name)
182
- begin
183
- package = read_local_package(package_name, version_name)
184
- temp_dir = temp_dir_for_package(package_name, version_name)
185
- @os.clear_directory(temp_dir)
186
- package.archive_urls.each do |archive_url|
187
- if not Repository.is_url?(archive_url)
188
- archive_url = remote_dir_for_package(package_name, version_name) + '/' + archive_url
189
- end
190
- @os.download_archive(archive_url, File.join(temp_dir))
191
- end
192
- package.resource_urls.each do |resource_url|
193
- if not Repository.is_url?(resource_url)
194
- resource_url = remote_dir_for_package(package_name, version_name) + '/' + resource_url
195
- end
196
- @os.download_resource(resource_url, File.join(temp_dir))
197
- end
198
- local_dir = local_dir_for_package(package_name, version_name)
199
- @os.clear_directory(local_dir)
200
- # some packages contain no files, only a fig file.
201
- if not (package.archive_urls.empty? && package.resource_urls.empty?)
202
- FileUtils.mv(Dir.glob(File.join(temp_dir, '*')), local_dir)
203
- end
204
- write_local_package(package_name, version_name, package)
205
- rescue
206
- Logging.fatal 'Install failed, cleaning up.'
207
- delete_local_package(package_name, version_name)
208
- raise RepositoryError.new
209
- end
210
- end
227
+ @packages.add_package(package)
211
228
 
212
- # 'resources' is an Array of filenames: ['tmp/foo/file1', 'tmp/foo/*.jar']
213
- def expand_globs_from(resources)
214
- expanded_files = []
215
- resources.each {|f| expanded_files.concat(Dir.glob(f))}
216
- expanded_files
229
+ return package
217
230
  end
218
231
 
219
232
  def delete_local_package(package_name, version_name)
@@ -222,7 +235,7 @@ module Fig
222
235
 
223
236
  def write_local_package(package_name, version_name, package)
224
237
  file = local_fig_file_for_package(package_name, version_name)
225
- @os.write(file, package.unparse)
238
+ @operating_system.write(file, package.unparse)
226
239
  end
227
240
 
228
241
  def remote_fig_file_for_package(package_name, version_name)
@@ -237,6 +250,10 @@ module Fig
237
250
  "#{@remote_repository_url}/#{package_name}/#{version_name}"
238
251
  end
239
252
 
253
+ def local_dir_for_package(package_name, version_name)
254
+ return File.join(@local_repository_dir, package_name, version_name)
255
+ end
256
+
240
257
  def temp_dir_for_package(package_name, version_name)
241
258
  File.join(@local_repository_dir, 'tmp')
242
259
  end
@@ -244,5 +261,37 @@ module Fig
244
261
  def package_missing?(package_name, version_name)
245
262
  not File.exist?(local_fig_file_for_package(package_name, version_name))
246
263
  end
264
+
265
+ def derive_package_content(
266
+ package_statements, package_name, version_name, local_dir, local_only
267
+ )
268
+ return bundle_resources(package_statements).map do |statement|
269
+ if statement.is_a?(Statement::Publish)
270
+ nil
271
+ elsif statement.is_a?(Statement::Archive) || statement.is_a?(Statement::Resource)
272
+ if statement.is_a?(Statement::Resource) && !Repository.is_url?(statement.url)
273
+ archive_name = statement.url
274
+ archive_remote = "#{remote_dir_for_package(package_name, version_name)}/#{statement.url}"
275
+ else
276
+ archive_name = statement.url.split('/').last
277
+ archive_remote = "#{remote_dir_for_package(package_name, version_name)}/#{archive_name}"
278
+ end
279
+ if Repository.is_url?(statement.url)
280
+ archive_local = File.join(temp_dir, archive_name)
281
+ @operating_system.download(statement.url, archive_local)
282
+ else
283
+ archive_local = statement.url
284
+ end
285
+ @operating_system.upload(archive_local, archive_remote, @remote_repository_user) unless local_only
286
+ @operating_system.copy(archive_local, local_dir + '/' + archive_name)
287
+ if statement.is_a?(Statement::Archive)
288
+ @operating_system.unpack_archive(local_dir, archive_name)
289
+ end
290
+ statement.class.new(archive_name).unparse('')
291
+ else
292
+ statement.unparse('')
293
+ end
294
+ end.select { |s|not s.nil? }
295
+ end
247
296
  end
248
297
  end