rdiff-simple 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +2 -0
- data/lib/rdiff_simple/options_parser.rb +2 -7
- data/lib/rdiff_simple/rdiff_backup.rb +25 -10
- data/lib/rdiff_simple/version.rb +1 -1
- data/lib/rdiff_simple.rb +1 -1
- data/rdiff-simple.gemspec +1 -2
- data/spec/lib/rdiff_simple/options_parser_spec.rb +6 -6
- data/spec/lib/rdiff_simple/rdiff_backup_spec.rb +47 -8
- data/spec/spec_helper.rb +7 -9
- metadata +6 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d970e3aa2acff1a199aae08d11ecbbbef78cd396
|
|
4
|
+
data.tar.gz: 4ca3e46b6106f5cabc1fcce4e5fa07652ae39ef3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6628d830fe10b8065ce6ce9b070caae379365ad425e12e4d28faa25dd0717f4a5f54c8fa5c401841a734f488c39944087a8e61b97c93cbf9771d86fa7483f592
|
|
7
|
+
data.tar.gz: 4fc368e8ea6c7805d2ca1f7faef5b882ffad3ea0576aeafab6d123086826db1c017ea5239c751590199d3ceb32e6d871e9c3ac5279f6ff2d4e3a277cc18eae79
|
data/.gitignore
CHANGED
data/README.md
CHANGED
|
@@ -3,15 +3,10 @@ module RdiffSimple
|
|
|
3
3
|
def self.parse(*args)
|
|
4
4
|
options = args.extract_options!
|
|
5
5
|
|
|
6
|
-
args.
|
|
7
|
-
|
|
8
|
-
source = args.pop
|
|
9
|
-
destination = args.pop
|
|
10
|
-
|
|
11
|
-
flags = args.reverse.map { |flag| flag.size == 1 ? "-#{flag}" : "--#{flag}" } * ' '
|
|
6
|
+
flags = args.map { |flag| flag.size == 1 ? "-#{flag}" : "--#{flag}" } * ' '
|
|
12
7
|
arguments = options.map { |key, value| (key.size == 1 ? "-#{key}" : "--#{key}") + " #{value}" } * ' '
|
|
13
8
|
|
|
14
|
-
"#{flags} #{arguments}
|
|
9
|
+
"#{flags} #{arguments}".dasherize.strip
|
|
15
10
|
end
|
|
16
11
|
end
|
|
17
12
|
end
|
|
@@ -1,20 +1,35 @@
|
|
|
1
|
-
|
|
2
1
|
module RdiffSimple
|
|
3
2
|
class RdiffBackup
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
attr_accessor :logger, :open3
|
|
4
|
+
|
|
5
|
+
def initialize
|
|
6
|
+
yield self if block_given?
|
|
7
|
+
|
|
8
|
+
@open3 ||= Open3
|
|
9
|
+
@logger ||= Logger.new(STDOUT)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def backup(source, destination, *args)
|
|
13
|
+
command_args = OptionsParser.parse *args
|
|
14
|
+
execute "#{command_args} #{source} #{destination}"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def verify(destination)
|
|
18
|
+
verify_at_time destination, "now"
|
|
7
19
|
end
|
|
8
20
|
|
|
9
|
-
def
|
|
10
|
-
|
|
21
|
+
def verify_at_time(destination, time)
|
|
22
|
+
execute "--verify-at-time #{time} #{destination}"
|
|
23
|
+
end
|
|
11
24
|
|
|
12
|
-
|
|
25
|
+
private
|
|
26
|
+
def execute(command)
|
|
27
|
+
output, error, result = open3.capture3 "rdiff-backup #{command}"
|
|
13
28
|
|
|
14
|
-
|
|
15
|
-
|
|
29
|
+
logger.info output unless output.empty?
|
|
30
|
+
logger.error error unless error.empty?
|
|
16
31
|
|
|
17
|
-
|
|
32
|
+
result.exitstatus
|
|
18
33
|
end
|
|
19
34
|
end
|
|
20
35
|
end
|
data/lib/rdiff_simple/version.rb
CHANGED
data/lib/rdiff_simple.rb
CHANGED
data/rdiff-simple.gemspec
CHANGED
|
@@ -24,7 +24,6 @@ Gem::Specification.new do |spec|
|
|
|
24
24
|
spec.add_dependency "activesupport"
|
|
25
25
|
|
|
26
26
|
spec.add_development_dependency "rake"
|
|
27
|
-
spec.add_development_dependency "rspec", "
|
|
27
|
+
spec.add_development_dependency "rspec", ">= 2.0.0"
|
|
28
28
|
spec.add_development_dependency "coveralls"
|
|
29
|
-
spec.add_development_dependency "guard-rspec"
|
|
30
29
|
end
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe RdiffSimple::OptionsParser do
|
|
4
|
-
subject { RdiffSimple::OptionsParser.parse(
|
|
4
|
+
subject { RdiffSimple::OptionsParser.parse(:b, :exclude_other_filesystems, verbosity: 5, exclude: '*.png', r: Date.today) }
|
|
5
5
|
|
|
6
6
|
describe '.parse' do
|
|
7
7
|
it 'converts options to long argument format' do
|
|
8
|
-
expect(subject).to match
|
|
8
|
+
expect(subject).to match /--verbosity/
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
it 'sets value for argument' do
|
|
12
|
-
expect(subject).to match
|
|
12
|
+
expect(subject).to match /--verbosity 5/
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it 'converts symbols to dasherized strings' do
|
|
16
|
-
expect(subject).to match
|
|
16
|
+
expect(subject).to match /--exclude-other-filesystems/
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it 'handles single letter argument' do
|
|
20
|
-
expect(subject).to match
|
|
20
|
+
expect(subject).to match /-b/
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it 'sets value for single letter argument' do
|
|
24
|
-
expect(subject).to match
|
|
24
|
+
expect(subject).to match /-r #{Date.today}/
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
end
|
|
@@ -1,20 +1,59 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe RdiffSimple::RdiffBackup do
|
|
4
|
-
let(:
|
|
4
|
+
let(:source) { '~/Documents' }
|
|
5
|
+
let(:destination) { '~/Test' }
|
|
5
6
|
let(:status) { double('status', exitstatus: Random.rand(100)) }
|
|
6
7
|
let(:open3) { double('open3') }
|
|
7
|
-
let(:
|
|
8
|
+
let(:file) { StringIO.new }
|
|
9
|
+
let(:rdiff) do
|
|
10
|
+
RdiffSimple::RdiffBackup.new do |r|
|
|
11
|
+
r.logger = Logger.new file
|
|
12
|
+
r.open3 = open3
|
|
13
|
+
end
|
|
14
|
+
end
|
|
8
15
|
|
|
9
|
-
|
|
16
|
+
before do
|
|
17
|
+
open3.stub(:capture3).with(args) { ['output', 'error', status] }
|
|
18
|
+
end
|
|
10
19
|
|
|
11
|
-
|
|
12
|
-
before
|
|
13
|
-
expect(open3).to receive(:capture3).with(args) { ['', '', status] }
|
|
14
|
-
end
|
|
20
|
+
shared_examples "a command" do
|
|
21
|
+
before { subject }
|
|
15
22
|
|
|
16
|
-
it 'returns the exit code' do
|
|
23
|
+
it 'and returns the exit code' do
|
|
17
24
|
expect(subject).to eq status.exitstatus
|
|
18
25
|
end
|
|
26
|
+
|
|
27
|
+
it 'and logs the output' do
|
|
28
|
+
expect(file.string).to match /output/
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'and logs any errors' do
|
|
32
|
+
expect(file.string).to match /error/
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe '#backup' do
|
|
37
|
+
let(:args) { "rdiff-backup --exclude-other-filesystems --verbosity 5 --exclude *.png #{source} #{destination}" }
|
|
38
|
+
|
|
39
|
+
subject { rdiff.backup(source, destination, :exclude_other_filesystems, verbosity: 5, exclude: '*.png') }
|
|
40
|
+
|
|
41
|
+
it_behaves_like "a command"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe '#verify' do
|
|
45
|
+
let(:args) { "rdiff-backup --verify-at-time now #{destination}" }
|
|
46
|
+
|
|
47
|
+
subject { rdiff.verify destination }
|
|
48
|
+
|
|
49
|
+
it_behaves_like "a command"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe '#verify_at_time' do
|
|
53
|
+
let(:args) { "rdiff-backup --verify-at-time now #{destination}" }
|
|
54
|
+
|
|
55
|
+
subject { rdiff.verify_at_time destination, 'now' }
|
|
56
|
+
|
|
57
|
+
it_behaves_like "a command"
|
|
19
58
|
end
|
|
20
59
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
require 'bundler/setup'
|
|
2
2
|
|
|
3
|
-
if
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
SimpleCov.start
|
|
10
|
-
end
|
|
3
|
+
if ENV['TRAVIS']
|
|
4
|
+
require 'coveralls'
|
|
5
|
+
Coveralls.wear!
|
|
6
|
+
else
|
|
7
|
+
require 'simplecov'
|
|
8
|
+
SimpleCov.start
|
|
11
9
|
end
|
|
12
10
|
|
|
13
11
|
require 'rdiff_simple'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rdiff-simple
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Hansen
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-
|
|
11
|
+
date: 2013-12-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -40,34 +40,20 @@ dependencies:
|
|
|
40
40
|
version: '0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: rspec
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - ~>
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '2'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - ~>
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '2'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: coveralls
|
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
|
58
44
|
requirements:
|
|
59
45
|
- - '>='
|
|
60
46
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
47
|
+
version: 2.0.0
|
|
62
48
|
type: :development
|
|
63
49
|
prerelease: false
|
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
51
|
requirements:
|
|
66
52
|
- - '>='
|
|
67
53
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
54
|
+
version: 2.0.0
|
|
69
55
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
56
|
+
name: coveralls
|
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
|
72
58
|
requirements:
|
|
73
59
|
- - '>='
|
|
@@ -126,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
126
112
|
version: '0'
|
|
127
113
|
requirements: []
|
|
128
114
|
rubyforge_project:
|
|
129
|
-
rubygems_version: 2.0.
|
|
115
|
+
rubygems_version: 2.0.14
|
|
130
116
|
signing_key:
|
|
131
117
|
specification_version: 4
|
|
132
118
|
summary: A wrapper around the rdiff-backup executable
|