revolt 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -5,10 +5,7 @@ A library for easy managing of Re-Volt's files in various ways.
5
5
  gem install rubyzip
6
6
 
7
7
  == Install
8
- Download the gem:
9
- http://users.tkk.fi/~ajalkane/ruby/revolt-0.5.0.gem
10
- Install it:
11
- gem install revolt-0.5.0.gem
8
+ gem install revolt
12
9
 
13
10
  == Summary
14
11
  For the moment the library mostly has functionality related to
@@ -8,6 +8,7 @@ require 'set'
8
8
 
9
9
  def main
10
10
  @cmd = CmdArguments.new(ARGV)
11
+ ReVolt::Logger.enable if @cmd[:debug]
11
12
 
12
13
  @summary = {
13
14
  :installed => [],
@@ -26,13 +27,15 @@ def main
26
27
  tmplevels.base_path.rmtree
27
28
  tmplevels.create_dir_structure
28
29
 
29
- puts "Enter track URLs to install. Press Ctrl+D to install."
30
- input_open(@cmd[:input]) do |input|
31
- input.each_line do |tracksrc|
32
- tmplevels.install_urls tracksrc
30
+ puts "Enter track URLs to install. Enter '.' on single line or Ctrl+D to install."
31
+ catch :done do
32
+ input_open(@cmd[:input]) do |input|
33
+ input.each_line do |tracksrc|
34
+ throw :done if tracksrc.chomp == '.'
35
+ tmplevels.install_urls tracksrc
36
+ end
33
37
  end
34
38
  end
35
-
36
39
  puts "Installing tracks"
37
40
  tmplevels.each do |level|
38
41
  # Install only levels that do not exist already
@@ -164,6 +167,11 @@ class CmdArguments < Hash
164
167
  opts.separator ""
165
168
  opts.separator "Options:"
166
169
 
170
+ opts.on('-d', '--debug',
171
+ 'Outputs debug information') do
172
+ self[:debug] = true
173
+ end
174
+
167
175
  opts.on('-i', '--input [FILE]',
168
176
  'Reads the URLs from given file') do |value|
169
177
  self[:input] = value
@@ -86,6 +86,17 @@ module ReVolt::Package::Installer
86
86
  # Copy as a temporary file and try to install it
87
87
  tmpfile = ReVolt::Util::tmpdir
88
88
  tmpfile += File.basename(file.to_s)
89
+ tmpfile_ext = tmpfile.extname
90
+ tmpfile_base = tmpfile.basename(tmpfile_ext)
91
+ # If the filename already exists, choose another name
92
+ ndx = 1
93
+ while tmpfile.exist? do
94
+ debug("#{tmpfile} exists")
95
+ tmpfile = Pathname.new(tmpfile_base.to_s + ".#{ndx}" + tmpfile_ext)
96
+ debug("Using target name #{tmpfile}")
97
+ ndx += 1
98
+ end
99
+ # tmpfile += ReVolt::Util::tmpname(file.to_s); # File.basename(file.to_s)
89
100
  browser.copy(file, tmpfile)
90
101
  begin
91
102
  tmp_ids = ReVolt::Package.install_track(tmpfile, rv_target, @args)
data/lib/revolt/util.rb CHANGED
@@ -13,6 +13,10 @@ module ReVolt
13
13
  Pathname.new(Dir.tmpdir)
14
14
  end
15
15
 
16
+ def tmpfile
17
+
18
+ end
19
+
16
20
  def caseinsensitiveglob(glob)
17
21
  glob.downcase.gsub(/[a-z]/) {|m| '['+m.downcase+m.upcase+']' }
18
22
  end
data/lib/revolt.rb CHANGED
@@ -8,5 +8,5 @@ require 'revolt/util/fs_browser'
8
8
  require 'revolt/args'
9
9
 
10
10
  module ReVolt
11
- VERSION = '0.5.1'
11
+ VERSION = '0.5.2'
12
12
  end
data/test/common.rb CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  require 'pathname'
4
4
 
5
+ # Modify path so that the install path has test library as first
6
+ $:.unshift(File.join(File.dirname(__FILE__), '../lib'))
7
+
8
+ puts "Path: #{$:.join(' ')}"
9
+
5
10
  module ReVolt
6
11
  module Test
7
12
  ZIPS = {
@@ -9,6 +14,8 @@ module ReVolt
9
14
  :standard_rev => 'standard_rev_track.zip',
10
15
  :standard_multi => 'standard_multi.zip',
11
16
  :zips_inside => 'zips_inside.zip',
17
+ # Zips inside, same name
18
+ :zips_inside_sn => 'zips_inside_sn.zip',
12
19
  :rickyd_style => 'rickyd_track.zip',
13
20
  :nodirs_style => 'nodirs_track.zip'
14
21
  }
@@ -0,0 +1 @@
1
+
@@ -85,4 +85,38 @@ class LevelInstaller < Test::Unit::TestCase
85
85
  stringify_and_order_structure(ZIPS_IDS[zip_id]))
86
86
  end
87
87
 
88
+ def test_install_zips_same_inside_package
89
+ zip_id = :zips_inside_sn
90
+ f = get_test_file(ZIPS[zip_id])
91
+ # This tests that installing works even with zips inside a zip
92
+ # with the same name as parent zip. Common case with some old tracks.
93
+ ids = @levels.install(f, @output_dir)
94
+ result = installed_tracks
95
+ expect = %w(
96
+ gfx
97
+ gfx/levid.bmp
98
+ gfx/levid.bmq
99
+ gfx/levidrev.bmp
100
+ gfx/levidrev.bmq
101
+ levels
102
+ levels/levid
103
+ levels/levid/levid.inf
104
+ levels/levid/levid.w
105
+ levels/levid/levida.bmp
106
+ levels/levid/readme.txt
107
+ levels/levidrev
108
+ levels/levidrev/levidrev.inf
109
+ levels/levidrev/levidrev.w
110
+ levels/levidrev/levidreva.bmp
111
+ levels/levidrev/readme.txt
112
+ levels/levidrev/reversed
113
+ levels/levidrev/reversed/levidrev.cam
114
+ levels/levidrev/reversed/levidrev.fan
115
+ levels/levidrev/reversed/levidrev.fin
116
+ )
117
+
118
+ assert_equal(stringify_and_order_structure(expect),
119
+ stringify_and_order_structure(result))
120
+ end
121
+
88
122
  end
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/ruby -w
2
2
 
3
- require File.join(File.dirname(__FILE__), '../lib/revolt')
3
+ # require File.join(File.dirname(__FILE__), '../lib/revolt')
4
4
  require File.join(File.dirname(__FILE__), 'common')
5
+ require 'revolt'
5
6
 
6
7
  require 'test/unit'
7
8
  require 'fileutils'
@@ -171,4 +172,41 @@ class PackageTrackInstallerTest < Test::Unit::TestCase
171
172
  assert_equal(stringify_and_order_structure(expect),
172
173
  stringify_and_order_structure(result))
173
174
  end
175
+
176
+ # Zips inside, same name, test for the case that the downloaded
177
+ # packet is extracted to a (temp) directory and extracted having
178
+ # the same name as original.
179
+ def test_zips_same_name_inside_package
180
+ # First copy to tmp dir
181
+ tmpfile = ReVolt::Util::tmpdir + ZIPS[:zips_inside_sn]
182
+ File.copy(get_test_file(ZIPS[:zips_inside_sn]), tmpfile)
183
+ install_track(tmpfile, @output_dir)
184
+ result = installed_tracks
185
+ expect = %w(
186
+ gfx
187
+ gfx/levid.bmp
188
+ gfx/levid.bmq
189
+ gfx/levidrev.bmp
190
+ gfx/levidrev.bmq
191
+ levels
192
+ levels/levid
193
+ levels/levid/levid.inf
194
+ levels/levid/levid.w
195
+ levels/levid/levida.bmp
196
+ levels/levid/readme.txt
197
+ levels/levidrev
198
+ levels/levidrev/levidrev.inf
199
+ levels/levidrev/levidrev.w
200
+ levels/levidrev/levidreva.bmp
201
+ levels/levidrev/readme.txt
202
+ levels/levidrev/reversed
203
+ levels/levidrev/reversed/levidrev.cam
204
+ levels/levidrev/reversed/levidrev.fan
205
+ levels/levidrev/reversed/levidrev.fin
206
+ )
207
+
208
+ assert_equal(stringify_and_order_structure(expect),
209
+ stringify_and_order_structure(result))
210
+ end
211
+
174
212
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: revolt
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.1
7
- date: 2006-09-27 00:00:00 +03:00
6
+ version: 0.5.2
7
+ date: 2006-12-28 00:00:00 +02:00
8
8
  summary: Library for managing Re-Volt game, and some Commandline tools
9
9
  require_paths:
10
10
  - lib
@@ -77,7 +77,12 @@ files:
77
77
  - test/fixtures/files/standard_multi.zip
78
78
  - test/fixtures/files/standard_rev_track.zip
79
79
  - test/fixtures/files/standard_track.zip
80
+ - test/fixtures/files/tmp
80
81
  - test/fixtures/files/zips_inside.zip
82
+ - test/fixtures/files/zips_inside_sn.zip
83
+ - test/fixtures/files/tmp/readme.txt
84
+ - test/fixtures/files/tmp/standard_rev_track.zip
85
+ - test/fixtures/files/tmp/zips_inside_sn.zip
81
86
  - test/fixtures/rv/gfx
82
87
  - test/fixtures/rv/levels
83
88
  - test/fixtures/rv/gfx/levid.bmp