thin_out_backups 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/thin_out_backups/version.rb +1 -1
- data/lib/thin_out_backups.rb +5 -3
- data/spec/thin_out_backups_spec.rb +3 -3
- data/thin_out_backups.gemspec +1 -0
- metadata +16 -3
- data/lib/thin_out_backups/time_fixes.rb +0 -131
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 661c20167ace8b36008890eaee10ac93d662c591
|
4
|
+
data.tar.gz: f85c7b2d8155cb91edff3795baec40438ff80cb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f8867b4f850c67601ab97ac1819b1491743a51b5e6186cecd1d2d9fcc615c46b0ca4efdb06c74b65c19e721c48155710f2a7c89334941f0e315746706a6dfc8
|
7
|
+
data.tar.gz: df07738545e69a9203ec2d7254af5bfa4f8876f4c7c81df180f3c690d5c514661500aad7ac24ab64f218b9c1f4a7fd560b7bc01a5b1574ba869e2331dc3f57d7
|
data/lib/thin_out_backups.rb
CHANGED
@@ -8,9 +8,11 @@ require 'delegate'
|
|
8
8
|
|
9
9
|
#require 'rubygems'
|
10
10
|
require 'facets/time'
|
11
|
+
require 'facets/time/hence'
|
12
|
+
require 'active_support/core_ext/time/calculations'
|
13
|
+
require 'active_support/core_ext/date/calculations'
|
11
14
|
require 'colored'
|
12
15
|
require 'quality_extensions/module/attribute_accessors'
|
13
|
-
require 'thin_out_backups/time_fixes'
|
14
16
|
|
15
17
|
class ThinOutBackups::Command
|
16
18
|
#---------------------------------------------------------------------------------------------------------------------------------------------------
|
@@ -81,7 +83,7 @@ class ThinOutBackups::Command
|
|
81
83
|
def start_time
|
82
84
|
start_time = parent.now.dup
|
83
85
|
if parent.align_at_beginning_of_time_interval
|
84
|
-
beginning_of_interval =
|
86
|
+
beginning_of_interval =
|
85
87
|
case unit
|
86
88
|
when :minutes
|
87
89
|
start_time.change(:sec => 0)
|
@@ -90,7 +92,7 @@ class ThinOutBackups::Command
|
|
90
92
|
when :days
|
91
93
|
start_time.change(:hour => 0)
|
92
94
|
when :weeks
|
93
|
-
start_time.beginning_of_week
|
95
|
+
start_time.beginning_of_week(:sunday)
|
94
96
|
when :months
|
95
97
|
start_time.change( :day => 1, :hour => 0)
|
96
98
|
when :years
|
@@ -13,9 +13,9 @@ describe '.time_format' do
|
|
13
13
|
it { 'db_backup.2016-04-28T01:04.sql.gz'.should match subject }
|
14
14
|
end
|
15
15
|
|
16
|
-
describe Time, "#beginning_of_week" do
|
16
|
+
describe Time, "#beginning_of_week(:sunday)" do
|
17
17
|
it "should return a Sunday" do
|
18
|
-
Time.utc(2008,11,12).beginning_of_week.should == Time.utc(2008,11,9)
|
18
|
+
Time.utc(2008,11,12).beginning_of_week(:sunday).should == Time.utc(2008,11,9)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -56,7 +56,7 @@ end
|
|
56
56
|
|
57
57
|
$command = <<End
|
58
58
|
thin_out_backups --force --daily=3 --weekly=3 --monthly=* \
|
59
|
-
--now='#{$now.
|
59
|
+
--now='#{$now.strftime("%Y-%m-%d %H:%M:%S")}'\
|
60
60
|
spec/test_dir/db_dumps \
|
61
61
|
spec/test_dir/maildir
|
62
62
|
End
|
data/thin_out_backups.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thin_out_backups
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Rick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: facets
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rspec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -83,7 +97,6 @@ files:
|
|
83
97
|
- Readme.md
|
84
98
|
- bin/thin_out_backups
|
85
99
|
- lib/thin_out_backups.rb
|
86
|
-
- lib/thin_out_backups/time_fixes.rb
|
87
100
|
- lib/thin_out_backups/version.rb
|
88
101
|
- spec/thin_out_backups_spec.rb
|
89
102
|
- thin_out_backups.gemspec
|
@@ -1,131 +0,0 @@
|
|
1
|
-
# Until facets gets patched proper, we'll monkey patch it here:
|
2
|
-
# TODO: Is this still needed?
|
3
|
-
#require '/home/tyler/dev/ruby/facets/lib/core/facets/time/hence'
|
4
|
-
class Time
|
5
|
-
|
6
|
-
if defined?(::ActiveSupport)
|
7
|
-
|
8
|
-
alias_method :in, :since
|
9
|
-
alias_method :hence, :since
|
10
|
-
|
11
|
-
else
|
12
|
-
|
13
|
-
# Returns a new Time representing the time
|
14
|
-
# a number of time-units ago.
|
15
|
-
#
|
16
|
-
def ago(number, units=:seconds)
|
17
|
-
time =(
|
18
|
-
case units.to_s.downcase.to_sym
|
19
|
-
when :years
|
20
|
-
set(:year => (year - number))
|
21
|
-
when :months
|
22
|
-
y = ((month - number) / 12).to_i
|
23
|
-
#puts "(#{month} - #{number}) / 12 == #{y}"
|
24
|
-
|
25
|
-
new_month = ((month - number - 1) % 12) + 1
|
26
|
-
y += 1 if new_month > month
|
27
|
-
#puts y
|
28
|
-
|
29
|
-
set(:year => (year - y), :month => new_month)
|
30
|
-
when :weeks
|
31
|
-
self - (number * 604800)
|
32
|
-
when :days
|
33
|
-
self - (number * 86400)
|
34
|
-
when :hours
|
35
|
-
self - (number * 3600)
|
36
|
-
when :minutes
|
37
|
-
self - (number * 60)
|
38
|
-
when :seconds, nil
|
39
|
-
self - number
|
40
|
-
else
|
41
|
-
raise ArgumentError, "unrecognized time units -- #{units}"
|
42
|
-
end
|
43
|
-
)
|
44
|
-
dst_adjustment(time)
|
45
|
-
end
|
46
|
-
#
|
47
|
-
# Returns a new Time representing the time
|
48
|
-
# a number of time-units hence.
|
49
|
-
|
50
|
-
def hence(number, units=:seconds)
|
51
|
-
time =(
|
52
|
-
case units.to_s.downcase.to_sym
|
53
|
-
when :years
|
54
|
-
set( :year=>(year + number) )
|
55
|
-
when :months
|
56
|
-
y = ((month + number - 1) / 12).to_i
|
57
|
-
m = ((month + number - 1) % 12) + 1
|
58
|
-
set(:year => (year + y), :month => m)
|
59
|
-
when :weeks
|
60
|
-
self + (number * 604800)
|
61
|
-
when :days
|
62
|
-
self + (number * 86400)
|
63
|
-
when :hours
|
64
|
-
self + (number * 3600)
|
65
|
-
when :minutes
|
66
|
-
self + (number * 60)
|
67
|
-
when :seconds
|
68
|
-
self + number
|
69
|
-
else
|
70
|
-
raise ArgumentError, "unrecognized time units -- #{units}"
|
71
|
-
end
|
72
|
-
)
|
73
|
-
dst_adjustment(time)
|
74
|
-
end
|
75
|
-
|
76
|
-
alias_method :in, :hence
|
77
|
-
alias_method :since, :hence
|
78
|
-
|
79
|
-
# Adjust DST
|
80
|
-
#
|
81
|
-
# TODO: Can't seem to get this to pass ActiveSupport tests.
|
82
|
-
# Even though it is essentially identical to the
|
83
|
-
# ActiveSupport code (see Time#since in time/calculations.rb).
|
84
|
-
# It handles all but 4 tests.
|
85
|
-
def dst_adjustment(time)
|
86
|
-
self_dst = self.dst? ? 1 : 0
|
87
|
-
time_dst = time.dst? ? 1 : 0
|
88
|
-
seconds = (self - time).abs
|
89
|
-
if (seconds >= 86400 && self_dst != time_dst)
|
90
|
-
time + ((self_dst - time_dst) * 60 * 60)
|
91
|
-
else
|
92
|
-
time
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
|
98
|
-
end
|
99
|
-
|
100
|
-
|
101
|
-
class DateTime
|
102
|
-
def to_time
|
103
|
-
Time.mktime(year, month, day, hour, min, sec)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
class Time
|
108
|
-
def to_s
|
109
|
-
#strftime("%Y%m%dT%H%M%S")
|
110
|
-
strftime("%Y-%m-%d %H:%M")
|
111
|
-
end
|
112
|
-
def to_s_full
|
113
|
-
strftime("%Y-%m-%d %H:%M:%S")
|
114
|
-
end
|
115
|
-
|
116
|
-
# /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/core_ext/time/calculations.rb
|
117
|
-
|
118
|
-
def beginning_of_day
|
119
|
-
change(:hour => 0)
|
120
|
-
end
|
121
|
-
alias :midnight :beginning_of_day
|
122
|
-
|
123
|
-
# Returns a new Time representing the "start" of this week (Sunday, 0:00)
|
124
|
-
def beginning_of_week
|
125
|
-
days_to_sunday = self.wday
|
126
|
-
self.ago(days_to_sunday, :days).midnight
|
127
|
-
end
|
128
|
-
alias :sunday :beginning_of_week
|
129
|
-
|
130
|
-
end
|
131
|
-
|