Skip to content

Commit

Permalink
Ruby compatability: only 1.9.3+ have chmod_R string modes
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyates committed Jun 12, 2012
1 parent 9e61f4e commit d6d800a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: ruby
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
script: "bundle exec rake spec"

6 changes: 4 additions & 2 deletions lib/imap/backup/serializer/directory.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8
require 'fileutils'

module Imap
module Backup
Expand All @@ -9,8 +10,9 @@ class Directory

def initialize(path, folder)
@path, @folder = path, folder
check_permissions(@path, 0700)
make_folder(@path, @folder, 'g-wrx,o-wrx')
permissions = 0700
check_permissions(@path, permissions)
make_folder(@path, @folder, permissions)
end

def uids
Expand Down
5 changes: 3 additions & 2 deletions lib/imap/backup/utils.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'fileutils'

module Imap
Expand All @@ -17,9 +18,9 @@ def make_folder(base_path, path, permissions)
parts = path.split('/')
return if parts.size == 0
full_path = File.join(base_path, path)
FileUtils.mkdir_p(full_path)
FileUtils.mkdir_p full_path
first_directory = File.join(base_path, parts[0])
FileUtils.chmod_R(permissions, first_directory)
FileUtils.chmod permissions, first_directory
end

private
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/serializer/directory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
stat = stub('File::Stat', :mode => 0700)
File.stub!(:stat).with('/base/path').and_return(stat)
FileUtils.stub!(:mkdir_p).with('/base/path/my_folder')
FileUtils.stub!(:chmod_R).with('g-wrx,o-wrx', '/base/path/my_folder')
FileUtils.stub!(:chmod).with(0700, '/base/path/my_folder')
end

subject { Imap::Backup::Serializer::Directory.new('/base/path', 'my_folder') }
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
end

it 'should create the path' do
FileUtils.stub!(:chmod_R)
FileUtils.stub!(:chmod)

FileUtils.should_receive(:mkdir_p).with('/base/path/new/folder')

Expand All @@ -62,7 +62,7 @@
it 'should set permissions on the path' do
FileUtils.stub!(:mkdir_p)

FileUtils.should_receive(:chmod_R).with(0222, '/base/path/new')
FileUtils.should_receive(:chmod).with(0222, '/base/path/new')

make_folder('/base/path', 'new/folder', 0222)
end
Expand Down

0 comments on commit d6d800a

Please sign in to comment.