deathnote 0.1.1 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d803893053af72a3692f28ce2eabebbc91b96f29
4
- data.tar.gz: 21afd988adf1d4b7bf2b484104c6a3c8bbaac21e
3
+ metadata.gz: ff1992993b2ffb3d3bff206c922aed61df172b72
4
+ data.tar.gz: 229c58189b2ff5c339edfccbeafd9abb392975e6
5
5
  SHA512:
6
- metadata.gz: d95f737032733f0f1d7d4a3262050f882e1ac831d740117e1f867f4ee252f2970c32623e4cb7b86cb886e78a5e6a1ea041fa58ae881a918f5a4231af5ebb60c6
7
- data.tar.gz: 0646d78846d451737466632714e552990b2784039b0b91803d53367313f1501457ec36765e42bb96864a598f1bc4831233d6e1394c46137b704410d225671e4e
6
+ metadata.gz: d14035c3ca967ca2689159c1d59dd73b698bd9521c172727bb95959c6163336403dd4c319ca97c342e5ffcb3530723d6a96e6fadeb28c9d2c8e694c169ee1d6d
7
+ data.tar.gz: 101d59c1a2bd001a5f12c894ec25a397d7ee3d1103d4558037f521ae478cc0372cac06e1ed1ab15f90fcf2daba70c2bbff5267bfd93a91c21815935c96f38a8a
@@ -9,19 +9,27 @@ module Deathnote
9
9
  class << self
10
10
  def run(argv)
11
11
  options = parse_options(argv)
12
- old_branch = Open3.popen3('git rev-parse --abbrev-ref HEAD') { |_i, o, _e, _t| o.read.chomp }
12
+ backup_commit = cmd('git rev-parse --abbrev-ref HEAD')
13
13
 
14
- base_missing = DeadCodes.new(branch: options[:base_commit], options: options.deep_clone).run
15
- pr_missing = DeadCodes.new(branch: options[:compare_commit], options: options.deep_clone).run
16
- Open3.popen3("git checkout #{old_branch}")
14
+ cmd("git checkout #{options[:past_commit]}")
15
+ past_missing = DeadCodes.new(options.deep_clone).run
17
16
 
18
- pr_missing.
19
- reject { |unused, _location| base_missing.has_key?(unused) }.
17
+ cmd("git checkout #{options[:newer_commit]}")
18
+ newer_missing = DeadCodes.new(options.deep_clone).run
19
+
20
+ newer_missing.
21
+ reject { |unused, _location| past_missing.has_key?(unused) }.
20
22
  each { |unused, location| puts "#{unused} #{location}" }
23
+ ensure
24
+ cmd("git checkout #{backup_commit}")
21
25
  end
22
26
 
23
27
  private
24
28
 
29
+ def cmd(command)
30
+ Open3.popen3(command) { |_i, o, _e, _t| o.read.chomp }
31
+ end
32
+
25
33
  def parse_options(argv)
26
34
  options = {}
27
35
  OptionParser.new do |opts|
@@ -31,11 +39,12 @@ module Deathnote
31
39
  puts opts
32
40
  exit
33
41
  end
34
- opts.on('-b', '--base=[commit hash]', 'Specify base commit hash.') do |base_commit|
35
- options[:base_commit] = base_commit
42
+ opts.on('-p[commit hash]', '--past-commit=[commit hash]', 'Specify past commit hash.') do |past_commit|
43
+ p past_commit
44
+ options[:past_commit] = past_commit
36
45
  end
37
- opts.on('-c', '--compare[commit hash]', 'Specify compare commit hash.') do |compare_commit|
38
- options[:compare_commit] = compare_commit
46
+ opts.on('-n[commit hash]', '--newer-commit=[commit hash]', 'Specify newer commit hash.') do |newer_commit|
47
+ options[:newer_commit] = newer_commit
39
48
  end
40
49
  opts.on('-r', '--rails', 'Filter some rails call conversions.') do
41
50
  options[:rails] = true
@@ -48,21 +57,18 @@ module Deathnote
48
57
 
49
58
  options
50
59
  rescue OptionParser::InvalidOption => e
51
- warn op.to_s
52
- warn ""
60
+ warn "Fail to parse options."
53
61
  warn e.message
54
62
  exit 1
55
63
  end
56
64
  end
57
65
 
58
66
  class DeadCodes
59
- def initialize(branch:, options:)
60
- @branch = branch
67
+ def initialize(options)
61
68
  @options = options
62
69
  end
63
70
 
64
71
  def run
65
- Open3.popen3("git checkout #{@branch}")
66
72
  to_list(run_debride)
67
73
  end
68
74
 
@@ -1,3 +1,3 @@
1
1
  module Deathnote
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deathnote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shia
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-03 00:00:00.000000000 Z
11
+ date: 2018-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler