stashify 1.0.1 → 1.0.2

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: 9469fa1d661bcb4852b3eb11964c6838dc3fd26185d3847f0fc5186fce4610d8
4
- data.tar.gz: 6f4ea369267528677dd3a2ed2800bab46348733894020a4a74ee75704c8a3db2
3
+ metadata.gz: 84f0655199b71b4079fc0405ed2bd68ccd65f0231f1531005c59f1ada5b88efe
4
+ data.tar.gz: b8f4d4b7491ea3d51271579e455fcbe08e4e9a74040f3deba84581b2d1b02538
5
5
  SHA512:
6
- metadata.gz: '078f0add9fe974e70e6b53e379ec9d183794414db193df3e0c225ddae3087f86296a7620f5b48e38654182e63ab941c9532a5cc46bbdee54cf89782de40db5e2'
7
- data.tar.gz: 0d6845f6dbc623843be2e4fa6441635eb0281dedb1bf73ba72a331eded002dd485a693bd141a98a87decbba7f4f48b4918c6b53b9ed20f77306763f39638af68
6
+ metadata.gz: 623475feb2be6768f59519458108029af6b244396d36d67c3d3529e60bbf231f8164921d1cd334a6a7eebdd6059578083be2f841e50e4b7dc20327e3853707ef
7
+ data.tar.gz: 33b63c2878050f49c35d24d00f81917f35503353019dc7b23c3f4f1a4fcfb7f95897b66d5dbb288012fcbd57b0a91bd162d8015b89802b70e7b81840222b77ed
data/.rubocop.yml CHANGED
@@ -19,3 +19,6 @@ Layout/LineLength:
19
19
  Metrics/BlockLength:
20
20
  AllowedMethods:
21
21
  - describe
22
+
23
+ Style/TrailingCommaInArguments:
24
+ EnforcedStyleForMultiline: consistent_comma
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stashify (1.1)
4
+ stashify (1.0.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -13,13 +13,15 @@ module Stashify
13
13
  super(name: ::File.basename(path))
14
14
  end
15
15
 
16
- def write(file)
17
- path = ::File.join(@path, file.name)
18
- if file.is_a?(Stashify::Directory)
19
- FileUtils.mkdir(path)
20
- else
21
- ::File.write(path, file.contents)
22
- end
16
+ def write_directory(directory)
17
+ path = path_of(directory.name)
18
+ FileUtils.mkdir(path)
19
+ subdir = Stashify::Directory::Local.new(path)
20
+ directory.files.each { |file| subdir.write(file) }
21
+ end
22
+
23
+ def write_file(file)
24
+ ::File.write(path_of(file.name), file.contents)
23
25
  end
24
26
 
25
27
  def delete(name)
@@ -31,6 +33,12 @@ module Stashify
31
33
  end
32
34
  end
33
35
 
36
+ def files
37
+ Dir.entries(@path).grep_v(/^[.][.]?$/).map do |file_name|
38
+ find(::File.basename(file_name))
39
+ end
40
+ end
41
+
34
42
  def ==(other)
35
43
  @path == other.path
36
44
  end
@@ -2,10 +2,11 @@
2
2
 
3
3
  module Stashify
4
4
  class Directory
5
- attr_reader :name
5
+ attr_reader :name, :files
6
6
 
7
- def initialize(name:)
7
+ def initialize(name:, files: [])
8
8
  @name = name
9
+ @files = files
9
10
  end
10
11
 
11
12
  def find(name)
@@ -15,5 +16,13 @@ module Stashify
15
16
  file(name)
16
17
  end
17
18
  end
19
+
20
+ def write(file)
21
+ if file.is_a?(Stashify::Directory)
22
+ write_directory(file)
23
+ else
24
+ write_file(file)
25
+ end
26
+ end
18
27
  end
19
28
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stashify
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stashify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lambda Null