drone-hunter 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/bin/drone-hunter +5 -1
- data/lib/drone_hunter.rb +9 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e480e4c3cedc73d1c18070de5285a2a9ec12a01e203d87d96d33a4b3cd4239a
|
4
|
+
data.tar.gz: 5d5ff07a714bad22fac37ee885fa65f020a2a1c77f25975a375a54aa6083b512
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e59220a2943629071563fe2d3c05571a31637801ef42782c40d44a60676d537e29d303868bc2f1021a3e69952acc26de41409eb6b60f429b18e0d5b6b51b235a
|
7
|
+
data.tar.gz: a3d03c03c714a27d1091f228473f638181008780dd665afb0d7fcf0d59a59515a029cbcbf49541a2bd4c1078209f38023e03569e284c0ede4158abe8e2f3ec26
|
data/CHANGELOG.md
CHANGED
data/bin/drone-hunter
CHANGED
@@ -71,6 +71,9 @@ config = {
|
|
71
71
|
auto_paginate: boolean_from(ENV.fetch("DRONE_HUNTER_GITHUB_AUTO_PAGINATE", "true")),
|
72
72
|
access_token: github_access_token_from_environment
|
73
73
|
},
|
74
|
+
ignore: {
|
75
|
+
archived: boolean_from(ENV.fetch("DRONE_HUNTER_IGNORE_ARCHIVED", "false"))
|
76
|
+
},
|
74
77
|
log: {
|
75
78
|
level: log_level_from(ENV.fetch("DRONE_HUNTER_LOG_LEVEL", "info"))
|
76
79
|
},
|
@@ -93,6 +96,7 @@ OptionParser.new do |options|
|
|
93
96
|
options.on("-o", "--output-format=FORMAT", "env: DRONE_HUNTER_OUTPUT_FORMAT") { |argument| config[:output][:format] = output_format_from(argument) }
|
94
97
|
options.on("-p", "--output-path=PATH", "env: DRONE_HUNTER_OUTPUT_PATH") { |argument| config[:output][:path] = File.expand_path(argument) }
|
95
98
|
options.on("-N", "--[no-]output-normalize", "env: DRONE_HUNTER_OUTPUT_NORMALIZE") { |argument| config[:output][:normalize] = argument }
|
99
|
+
options.on("-A", "--[no-]ignore-archived", "env: DRONE_HUNTER_IGNORE_ARCHIVED") { |argument| config[:ignore][:archived] = argument }
|
96
100
|
end.parse!
|
97
101
|
|
98
102
|
#################
|
@@ -134,7 +138,7 @@ cache = Moneta.new(:File, dir: config[:cache][:dir])
|
|
134
138
|
# Main Program #
|
135
139
|
################
|
136
140
|
|
137
|
-
hunt = DroneHunter.new(owners: ARGV, log: log, github: github, cache: cache)
|
141
|
+
hunt = DroneHunter.new(owners: ARGV, log: log, github: github, cache: cache, ignore: config[:ignore])
|
138
142
|
|
139
143
|
if config[:hacking]
|
140
144
|
require "pry"
|
data/lib/drone_hunter.rb
CHANGED
@@ -21,12 +21,18 @@ class DroneHunter
|
|
21
21
|
@github ||= options.fetch(:client) { Octokit::Client.new(auto_paginate: true) }
|
22
22
|
@cache ||= options.fetch(:cache) { Moneta.new(:File, dir: 'drone-hunter.cache') }
|
23
23
|
@owners ||= Set.new(options.fetch(:owners, []))
|
24
|
+
@ignoring ||= { archived: false }.merge(options.fetch(:ignore, {}))
|
24
25
|
end
|
25
26
|
|
26
27
|
attr_reader :log
|
27
28
|
attr_reader :github
|
28
29
|
attr_reader :cache
|
29
30
|
attr_reader :owners
|
31
|
+
attr_reader :ignoring
|
32
|
+
|
33
|
+
def ignoring_archived?
|
34
|
+
ignoring.fetch(:archived, false)
|
35
|
+
end
|
30
36
|
|
31
37
|
def cached(key, *rest, &block)
|
32
38
|
if cache.key?(key)
|
@@ -41,7 +47,9 @@ class DroneHunter
|
|
41
47
|
def repositories(owner = nil)
|
42
48
|
case owner
|
43
49
|
when String then cached("repositories/#{owner}") { github.repositories(owner) }
|
44
|
-
when nil then owners.flat_map { |owner| repositories(owner) }
|
50
|
+
when nil then owners.flat_map { |owner| repositories(owner) }.reject do |repo|
|
51
|
+
ignoring_archived? && repo.archived
|
52
|
+
end
|
45
53
|
else raise TypeError
|
46
54
|
end
|
47
55
|
end
|