gry 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/lib/gry.rb +1 -0
- data/lib/gry/cli.rb +33 -2
- data/lib/gry/option.rb +3 -1
- data/lib/gry/rubocop_adapter.rb +4 -0
- data/lib/gry/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61403908364d6b8a076ca3b158db740638fd99e6
|
4
|
+
data.tar.gz: 9f8a3b348cb9990fd1cf20994f4aa115a78ebbd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67ae839eb8b9fdf577a41e7ee82060c4b87c251bb95e9ff939ee270179ecd5ee262a06624299fc36d549e625deabf0dd4846668a25fcfe48fae43eb6e44c81fc
|
7
|
+
data.tar.gz: 0b898367f552894f237520ad88432628f77ada36703024b19073f45e12df553fed9dadd7d502aa2ed240347d62e3aeb4ec7cff736530895234b101c8e6fdbea7
|
data/.travis.yml
CHANGED
data/lib/gry.rb
CHANGED
data/lib/gry/cli.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Gry
|
2
2
|
class CLI
|
3
|
+
CACHE_PATH = Pathname(ENV['XDG_CACHE_HOME'] || '~/.cache').expand_path / 'gry/cache'
|
4
|
+
|
3
5
|
def initialize(argv)
|
4
6
|
@argv = argv
|
5
7
|
end
|
@@ -16,9 +18,14 @@ module Gry
|
|
16
18
|
if opt.fast
|
17
19
|
cops.reject!{|cop| cop == 'Style/AlignHash'}
|
18
20
|
end
|
19
|
-
pilot_study = Gry::PilotStudy.new(cops, process: opt.process)
|
20
21
|
|
21
|
-
bills =
|
22
|
+
bills = (opt.cache && restore_cache(cops)) || begin
|
23
|
+
pilot_study = Gry::PilotStudy.new(cops, process: opt.process)
|
24
|
+
pilot_study.analyze.tap do |b|
|
25
|
+
save_cache(b, cops)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
22
29
|
congress = Congress.new(
|
23
30
|
max_count: opt.max_count,
|
24
31
|
min_difference: opt.min_difference,
|
@@ -31,5 +38,29 @@ module Gry
|
|
31
38
|
fmt = Formatter.new(display_disabled_cops: opt.display_disabled_cops)
|
32
39
|
writer.puts fmt.format(laws)
|
33
40
|
end
|
41
|
+
|
42
|
+
def save_cache(bills, cops)
|
43
|
+
cache_dir = CACHE_PATH.dirname
|
44
|
+
Dir.mkdir(cache_dir) unless cache_dir.exist?
|
45
|
+
cache = {
|
46
|
+
bills: bills,
|
47
|
+
cops: cops,
|
48
|
+
created_at: Time.now,
|
49
|
+
}
|
50
|
+
File.write(CACHE_PATH, Marshal.dump(cache))
|
51
|
+
end
|
52
|
+
|
53
|
+
def restore_cache(cops)
|
54
|
+
return unless CACHE_PATH.exist?
|
55
|
+
cache = Marshal.load(File.read(CACHE_PATH))
|
56
|
+
|
57
|
+
return unless cops == cache[:cops]
|
58
|
+
|
59
|
+
cached_time = cache[:created_at]
|
60
|
+
not_changed = RubocopAdapter.find_target_files.map(&:chomp).all?{|file| File.ctime(file) < cached_time}
|
61
|
+
return unless not_changed
|
62
|
+
|
63
|
+
return cache[:bills]
|
64
|
+
end
|
34
65
|
end
|
35
66
|
end
|
data/lib/gry/option.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Gry
|
2
2
|
class Option
|
3
|
-
attr_reader :args, :process, :version, :fast, :max_count, :min_difference, :display_disabled_cops, :metrics_percentile
|
3
|
+
attr_reader :args, :process, :version, :fast, :max_count, :min_difference, :display_disabled_cops, :metrics_percentile, :cache
|
4
4
|
|
5
5
|
def initialize(argv)
|
6
6
|
opt = OptionParser.new
|
@@ -11,6 +11,7 @@ module Gry
|
|
11
11
|
@min_difference = 10
|
12
12
|
@display_disabled_cops = false
|
13
13
|
@metrics_percentile = 95
|
14
|
+
@cache = true
|
14
15
|
|
15
16
|
opt.banner = 'Usage: gry [options] [Cop1, Cop2, ...]'
|
16
17
|
|
@@ -22,6 +23,7 @@ module Gry
|
|
22
23
|
opt.on('--min-difference=10', 'Lower limit of issues number difference') {|v| @min_difference = v.to_i}
|
23
24
|
opt.on('--metrics-percentile=95', 'Percentile for allowed complex code') {|v| @metrics_percentile = v.to_i}
|
24
25
|
opt.on('--display-disabled-cops', 'Display disabled cops') {|v| @display_disabled_cops = v}
|
26
|
+
opt.on('--[no-]cache', 'Run gry with cache. Default: true') {|v| @cache = v}
|
25
27
|
|
26
28
|
@args = opt.parse(argv)
|
27
29
|
end
|
data/lib/gry/rubocop_adapter.rb
CHANGED
data/lib/gry/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masataka Kuwabara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|