Skip to content

Instantly share code, notes, and snippets.

@killme2008
Last active December 15, 2015 05:39
Show Gist options
  • Select an option

  • Save killme2008/5211094 to your computer and use it in GitHub Desktop.

Select an option

Save killme2008/5211094 to your computer and use it in GitHub Desktop.

Revisions

  1. killme2008 revised this gist Mar 21, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions environ.rb
    Original file line number Diff line number Diff line change
    @@ -7,9 +7,9 @@
    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[1]}" if vars[matches[0]]
    vars[matches[0]]= matches[1]
    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
  2. killme2008 revised this gist Mar 21, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion environ.rb
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@
    File.open(name,"r") do |f|
    content = f.read
    if content =~ /environ.core/
    content.scan(/\(env :([a-zA-Z\-]+) "([^\)]+)"\)/).each do |matches|
    content.scan(/\(env :([a-zA-Z\-]+) ("[^\)]+")?\)/).each do |matches|
    $stderr.puts "Duplicated var #{matches[0]} in #{name}:current #{vars[matches[0]]},found:#{matches[1]}" if vars[matches[0]]
    vars[matches[0]]= matches[1]
    end
  3. killme2008 created this gist Mar 21, 2013.
    22 changes: 22 additions & 0 deletions environ.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #!/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[1]}" if vars[matches[0]]
    vars[matches[0]]= matches[1]
    end
    end
    end
    end
    end
    vars.each do |k,v|
    puts "export #{k.gsub(/\-/,"_").upcase}=#{v.gsub(/\$/,"\\$")}"
    end
    end