@@ -116,6 +116,24 @@ def self.manage_file(puppet_module, filename, settings, options)
116116 end
117117 end
118118
119+ def self . update_readme_badges ( puppet_module )
120+ return unless File . exist? ( puppet_module . path ( 'README.md' ) )
121+
122+ content = File . read ( puppet_module . path ( 'README.md' ) )
123+ badge_regex = %r{^\[ //\] : # \( modulesync badge placeholder, do not remove\) $}
124+
125+ build_status = "\n "
126+ code_coverage = "[](https://coveralls.io/github/voxpupuli/#{ puppet_module . repository_name } )\n "
127+ license = "[](LICENSE)\n "
128+
129+ badges = build_status
130+ badges << license
131+ badges << code_coverage if Dir . exist? ( File . expand_path ( './lib' , puppet_module . path ) )
132+ content . gsub! ( badge_regex , badges . chomp )
133+
134+ File . write ( puppet_module . path ( 'README.md' ) , content )
135+ end
136+
119137 def self . manage_module ( puppet_module , module_files , defaults )
120138 puts "Syncing '#{ puppet_module . given_name } '"
121139 # NOTE: #prepare_workspace now supports to execute only offline operations
@@ -140,6 +158,7 @@ def self.manage_module(puppet_module, module_files, defaults)
140158
141159 files_to_manage = settings . managed_files ( module_files )
142160 files_to_manage . each { |filename | manage_file ( puppet_module , filename , settings , options ) }
161+ update_readme_badges ( puppet_module )
143162
144163 if options [ :noop ]
145164 puts "Using no-op. Files in '#{ puppet_module . given_name } ' may be changed but will not be committed."
0 commit comments