pathtree 0.4.0 → 0.4.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: 2fa0b4b00d649556ade2438672e8f579096425641c87dc12904c0b1e83896f4c
4
- data.tar.gz: a20dc412a32816c46688ae0ee426f1ee19d954290d3def13f64d50099a737956
3
+ metadata.gz: 2a89a8102337f662cf6a726f1d691840b15aadf2c8aaeae2b20afabe38e4fe22
4
+ data.tar.gz: 4bcfb2691c0ee51cc0b7f114e9f0d5000157c5831a21bf09f09952ee815cec60
5
5
  SHA512:
6
- metadata.gz: 19b2cf1822c9380fbd6161ee50b3fd57990811d93331ddd22530982907654b2e6dee118715da9ccd76c5921afd01249a7fa1357b30886cab3f4ce45430f2f53f
7
- data.tar.gz: 01bda1e63a6dcc19803a10857cb581d7457a87329e1c2592cfb355a6f5a4e235e301eea171f22a4fd613afcdaff69a6369433824c5e4595160ceee3660d6fd94
6
+ metadata.gz: 590ef5145f866765ec2ad6cacb8a42c9235a155670fd7022f01386c1d2936a69e663a615cfb6359c42185dd004b2d0f2106c3af0b28feb9ba46d3b1fc51fc101
7
+ data.tar.gz: 10265bcc1e67bbf922e3412ee52412c288e299e1d164b86d982d4c756d4ba7fc2e1a4101d22ac848cf7ccb1f54b82fdb92080f221a54c77ef7f678e935ce6056
data/CHANGELOG.md CHANGED
@@ -7,6 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 0.4.2
11
+
12
+ * Added Guix manifest; `guix shell` to enter the dev env.
13
+ * Updated gem versions.
14
+ * Clean gemspec file.
15
+ * Updated RuboCop configs.
16
+
17
+ ### Added in 0.4.2
18
+
19
+ * Support Ruby 2.7 or later.
20
+
21
+ ## 0.4.1
22
+
23
+ ### Fixed in 0.4.1
24
+
25
+ * It is now possible to define identically named paths in different hierarchies.
26
+ In 0.4.0, duplicate names caused an exception.
27
+
28
+ ```ruby
29
+ directory :aaa do
30
+ file :xxx
31
+
32
+ directory :bbb do
33
+ file :xxx # OK
34
+ end
35
+ end
36
+ ```
37
+
10
38
  ## 0.4.0 - 2022-05-14
11
39
 
12
40
  ### Changed in 0.4.0
data/lib/pathtree/dsl.rb CHANGED
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'pathname'
4
2
 
5
3
  module Pathtree
@@ -16,10 +14,8 @@ module Pathtree
16
14
  # * Otherwise, +path+ itself is used.
17
15
  def file(name, path = nil)
18
16
  check_name(name)
19
- path = normalize(name: name, path: path)
20
- path = @root / path if @root
21
- @names << name
22
- define_singleton_method(name) { path }
17
+ path = normalize(path, name: name).then { nest(_1) }
18
+ sprout(name: name, path: path)
23
19
  end
24
20
 
25
21
  # Grows directory branch from the branch.
@@ -27,23 +23,16 @@ module Pathtree
27
23
  # This method has optional block, which represents nested file structure.
28
24
  def directory(name, path = nil, &block)
29
25
  check_name(name)
30
- path = normalize(name: name, path: path)
31
- path = @root / path if @root
32
- @names << name
33
-
34
- define_singleton_method(name) do
35
- path.tap do |p|
36
- Dsl.extend(p, root: path)
37
- p.instance_eval(&block) if block
38
- end
39
- end
26
+ path = normalize(path, name: name).then { nest(_1) }
27
+ .then { Dsl.extend(_1) }
28
+ .tap { _1.instance_eval(&block) if block }
29
+ sprout(name: name, path: path)
40
30
  end
41
31
 
42
32
  alias dir directory
43
33
 
44
- def self.extend(path, root: nil)
34
+ def self.extend(path)
45
35
  path.instance_variable_set(:@names, [])
46
- path.instance_variable_set(:@root, root)
47
36
  path.extend(Dsl)
48
37
  path
49
38
  end
@@ -54,16 +43,25 @@ module Pathtree
54
43
  raise MethodDuplicationError, name if respond_to?(name)
55
44
  end
56
45
 
57
- def normalize(name:, path: nil)
46
+ def normalize(path, name:)
58
47
  if path.nil?
59
48
  Pathname(name.to_s)
60
49
  elsif path.is_a?(String)
61
50
  Pathname(path)
62
51
  elsif path.respond_to?(:call)
63
- path.call(name).then { normalize(name: _1) }
52
+ path.call(name).to_s.then { Pathname(_1) }
64
53
  else
65
54
  path
66
55
  end
67
56
  end
57
+
58
+ def nest(path)
59
+ is_a?(Trunk) ? path : self / path
60
+ end
61
+
62
+ def sprout(name:, path:)
63
+ define_singleton_method(name) { path }
64
+ @names << name
65
+ end
68
66
  end
69
67
  end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'pathname'
4
2
  require_relative 'dsl'
5
3
 
@@ -10,7 +8,6 @@ module Pathtree
10
8
 
11
9
  def initialize
12
10
  @names = []
13
- @root = nil
14
11
  end
15
12
  end
16
13
  end
@@ -1,7 +1,5 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'pathname'
4
2
 
5
3
  module Pathtree
6
- VERSION = '0.4.0'
4
+ VERSION = '0.4.2'.freeze
7
5
  end
data/lib/pathtree.rb CHANGED
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require_relative 'pathtree/version'
4
2
  require_relative 'pathtree/trunk'
5
3
 
@@ -25,7 +23,7 @@ module Pathtree
25
23
 
26
24
  def to_path(value)
27
25
  value = Pathname(value) if value.is_a?(String)
28
- Dsl.extend(value, root: value)
26
+ Dsl.extend(value)
29
27
  end
30
28
  end
31
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pathtree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - gemmaro
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-14 00:00:00.000000000 Z
11
+ date: 2023-05-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Pathname DSL
14
14
  email:
@@ -29,7 +29,7 @@ licenses:
29
29
  - MIT
30
30
  metadata:
31
31
  rubygems_mfa_required: 'true'
32
- post_install_message:
32
+ post_install_message:
33
33
  rdoc_options: []
34
34
  require_paths:
35
35
  - lib
@@ -37,15 +37,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 3.0.0
40
+ version: '2.7'
41
41
  required_rubygems_version: !ruby/object:Gem::Requirement
42
42
  requirements:
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  requirements: []
47
- rubygems_version: 3.3.7
48
- signing_key:
47
+ rubygems_version: 3.1.6
48
+ signing_key:
49
49
  specification_version: 4
50
50
  summary: Pathname DSL
51
51
  test_files: []