folder_stash 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93dce10844def9a81b889a6d7c2945478d5c28071134ae2e4c82c3c7eddf8821
4
- data.tar.gz: 1159df6fc56cf5eae6381bc10c9871bc97389293d267d0cf156b810a141f8f63
3
+ metadata.gz: 2ed23473d361dfa0ae4bd1f0a38b113668199c2d4c168c185db38b42d03aaa95
4
+ data.tar.gz: ac7cdca3255197f1b1b53c8db011c212c5573cb765a15690d53534115a9da0f2
5
5
  SHA512:
6
- metadata.gz: 03f4b85520693efbc1ec1b23064adfff34c342a57c50beb47861f4b82d52d12b8fbc07896d68737a09ee73e60be9d16c46328159f1b3ddeeb3cd20f15e50a40b
7
- data.tar.gz: 7b33bb6277bd78933e6a0d247eb5bd30e26a10f83d5b9a3e9be3099a283fb7100426cd47cadd82123b8b2ba8e0cb034f46f64e702338fcdbf35c8af3095d932c
6
+ metadata.gz: 307855d56e517dcf1bb729508a4bd273f66f8bcb26acdbe37b00a8377c8e73f29c2a0951a406c455edca926106ad6a3b0409cb8afb9c4ceadd8d11d397525a36
7
+ data.tar.gz: 9252ff064589fde254252d8ec9a3f80b53bdc409eddc179adb558addafac69297fb611ddeaa73a55157cfb3d4375cf5242491c5a99f3e5b867c6abd3fc9dc38b
@@ -46,8 +46,12 @@ module FolderStash
46
46
  end
47
47
 
48
48
  # Copies +file+ to linked path.
49
- def copy(file, pathtype: :tree)
50
- path = store_path(file)
49
+ #
50
+ # The optional <tt>new_basename</tt> argument is passed when the file is to
51
+ # be renamed.
52
+ def copy(file, new_basename = nil, pathtype: :tree)
53
+ filename = new_basename || File.basename(file)
54
+ path = store_path(filename)
51
55
  File.open(path, 'wb') { |f| f.write(File.new(file).read) }
52
56
  file_path path, pathtype
53
57
  end
@@ -77,9 +81,13 @@ module FolderStash
77
81
  end
78
82
 
79
83
  # Moves +file+ to the #linked_path.
80
- def move(file, pathtype: :tree)
81
- path = store_path(file)
82
- FileUtils.mv File.expand_path(file), store_path(file)
84
+ #
85
+ # The optional <tt>new_basename</tt> argument is passed when the file is to
86
+ # be renamed.
87
+ def move(file, new_basename = nil, pathtype: :tree)
88
+ filename = new_basename || File.basename(file)
89
+ path = store_path(filename)
90
+ FileUtils.mv File.expand_path(file), path
83
91
  file_path path, pathtype
84
92
  end
85
93
 
@@ -148,9 +156,10 @@ module FolderStash
148
156
  end
149
157
 
150
158
  # Returns the next available path (_String_) for a file to be stored under.
151
- def store_path(file)
159
+ # +filename+ is the basename for the file to be stored.
160
+ def store_path(filename)
152
161
  update_link if folder_limit && current_folder.count >= folder_limit
153
- File.join current_directory, File.basename(file)
162
+ File.join current_directory, filename
154
163
  end
155
164
 
156
165
  # Creates new subdirectories points the #current_directory symlink to the
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: folder_stash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Stein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-19 00:00:00.000000000 Z
11
+ date: 2019-08-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  The folder_stash gem will store files in a directory with a user definable