codeclimate 0.20.1 → 0.20.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 +4 -4
- data/lib/cc/workspace.rb +1 -1
- data/lib/cc/workspace/path_tree.rb +16 -77
- data/lib/cc/workspace/path_tree/dir_node.rb +65 -0
- data/lib/cc/workspace/path_tree/file_node.rb +31 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bccbea964c2e9fbbfeb2b1155ef0bac717572d3
|
4
|
+
data.tar.gz: 90cad595d54c5f785c3690a5a7a110c346d07a26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99471f9cbc7508d2a13316093ec28151b97bc0b0a9ed0d2bf5c6f88dbb2eb7f867c3fdb534ef39824bd7c992c087bde4a1be13074178fa2bfb007cfc9ff7bbde
|
7
|
+
data.tar.gz: 29763fbda32cad04ed2c4b0b32d79ceb3f97ec4a3968d7bdb46fc6ff9d50ab574b0fa16da71363363ebb428fdabec8eebf055a69d18aa53c5c9d09d8f8549100
|
data/lib/cc/workspace.rb
CHANGED
@@ -4,107 +4,46 @@ require "set"
|
|
4
4
|
module CC
|
5
5
|
class Workspace
|
6
6
|
class PathTree
|
7
|
-
|
7
|
+
autoload :DirNode, "cc/workspace/path_tree/dir_node"
|
8
|
+
autoload :FileNode, "cc/workspace/path_tree/file_node"
|
9
|
+
|
10
|
+
def self.node_for_pathname(pathname)
|
8
11
|
if pathname.directory?
|
9
|
-
new(pathname.to_s)
|
12
|
+
DirNode.new(pathname.to_s)
|
10
13
|
else
|
11
14
|
FileNode.new(pathname.to_s)
|
12
15
|
end
|
13
16
|
end
|
14
17
|
|
15
|
-
def
|
16
|
-
|
17
|
-
|
18
|
+
def self.for_path(path)
|
19
|
+
new(node_for_pathname(Pathname.new(path)))
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(root_node)
|
23
|
+
@root_node = root_node
|
18
24
|
end
|
19
25
|
|
20
26
|
def clone
|
21
|
-
self.class.new(
|
27
|
+
self.class.new(root_node.clone)
|
22
28
|
end
|
23
29
|
|
24
30
|
def exclude_paths(paths)
|
25
|
-
paths.each { |path| remove(*normalized_path_pieces(path)) }
|
31
|
+
paths.each { |path| root_node.remove(*normalized_path_pieces(path)) }
|
26
32
|
end
|
27
33
|
|
28
34
|
def include_paths(paths)
|
29
|
-
paths.each { |path| add(*normalized_path_pieces(path)) }
|
30
|
-
end
|
31
|
-
|
32
|
-
def all_paths
|
33
|
-
if populated?
|
34
|
-
children.values.flat_map(&:all_paths)
|
35
|
-
else
|
36
|
-
[File.join(root_path, File::SEPARATOR)]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
protected
|
41
|
-
|
42
|
-
def populated?
|
43
|
-
children.present?
|
44
|
-
end
|
45
|
-
|
46
|
-
def remove(head = nil, *tail)
|
47
|
-
return if head.nil? && tail.empty?
|
48
|
-
populate_direct_children
|
49
|
-
|
50
|
-
if (child = children[head])
|
51
|
-
child.remove(*tail)
|
52
|
-
children.delete(head) unless child.populated?
|
53
|
-
end
|
35
|
+
paths.each { |path| root_node.add(*normalized_path_pieces(path)) }
|
54
36
|
end
|
55
37
|
|
56
|
-
|
57
|
-
return if head.nil? && tail.empty?
|
58
|
-
|
59
|
-
if (entry = find_direct_child(head))
|
60
|
-
children[entry.basename.to_s] = self.class.create(entry)
|
61
|
-
children[entry.basename.to_s].add(*tail)
|
62
|
-
else
|
63
|
-
CLI.debug("Couldn't include because part of path doesn't exist.", path: File.join(root_path, head))
|
64
|
-
end
|
65
|
-
end
|
38
|
+
delegate :all_paths, to: :root_node
|
66
39
|
|
67
40
|
private
|
68
41
|
|
69
|
-
attr_reader :
|
70
|
-
|
71
|
-
def populate_direct_children
|
72
|
-
return if populated?
|
73
|
-
|
74
|
-
Pathname.new(root_path).each_child do |child_path|
|
75
|
-
children[child_path.basename.to_s] = self.class.create(child_path)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def find_direct_child(name)
|
80
|
-
Pathname.new(root_path).children.detect { |c| c.basename.to_s == name }
|
81
|
-
end
|
42
|
+
attr_reader :root_node
|
82
43
|
|
83
44
|
def normalized_path_pieces(path)
|
84
45
|
Pathname.new(path).cleanpath.to_s.split(File::SEPARATOR).reject(&:blank?)
|
85
46
|
end
|
86
|
-
|
87
|
-
class FileNode
|
88
|
-
def initialize(root_path)
|
89
|
-
@root_path = root_path.dup.freeze
|
90
|
-
end
|
91
|
-
|
92
|
-
def all_paths
|
93
|
-
[@root_path]
|
94
|
-
end
|
95
|
-
|
96
|
-
def populated?
|
97
|
-
false
|
98
|
-
end
|
99
|
-
|
100
|
-
def remove(*)
|
101
|
-
# this space intentionally left blank
|
102
|
-
end
|
103
|
-
|
104
|
-
def add(*)
|
105
|
-
# this space intentionally left blank
|
106
|
-
end
|
107
|
-
end
|
108
47
|
end
|
109
48
|
end
|
110
49
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module CC
|
2
|
+
class Workspace
|
3
|
+
class PathTree
|
4
|
+
class DirNode
|
5
|
+
def initialize(root_path, children = {})
|
6
|
+
@root_path = root_path.dup.freeze
|
7
|
+
@children = children
|
8
|
+
end
|
9
|
+
|
10
|
+
def clone
|
11
|
+
self.class.new(root_path, children.dup)
|
12
|
+
end
|
13
|
+
|
14
|
+
def all_paths
|
15
|
+
if populated?
|
16
|
+
children.values.flat_map(&:all_paths)
|
17
|
+
else
|
18
|
+
[File.join(root_path, File::SEPARATOR)]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def populated?
|
23
|
+
children.present?
|
24
|
+
end
|
25
|
+
|
26
|
+
def remove(head = nil, *tail)
|
27
|
+
return if head.nil? && tail.empty?
|
28
|
+
populate_direct_children
|
29
|
+
|
30
|
+
if (child = children[head])
|
31
|
+
child.remove(*tail)
|
32
|
+
children.delete(head) if !child.populated? || tail.empty?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def add(head = nil, *tail)
|
37
|
+
return if head.nil? && tail.empty?
|
38
|
+
|
39
|
+
if (entry = find_direct_child(head))
|
40
|
+
children[entry.basename.to_s] = PathTree.node_for_pathname(entry)
|
41
|
+
children[entry.basename.to_s].add(*tail)
|
42
|
+
else
|
43
|
+
CLI.debug("Couldn't include because part of path doesn't exist.", path: File.join(root_path, head))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
attr_reader :children, :root_path
|
50
|
+
|
51
|
+
def populate_direct_children
|
52
|
+
return if populated?
|
53
|
+
|
54
|
+
Pathname.new(root_path).each_child do |child_path|
|
55
|
+
children[child_path.basename.to_s] = PathTree.node_for_pathname(child_path)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def find_direct_child(name)
|
60
|
+
Pathname.new(root_path).children.detect { |c| c.basename.to_s == name }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module CC
|
2
|
+
class Workspace
|
3
|
+
class PathTree
|
4
|
+
class FileNode
|
5
|
+
def initialize(root_path)
|
6
|
+
@root_path = root_path.dup.freeze
|
7
|
+
end
|
8
|
+
|
9
|
+
def all_paths
|
10
|
+
[root_path]
|
11
|
+
end
|
12
|
+
|
13
|
+
def populated?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def remove(*)
|
18
|
+
# this space intentionally left blank
|
19
|
+
end
|
20
|
+
|
21
|
+
def add(*)
|
22
|
+
# this space intentionally left blank
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
attr_reader :root_path
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codeclimate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.20.
|
4
|
+
version: 0.20.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code Climate
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -246,6 +246,8 @@ files:
|
|
246
246
|
- lib/cc/workspace.rb
|
247
247
|
- lib/cc/workspace/exclusion.rb
|
248
248
|
- lib/cc/workspace/path_tree.rb
|
249
|
+
- lib/cc/workspace/path_tree/dir_node.rb
|
250
|
+
- lib/cc/workspace/path_tree/file_node.rb
|
249
251
|
homepage: https://codeclimate.com
|
250
252
|
licenses:
|
251
253
|
- MIT
|
@@ -271,4 +273,3 @@ signing_key:
|
|
271
273
|
specification_version: 4
|
272
274
|
summary: Code Climate CLI
|
273
275
|
test_files: []
|
274
|
-
has_rdoc:
|