dump 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +7 -15
  2. data/.rubocop_todo.yml +1 -1
  3. data/Gemfile +6 -1
  4. data/LICENSE.txt +1 -1
  5. data/README.markdown +2 -2
  6. data/dump.gemspec +2 -2
  7. data/lib/dump.rb +86 -2
  8. data/lib/{dump_rake/archive_tar_minitar_fix.rb → dump/archive_tar_minitar.rb} +0 -0
  9. data/lib/{dump_rake → dump}/assets.rb +6 -4
  10. data/lib/dump/capistrano/v2.rb +34 -34
  11. data/lib/{dump_rake → dump}/continious_timeout.rb +1 -1
  12. data/lib/{dump_rake → dump}/env.rb +4 -4
  13. data/lib/{dump_rake → dump}/env/filter.rb +1 -1
  14. data/lib/dump/rails_root.rb +19 -0
  15. data/lib/{dump_rake/dump_reader.rb → dump/reader.rb} +25 -17
  16. data/lib/{dump_rake/dump.rb → dump/snapshot.rb} +9 -5
  17. data/lib/{dump_rake → dump}/table_manipulation.rb +28 -14
  18. data/lib/{dump_rake/dump_writer.rb → dump/writer.rb} +13 -5
  19. data/lib/tasks/assets.rake +4 -4
  20. data/lib/tasks/dump.rake +10 -10
  21. data/script/update_readme +3 -3
  22. data/spec/cycle_spec.rb +78 -84
  23. data/spec/{lib/dump_rake → dump}/env/filter_spec.rb +14 -14
  24. data/spec/dump/env_spec.rb +139 -0
  25. data/spec/{lib/dump_rake → dump}/rails_root_spec.rb +11 -13
  26. data/spec/{lib/dump_rake/dump_reader_spec.rb → dump/reader_spec.rb} +89 -89
  27. data/spec/dump/snapshot_spec.rb +290 -0
  28. data/spec/{lib/dump_rake → dump}/table_manipulation_spec.rb +54 -55
  29. data/spec/{lib/dump_rake/dump_writer_spec.rb → dump/writer_spec.rb} +41 -42
  30. data/spec/dump_spec.rb +327 -0
  31. data/spec/recipes/dump_spec.rb +92 -93
  32. data/spec/spec_helper.rb +0 -3
  33. data/spec/tasks/assets_spec.rb +16 -15
  34. data/spec/tasks/dump_spec.rb +30 -29
  35. metadata +75 -98
  36. data/.autotest +0 -13
  37. data/lib/dump_rake.rb +0 -94
  38. data/lib/dump_rake/rails_root.rb +0 -13
  39. data/spec/lib/dump_rake/dump_spec.rb +0 -289
  40. data/spec/lib/dump_rake/env_spec.rb +0 -139
  41. data/spec/lib/dump_rake_spec.rb +0 -326
  42. data/spec/spec.opts +0 -4
@@ -1,9 +1,6 @@
1
1
  ENV['RAILS_ENV'] ||= 'test'
2
2
 
3
3
  require 'dummy_rails_app'
4
- require 'dump_rake'
5
-
6
- ActiveRecord::Base.logger = Logger.new(File.join(DumpRake::RailsRoot, 'log/dump.log'))
7
4
 
8
5
  def grab_output
9
6
  real_stdout, $stdout = $stdout, StringIO.new
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'dump'
2
3
  require 'rake'
3
4
 
4
5
  describe 'rake assets' do
@@ -9,17 +10,17 @@ describe 'rake assets' do
9
10
  ENV['ASSETS'] = nil
10
11
  end
11
12
 
12
- it "should set ENV['ASSETS'] to paths from config/assets" do
13
+ it "sets ENV['ASSETS'] to paths from config/assets" do
13
14
  data = <<-end_src
14
15
  public/images/a
15
16
  public/images/b
16
17
  end_src
17
- expect(File).to receive(:readlines).with(File.join(DumpRake::RailsRoot, 'config/assets')).and_return(StringIO.new(data).readlines)
18
+ expect(File).to receive(:readlines).with(File.join(Dump.rails_root, 'config/assets')).and_return(StringIO.new(data).readlines)
18
19
  @rake['assets'].invoke
19
20
  expect(ENV['ASSETS']).to eq('public/images/a:public/images/b')
20
21
  end
21
22
 
22
- it 'should ignore comments in config/assets' do
23
+ it 'ignores comments in config/assets' do
23
24
  data = <<-end_src
24
25
  #comment
25
26
  #comment
@@ -31,13 +32,13 @@ describe 'rake assets' do
31
32
  expect(ENV['ASSETS']).to eq('public/images/a:public/images/b')
32
33
  end
33
34
 
34
- it "should not change ENV['ASSETS'] if it already exists" do
35
+ it "does not change ENV['ASSETS'] if it already exists" do
35
36
  data = <<-end_src
36
37
  public/images/a
37
38
  public/images/b
38
39
  end_src
39
40
  allow(File).to receive(:readlines).and_return(StringIO.new(data).readlines)
40
- DumpRake::Env.with_env :assets => 'public/images' do
41
+ Dump::Env.with_env :assets => 'public/images' do
41
42
  @rake['assets'].invoke
42
43
  expect(ENV['ASSETS']).to eq('public/images')
43
44
  end
@@ -48,26 +49,26 @@ describe 'rake assets' do
48
49
  allow(FileUtils).to receive(:remove_entry)
49
50
  end
50
51
 
51
- it 'should require assets task' do
52
+ it 'requires assets task' do
52
53
  expect(@rake['assets:delete'].prerequisites).to include('assets')
53
54
  end
54
55
 
55
56
  describe 'deleting existing assets' do
56
- it 'should go through each asset from config' do
57
+ it 'goes through each asset from config' do
57
58
  allow(ENV).to receive(:[]).with('ASSETS').and_return('images:videos')
58
59
 
59
- expect(File).to receive(:expand_path).with('images', DumpRake::RailsRoot).and_return('')
60
- expect(File).to receive(:expand_path).with('videos', DumpRake::RailsRoot).and_return('')
60
+ expect(File).to receive(:expand_path).with('images', Dump.rails_root).and_return('')
61
+ expect(File).to receive(:expand_path).with('videos', Dump.rails_root).and_return('')
61
62
 
62
63
  @rake['assets:delete'].invoke
63
64
  end
64
65
 
65
- it 'should glob all assets and delete content' do
66
+ it 'globs all assets and deletes content' do
66
67
  @assets = %w[images videos]
67
68
  allow(ENV).to receive(:[]).with('ASSETS').and_return(@assets.join(':'))
68
69
  @assets.each do |asset|
69
- mask = File.join(DumpRake::RailsRoot, asset, '*')
70
- paths = %w[file1 file2 dir].map{ |file| File.join(DumpRake::RailsRoot, asset, file) }
70
+ mask = File.join(Dump.rails_root, asset, '*')
71
+ paths = %w[file1 file2 dir].map{ |file| File.join(Dump.rails_root, asset, file) }
71
72
  expect(Dir).to receive(:[]).with(mask).and_return([paths[0], paths[1], paths[2]])
72
73
  paths.each do |path|
73
74
  expect(FileUtils).to receive(:remove_entry).with(path)
@@ -77,12 +78,12 @@ describe 'rake assets' do
77
78
  @rake['assets:delete'].invoke
78
79
  end
79
80
 
80
- it 'should not glob risky paths' do
81
+ it 'does not glob risky paths' do
81
82
  @assets = %w[images / /private ../ ../.. ./../ dir/.. dir/../..]
82
83
  allow(ENV).to receive(:[]).with('ASSETS').and_return(@assets.join(':'))
83
84
 
84
- expect(Dir).to receive(:[]).with(File.join(DumpRake::RailsRoot, 'images/*')).and_return([])
85
- expect(Dir).to receive(:[]).with(File.join(DumpRake::RailsRoot, '*')).and_return([])
85
+ expect(Dir).to receive(:[]).with(File.join(Dump.rails_root, 'images/*')).and_return([])
86
+ expect(Dir).to receive(:[]).with(File.join(Dump.rails_root, '*')).and_return([])
86
87
  expect(FileUtils).not_to receive(:remove_entry)
87
88
 
88
89
  @rake['assets:delete'].invoke
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'dump'
2
3
  require 'rake'
3
4
 
4
5
  describe 'rake dump' do
@@ -11,7 +12,7 @@ describe 'rake dump' do
11
12
 
12
13
  %w[versions create restore cleanup].each do |task|
13
14
  describe task do
14
- it 'should require environment task' do
15
+ it 'requires environment task' do
15
16
  expect(@rake["dump:#{task}"].prerequisites).to include('environment')
16
17
  end
17
18
  end
@@ -22,16 +23,16 @@ describe 'rake dump' do
22
23
  @task = @rake['dump:versions']
23
24
  end
24
25
 
25
- it 'should call DumpRake.versions' do
26
- expect(DumpRake).to receive(:versions)
26
+ it 'calls Dump.versions' do
27
+ expect(Dump).to receive(:versions)
27
28
  @task.invoke
28
29
  end
29
30
 
30
- DumpRake::Env.variable_names_for_command(:versions) do |variable|
31
- DumpRake::Env::DICTIONARY[variable].each do |name|
32
- it "should pass version if it is set through environment variable #{name}" do
33
- expect(DumpRake).to receive(:versions).with(variable => '21376')
34
- DumpRake::Env.with_env name => '21376' do
31
+ Dump::Env.variable_names_for_command(:versions) do |variable|
32
+ Dump::Env::DICTIONARY[variable].each do |name|
33
+ it "passes version if it is set through environment variable #{name}" do
34
+ expect(Dump).to receive(:versions).with(variable => '21376')
35
+ Dump::Env.with_env name => '21376' do
35
36
  @task.invoke
36
37
  end
37
38
  end
@@ -44,16 +45,16 @@ describe 'rake dump' do
44
45
  @task = @rake['dump:create']
45
46
  end
46
47
 
47
- it 'should call DumpRake.create' do
48
- expect(DumpRake).to receive(:create)
48
+ it 'calls Dump.create' do
49
+ expect(Dump).to receive(:create)
49
50
  @task.invoke
50
51
  end
51
52
 
52
- DumpRake::Env.variable_names_for_command(:create) do |variable|
53
- DumpRake::Env::DICTIONARY[variable].each do |name|
54
- it "should pass description if it is set through environment variable #{name}" do
55
- expect(DumpRake).to receive(:create).with(variable => 'simple dump')
56
- DumpRake::Env.with_env name => 'simple dump' do
53
+ Dump::Env.variable_names_for_command(:create) do |variable|
54
+ Dump::Env::DICTIONARY[variable].each do |name|
55
+ it "passes description if it is set through environment variable #{name}" do
56
+ expect(Dump).to receive(:create).with(variable => 'simple dump')
57
+ Dump::Env.with_env name => 'simple dump' do
57
58
  @task.invoke
58
59
  end
59
60
  end
@@ -66,16 +67,16 @@ describe 'rake dump' do
66
67
  @task = @rake['dump:restore']
67
68
  end
68
69
 
69
- it 'should call DumpRake.restore' do
70
- expect(DumpRake).to receive(:restore)
70
+ it 'calls Dump.restore' do
71
+ expect(Dump).to receive(:restore)
71
72
  @task.invoke
72
73
  end
73
74
 
74
- DumpRake::Env.variable_names_for_command(:restore) do |variable|
75
- DumpRake::Env::DICTIONARY[variable].each do |name|
76
- it "should pass version if it is set through environment variable #{name}" do
77
- expect(DumpRake).to receive(:restore).with(variable => '21378')
78
- DumpRake::Env.with_env name => '21378' do
75
+ Dump::Env.variable_names_for_command(:restore) do |variable|
76
+ Dump::Env::DICTIONARY[variable].each do |name|
77
+ it "passes version if it is set through environment variable #{name}" do
78
+ expect(Dump).to receive(:restore).with(variable => '21378')
79
+ Dump::Env.with_env name => '21378' do
79
80
  @task.invoke
80
81
  end
81
82
  end
@@ -88,16 +89,16 @@ describe 'rake dump' do
88
89
  @task = @rake['dump:cleanup']
89
90
  end
90
91
 
91
- it 'should call DumpRake.cleanup' do
92
- expect(DumpRake).to receive(:cleanup)
92
+ it 'calls Dump.cleanup' do
93
+ expect(Dump).to receive(:cleanup)
93
94
  @task.invoke
94
95
  end
95
96
 
96
- DumpRake::Env.variable_names_for_command(:cleanup) do |variable|
97
- DumpRake::Env::DICTIONARY[variable].each do |name|
98
- it "should pass number of dumps to leave if it is set through environment variable #{name}" do
99
- expect(DumpRake).to receive(:versions).with(variable => '21376')
100
- DumpRake::Env.with_env name => '21376' do
97
+ Dump::Env.variable_names_for_command(:cleanup) do |variable|
98
+ Dump::Env::DICTIONARY[variable].each do |name|
99
+ it "passes number of dumps to leave if it is set through environment variable #{name}" do
100
+ expect(Dump).to receive(:versions).with(variable => '21376')
101
+ Dump::Env.with_env name => '21376' do
101
102
  @task.invoke
102
103
  end
103
104
  end
metadata CHANGED
@@ -1,78 +1,57 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: dump
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.5
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.6
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Ivan Kuchin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-08 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
11
+
12
+ date: 2015-01-15 00:00:00 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
14
15
  name: archive-tar-minitar
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '='
18
- - !ruby/object:Gem::Version
19
- version: 0.5.2
20
- type: :runtime
21
16
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '='
25
- - !ruby/object:Gem::Version
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "="
20
+ - !ruby/object:Gem::Version
26
21
  version: 0.5.2
27
- - !ruby/object:Gem::Dependency
28
- name: progress
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: 2.4.0
34
22
  type: :runtime
23
+ version_requirements: *id001
24
+ - !ruby/object:Gem::Dependency
25
+ name: progress
35
26
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
27
+ requirement: &id002 !ruby/object:Gem::Requirement
28
+ requirements:
38
29
  - - ~>
39
- - !ruby/object:Gem::Version
40
- version: 2.4.0
41
- - !ruby/object:Gem::Dependency
30
+ - &id003 !ruby/object:Gem::Version
31
+ version: "3.0"
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 3.0.1
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
42
38
  name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ~>
46
- - !ruby/object:Gem::Version
47
- version: '3.0'
48
- type: :development
49
39
  prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: '3.0'
55
- - !ruby/object:Gem::Dependency
56
- name: rubocop
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
40
+ requirement: &id004 !ruby/object:Gem::Requirement
41
+ requirements:
59
42
  - - ~>
60
- - !ruby/object:Gem::Version
61
- version: '0.27'
43
+ - *id003
62
44
  type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ~>
67
- - !ruby/object:Gem::Version
68
- version: '0.27'
45
+ version_requirements: *id004
69
46
  description:
70
47
  email:
71
48
  executables: []
49
+
72
50
  extensions: []
51
+
73
52
  extra_rdoc_files: []
74
- files:
75
- - .autotest
53
+
54
+ files:
76
55
  - .gitignore
77
56
  - .rubocop.yml
78
57
  - .rubocop_todo.yml
@@ -83,20 +62,19 @@ files:
83
62
  - README.markdown
84
63
  - dump.gemspec
85
64
  - lib/dump.rb
65
+ - lib/dump/archive_tar_minitar.rb
66
+ - lib/dump/assets.rb
86
67
  - lib/dump/capistrano.rb
87
68
  - lib/dump/capistrano/v2.rb
69
+ - lib/dump/continious_timeout.rb
70
+ - lib/dump/env.rb
71
+ - lib/dump/env/filter.rb
72
+ - lib/dump/rails_root.rb
88
73
  - lib/dump/railtie.rb
89
- - lib/dump_rake.rb
90
- - lib/dump_rake/archive_tar_minitar_fix.rb
91
- - lib/dump_rake/assets.rb
92
- - lib/dump_rake/continious_timeout.rb
93
- - lib/dump_rake/dump.rb
94
- - lib/dump_rake/dump_reader.rb
95
- - lib/dump_rake/dump_writer.rb
96
- - lib/dump_rake/env.rb
97
- - lib/dump_rake/env/filter.rb
98
- - lib/dump_rake/rails_root.rb
99
- - lib/dump_rake/table_manipulation.rb
74
+ - lib/dump/reader.rb
75
+ - lib/dump/snapshot.rb
76
+ - lib/dump/table_manipulation.rb
77
+ - lib/dump/writer.rb
100
78
  - lib/generators/assets_config/assets_config_generator.rb
101
79
  - lib/generators/assets_config/templates/assets
102
80
  - lib/tasks/assets.rake
@@ -220,45 +198,45 @@ files:
220
198
  - spec/dummy-4.1/db/seeds.rb
221
199
  - spec/dummy-4.1/log/.keep
222
200
  - spec/dummy_rails_app.rb
223
- - spec/lib/dump_rake/dump_reader_spec.rb
224
- - spec/lib/dump_rake/dump_spec.rb
225
- - spec/lib/dump_rake/dump_writer_spec.rb
226
- - spec/lib/dump_rake/env/filter_spec.rb
227
- - spec/lib/dump_rake/env_spec.rb
228
- - spec/lib/dump_rake/rails_root_spec.rb
229
- - spec/lib/dump_rake/table_manipulation_spec.rb
230
- - spec/lib/dump_rake_spec.rb
201
+ - spec/dump/env/filter_spec.rb
202
+ - spec/dump/env_spec.rb
203
+ - spec/dump/rails_root_spec.rb
204
+ - spec/dump/reader_spec.rb
205
+ - spec/dump/snapshot_spec.rb
206
+ - spec/dump/table_manipulation_spec.rb
207
+ - spec/dump/writer_spec.rb
208
+ - spec/dump_spec.rb
231
209
  - spec/recipes/dump_spec.rb
232
- - spec/spec.opts
233
210
  - spec/spec_helper.rb
234
211
  - spec/tasks/assets_spec.rb
235
212
  - spec/tasks/dump_spec.rb
236
213
  homepage: http://github.com/toy/dump
237
- licenses:
214
+ licenses:
238
215
  - MIT
239
216
  metadata: {}
217
+
240
218
  post_install_message:
241
219
  rdoc_options: []
242
- require_paths:
220
+
221
+ require_paths:
243
222
  - lib
244
- required_ruby_version: !ruby/object:Gem::Requirement
245
- requirements:
246
- - - ! '>='
247
- - !ruby/object:Gem::Version
248
- version: '0'
249
- required_rubygems_version: !ruby/object:Gem::Requirement
250
- requirements:
251
- - - ! '>='
252
- - !ruby/object:Gem::Version
253
- version: '0'
223
+ required_ruby_version: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - &id005
226
+ - ">="
227
+ - !ruby/object:Gem::Version
228
+ version: "0"
229
+ required_rubygems_version: !ruby/object:Gem::Requirement
230
+ requirements:
231
+ - *id005
254
232
  requirements: []
233
+
255
234
  rubyforge_project: dump
256
235
  rubygems_version: 2.4.4
257
236
  signing_key:
258
237
  specification_version: 4
259
- summary: Rails app rake and capistrano tasks to create and restore dumps of database
260
- and assets
261
- test_files:
238
+ summary: Rails app rake and capistrano tasks to create and restore dumps of database and assets
239
+ test_files:
262
240
  - spec/cycle_spec.rb
263
241
  - spec/db/database.example.yml
264
242
  - spec/db/schema.rb
@@ -374,16 +352,15 @@ test_files:
374
352
  - spec/dummy-4.1/db/seeds.rb
375
353
  - spec/dummy-4.1/log/.keep
376
354
  - spec/dummy_rails_app.rb
377
- - spec/lib/dump_rake/dump_reader_spec.rb
378
- - spec/lib/dump_rake/dump_spec.rb
379
- - spec/lib/dump_rake/dump_writer_spec.rb
380
- - spec/lib/dump_rake/env/filter_spec.rb
381
- - spec/lib/dump_rake/env_spec.rb
382
- - spec/lib/dump_rake/rails_root_spec.rb
383
- - spec/lib/dump_rake/table_manipulation_spec.rb
384
- - spec/lib/dump_rake_spec.rb
355
+ - spec/dump/env/filter_spec.rb
356
+ - spec/dump/env_spec.rb
357
+ - spec/dump/rails_root_spec.rb
358
+ - spec/dump/reader_spec.rb
359
+ - spec/dump/snapshot_spec.rb
360
+ - spec/dump/table_manipulation_spec.rb
361
+ - spec/dump/writer_spec.rb
362
+ - spec/dump_spec.rb
385
363
  - spec/recipes/dump_spec.rb
386
- - spec/spec.opts
387
364
  - spec/spec_helper.rb
388
365
  - spec/tasks/assets_spec.rb
389
366
  - spec/tasks/dump_spec.rb
data/.autotest DELETED
@@ -1,13 +0,0 @@
1
- Autotest.add_hook :reset do |at|
2
- at.clear_mappings
3
- at.add_mapping(%r%^(([^/]+)/.*)\.(?:rb|rake)$%) { |filename, m|
4
- if m[2] == 'spec'
5
- filename
6
- else
7
- at.files_matching(%r%^spec\/#{Regexp.escape(m[1])}_spec.rb%)
8
- end
9
- }
10
- at.add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) {
11
- at.files_matching %r%^spec/.*_spec\.rb$%
12
- }
13
- end