compath 0.1.3 → 0.1.4
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 +4 -4
- data/.compath.yml +7 -41
- data/lib/compath.rb +0 -1
- data/lib/compath/cli.rb +1 -0
- data/lib/compath/config_loader.rb +14 -5
- data/lib/compath/guide.rb +14 -15
- data/lib/compath/guide_book.rb +4 -3
- data/lib/compath/path_sorter.rb +3 -0
- data/lib/compath/version.rb +1 -1
- metadata +2 -3
- data/lib/compath/dumper.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db1088c56006f4e8bcbfc910a58e7f1b42a1db1f
|
4
|
+
data.tar.gz: 00a2e3283fdfb1e8da6ecb3fb05330df34abfa58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b62dace41df7c5911709aa5dccd65a7b73258becac6287f990fe93a2bba8511ebb381911c768b1e3d45371075bec39bf66f70c01d546090e70c72168f5b4da2
|
7
|
+
data.tar.gz: 5947e8bd948198cb120acdf10a5e0cb0cce5a6260ddbcba436d0531c2dd1b7b697742f8f21738b87ce7682ce8f67d128f0400a3ccfd283a5c8d067c855a64039
|
data/.compath.yml
CHANGED
@@ -1,42 +1,8 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
desc: Configuration file for travis
|
10
|
-
- bin/:
|
11
|
-
desc:
|
12
|
-
- bin/console:
|
13
|
-
desc:
|
14
|
-
- bin/setup:
|
15
|
-
desc:
|
16
|
-
- compath.gemspec:
|
17
|
-
desc:
|
18
|
-
- exe/:
|
19
|
-
desc:
|
20
|
-
- exe/compath:
|
21
|
-
desc:
|
22
|
-
- Gemfile:
|
23
|
-
desc:
|
24
|
-
- lib/:
|
25
|
-
desc:
|
26
|
-
- lib/compath/:
|
27
|
-
desc:
|
28
|
-
scan: false
|
29
|
-
- lib/compath.rb:
|
30
|
-
desc:
|
31
|
-
- LICENSE.txt:
|
32
|
-
desc:
|
33
|
-
- Rakefile:
|
34
|
-
desc:
|
35
|
-
- README.md:
|
36
|
-
desc:
|
37
|
-
- spec/:
|
38
|
-
desc:
|
39
|
-
- spec/compath_spec.rb:
|
40
|
-
desc:
|
41
|
-
- spec/spec_helper.rb:
|
42
|
-
desc:
|
2
|
+
bin/:
|
3
|
+
exe/:
|
4
|
+
lib/:
|
5
|
+
lib/compath/:
|
6
|
+
desc:
|
7
|
+
scan: false
|
8
|
+
spec/:
|
data/lib/compath.rb
CHANGED
data/lib/compath/cli.rb
CHANGED
@@ -5,6 +5,7 @@ module Compath
|
|
5
5
|
paths = Compath::PathSorter.sort(finder.paths.keys)
|
6
6
|
|
7
7
|
guides = paths.map {|path| Compath::Guide.new(path) }
|
8
|
+
guides.select!(&:directory?)
|
8
9
|
guide_book = Compath::GuideBook.new(guides)
|
9
10
|
if FileTest.exist?('.compath.yml')
|
10
11
|
config = Compath::ConfigLoader.load(File.read('.compath.yml'))
|
@@ -4,12 +4,21 @@ module Compath
|
|
4
4
|
def load(config)
|
5
5
|
conf = YAML.load(config)
|
6
6
|
|
7
|
-
guides = conf.map do |
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
guides = conf.map do |path, guide|
|
8
|
+
if guide.is_a?(Hash)
|
9
|
+
# symbolize keys
|
10
|
+
options = guide.each_with_object({}) do |(key, value), hash|
|
11
|
+
hash[key.to_sym] = value
|
12
|
+
end
|
13
|
+
else
|
14
|
+
# nil or String
|
15
|
+
options = {
|
16
|
+
scan: true,
|
17
|
+
desc: guide,
|
18
|
+
}
|
12
19
|
end
|
20
|
+
|
21
|
+
# TODO: Bad interface...
|
13
22
|
Guide.new(path, **options)
|
14
23
|
end
|
15
24
|
end
|
data/lib/compath/guide.rb
CHANGED
@@ -28,23 +28,11 @@ module Compath
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def to_object
|
31
|
-
|
32
|
-
{}
|
33
|
-
else
|
34
|
-
{
|
35
|
-
'scan' => false
|
36
|
-
}
|
37
|
-
end
|
38
|
-
|
39
|
-
object = {
|
40
|
-
object_key => {
|
41
|
-
'desc' => @description
|
42
|
-
}.merge(scan_or_not)
|
43
|
-
}
|
44
|
-
|
45
|
-
object
|
31
|
+
{ object_key => object_value }
|
46
32
|
end
|
47
33
|
|
34
|
+
private
|
35
|
+
|
48
36
|
def object_key
|
49
37
|
if directory?
|
50
38
|
pathname.to_s + '/'
|
@@ -52,5 +40,16 @@ module Compath
|
|
52
40
|
pathname.to_s
|
53
41
|
end
|
54
42
|
end
|
43
|
+
|
44
|
+
def object_value
|
45
|
+
if !directory? || @scan_children
|
46
|
+
@description
|
47
|
+
else
|
48
|
+
{
|
49
|
+
'desc' => @description,
|
50
|
+
'scan' => @scan_children,
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
55
54
|
end
|
56
55
|
end
|
data/lib/compath/guide_book.rb
CHANGED
@@ -20,14 +20,15 @@ module Compath
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def publish
|
23
|
-
|
23
|
+
@index.each_with_object({}) do |(path, guide), hash|
|
24
24
|
scan_children = true
|
25
25
|
scan_children = guide.ancestors.all? do |ancestor|
|
26
26
|
@index[ancestor.to_path].scan_children
|
27
27
|
end
|
28
28
|
next unless scan_children
|
29
|
-
|
30
|
-
|
29
|
+
|
30
|
+
hash.update(guide.to_object)
|
31
|
+
end
|
31
32
|
end
|
32
33
|
|
33
34
|
def publish_yaml
|
data/lib/compath/path_sorter.rb
CHANGED
data/lib/compath/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- meganemura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -89,7 +89,6 @@ files:
|
|
89
89
|
- lib/compath.rb
|
90
90
|
- lib/compath/cli.rb
|
91
91
|
- lib/compath/config_loader.rb
|
92
|
-
- lib/compath/dumper.rb
|
93
92
|
- lib/compath/finder.rb
|
94
93
|
- lib/compath/guide.rb
|
95
94
|
- lib/compath/guide_book.rb
|
data/lib/compath/dumper.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module Compath
|
2
|
-
class Dumper
|
3
|
-
def initialize(paths)
|
4
|
-
@paths = paths.each_with_object({}) do |path, hash|
|
5
|
-
hash[path] = Guide.new(path)
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
def dump
|
10
|
-
@paths.values.map do |path|
|
11
|
-
scan_target = true
|
12
|
-
scan_target = path.ancestors.all?(&:scan_children)
|
13
|
-
next unless scan_target
|
14
|
-
path.to_object
|
15
|
-
end.compact
|
16
|
-
end
|
17
|
-
alias_method :dump_hash, :dump
|
18
|
-
|
19
|
-
def dump_yaml
|
20
|
-
YAML.dump(dump_hash)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|