compath 0.1.4 → 0.1.5

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
  SHA1:
3
- metadata.gz: db1088c56006f4e8bcbfc910a58e7f1b42a1db1f
4
- data.tar.gz: 00a2e3283fdfb1e8da6ecb3fb05330df34abfa58
3
+ metadata.gz: 81145d6e4ff289cabb7850889c6ee6d8b3af8892
4
+ data.tar.gz: 0bc1060c4f3108641a7ac76e38c4329a1cb7f85e
5
5
  SHA512:
6
- metadata.gz: 2b62dace41df7c5911709aa5dccd65a7b73258becac6287f990fe93a2bba8511ebb381911c768b1e3d45371075bec39bf66f70c01d546090e70c72168f5b4da2
7
- data.tar.gz: 5947e8bd948198cb120acdf10a5e0cb0cce5a6260ddbcba436d0531c2dd1b7b697742f8f21738b87ce7682ce8f67d128f0400a3ccfd283a5c8d067c855a64039
6
+ metadata.gz: 86252244473fc34c9cdc716512b421a0ffe2c5b6f49c3dfd9ccd3b66b89b05448a8ee4cd4aaec84bed6e2f811547dde7f88c02fb7d4900d81120963bb8463782
7
+ data.tar.gz: aa4c1de3a9cd719af1811274194c63331303c7760b208ae27b9cda32861c4c87413169a32a5b9aedac70c4cadf710ee340dcb937cf7f604702fe92a5412db07c
@@ -2,7 +2,5 @@
2
2
  bin/:
3
3
  exe/:
4
4
  lib/:
5
- lib/compath/:
6
- desc:
7
- scan: false
5
+ lib/compath/**/*:
8
6
  spec/:
data/README.md CHANGED
@@ -13,35 +13,45 @@ Compath generates a guide of directory structure in the project.
13
13
  It creates or updates `.compath.yml`.
14
14
 
15
15
  ```yaml
16
- - ".gitignore":
17
- desc:
18
- - bin/:
19
- desc:
20
- - bin/console:
21
- desc:
22
- - bin/setup:
23
- desc:
16
+ ---
17
+ bin/:
18
+ exe/:
19
+ lib/:
20
+ lib/compath/:
21
+ spec/:
24
22
 
25
23
  ...
26
24
  ```
27
25
 
28
- Each object of sequences has a key to object structure.
29
- The key means path, and the object is only able to have `desc` or `scan/` keys.
30
- `desc` is to describe what the path means.
31
- `scan` is to switch scanning files or not for the directory by configuring boolean value (`true`, `false`).
26
+ The top level object of yaml is mapping. Each key of objects means path, and each value of objects means description.
27
+ Additional convention of configuration is that the path (key) which is end with `**/*` or `*` tells Compath to stop scanning of children of the directory.
32
28
 
33
29
  With the following config, `compath` does not scan files of `bin/` directory.
34
30
 
35
31
  ```yaml
36
- - ".gitignore":
37
- desc:
38
- - bin/:
39
- desc:
40
- scan: false
32
+ ---
33
+ bin/:
34
+ exe/:
35
+ lib/**/*: # Modified!
36
+ lib/compath/:
37
+ spec/:
41
38
 
42
39
  ...
43
40
  ```
44
41
 
42
+ will be updated to the following content by compath.
43
+
44
+ ```yaml
45
+ ---
46
+ bin/:
47
+ exe/:
48
+ lib/**/*:
49
+ spec/:
50
+
51
+ ...
52
+ ```
53
+
54
+
45
55
  ## Contributing
46
56
 
47
57
  Bug reports and pull requests are welcome on GitHub at https://github.com/meganemura/compath.
@@ -1,6 +1,9 @@
1
1
  module Compath
2
2
  module ConfigLoader
3
3
  module_function
4
+
5
+ SCAN_FALSE_REGEXP = %r{(?<new_path>[^\*]*)(/\*\*)?/\*$}
6
+
4
7
  def load(config)
5
8
  conf = YAML.load(config)
6
9
 
@@ -18,6 +21,12 @@ module Compath
18
21
  }
19
22
  end
20
23
 
24
+ # if path is end with `/` character, it represents `scan_children is false`.
25
+ if m = SCAN_FALSE_REGEXP.match(path)
26
+ path = m[:new_path]
27
+ options[:scan] = false
28
+ end
29
+
21
30
  # TODO: Bad interface...
22
31
  Guide.new(path, **options)
23
32
  end
@@ -35,21 +35,18 @@ module Compath
35
35
 
36
36
  def object_key
37
37
  if directory?
38
- pathname.to_s + '/'
38
+ if @scan_children
39
+ pathname.to_s + '/'
40
+ else
41
+ pathname.to_s + '/**/*'
42
+ end
39
43
  else
40
44
  pathname.to_s
41
45
  end
42
46
  end
43
47
 
44
48
  def object_value
45
- if !directory? || @scan_children
46
- @description
47
- else
48
- {
49
- 'desc' => @description,
50
- 'scan' => @scan_children,
51
- }
52
- end
49
+ @description
53
50
  end
54
51
  end
55
52
  end
@@ -1,3 +1,3 @@
1
1
  module Compath
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compath
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - meganemura