Skip to content

Commit

Permalink
Merge pull request #244 from lotus/fix-lotusrc-do-not-pollute-env
Browse files Browse the repository at this point in the history
Don't let .lotusrc read to pollute ENV
  • Loading branch information
jodosha committed Jun 3, 2015
2 parents ff1e9c3 + c9b8dda commit 4eb4129
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
11 changes: 8 additions & 3 deletions lib/lotus/lotusrc.rb
@@ -1,5 +1,5 @@
require 'pathname'
require 'dotenv'
require 'dotenv/parser'

module Lotus
# Create and read the .lotusrc file in the root of the application
Expand Down Expand Up @@ -93,8 +93,9 @@ def initialize(root, options = {})
# # => { architecture: 'application', test: 'rspec', template: 'slim' }
def read
if exists?
lotusrc_options = Dotenv.load path_file
Utils::Hash.new(lotusrc_options).symbolize!
Utils::Hash.new(
Dotenv::Parser.call(content)
).symbolize!
end
end

Expand Down Expand Up @@ -142,5 +143,9 @@ def exists?
def path_file
@root.join FILE_NAME
end

def content
path_file.read
end
end
end
2 changes: 1 addition & 1 deletion lotusrb.gemspec
Expand Up @@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'lotus-view', '~> 0.4'
spec.add_dependency 'lotus-helpers', '~> 0.2'
spec.add_dependency 'shotgun', '~> 0.9'
spec.add_dependency 'dotenv', '~> 1.0'
spec.add_dependency 'dotenv', '~> 2.0'
spec.add_dependency 'thor', '~> 0.19'

spec.add_development_dependency 'bundler', '~> 1.6'
Expand Down
9 changes: 9 additions & 0 deletions test/lotusrc_test.rb
Expand Up @@ -30,6 +30,15 @@
options[:test].must_equal 'minitest'
options[:template].must_equal 'erb'
end

# Bug: https://github.com/lotus/lotus/issues/243
it "doesn't pollute ENV" do
@lotusrc.read

ENV.key?('architecture').must_equal false
ENV.key?('test').must_equal false
ENV.key?('template').must_equal false
end
end

describe "file doesn't exist" do
Expand Down

0 comments on commit 4eb4129

Please sign in to comment.