Skip to content

Commit

Permalink
Merge pull request #239 from koic/fix_rubocop_offenses
Browse files Browse the repository at this point in the history
Fix Rubocop offenses
  • Loading branch information
bkeepers committed Feb 26, 2016
2 parents 5faa6cd + 25a7418 commit 4225eec
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 22 deletions.
6 changes: 3 additions & 3 deletions Guardfile
Expand Up @@ -3,7 +3,7 @@ guard "bundler" do
end

guard "rspec", :cmd => "bundle exec rspec" do
watch(/^spec\/.+_spec\.rb$/)
watch(/^spec\/spec_helper.rb$/) { "spec" }
watch(/^lib\/(.+)\.rb$/) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^spec/spec_helper.rb$}) { "spec" }
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
end
5 changes: 3 additions & 2 deletions dotenv-rails.gemspec
Expand Up @@ -7,8 +7,9 @@ Gem::Specification.new "dotenv-rails", Dotenv::VERSION do |gem|
gem.description = gem.summary = "Autoload dotenv in Rails."
gem.homepage = "https://github.com/bkeepers/dotenv"
gem.license = "MIT"
gem.files = `git ls-files lib | grep rails`
.split($OUTPUT_RECORD_SEPARATOR) + ["README.md", "LICENSE"]
gem.files = `git ls-files lib | grep rails`.split(
$OUTPUT_RECORD_SEPARATOR
) + ["README.md", "LICENSE"]

gem.add_dependency "dotenv", Dotenv::VERSION
gem.add_dependency "railties", ">= 4.0", "< 5.1"
Expand Down
6 changes: 3 additions & 3 deletions dotenv.gemspec
Expand Up @@ -8,9 +8,9 @@ Gem::Specification.new "dotenv", Dotenv::VERSION do |gem|
gem.homepage = "https://github.com/bkeepers/dotenv"
gem.license = "MIT"

gem.files = `git ls-files README.md LICENSE lib bin | grep -v rails`
.split($OUTPUT_RECORD_SEPARATOR)
gem.executables = gem.files.grep(/^bin\//).map { |f| File.basename(f) }
gem_files = `git ls-files README.md LICENSE lib bin | grep -v rails`
gem.files = gem_files.split($OUTPUT_RECORD_SEPARATOR)
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }

gem.add_development_dependency "rake"
gem.add_development_dependency "rspec"
Expand Down
6 changes: 3 additions & 3 deletions lib/dotenv.rb
Expand Up @@ -39,19 +39,19 @@ def overload(*filenames)
# Internal: Helper to expand list of filenames.
#
# Returns a hash of all the loaded environment variables.
def with(*filenames, &block)
def with(*filenames)
filenames << ".env" if filenames.empty?

filenames.reduce({}) do |hash, filename|
hash.merge! block.call(File.expand_path(filename)) || {}
hash.merge!(yield(File.expand_path(filename)) || {})
end
end

def instrument(name, payload = {}, &block)
if instrumenter
instrumenter.instrument(name, payload, &block)
else
block.call
yield
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/dotenv/environment.rb
Expand Up @@ -14,7 +14,7 @@ def load
end

def read
File.open(@filename, "rb:bom|utf-8") { |file| file.read }
File.open(@filename, "rb:bom|utf-8", &:read)
end

def apply
Expand Down
4 changes: 2 additions & 2 deletions lib/dotenv/parser.rb
Expand Up @@ -55,10 +55,10 @@ def parse_line(line)
@hash[key] = parse_value(value || "")
elsif line.split.first == "export"
if variable_not_set?(line)
fail FormatError, "Line #{line.inspect} has an unset variable"
raise FormatError, "Line #{line.inspect} has an unset variable"
end
elsif line !~ /\A\s*(?:#.*)?\z/ # not comment or blank line
fail FormatError, "Line #{line.inspect} doesn't match format"
raise FormatError, "Line #{line.inspect} doesn't match format"
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/dotenv/version.rb
@@ -1,3 +1,3 @@
module Dotenv
VERSION = "2.1.0"
VERSION = "2.1.0".freeze
end
12 changes: 7 additions & 5 deletions spec/dotenv/rails_spec.rb
Expand Up @@ -51,11 +51,13 @@ def add(*items)
end

it "loads .env, .env.local, and .env.#{Rails.env}" do
expect(Spring.watcher.items).to eql([
Rails.root.join(".env.local").to_s,
Rails.root.join(".env.test").to_s,
Rails.root.join(".env").to_s
])
expect(Spring.watcher.items).to eql(
[
Rails.root.join(".env.local").to_s,
Rails.root.join(".env.test").to_s,
Rails.root.join(".env").to_s
]
)
end

it "loads .env.local before .env" do
Expand Down
4 changes: 2 additions & 2 deletions spec/dotenv_spec.rb
Expand Up @@ -140,8 +140,8 @@
end

it "fixture file has UTF-8 BOM" do
contents = File.open(subject, "rb") { |f| f.read }.force_encoding("UTF-8")
expect(contents).to start_with("\xEF\xBB\xBF")
contents = File.open(subject, "rb", &:read).force_encoding("UTF-8")
expect(contents).to start_with("\xEF\xBB\xBF".force_encoding("UTF-8"))
end
end

Expand Down

0 comments on commit 4225eec

Please sign in to comment.