Permalink
Browse files

Add specific installation modes for gzip and bzip2 compression.

Fix LoginSystem spec again as well.
  • Loading branch information...
1 parent e70f3b6 commit 47770824527c982e2ed8e788b8fe2d1071aad7c3 @seancribbs seancribbs committed Jul 20, 2008
Showing with 61 additions and 11 deletions.
  1. +1 −0 CHANGELOG
  2. +29 −2 lib/radiant/extension/script.rb
  3. +1 −1 spec/lib/login_system_spec.rb
  4. +30 −8 spec/lib/radiant/extension/script_spec.rb
View
1 CHANGELOG
@@ -1,6 +1,7 @@
== Change Log
=== Edge
+* Add specific installation modes for gzip and bzip2 compression. [Sean Cribbs]
* Added extension installation scripts. [Sean Cribbs]
* Added find attr to r:if_content and r:unless_content to expand based on
finding 'any' or 'all' specified parts [Jim Gay]
View
31 lib/radiant/extension/script.rb
@@ -147,12 +147,39 @@ def unpack
end
class Tarball < Download
+ def filename
+ "#{self.name}.tar"
+ end
+
def unpack
- packed = filename =~ /gz/ ? 'z' : ''
- output = `cd #{Dir.tmpdir}; tar xvf#{packed} #{filename}`
+ output = `cd #{Dir.tmpdir}; tar xvf #{filename}`
self.path = File.join(Dir.tmpdir, output.split(/\n/).first.split('/').first)
end
end
+
+ class Gzip < Tarball
+ def filename
+ @unpacked ? super : "#{self.name}.tar.gz"
+ end
+
+ def unpack
+ system "cd #{Dir.tmpdir}; gunzip #{self.filename}"
+ @unpacked = true
+ super
+ end
+ end
+
+ class Bzip2 < Tarball
+ def filename
+ @unpacked ? super : "#{self.name}.tar.bz2"
+ end
+
+ def unpack
+ system "cd #{Dir.tmpdir}; bunzip2 #{self.filename}"
+ @unpacked = true
+ super
+ end
+ end
class Zip < Download
def unpack
View
2 spec/lib/login_system_spec.rb
@@ -37,7 +37,7 @@ def method_missing(method, *args, &block)
it "should store location" do
get 'protected_action'
- session[:return_to].should match(/login_required\/protected_action/)
+ session[:return_to].should match(%r{stub_controller/login_required_controller_\d/protected_action})
end
end
View
38 spec/lib/radiant/extension/script_spec.rb
@@ -300,24 +300,46 @@
describe "Registry::Tarball" do
before :each do
- @extension = mock("Extension", :name => 'example', :download_url => 'http://localhost/example-1.0.0.tar.gz')
+ @extension = mock("Extension", :name => 'example', :download_url => 'http://localhost/example-1.0.0.tar')
@tar = Registry::Tarball.new(@extension)
end
- it "should unpack the tarball with compression" do
- @tar.should_receive(:`).with(/tar xvfz example-1.0.0.tar.gz/).and_return('example-1.0.0/example_extension.rb\n')
+ it "should unpack the tarball without compression" do
+ @tar.should_receive(:`).with(/tar xvf example.tar/).and_return('example-1.0.0/example_extension.rb\n')
@tar.unpack
@tar.path.should =~ /example-1\.0\.0$/
end
+end
- it "should unpack the tarball without compression" do
- @tar.url = @tar.url.sub(/.gz$/, '')
- @tar.should_receive(:`).with(/tar xvf example-1.0.0.tar/).and_return('example-1.0.0/example_extension.rb\n')
- @tar.unpack
- @tar.path.should =~ /example-1\.0\.0$/
+describe "Registry::Gzip" do
+ before :each do
+ @extension = mock("Extension", :name => 'example', :download_url => 'http://localhost/example-1.0.0.tar.gz')
+ @gzip = Registry::Gzip.new(@extension)
+ end
+
+ it "should unpack the archive with compression" do
+ @gzip.should_receive(:system).with(/gunzip example.tar.gz/)
+ @gzip.should_receive(:`).with(/tar xvf example.tar/).and_return('example-1.0.0/example_extension.rb\n')
+ @gzip.unpack
+ @gzip.path.should =~ /example-1\.0\.0$/
+ end
+end
+
+describe "Registry::Bzip2" do
+ before :each do
+ @extension = mock("Extension", :name => 'example', :download_url => 'http://localhost/example-1.0.0.tar.bz2')
+ @gzip = Registry::Bzip2.new(@extension)
+ end
+
+ it "should unpack the archive with compression" do
+ @gzip.should_receive(:system).with(/bunzip2 example.tar.bz2/)
+ @gzip.should_receive(:`).with(/tar xvf example.tar/).and_return('example-1.0.0/example_extension.rb\n')
+ @gzip.unpack
+ @gzip.path.should =~ /example-1\.0\.0$/
end
end
+
describe "Registry::Zip" do
before :each do
@extension = mock("Extension", :name => 'example', :download_url => 'http://localhost/example-1.0.0.zip')

0 comments on commit 4777082

Please sign in to comment.