prlbackup 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,126 @@
1
+ require 'spec_helper'
2
+
3
+ module PrlBackup
4
+ class Foo
5
+ include PrlBackup
6
+ end
7
+
8
+ describe '#command!' do
9
+ before do
10
+ @foo = Foo.new
11
+ @foo.stub(:command).and_return('')
12
+ @foo.stub_chain(:logger, :info)
13
+ end
14
+
15
+ context 'without option --dry-run' do
16
+ before do
17
+ PrlBackup.stub(:config).and_return({:dry_run => false})
18
+ end
19
+
20
+ it 'should run the command' do
21
+ @foo.should_receive(:command).with('hello', 'world')
22
+ @foo.command!('hello', 'world')
23
+ end
24
+
25
+ it 'should return stdout from command' do
26
+ @foo.stub(:command).and_return("hello\nworld")
27
+ @foo.command!.should eql("hello\nworld")
28
+ end
29
+
30
+ it 'should log the last stdout line' do
31
+ @foo.stub(:command).and_return("first line\nlast line")
32
+ @foo.logger.should_receive(:info).with('last line')
33
+ @foo.command!
34
+ end
35
+ end
36
+
37
+ context 'with option --dry run' do
38
+ before do
39
+ PrlBackup.stub(:config).and_return({:dry_run => true})
40
+ end
41
+
42
+ it 'should not run the command' do
43
+ @foo.should_not_receive(:command)
44
+ @foo.command!
45
+ end
46
+
47
+ it 'should return a blank string' do
48
+ @foo.command!.should eql('')
49
+ end
50
+ end
51
+
52
+ context 'with options --dry-run and --verbose' do
53
+ before do
54
+ PrlBackup.stub(:config).and_return({:dry_run => true, :verbose => true})
55
+ end
56
+
57
+ it 'should log which command would be running' do
58
+ @foo.logger.should_receive(:info).with('Running `some command`...')
59
+ @foo.command!('some', 'command')
60
+ end
61
+ end
62
+ end
63
+
64
+ # describe '#command' do
65
+ # before do
66
+ # @foo = Foo.new
67
+ # @pid = double('pid')
68
+ # @stdin = double('stdin')
69
+ # @stdout = double('stdout', :read => "")
70
+ # @stderr = double('stderr')
71
+ # @status = double('status')
72
+ # @status.stub(:success?).and_return(true)
73
+ # @popen4_return = [@pid, @stdin, @stdout, @stderr]
74
+ # @waitpid2_return = [nil, @status]
75
+ # Open4.stub(:popen4).and_return(@popen4_return)
76
+ # Process.stub(:waitpid2).and_return(@waitpid2_return)
77
+ # PrlBackup.stub(:config).and_return({:verbose => false})
78
+ # end
79
+ #
80
+ # it 'should run a command and wait for it' do
81
+ # Open4.should_receive(:popen4).with('hello', 'world').and_return(@popen4_return)
82
+ # Process::should_receive(:waitpid2).with(@pid).and_return(@waitpid2_return)
83
+ # @foo.command('hello', 'world')
84
+ # end
85
+ #
86
+ # it 'should read and return the stdout' do
87
+ # @stdout.stub(:read).and_return('hello')
88
+ # @foo.command("ruby -e 'puts %q{hello}'").should eql('hello')
89
+ # end
90
+ #
91
+ # context 'with a failing command' do
92
+ # before do
93
+ # @foo.stub(:exit)
94
+ # @foo.stub_chain(:logger, :error)
95
+ # @status.stub(:success?).and_return(false)
96
+ # @stdout.stub(:read).and_return('stdout')
97
+ # @stderr.stub(:read).and_return('stderr')
98
+ # @status.stub(:exitstatus).and_return(42)
99
+ # end
100
+ #
101
+ # it 'should log failing commands' do
102
+ # @foo.logger.should_receive(:error).with("Command `some command` failed with exit status 42:\nstdoutstderr")
103
+ # output = @foo.command('some', 'command')
104
+ # end
105
+ #
106
+ # it 'should exit immediately' do
107
+ # @foo.should_receive(:exit).with(1)
108
+ # @foo.command('some', 'command')
109
+ # end
110
+ # end
111
+ # end
112
+
113
+ describe '#logger' do
114
+ before do
115
+ @logger = double('logger')
116
+ @logger.stub(:formatter=)
117
+ Logger.stub(:new).and_return(@logger)
118
+ @foo = Foo.new
119
+ end
120
+
121
+ it 'should initialize a new logger' do
122
+ Logger.should_receive(:new).with(STDOUT).and_return(@logger)
123
+ @foo.logger
124
+ end
125
+ end
126
+ end
@@ -0,0 +1 @@
1
+ require 'prlbackup'
metadata ADDED
@@ -0,0 +1,213 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: prlbackup
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Björn Albers
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-01 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mixlib-cli
16
+ requirement: &70172014685200 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70172014685200
25
+ - !ruby/object:Gem::Dependency
26
+ name: gem-man
27
+ requirement: &70172014682100 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.3.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70172014682100
36
+ - !ruby/object:Gem::Dependency
37
+ name: cucumber
38
+ requirement: &70172014679660 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 1.1.4
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70172014679660
47
+ - !ruby/object:Gem::Dependency
48
+ name: aruba
49
+ requirement: &70172014677460 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.4.11
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70172014677460
58
+ - !ruby/object:Gem::Dependency
59
+ name: aruba-doubles
60
+ requirement: &70172014675380 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 1.2.1
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70172014675380
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-cucumber
71
+ requirement: &70172014672880 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: 0.7.5
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70172014672880
80
+ - !ruby/object:Gem::Dependency
81
+ name: guard-rspec
82
+ requirement: &70172014667540 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: 0.5.1
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70172014667540
91
+ - !ruby/object:Gem::Dependency
92
+ name: guard-ronn
93
+ requirement: &70172014666160 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: 0.1.2
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *70172014666160
102
+ - !ruby/object:Gem::Dependency
103
+ name: ronn
104
+ requirement: &70172014664800 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 0.7.3
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *70172014664800
113
+ - !ruby/object:Gem::Dependency
114
+ name: rake
115
+ requirement: &70172014663740 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: *70172014663740
124
+ - !ruby/object:Gem::Dependency
125
+ name: rb-fsevent
126
+ requirement: &70172014662460 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: 0.9.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: *70172014662460
135
+ description: ! 'prlbackup simplifies the backup of one or multiple Virtual Machines
136
+
137
+ (VM) running on Parallels Server by stoping them during backup and
138
+
139
+ deleting old backups on demand.'
140
+ email:
141
+ - bjoernalbers@googlemail.com
142
+ executables:
143
+ - prlbackup
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - .gitignore
148
+ - Gemfile
149
+ - Guardfile
150
+ - README.md
151
+ - Rakefile
152
+ - bin/prlbackup
153
+ - features/cleanup.feature
154
+ - features/create_backups.feature
155
+ - features/dev_steps.feature
156
+ - features/logging.feature
157
+ - features/steps/dev_steps.rb
158
+ - features/support/env.rb
159
+ - lib/prlbackup.rb
160
+ - lib/prlbackup/cli.rb
161
+ - lib/prlbackup/version.rb
162
+ - lib/prlbackup/virtual_machine.rb
163
+ - man/prlbackup
164
+ - man/prlbackup.1
165
+ - man/prlbackup.1.html
166
+ - man/prlbackup.1.ronn
167
+ - man/prlbackup.html
168
+ - prlbackup.gemspec
169
+ - spec/prlbackup/cli_spec.rb
170
+ - spec/prlbackup/virtual_machine_spec.rb
171
+ - spec/prlbackup_spec.rb
172
+ - spec/spec_helper.rb
173
+ homepage: https://github.com/bjoernalbers/prlbackup
174
+ licenses: []
175
+ post_install_message:
176
+ rdoc_options: []
177
+ require_paths:
178
+ - lib
179
+ required_ruby_version: !ruby/object:Gem::Requirement
180
+ none: false
181
+ requirements:
182
+ - - ! '>='
183
+ - !ruby/object:Gem::Version
184
+ version: '0'
185
+ segments:
186
+ - 0
187
+ hash: -4398640061399519980
188
+ required_rubygems_version: !ruby/object:Gem::Requirement
189
+ none: false
190
+ requirements:
191
+ - - ! '>='
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ segments:
195
+ - 0
196
+ hash: -4398640061399519980
197
+ requirements: []
198
+ rubyforge_project:
199
+ rubygems_version: 1.8.10
200
+ signing_key:
201
+ specification_version: 3
202
+ summary: an awesome backup tool for Parallels Server Virtual Machines
203
+ test_files:
204
+ - features/cleanup.feature
205
+ - features/create_backups.feature
206
+ - features/dev_steps.feature
207
+ - features/logging.feature
208
+ - features/steps/dev_steps.rb
209
+ - features/support/env.rb
210
+ - spec/prlbackup/cli_spec.rb
211
+ - spec/prlbackup/virtual_machine_spec.rb
212
+ - spec/prlbackup_spec.rb
213
+ - spec/spec_helper.rb