compath 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.compath.yml +1 -3
- data/README.md +27 -17
- data/lib/compath/config_loader.rb +9 -0
- data/lib/compath/guide.rb +6 -9
- data/lib/compath/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81145d6e4ff289cabb7850889c6ee6d8b3af8892
|
4
|
+
data.tar.gz: 0bc1060c4f3108641a7ac76e38c4329a1cb7f85e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86252244473fc34c9cdc716512b421a0ffe2c5b6f49c3dfd9ccd3b66b89b05448a8ee4cd4aaec84bed6e2f811547dde7f88c02fb7d4900d81120963bb8463782
|
7
|
+
data.tar.gz: aa4c1de3a9cd719af1811274194c63331303c7760b208ae27b9cda32861c4c87413169a32a5b9aedac70c4cadf710ee340dcb937cf7f604702fe92a5412db07c
|
data/.compath.yml
CHANGED
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
29
|
-
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
data/lib/compath/guide.rb
CHANGED
@@ -35,21 +35,18 @@ module Compath
|
|
35
35
|
|
36
36
|
def object_key
|
37
37
|
if directory?
|
38
|
-
|
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
|
-
|
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
|
data/lib/compath/version.rb
CHANGED