Skip to content

Instantly share code, notes, and snippets.

@darrenterhune
Created May 31, 2019 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrenterhune/626e6e8fbb55c667a518699ebc6ee5b8 to your computer and use it in GitHub Desktop.
Save darrenterhune/626e6e8fbb55c667a518699ebc6ee5b8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# frozen_string_literal: true
class String
def underscore
return self unless /[A-Z-]|::/.match?(self)
word = to_s.gsub("::", "/")
word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
word.tr!("-", "_")
word.downcase!
word
end
end
less_file = File.expand_path("../app/javascript/semantic_ui/site/globals/site.variables", __dir__)
scss_file = File.expand_path("../app/javascript/stylesheets/variables.scss", __dir__)
abort("File not found #{less_file}") unless File.exist?(less_file)
abort("File not found #{scss_file}") unless File.exist?(scss_file)
less_lines = File.readlines(less_file).each
scss_lines = File.readlines(scss_file).each
i = 0
loop do
less = less_lines.next
scss = scss_lines.next
less_compare = less.strip.underscore.gsub(/(\@|\$)/, "")
scss_compare = scss.strip.underscore.gsub(/(\@|\$)/, "")
i += 1
unless less_compare == scss_compare
print "Expected '#{less.strip}' to equal '#{scss.strip}' on line: #{i}\n"
abort
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment