diff_influence 0.2.0 → 0.3.0

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: 5eba67ab25882f71a3576b52acbc8b381e0f7280
4
- data.tar.gz: dae12e5394b4cf018482cb2bc718521526a11819
3
+ metadata.gz: ded887aba89fc0d05fad74e61bb45011e6d30006
4
+ data.tar.gz: 4489751b59a9e8f84022dd27fa8df69f9c03d216
5
5
  SHA512:
6
- metadata.gz: dc91ec4e06ec21e54dafe2674e456dc8f35fa782003c6ab7f6452af6f2a41d40126eca393580ded039021b55d0d09df46e6d37c61a32ecdbc9cd5acb57917769
7
- data.tar.gz: 46487ffedc69981a28b4f6b35eedd5e652bd55e16142ec308705574c4dd632692fac811a6839c2c924f5f39c4d59ab9551c24d8543e59296bdfe505c541b088b
6
+ metadata.gz: 834c1c313cbe4cbee59e1d6b4ed41a654cfd4ee1c8013c50cd09a634566ad95d6bad8111e4133d8d5e44e643e449c159538eb39207412b69ae7ed8965b6150c1
7
+ data.tar.gz: 7ed8af9057c906a990d3448582a20f77de7818ecd39bf66de8a1c4070ccf4f0fc4b632cd7c95a8dce2fe6cae736e144427b4c866011647af0ca76e180e23075b
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.1
data/README.md CHANGED
@@ -36,6 +36,7 @@ Usage: diff-influence [Options]
36
36
 
37
37
  Options:
38
38
 
39
+ -c --commit commit_id,commit_id git commit id(s) uses diff (default: none)
39
40
  -p --path path,path,... path(s) to search file (default: app,lib)
40
41
  -e --ext extension,extension,... extension(s) to search file (default: rb)
41
42
  -g --grep use grep command with OS
@@ -43,7 +44,6 @@ Usage: diff-influence [Options]
43
44
 
44
45
  Feature Options:
45
46
 
46
- -c --commit commit_id,commit_id git commit id(s) uses diff (default: none)
47
47
  -o --output path to output file (default: STDOUT)
48
48
  ==============================================================================
49
49
  ```
@@ -9,6 +9,7 @@ Usage: diff_influence [Options]
9
9
 
10
10
  Options:
11
11
 
12
+ -c --commit commit_id,commit_id git commit id(s) uses diff (default: none)
12
13
  -p --path path,path,... path(s) to search file (default: app,lib)
13
14
  -e --ext extension,extension,... extension(s) to search file (default: rb)
14
15
  -g --grep use grep command with OS
@@ -16,7 +17,6 @@ Usage: diff_influence [Options]
16
17
 
17
18
  Feature Options:
18
19
 
19
- -c --commit commit_id,commit_id git commit id(s) uses diff (default: none)
20
20
  -o --output path to output file (default: STDOUT)
21
21
  ==============================================================================
22
22
  EOS
@@ -79,7 +79,7 @@ Usage: diff_influence [Options]
79
79
  when /\A--output\z/, /\A-o\z/
80
80
  @@output = argv.shift
81
81
  when /\A--grep\z/, /\A-g\z/
82
- @@debug = true
82
+ @@os_grep = true
83
83
  when /\A--debug\z/, /\A-d\z/
84
84
  @@debug = true
85
85
  when /\A--help\z/, /\A-h\z/
@@ -23,7 +23,7 @@ module DiffInfluence
23
23
  end
24
24
 
25
25
  def self.git_diff(file_path)
26
- `git --no-pager diff --no-ext-diff -U1000000 #{file_path}`
26
+ `git --no-pager diff --no-ext-diff -U1000000 #{DiffInfluence::Config.commits.join(" ")} #{file_path}`
27
27
  end
28
28
 
29
29
  def self.search_methods(file_path)
@@ -32,7 +32,8 @@ module DiffInfluence
32
32
  cnt = 0
33
33
  lines = self.git_diff(file_path).lines
34
34
  lines.each_with_index do |line, idx|
35
- if line =~ /(\s|\t|;)def/
35
+ method_line = line =~ /(\s|\t|;)def\s/
36
+ if method_line
36
37
  last_method = lines[idx].split("def ").last.chomp.gsub("self\.","")
37
38
  self.debug_log "Method line => #{last_method}"
38
39
  end
@@ -43,15 +44,13 @@ module DiffInfluence
43
44
  when /\A\+/, /\A\-/
44
45
  cnt += 1 if line =~ /\A\+/
45
46
  self.debug_log "idx:#{idx}, cnt:#{cnt}, #{line}"
46
-
47
- t = case line
48
- when /\A-(\s|\t)*def/
49
- "remove"
50
- when /\A\+(\s|\t)*def/
51
- "add"
47
+
48
+ t = if method_line
49
+ line =~ /\A\-/ ? "remove" : "add"
52
50
  else
53
51
  "effect"
54
52
  end
53
+
55
54
  methods.push EMeth.new(
56
55
  name: last_method,
57
56
  type: t,
@@ -23,7 +23,7 @@ module DiffInfluence
23
23
  end
24
24
 
25
25
  def self.git_diff(file_path)
26
- `git --no-pager diff --no-ext-diff -U1000000 #{file_path}`
26
+ `git --no-pager diff --no-ext-diff -U1000000 #{DiffInfluence::Config.commits.join(" ")} #{file_path}`
27
27
  end
28
28
 
29
29
  def self.search_methods(file_path)
@@ -32,7 +32,8 @@ module DiffInfluence
32
32
  cnt = 0
33
33
  lines = self.git_diff(file_path).lines.to_a
34
34
  lines.each_with_index do |line, idx|
35
- if line =~ /(\s|\t|;)def/
35
+ method_line = line =~ /(\s|\t|;)def\s/
36
+ if method_line
36
37
  last_method = lines[idx].split("def ").last.chomp.gsub("self\.","")
37
38
  self.debug_log "Method line => #{last_method}"
38
39
  end
@@ -43,15 +44,13 @@ module DiffInfluence
43
44
  when /\A\+/, /\A\-/
44
45
  cnt += 1 if line =~ /\A\+/
45
46
  self.debug_log "idx:#{idx}, cnt:#{cnt}, #{line}"
46
-
47
- t = case line
48
- when /\A-(\s|\t)*def/
49
- "remove"
50
- when /\A\+(\s|\t)*def/
51
- "add"
47
+
48
+ t = if method_line
49
+ line =~ /\A\-/ ? "remove" : "add"
52
50
  else
53
51
  "effect"
54
52
  end
53
+
55
54
  methods.push EMeth.new(
56
55
  :name => last_method,
57
56
  :type => t,
@@ -1,3 +1,3 @@
1
1
  module DiffInfluence
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diff_influence
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - metalels
@@ -76,6 +76,7 @@ extra_rdoc_files: []
76
76
  files:
77
77
  - ".gitignore"
78
78
  - ".rspec"
79
+ - ".ruby-version"
79
80
  - ".travis.yml"
80
81
  - Gemfile
81
82
  - LICENSE