Sha256: e3fbbe459cf2c337f188ce57360e4253f5b41da8f09fc4943397b90e55b6bfa2
Contents?: true
Size: 1.98 KB
Versions: 2
Compression:
Stored size: 1.98 KB
Contents
#!/usr/bin/env ruby ruby_regex = /^#.\*{79}.*#.\*{79}$/m erb_regex = /^<%.*#.\*{79}.*#.\*{79}.%>$/m js_regex = /^\/\* @preserve.*Copyright.*#.\*\//m ruby_header_text = <<EOT # ******************************************************************************* # OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC. # See also https://openstudio.net/license # ******************************************************************************* EOT ruby_header_text.strip! erb_header_text = <<EOT <% # ******************************************************************************* # OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC. # See also https://openstudio.net/license # ******************************************************************************* %> EOT erb_header_text.strip! js_header_text = <<EOT /* @preserve * OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC. reserved. * See also https://openstudio.net/license */ EOT js_header_text.strip! paths = [ { glob: 'lib/**/*.rb', license: ruby_header_text, regex: ruby_regex }, { glob: 'spec/openstudio/**/*.rb', license: ruby_header_text, regex: ruby_regex }, { glob: 'spec/integration/**/*.rb', license: ruby_header_text, regex: ruby_regex }, # single files { glob: 'Rakefile', license: ruby_header_text, regex: ruby_regex }, { glob: 'spec/spec_helper.rb', license: ruby_header_text, regex: ruby_regex } ] paths.each do |path| Dir[path[:glob]].each do |file| puts "Updating license in file #{file}" f = File.read(file) if f =~ path[:regex] puts ' License found -- updating' File.open(file, 'w') { |write| write << f.gsub(path[:regex], path[:license]) } else puts ' No license found -- adding' if f =~ /#!/ 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\n") } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
openstudio-analysis-1.3.5 | update_license.rb |
openstudio-analysis-1.3.4 | update_license.rb |