Skip to content

Commit

Permalink
Bugfix/copyright rake fixes (SeleniumHQ#7817)
Browse files Browse the repository at this point in the history
Fix make copyright rake task work. Uses an initialization 
method to set the state per language.
  • Loading branch information
luke-hill authored and shs96c committed Nov 29, 2019
1 parent 2f8943e commit ec05ff0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
13 changes: 5 additions & 8 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ end

namespace :copyright do
task :update do
Copyright.update(
Copyright.new.update(
FileList['javascript/**/*.js'].exclude(
'javascript/atoms/test/jquery.min.js',
'javascript/jsunit/**/*.js',
Expand All @@ -472,13 +472,10 @@ namespace :copyright do
'javascript/selenium-core/xpath/**/*.js'
)
)
Copyright.update(FileList['py/**/*.py'], style: '#')
Copyright.update(
FileList['rb/**/*.rb'],
style: '#',
prefix: ["# frozen_string_literal: true\n", "\n"]
)
Copyright.update(FileList['java/**/*.java'])
Copyright.new(comment_characters: '#').update(FileList['py/**/*.py'])
Copyright.new(comment_characters: '#', prefix: ["# frozen_string_literal: true\n", "\n"])
.update(FileList['rb/**/*.rb'])
Copyright.new.update(FileList['java/**/*.java'])
end
end

Expand Down
10 changes: 5 additions & 5 deletions rake_tasks/copyright.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

module Copyright
module_function

def update(files, style: '//', prefix: nil)
@comment_characters = style
class Copyright
def initialize(comment_characters: '//', prefix: nil)
@comment_characters = comment_characters
@prefix = prefix
end

def update(files)
files.each do |file|
lines = IO.readlines(file)

Expand Down

0 comments on commit ec05ff0

Please sign in to comment.