title: Extract env variables from file using regex
body: <pre><code># code
  
  ENV['VAR_1'] = 'HELLO 1'
  ENV['VAR_2'] = 'HELLO 2'
  ENV['VAR_3'] = 'HELLO 3'
  
  # code
  </code></pre>
  
  <p>How do I extract using ruby and regex each variable and it's value?</p>
  
  <p>Currently I'm doing line by line which is stupid.</p>
  
  <pre><code>S3_SECRET       = line.split(' = ').last.delete("'") if line =~ /ENV\['S3_SECRET'\]/
  S3_KEY          = line.split(' = ').last.delete("'") if line =~ /ENV\['S3_KEY'\]/
  S3_BUCKET       = line.split(' = ').last.delete("'") if line =~ /ENV\['S3_BUCKET'\]/
  </code></pre>