Skip to content
This repository was archived by the owner on Oct 22, 2020. It is now read-only.

Commit 112faeb

Browse files
committed
Move loot into ~/.wpxf/loot
1 parent 3fe58dd commit 112faeb

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

lib/wpxf.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ def self.version
2727
end
2828

2929
def self.home_directory
30-
File.join(Dir.home, '.wpxf')
30+
path = File.join(Dir.home, '.wpxf')
31+
FileUtils.mkdir_p(path) unless File.directory?(path)
32+
path
3133
end
3234

3335
def self.databases_path

lib/wpxf/cli/loot.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def list_loot
3535
rows = build_loot_table
3636
print_table rows
3737
puts
38-
print_std "All filenames are relative to #{home_directory}".yellow
38+
print_std "All filenames are relative to #{File.join(home_directory, 'loot')}".yellow
3939
end
4040

4141
def find_loot_item(id)

lib/wpxf/helpers/export.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def export_path
2828

2929
# @return [String] the path to a unique filename in the wpxf home directory.
3030
def generate_unique_filename(file_extension)
31-
storage_path = File.join(Dir.home, '.wpxf')
31+
storage_path = File.join(Dir.home, '.wpxf', 'loot')
3232
FileUtils.mkdir_p(storage_path) unless File.directory?(storage_path)
3333
filename = "#{Time.now.strftime('%Y-%m-%d_%H-%M-%S')}#{file_extension}"
3434
File.join(storage_path, filename)

spec/lib/wpxf/helpers/export_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@
6565
expect(filename).to match(/\.txt$/)
6666
end
6767

68-
it 'should ensure the home directory is created' do
68+
it 'should ensure the home loot directory is created' do
6969
allow(File).to receive(:directory?).and_return(false)
7070
allow(FileUtils).to receive(:mkdir_p)
7171
allow(Dir).to receive(:home).and_return('/home')
7272
subject.generate_unique_filename('.txt')
7373
expect(FileUtils).to have_received(:mkdir_p)
74-
.with('/home/.wpxf')
74+
.with('/home/.wpxf/loot')
7575
.exactly(1).times
7676
end
7777
end
@@ -83,7 +83,7 @@
8383
subject.set_option_value('host', '127.0.0.1')
8484
end
8585

86-
it 'should write the content to a file in the home directory' do
86+
it 'should write the content to a file in the home loot directory' do
8787
subject.export_and_log_loot('content', 'description', 'type')
8888
expect(File).to have_received(:write)
8989
.with('filename', 'content')

0 commit comments

Comments
 (0)