/Languages/Ruby/Scripts/license_check.rb

https://github.com/kumaryu/IronLanguages-main · Ruby · 56 lines · 52 code · 4 blank · 0 comment · 3 complexity · c71b5aaa7bc28a6b8845f316fa152c5c MD5 · raw file

  1. str_array = [
  2. "/* ****************************************************************************\n",
  3. " *\n",
  4. " * Copyright (c) Microsoft Corporation. \n",
  5. " *\n",
  6. " * This source code is subject to terms and conditions of the Apache License, Version 2.0. A \n",
  7. " * copy of the license can be found in the License.html file at the root of this distribution. If \n",
  8. " * you cannot locate the Apache License, Version 2.0, please send an email to \n",
  9. " * ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound \n",
  10. " * by the terms of the Apache License, Version 2.0.\n",
  11. " *\n",
  12. " * You must not remove this notice, or any other, from this software.\n",
  13. " *\n",
  14. " *\n",
  15. " * ***************************************************************************/\n"]
  16. unicode_str_array = [
  17. "\357\273\277/* ****************************************************************************\n",
  18. "\357\273\277 *\n",
  19. "\357\273\277 * Copyright (c) Microsoft Corporation. \n",
  20. "\357\273\277 *\n",
  21. "\357\273\277 * This source code is subject to terms and conditions of the Apache License, Version 2.0. A \n",
  22. "\357\273\277 * copy of the license can be found in the License.html file at the root of this distribution. If \n",
  23. "\357\273\277 * you cannot locate the Apache License, Version 2.0, please send an email to \n",
  24. "\357\273\277 * ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound \n",
  25. "\357\273\277 * by the terms of the Apache License, Version 2.0.\n",
  26. "\357\273\277 *\n",
  27. "\357\273\277 * You must not remove this notice, or any other, from this software.\n",
  28. "\357\273\277 *\n",
  29. "\357\273\277 *\n",
  30. "\357\273\277 * ***************************************************************************/\n"]
  31. files = Dir["#{ARGV[0]}/**/*.{cs,rb}"]
  32. files.each do |file|
  33. lines = File.readlines file
  34. res = true
  35. str_array.each_with_index do |line, i|
  36. if line == lines[i]
  37. next
  38. elsif unicode_str_array[i] == lines[i]
  39. next
  40. else
  41. res = false
  42. puts "************************************************************"
  43. puts "FILE: #{file}"
  44. puts "ACTUAL: #{lines[i]}"
  45. puts "EXPECTED: #{line}"
  46. puts "OR: #{unicode_str_array[i]}"
  47. puts "************************************************************"
  48. break
  49. end
  50. end
  51. puts "#{file} OK" unless res
  52. end