modulesync 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8aebcf942cd3e1d9ccef2339d17bd07e208ee279305ba0bb6e7ad0b615ff69af
4
- data.tar.gz: d4a2d213c0ed6b96a3d7f616e3e5b4a26145e1d741246daea3e9b903df0ba380
3
+ metadata.gz: dab88d217406b70303f6514b14c56a6ec6652b962d3fa16fd967e36fdb17b0b4
4
+ data.tar.gz: 18f7c8f38c273f248f80005b2edd6fe5528138739aad2daf0ffe11f22fad40e6
5
5
  SHA512:
6
- metadata.gz: cd56a2ab522debc6a002dceb8b84f5296d970bbbc8e57f242e913f0f7e9ba6dbdc8ca16005937d2d45d79df4991baaec4122c288cbed0be39ae28502f90752a3
7
- data.tar.gz: 4301a8ace72c549965bec4438cf152c15bf7c4b4c9cda6a8ad14d3da8d2ff774fed8354ce9a13cdf94630cc18955d43bfdb520da3173501dc8e7aecdcfd36b9c
6
+ metadata.gz: 4be95c61128a95c5cb28689f6abe256f7c164a197ef44028a58963139a474568ec82aef11adc6608b3a9681b126014ccb699ea4b82686558563e41740d6608f0
7
+ data.tar.gz: 6341644230ec2cd827180917c692cbf6e6abc3c5e8866f5c72ba415d3079517a910ebee988fe9009f693b3d2dcd91b1e50c7403071088ab234b13157b0902c0d
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [2.5.0](https://github.com/voxpupuli/modulesync/tree/2.5.0) (2022-10-14)
6
+
7
+ [Full Changelog](https://github.com/voxpupuli/modulesync/compare/2.4.0...2.5.0)
8
+
9
+ **Implemented enhancements:**
10
+
11
+ - Copy file permissions from template to target [\#257](https://github.com/voxpupuli/modulesync/pull/257) ([ekohl](https://github.com/ekohl))
12
+
5
13
  ## [2.4.0](https://github.com/voxpupuli/modulesync/tree/2.4.0) (2022-09-27)
6
14
 
7
15
  [Full Changelog](https://github.com/voxpupuli/modulesync/compare/2.3.1...2.4.0)
@@ -10,13 +10,7 @@ module ModuleSync
10
10
  end
11
11
  end
12
12
 
13
- def self.build(target_name)
14
- template_file = if !File.exist?("#{target_name}.erb") && File.exist?(target_name)
15
- $stderr.puts "Warning: using '#{target_name}' as template without '.erb' suffix"
16
- target_name
17
- else
18
- "#{target_name}.erb"
19
- end
13
+ def self.build(template_file)
20
14
  template = File.read(template_file)
21
15
  erb_obj = if RUBY_VERSION >= '2.7'
22
16
  ERB.new(template, trim_mode: '-')
@@ -36,9 +30,10 @@ module ModuleSync
36
30
  ForgeModuleFile.new(configs, metadata).render
37
31
  end
38
32
 
39
- def self.sync(template, target_name)
33
+ def self.sync(template, target_name, mode = nil)
40
34
  FileUtils.mkdir_p(File.dirname(target_name))
41
35
  File.write(target_name, template)
36
+ File.chmod(mode, target_name) unless mode.nil?
42
37
  end
43
38
  end
44
39
  end
data/lib/modulesync.rb CHANGED
@@ -31,7 +31,13 @@ module ModuleSync # rubocop:disable Metrics/ModuleLength
31
31
  end
32
32
 
33
33
  def self.local_file(config_path, file)
34
- File.join(config_path, MODULE_FILES_DIR, file)
34
+ path = File.join(config_path, MODULE_FILES_DIR, file)
35
+ if !File.exist?("#{path}.erb") && File.exist?(path)
36
+ $stderr.puts "Warning: using '#{path}' as template without '.erb' suffix"
37
+ path
38
+ else
39
+ "#{path}.erb"
40
+ end
35
41
  end
36
42
 
37
43
  # List all template files.
@@ -88,9 +94,9 @@ module ModuleSync # rubocop:disable Metrics/ModuleLength
88
94
  if configs['delete']
89
95
  Renderer.remove(target_file)
90
96
  else
91
- templatename = local_file(options[:configs], filename)
97
+ template_file = local_file(options[:configs], filename)
92
98
  begin
93
- erb = Renderer.build(templatename)
99
+ erb = Renderer.build(template_file)
94
100
  # Meta data passed to the template as @metadata[:name]
95
101
  metadata = {
96
102
  :module_name => settings.additional_settings[:puppet_module],
@@ -99,7 +105,8 @@ module ModuleSync # rubocop:disable Metrics/ModuleLength
99
105
  :target_file => target_file,
100
106
  }
101
107
  template = Renderer.render(erb, configs, metadata)
102
- Renderer.sync(template, target_file)
108
+ mode = File.stat(template_file).mode
109
+ Renderer.sync(template, target_file, mode)
103
110
  rescue StandardError
104
111
  $stderr.puts "#{puppet_module.given_name}: Error while rendering file: '#{filename}'"
105
112
  raise
data/modulesync.gemspec CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'modulesync'
6
- spec.version = '2.4.0'
6
+ spec.version = '2.5.0'
7
7
  spec.authors = ['Vox Pupuli']
8
8
  spec.email = ['voxpupuli@groups.io']
9
9
  spec.summary = 'Puppet Module Synchronizer'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modulesync
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-27 00:00:00.000000000 Z
11
+ date: 2022-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba