bibliotech 0.1.0
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 +7 -0
- data/bin/bibliotech +5 -0
- data/doc/example_config_file.yml +58 -0
- data/doc/todo.txt +19 -0
- data/lib/bibliotech/application.rb +95 -0
- data/lib/bibliotech/backups/file_record.rb +16 -0
- data/lib/bibliotech/backups/prune_list.rb +58 -0
- data/lib/bibliotech/backups/pruner.rb +71 -0
- data/lib/bibliotech/backups/scheduler.rb +49 -0
- data/lib/bibliotech/builders/database.rb +25 -0
- data/lib/bibliotech/builders/file.rb +75 -0
- data/lib/bibliotech/builders/gzip.rb +51 -0
- data/lib/bibliotech/builders/mysql.rb +35 -0
- data/lib/bibliotech/builders/postgres.rb +37 -0
- data/lib/bibliotech/builders.rb +43 -0
- data/lib/bibliotech/cli.rb +24 -0
- data/lib/bibliotech/command_generator.rb +86 -0
- data/lib/bibliotech/command_runner.rb +36 -0
- data/lib/bibliotech/compression/bzip2.rb +6 -0
- data/lib/bibliotech/compression/gzip.rb +6 -0
- data/lib/bibliotech/compression/sevenzip.rb +5 -0
- data/lib/bibliotech/compression.rb +35 -0
- data/lib/bibliotech/config.rb +269 -0
- data/lib/bibliotech/rake_lib.rb +82 -0
- data/lib/bibliotech.rb +7 -0
- data/spec/bibliotech/backup_pruner_spec.rb +58 -0
- data/spec/bibliotech/backup_scheduler_spec.rb +108 -0
- data/spec/bibliotech/command_generator/mysql_spec.rb +170 -0
- data/spec/bibliotech/command_generator/postgres_spec.rb +180 -0
- data/spec/bibliotech/command_generator_spec.rb +99 -0
- data/spec/bibliotech/command_runner_spec.rb +50 -0
- data/spec/bibliotech/compression/bunzip2_spec.rb +9 -0
- data/spec/bibliotech/compression/bzip2_spec.rb +9 -0
- data/spec/bibliotech/compression/gzip_spec.rb +9 -0
- data/spec/bibliotech/compression/sevenzip_spec.rb +9 -0
- data/spec/bibliotech/compression_spec.rb +28 -0
- data/spec/bibliotech/config_spec.rb +151 -0
- data/spec/gem_test_suite.rb +0 -0
- data/spec/spec_helper.rb +2 -0
- metadata +150 -0
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'valise'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
module BiblioTech
|
5
|
+
describe Config do
|
6
|
+
describe 'initialization' do
|
7
|
+
let :valise do
|
8
|
+
Valise.define do
|
9
|
+
defaults do
|
10
|
+
file "config.yaml", {
|
11
|
+
"database_config_file" => "database.yml",
|
12
|
+
"database_config_env" => "development",
|
13
|
+
}
|
14
|
+
file "database.yml", {
|
15
|
+
"development" =>
|
16
|
+
{ "username" => 'root',
|
17
|
+
"database" => 'dev_db',
|
18
|
+
"adapter" => 'mysql',
|
19
|
+
},
|
20
|
+
"production" =>
|
21
|
+
{ "username" => 'root',
|
22
|
+
"database" => 'prod_db',
|
23
|
+
"adapter" => 'mysql2',
|
24
|
+
}
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
subject :config do
|
31
|
+
BiblioTech::Config.new(valise)
|
32
|
+
end
|
33
|
+
|
34
|
+
context "if the file contains database configs" do
|
35
|
+
context "with default(development) environment" do
|
36
|
+
it "should make the development hash available at config" do
|
37
|
+
expect(config.database).to eql "dev_db"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "with specified environment" do
|
42
|
+
it "should make the string-specified hash available at config" do
|
43
|
+
expect(config.merge("database_config_env" => "production").database).to eql "prod_db"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "when the file contains bad configs" do
|
49
|
+
context "with no matching environment" do
|
50
|
+
it "should raise an error" do
|
51
|
+
expect do
|
52
|
+
config.merge("database_config_env" => "only_for_pretend").database
|
53
|
+
end.to raise_error(KeyError)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe 'default config' do
|
60
|
+
let :valise do
|
61
|
+
Application.new.valise
|
62
|
+
end
|
63
|
+
|
64
|
+
subject :config do
|
65
|
+
Config.new(valise)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "schedule shorthands" do
|
70
|
+
let :config do
|
71
|
+
Config.new(nil).tap do |config|
|
72
|
+
config.hash = config_hash
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
let :config_hash do
|
77
|
+
{ "backups" => {
|
78
|
+
"frequency" => 60,
|
79
|
+
"keep" => {
|
80
|
+
60 => 24,
|
81
|
+
1440 => 7
|
82
|
+
}}}
|
83
|
+
end
|
84
|
+
|
85
|
+
let :schedule_array do
|
86
|
+
[].tap do |array|
|
87
|
+
config.each_prune_schedule do |freq, lim|
|
88
|
+
array << [freq, lim]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "simple numerics" do
|
94
|
+
it "should produce correct schedule" do
|
95
|
+
expect(schedule_array).to contain_exactly([60, 24], [1440, 7])
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context "mismatched frequency" do
|
100
|
+
let :config_hash do
|
101
|
+
{ "backups" => {
|
102
|
+
"frequency" => 59,
|
103
|
+
"keep" => {
|
104
|
+
60 => 24,
|
105
|
+
1440 => 7
|
106
|
+
}}}
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should raise an error" do
|
110
|
+
expect do
|
111
|
+
schedule_array
|
112
|
+
end.to raise_error(/59/)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
context "with garbage input" do
|
117
|
+
let :config_hash do
|
118
|
+
{ "backups" => {
|
119
|
+
"frequency" => "sometimes",
|
120
|
+
"keep" => {
|
121
|
+
"often" => 24,
|
122
|
+
"regular" => 7,
|
123
|
+
"chocolate" => 4
|
124
|
+
}}}
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should raise an error" do
|
128
|
+
expect do
|
129
|
+
schedule_array
|
130
|
+
end.to raise_error
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context "with shorthand words" do
|
135
|
+
let :config_hash do
|
136
|
+
{ "backups" => {
|
137
|
+
"frequency" => "hourly",
|
138
|
+
"keep" => {
|
139
|
+
"hourlies" => 24,
|
140
|
+
"daily" => 7,
|
141
|
+
"weeklies" => 4
|
142
|
+
}}}
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should produce correct schedule" do
|
146
|
+
expect(schedule_array).to contain_exactly([60, 24], [60*24, 7], [60*24*7, 4])
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
File without changes
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bibliotech
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Evan Dorn
|
8
|
+
- Judson Lester
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-08-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: caliph
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.3.1
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.3.1
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: mattock
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.8.0
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.8.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: valise
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.1.1
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.1.1
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: thor
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.19.1
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.19.1
|
70
|
+
description: |2
|
71
|
+
Tools for managing SQL backups and local/remote database
|
72
|
+
email:
|
73
|
+
- evan@lrdesign.com
|
74
|
+
- judson@lrdesign.com
|
75
|
+
executables:
|
76
|
+
- bibliotech
|
77
|
+
extensions: []
|
78
|
+
extra_rdoc_files:
|
79
|
+
- doc/todo.txt
|
80
|
+
- doc/example_config_file.yml
|
81
|
+
files:
|
82
|
+
- lib/bibliotech/builders.rb
|
83
|
+
- lib/bibliotech/builders/database.rb
|
84
|
+
- lib/bibliotech/builders/gzip.rb
|
85
|
+
- lib/bibliotech/builders/file.rb
|
86
|
+
- lib/bibliotech/builders/postgres.rb
|
87
|
+
- lib/bibliotech/builders/mysql.rb
|
88
|
+
- lib/bibliotech/config.rb
|
89
|
+
- lib/bibliotech/command_runner.rb
|
90
|
+
- lib/bibliotech/command_generator.rb
|
91
|
+
- lib/bibliotech/rake_lib.rb
|
92
|
+
- lib/bibliotech/compression.rb
|
93
|
+
- lib/bibliotech/compression/bzip2.rb
|
94
|
+
- lib/bibliotech/compression/gzip.rb
|
95
|
+
- lib/bibliotech/compression/sevenzip.rb
|
96
|
+
- lib/bibliotech/backups/scheduler.rb
|
97
|
+
- lib/bibliotech/backups/pruner.rb
|
98
|
+
- lib/bibliotech/backups/prune_list.rb
|
99
|
+
- lib/bibliotech/backups/file_record.rb
|
100
|
+
- lib/bibliotech/application.rb
|
101
|
+
- lib/bibliotech/cli.rb
|
102
|
+
- lib/bibliotech.rb
|
103
|
+
- bin/bibliotech
|
104
|
+
- spec/spec_helper.rb
|
105
|
+
- spec/bibliotech/config_spec.rb
|
106
|
+
- spec/bibliotech/command_generator/postgres_spec.rb
|
107
|
+
- spec/bibliotech/command_generator/mysql_spec.rb
|
108
|
+
- spec/bibliotech/backup_pruner_spec.rb
|
109
|
+
- spec/bibliotech/compression_spec.rb
|
110
|
+
- spec/bibliotech/compression/bzip2_spec.rb
|
111
|
+
- spec/bibliotech/compression/sevenzip_spec.rb
|
112
|
+
- spec/bibliotech/compression/bunzip2_spec.rb
|
113
|
+
- spec/bibliotech/compression/gzip_spec.rb
|
114
|
+
- spec/bibliotech/backup_scheduler_spec.rb
|
115
|
+
- spec/bibliotech/command_generator_spec.rb
|
116
|
+
- spec/bibliotech/command_runner_spec.rb
|
117
|
+
- spec/gem_test_suite.rb
|
118
|
+
- doc/todo.txt
|
119
|
+
- doc/example_config_file.yml
|
120
|
+
homepage: ''
|
121
|
+
licenses:
|
122
|
+
- MIT
|
123
|
+
metadata: {}
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options:
|
126
|
+
- --inline-source
|
127
|
+
- --main
|
128
|
+
- doc/README
|
129
|
+
- --title
|
130
|
+
- bibliotech-0.1.0 Documentation
|
131
|
+
require_paths:
|
132
|
+
- lib/
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - '>='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
requirements: []
|
144
|
+
rubyforge_project: bibliotech
|
145
|
+
rubygems_version: 2.0.14
|
146
|
+
signing_key:
|
147
|
+
specification_version: 4
|
148
|
+
summary: ''
|
149
|
+
test_files:
|
150
|
+
- spec/gem_test_suite.rb
|