Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add specific installation modes for gzip and bzip2 compression.

Fix LoginSystem spec again as well.
  • Loading branch information...
commit 47770824527c982e2ed8e788b8fe2d1071aad7c3 1 parent e70f3b6
Sean Cribbs seancribbs authored
1  CHANGELOG
... ... @@ -1,6 +1,7 @@
1 1 == Change Log
2 2
3 3 === Edge
  4 +* Add specific installation modes for gzip and bzip2 compression. [Sean Cribbs]
4 5 * Added extension installation scripts. [Sean Cribbs]
5 6 * Added find attr to r:if_content and r:unless_content to expand based on
6 7 finding 'any' or 'all' specified parts [Jim Gay]
31 lib/radiant/extension/script.rb
@@ -147,12 +147,39 @@ def unpack
147 147 end
148 148
149 149 class Tarball < Download
  150 + def filename
  151 + "#{self.name}.tar"
  152 + end
  153 +
150 154 def unpack
151   - packed = filename =~ /gz/ ? 'z' : ''
152   - output = `cd #{Dir.tmpdir}; tar xvf#{packed} #{filename}`
  155 + output = `cd #{Dir.tmpdir}; tar xvf #{filename}`
153 156 self.path = File.join(Dir.tmpdir, output.split(/\n/).first.split('/').first)
154 157 end
155 158 end
  159 +
  160 + class Gzip < Tarball
  161 + def filename
  162 + @unpacked ? super : "#{self.name}.tar.gz"
  163 + end
  164 +
  165 + def unpack
  166 + system "cd #{Dir.tmpdir}; gunzip #{self.filename}"
  167 + @unpacked = true
  168 + super
  169 + end
  170 + end
  171 +
  172 + class Bzip2 < Tarball
  173 + def filename
  174 + @unpacked ? super : "#{self.name}.tar.bz2"
  175 + end
  176 +
  177 + def unpack
  178 + system "cd #{Dir.tmpdir}; bunzip2 #{self.filename}"
  179 + @unpacked = true
  180 + super
  181 + end
  182 + end
156 183
157 184 class Zip < Download
158 185 def unpack
2  spec/lib/login_system_spec.rb
@@ -37,7 +37,7 @@ def method_missing(method, *args, &block)
37 37
38 38 it "should store location" do
39 39 get 'protected_action'
40   - session[:return_to].should match(/login_required\/protected_action/)
  40 + session[:return_to].should match(%r{stub_controller/login_required_controller_\d/protected_action})
41 41 end
42 42 end
43 43
38 spec/lib/radiant/extension/script_spec.rb
@@ -300,24 +300,46 @@
300 300
301 301 describe "Registry::Tarball" do
302 302 before :each do
303   - @extension = mock("Extension", :name => 'example', :download_url => 'http://localhost/example-1.0.0.tar.gz')
  303 + @extension = mock("Extension", :name => 'example', :download_url => 'http://localhost/example-1.0.0.tar')
304 304 @tar = Registry::Tarball.new(@extension)
305 305 end
306 306
307   - it "should unpack the tarball with compression" do
308   - @tar.should_receive(:`).with(/tar xvfz example-1.0.0.tar.gz/).and_return('example-1.0.0/example_extension.rb\n')
  307 + it "should unpack the tarball without compression" do
  308 + @tar.should_receive(:`).with(/tar xvf example.tar/).and_return('example-1.0.0/example_extension.rb\n')
309 309 @tar.unpack
310 310 @tar.path.should =~ /example-1\.0\.0$/
311 311 end
  312 +end
312 313
313   - it "should unpack the tarball without compression" do
314   - @tar.url = @tar.url.sub(/.gz$/, '')
315   - @tar.should_receive(:`).with(/tar xvf example-1.0.0.tar/).and_return('example-1.0.0/example_extension.rb\n')
316   - @tar.unpack
317   - @tar.path.should =~ /example-1\.0\.0$/
  314 +describe "Registry::Gzip" do
  315 + before :each do
  316 + @extension = mock("Extension", :name => 'example', :download_url => 'http://localhost/example-1.0.0.tar.gz')
  317 + @gzip = Registry::Gzip.new(@extension)
  318 + end
  319 +
  320 + it "should unpack the archive with compression" do
  321 + @gzip.should_receive(:system).with(/gunzip example.tar.gz/)
  322 + @gzip.should_receive(:`).with(/tar xvf example.tar/).and_return('example-1.0.0/example_extension.rb\n')
  323 + @gzip.unpack
  324 + @gzip.path.should =~ /example-1\.0\.0$/
  325 + end
  326 +end
  327 +
  328 +describe "Registry::Bzip2" do
  329 + before :each do
  330 + @extension = mock("Extension", :name => 'example', :download_url => 'http://localhost/example-1.0.0.tar.bz2')
  331 + @gzip = Registry::Bzip2.new(@extension)
  332 + end
  333 +
  334 + it "should unpack the archive with compression" do
  335 + @gzip.should_receive(:system).with(/bunzip2 example.tar.bz2/)
  336 + @gzip.should_receive(:`).with(/tar xvf example.tar/).and_return('example-1.0.0/example_extension.rb\n')
  337 + @gzip.unpack
  338 + @gzip.path.should =~ /example-1\.0\.0$/
318 339 end
319 340 end
320 341
  342 +
321 343 describe "Registry::Zip" do
322 344 before :each do
323 345 @extension = mock("Extension", :name => 'example', :download_url => 'http://localhost/example-1.0.0.zip')

0 comments on commit 4777082

Please sign in to comment.
Something went wrong with that request. Please try again.