Skip to content

Instantly share code, notes, and snippets.

@DavyLin
Forked from killme2008/environ.rb
Created March 21, 2013 09:00
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 DavyLin/5211681 to your computer and use it in GitHub Desktop.
Save DavyLin/5211681 to your computer and use it in GitHub Desktop.
#!/bin/ruby
if __FILE__ == $0
vars = {}
Dir.glob("**/*") do |name|
if File.file? name and name =~ /\.clj$/
File.open(name,"r") do |f|
content = f.read
if content =~ /environ.core/
content.scan(/\(env :([a-zA-Z\-]+) ("([^\)]+)")?\)/).each do |matches|
$stderr.puts "Duplicated var #{matches[0]} in #{name}:current #{vars[matches[0]]},found:#{matches[2]}" if vars[matches[0]]
vars[matches[0]]= matches[2]
end
end
end
end
end
vars.each do |k,v|
puts "export #{k.gsub(/\-/,"_").upcase}=#{v.gsub(/\$/,"\\$")}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment