Skip to content

Commit

Permalink
.dg/credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
henteko committed Oct 20, 2015
1 parent ff22979 commit b83a610
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/deploygate/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ class << self

# @return [String]
def file_path
ENV["HOME"] + "/.dg"
File.join(ENV["HOME"], '.dg/credentials')
end

# @param [Hash] config
# @return [void]
def write(config)
FileUtils.mkdir_p(File.dirname(file_path))

data = JSON.generate(config)
file = File.open(file_path, "w+")
file.print data
Expand Down
4 changes: 3 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
RSpec.configure do |config|
config.before :each do
# config file mock
allow(DeployGate::Config).to receive(:file_path).and_return(File.join(SPEC_FILE_PATH, 'test_files/.dg'))
allow(DeployGate::Config).to receive(:file_path).and_return(File.join(SPEC_FILE_PATH, 'test_files/.dg/credentials'))
# config dir mock
allow(FileUtils).to receive(:mkdir_p) {}
end
end

Expand Down

0 comments on commit b83a610

Please sign in to comment.