Showing with 71 additions and 9 deletions.
  1. +10 −1 CHANGELOG.md
  2. +2 −2 Gemfile
  3. +1 −1 README.md
  4. +2 −0 REFERENCE.md
  5. +13 −3 lib/puppet/provider/cron/crontab.rb
  6. +3 −1 lib/puppet/type/cron.rb
  7. +1 −1 metadata.json
  8. +39 −0 spec/unit/provider/cron/crontab_spec.rb
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).

## [1.0.3](https://github.com/puppetlabs/puppetlabs-cron_core/tree/1.0.3) (2019-10-31)
## [1.0.4](https://github.com/puppetlabs/puppetlabs-cron_core/tree/1.0.4) (2020-05-06)

[Full Changelog](https://github.com/puppetlabs/puppetlabs-cron_core/compare/1.0.3...1.0.4)

### Added

- \(maint\) bump to beaker 4 [\#29](https://github.com/puppetlabs/puppetlabs-cron_core/pull/29) ([ciprianbadescu](https://github.com/ciprianbadescu))
- \(MODULES-8603\) Ignore .keep\_\* files [\#12](https://github.com/puppetlabs/puppetlabs-cron_core/pull/12) ([ekohl](https://github.com/ekohl))

## [1.0.3](https://github.com/puppetlabs/puppetlabs-cron_core/tree/1.0.3) (2019-11-01)

[Full Changelog](https://github.com/puppetlabs/puppetlabs-cron_core/compare/1.0.2...1.0.3)

Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ end
group :system_tests do
gem "puppet-module-posix-system-r#{minor_version}", require: false, platforms: [:ruby]
gem "puppet-module-win-system-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 3.34')
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4')
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.5')
gem "beaker-pe", require: false
gem "beaker-hostgenerator"
gem "beaker-rspec"
gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || '~> 0.14')
gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || '~> 1.0')
end

puppet_version = ENV['PUPPET_GEM_VERSION']
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ To generate documentation locally, run the following command:

```
bundle install
bundle exec puppet strings generate ./lib/**/*.rb
bundle exec puppet strings generate --format markdown --out REFERENCE.md
```

This command will create a browsable \_index.html file in the doc directory. The references available here are all generated from YARD-style comments embedded in the code base. When any development happens on this module, the impacted documentation should also be updated.
Expand Down
2 changes: 2 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ must be either:
- A number between 0 and 7, inclusive, with 0 or 7 being Sunday
- The name of the day, such as 'Tuesday'.

Day ranges can only be numeric; e.g. '1-5' for weekdays, but not 'Mon-Fri'.

##### `month`

The month of the year. Optional; if specified,
Expand Down
16 changes: 13 additions & 3 deletions lib/puppet/provider/cron/crontab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,17 +273,27 @@ def user
'/var/spool/cron'
end

# Return the directory holding crontab files stored on the local system.
#
# @api private
def self.crontab_dir
CRONTAB_DIR
end

# Yield the names of all crontab files stored on the local system.
#
# @note Ignores files that are not writable for the puppet process.
# @note Ignores files that are not writable for the puppet process and hidden
# files that start with .keep
#
# @api private
def self.enumerate_crontabs
Puppet.debug "looking for crontabs in #{CRONTAB_DIR}"
return unless File.readable?(CRONTAB_DIR)
Dir.foreach(CRONTAB_DIR) do |file|
path = "#{CRONTAB_DIR}/#{file}"
yield(file) if File.file?(path) && File.writable?(path)
path = File.join(CRONTAB_DIR, file)
# Gentoo creates .keep_PACKAGE-SLOT files to make sure the directory is not
# removed
yield(file) if File.file?(path) && File.writable?(path) && !file.start_with?('.keep_')
end
end

Expand Down
4 changes: 3 additions & 1 deletion lib/puppet/type/cron.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ def alpha
must be either:
- A number between 0 and 7, inclusive, with 0 or 7 being Sunday
- The name of the day, such as 'Tuesday'."
- The name of the day, such as 'Tuesday'.
Day ranges can only be numeric; e.g. '1-5' for weekdays, but not 'Mon-Fri'."
end

newproperty(:month, parent: CronParam) do
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-cron_core",
"version": "1.0.3",
"version": "1.0.4",
"author": "puppetlabs",
"summary": "Install and manage cron resources.",
"license": "Apache-2.0",
Expand Down
39 changes: 39 additions & 0 deletions spec/unit/provider/cron/crontab_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,43 @@ def compare_crontab_record(have, want)
end
end
end

context '#enumerate_crontabs' do
before(:each) do
File.expects(:readable?).with(subject.crontab_dir).returns(true)
Dir.expects(:foreach).with(subject.crontab_dir).multiple_yields(*files)
end

context 'only a hidden file' do
let(:files) { ['.keep_cronbase-0'] }

before(:each) do
files.each do |filename|
path = File.join(subject.crontab_dir, filename)
File.expects(:file?).with(path).returns(true)
File.expects(:writable?).with(path).returns(true)
end
end

it 'ignores .keep_* files' do
expect { |b| described_class.enumerate_crontabs(&b) }.not_to yield_control
end
end

context 'multiple files' do
let(:files) { ['myuser', '.keep_cronbase-0'] }

before(:each) do
files.each do |filename|
path = File.join(subject.crontab_dir, filename)
File.expects(:file?).with(path).returns(true)
File.expects(:writable?).with(path).returns(true)
end
end

it 'ignores .keep_* files' do
expect { |b| described_class.enumerate_crontabs(&b) }.to yield_control.once
end
end
end
end