lazy_rotator 0.1.0 → 0.2.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 +4 -4
- data/.gitignore +2 -1
- data/.rubocop.yml +2 -1
- data/CHANGELOG.md +8 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +5 -4
- data/all_rubies +38 -12
- data/lazy_rotator.gemspec +4 -3
- data/lib/lazy_rotator/file/rename.rb +3 -4
- data/lib/lazy_rotator/file/touch.rb +1 -0
- data/lib/lazy_rotator/file/undetermined.rb +2 -2
- data/lib/lazy_rotator/set.rb +2 -2
- data/lib/lazy_rotator/version.rb +1 -1
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58a85b0a083026d845a67303c6165b6318a2df23363b645b12efc476f03d4647
|
4
|
+
data.tar.gz: d0a10aef6412f7a027d596a086ca786c81c281dd7e595c07f79ed22b2f06f494
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 165fa992d4da22adab7c2d25e74ac8ebf834e4ae3748e1ace667809db94ce1b216368f2f557537edf63ca6db6e3f735313d07663df6ee1b8b90765843207d9e2
|
7
|
+
data.tar.gz: 42c1431da57d52830741bbd724d17f614d7230e36dc0e85e5d912c402e5a60b63195a1364ede506178192078a34a90c6af297f1d625fb6b66390844186d08bf3
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -14,6 +14,14 @@
|
|
14
14
|
|
15
15
|
- N/A
|
16
16
|
|
17
|
+
## [0.2.0 (2022-01-29)](https://github.com/jlw/lazy_rotator/compare/v0.1.0...v0.2.0)
|
18
|
+
|
19
|
+
### Changes
|
20
|
+
|
21
|
+
- Ensure support of Ruby 2.6, 2.7, 3.0, 3.1
|
22
|
+
- Remove support of Ruby 2.2, 2.3, 2.4, 2.5 (all past their end of life)
|
23
|
+
- Prefer asdf as Ruby switcher
|
24
|
+
|
17
25
|
## [0.1.0 (2018-08-07)](https://github.com/jlw/lazy_rotator/releases/tag/v0.1.0)
|
18
26
|
|
19
27
|
- First release
|
data/CONTRIBUTING.md
CHANGED
@@ -23,7 +23,7 @@ If you discover issues, have ideas for improvements or new features, please repo
|
|
23
23
|
- Add an entry to the [Change Log](CHANGELOG.md) accordingly.
|
24
24
|
- Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
25
25
|
- Make sure the test suite is passing for all supported Ruby versions: `./all_rubies bundle && ./all_rubies spec`.
|
26
|
-
- Make sure the code you wrote doesn't produce RuboCop offenses
|
26
|
+
- Make sure the code you wrote doesn't produce RuboCop offenses `./all_rubies cop`.
|
27
27
|
- [Squash related commits together][5].
|
28
28
|
- Open a [pull request][4] that relates to _only_ one subject with a clear title and description in grammatically correct, complete sentences.
|
29
29
|
|
data/README.md
CHANGED
@@ -25,16 +25,17 @@ Or install it yourself as:
|
|
25
25
|
For a Rails app, add the following to `config/application.rb`:
|
26
26
|
|
27
27
|
```ruby
|
28
|
-
if
|
29
|
-
|
28
|
+
if Kernel.const_defined?(:LazyRotator) && (Rails.env.test? || Rails.env.development?)
|
29
|
+
log_file = File.expand_path("../log/#{Rails.env}.log", __dir__)
|
30
|
+
LazyRotator.rotate log_file
|
30
31
|
end
|
31
32
|
```
|
32
33
|
|
33
|
-
_Note:_ you will probably need to update your `.gitignore` file to match `/log/*.log*` - that trailing `*` will
|
34
|
+
_Note:_ you will probably need to update your `.gitignore` file to match `/log/*.log*` - that trailing `*` will make sure the rotated log files are ignored.
|
34
35
|
|
35
36
|
Set the number of copies to keep (the default is 5):
|
36
37
|
```ruby
|
37
|
-
LazyRotator.rotate
|
38
|
+
LazyRotator.rotate 'path/to/log', 20
|
38
39
|
```
|
39
40
|
|
40
41
|
|
data/all_rubies
CHANGED
@@ -1,43 +1,69 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
|
3
|
-
versions=('2.
|
3
|
+
versions=('2.6.9' '2.7.5' '3.0.3' '3.1.0')
|
4
4
|
|
5
|
-
switcher=`which
|
5
|
+
switcher=`which asdf`
|
6
6
|
if [[ $switcher = *[!\ ]* ]]; then
|
7
|
-
verb="local"
|
7
|
+
verb="local ruby"
|
8
8
|
else
|
9
|
-
switcher=`which
|
9
|
+
switcher=`which rbenv`
|
10
10
|
if [[ $switcher = *[!\ ]* ]]; then
|
11
|
-
verb="
|
11
|
+
verb="local"
|
12
12
|
else
|
13
|
-
|
14
|
-
|
13
|
+
switcher=`which rvm`
|
14
|
+
if [[ $switcher = *[!\ ]* ]]; then
|
15
|
+
verb="use"
|
16
|
+
else
|
17
|
+
echo "Please install asdf, rbenv, or rvm"
|
18
|
+
exit 1
|
19
|
+
fi
|
15
20
|
fi
|
16
21
|
fi
|
17
22
|
|
23
|
+
bundle_exec() {
|
24
|
+
local cmd="$1"
|
25
|
+
local version="$2"
|
26
|
+
echo "Run $cmd with Ruby $version"
|
27
|
+
eval "$switcher $verb $version"
|
28
|
+
if [[ -f "Gemfile.lock.$version" ]]; then
|
29
|
+
eval "cp Gemfile.lock.$version Gemfile.lock"
|
30
|
+
else
|
31
|
+
echo "Please run ./all_rubies bundle first"
|
32
|
+
fi
|
33
|
+
bundle exec $cmd
|
34
|
+
}
|
35
|
+
|
18
36
|
case "$1" in
|
19
37
|
bundle)
|
20
38
|
for version in ${versions[@]}
|
21
39
|
do
|
22
40
|
echo "Bundle for Ruby $version"
|
23
41
|
eval "$switcher $verb $version"
|
42
|
+
rm Gemfile.lock
|
43
|
+
if [[ -f "Gemfile.lock.$version" ]]; then
|
44
|
+
eval "cp Gemfile.lock.$version Gemfile.lock"
|
45
|
+
fi
|
24
46
|
gem list --local bundler | grep bundler || gem install bundler --no-ri --no-rdoc
|
25
|
-
|
47
|
+
gem update bundler
|
48
|
+
bundle install --path vendor/bundle
|
26
49
|
bundle update
|
50
|
+
eval "cp Gemfile.lock Gemfile.lock.$version"
|
27
51
|
done
|
28
52
|
;;
|
29
53
|
|
54
|
+
cop)
|
55
|
+
bundle_exec "rubocop" ${versions[0]}
|
56
|
+
;;
|
57
|
+
|
30
58
|
spec)
|
31
59
|
for version in ${versions[@]}
|
32
60
|
do
|
33
|
-
|
34
|
-
eval "$switcher $verb $version"
|
35
|
-
bundle exec rspec spec
|
61
|
+
bundle_exec "rspec spec" $version
|
36
62
|
done
|
37
63
|
;;
|
38
64
|
|
39
65
|
*)
|
40
|
-
echo $"Usage: $0 {bundle|spec}"
|
66
|
+
echo $"Usage: $0 {bundle|spec|cop}"
|
41
67
|
exit 1
|
42
68
|
esac
|
43
69
|
|
data/lazy_rotator.gemspec
CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.description = "Tie log (or other file) rotation to the (un-scheduled?) execution of code. The raison d'étre for this gem is that I'm too lazy to clear out test and development logs manually and am too anal-retentive to be happy with large log files accumulating in my various project directories."
|
15
15
|
spec.homepage = 'https://github.com/jlw/lazy_rotator'
|
16
16
|
spec.license = 'Unlicense'
|
17
|
+
spec.metadata = { 'rubygems_mfa_required' => 'true' }
|
17
18
|
|
18
19
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
20
|
f.match(%r{^(test|spec|features)/})
|
@@ -22,11 +23,11 @@ Gem::Specification.new do |spec|
|
|
22
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
24
|
spec.require_paths = ['lib']
|
24
25
|
|
25
|
-
spec.required_ruby_version = '>= 2.
|
26
|
+
spec.required_ruby_version = '>= 2.6.0'
|
26
27
|
|
27
|
-
spec.add_development_dependency 'bundler'
|
28
|
+
spec.add_development_dependency 'bundler'
|
28
29
|
spec.add_development_dependency 'fuubar'
|
29
|
-
spec.add_development_dependency 'rake', '~>
|
30
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
30
31
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
31
32
|
spec.add_development_dependency 'rubocop'
|
32
33
|
spec.add_development_dependency 'simplecov'
|
@@ -7,20 +7,19 @@ module LazyRotator
|
|
7
7
|
attr_reader :new_number
|
8
8
|
|
9
9
|
def initialize(file_name, new_number)
|
10
|
-
@file_name = file_name
|
11
10
|
@new_number = new_number
|
11
|
+
super file_name
|
12
12
|
end
|
13
13
|
|
14
14
|
def file_name_without_number
|
15
15
|
@file_name_without_number ||= begin
|
16
16
|
m = Regexp.new("^(.+)\\.#{number}$").match(::File.basename(file_name))
|
17
|
-
|
18
|
-
::File.join(::File.dirname(file_name), m[1])
|
17
|
+
m ? ::File.join(::File.dirname(file_name), m[1]) : file_name
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
21
|
def new_file_name
|
23
|
-
file_name_without_number
|
22
|
+
"#{file_name_without_number}.#{new_number}"
|
24
23
|
end
|
25
24
|
|
26
25
|
def process
|
@@ -17,19 +17,19 @@ module LazyRotator
|
|
17
17
|
|
18
18
|
def process; end
|
19
19
|
|
20
|
-
# rubocop:disable Metrics/AbcSize
|
21
20
|
def ==(other)
|
22
21
|
return false if self.class.name != other.class.name
|
23
22
|
return false if number != other.number
|
24
23
|
return false if file_name != other.file_name
|
25
24
|
return true unless respond_to?(:new_number)
|
26
25
|
return false if new_number != other.new_number
|
26
|
+
|
27
27
|
true
|
28
28
|
end
|
29
|
-
# rubocop:enable Metrics/AbcSize
|
30
29
|
|
31
30
|
def <=>(other)
|
32
31
|
return number <=> other.number unless number == other.number
|
32
|
+
|
33
33
|
file_name <=> other.file_name
|
34
34
|
end
|
35
35
|
|
data/lib/lazy_rotator/set.rb
CHANGED
@@ -23,7 +23,7 @@ module LazyRotator
|
|
23
23
|
|
24
24
|
class << self
|
25
25
|
def file_regexp(file_name)
|
26
|
-
Regexp.new(Regexp.quote(file_name)
|
26
|
+
Regexp.new("#{Regexp.quote(file_name)}(\\.\\d+)?$")
|
27
27
|
end
|
28
28
|
|
29
29
|
# return a set of collected files with correct processing decisions
|
@@ -44,7 +44,7 @@ module LazyRotator
|
|
44
44
|
# find all matching files that should be processed as part of the rotation
|
45
45
|
def collect_files(file_name)
|
46
46
|
regexp = file_regexp(file_name)
|
47
|
-
naive_list = Dir.glob(file_name
|
47
|
+
naive_list = Dir.glob("#{file_name}*")
|
48
48
|
file_list = naive_list.select { |f| regexp.match(f) }
|
49
49
|
file_list.map { |f| File::Undetermined.new(f) }.sort
|
50
50
|
end
|
data/lib/lazy_rotator/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazy_rotator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Weathers
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: fuubar
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,8 +129,9 @@ files:
|
|
129
129
|
homepage: https://github.com/jlw/lazy_rotator
|
130
130
|
licenses:
|
131
131
|
- Unlicense
|
132
|
-
metadata:
|
133
|
-
|
132
|
+
metadata:
|
133
|
+
rubygems_mfa_required: 'true'
|
134
|
+
post_install_message:
|
134
135
|
rdoc_options: []
|
135
136
|
require_paths:
|
136
137
|
- lib
|
@@ -138,16 +139,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
138
139
|
requirements:
|
139
140
|
- - ">="
|
140
141
|
- !ruby/object:Gem::Version
|
141
|
-
version: 2.
|
142
|
+
version: 2.6.0
|
142
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
144
|
requirements:
|
144
145
|
- - ">="
|
145
146
|
- !ruby/object:Gem::Version
|
146
147
|
version: '0'
|
147
148
|
requirements: []
|
148
|
-
|
149
|
-
|
150
|
-
signing_key:
|
149
|
+
rubygems_version: 3.3.3
|
150
|
+
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: Lazily rotate log files
|
153
153
|
test_files: []
|