lib/openstudio/extension/runner.rb in openstudio-extension-0.2.2 vs lib/openstudio/extension/runner.rb in openstudio-extension-0.2.3

- old
+ new

@@ -1,7 +1,5 @@ -# frozen_string_literal: true - # ******************************************************************************* # OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC. # All rights reserved. # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -561,24 +559,24 @@ puts "Encoding.default_external = #{Encoding.default_external}" puts "Encoding.default_internal = #{Encoding.default_internal}" paths.each do |path| - Dir[path[:glob]].each do |file| - puts "Updating license in file #{file}" - f = File.read(file) + Dir[path[:glob]].each do |dir_file| + puts "Updating license in file #{dir_file}" + f = File.read(dir_file) if f.match?(path[:regex]) puts ' License found -- updating' - File.open(file, 'w') { |write| write << f.gsub(path[:regex], path[:license]) } + File.open(dir_file, 'w') { |write| write << f.gsub(path[:regex], path[:license]) } elsif f =~ /\(C\)/i || f =~ /\(Copyright\)/i puts ' File already has copyright -- skipping' else puts ' No license found -- adding' if f.match?(/#!/) puts ' CANNOT add license to file automatically, add it manually and it will update automatically in the future' next end - File.open(file, 'w') { |write| write << f.insert(0, path[:license] + "\n") } + File.open(dir_file, 'w') { |write| write << f.insert(0, path[:license] + "\n") } end end end end