deal 0.0.1 → 0.0.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
  SHA256:
3
- metadata.gz: 9ae39b40eeecc6f975ba329d635d6253b8afeadaf1c3a13b2b6870bdedbbc4ee
4
- data.tar.gz: 3f442e74e003f64498b314437064d2ee55f96ef1d34b67ba5b50568eec7757c5
3
+ metadata.gz: 64c55e863d6ae854a1dade765920e7f336f46672eab7561e042569e2ea4581f2
4
+ data.tar.gz: f29ef62a31c14a95d19008d2196b2c1f026e060d5cb69b47098ecd1f2e62d2f3
5
5
  SHA512:
6
- metadata.gz: c9a864205ff7a952dc7f37629105a38bf292f8427b03943c26f79eb3a47f2b2b028d46dc2733a6cd54a933d8952a2266c004495111bb0904b0e46cc1dd86013d
7
- data.tar.gz: f799d1a78bcefeadd5681fc454beeb306d0ce9d64619cb389e301f249c97a79a4d0d6a738157173d77b64571c0edd18c3a3d574e3b1c734649fa519e94bae587
6
+ metadata.gz: 4e81a5706b06d860156ca0868acd5714bd8f5797c1fab507919ec5488d8366c0b8b89c2a9bc81e17f5dc11001377207441becb558b2c59d906c8c401eb9855f8
7
+ data.tar.gz: bceed1b4f3192cd8e29782adc4257d782260d94e3461e1d751b24f10a2bffd3e916d4e9c807845c5208f13c39f4156717bb565a67eac26b79acb2e4415ece9e0
@@ -1,3 +1,3 @@
1
1
  module Deal
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -17,11 +17,12 @@ module Deal
17
17
  }
18
18
 
19
19
  class DealResult
20
- def initialize(type,item,match_key,action)
20
+ def initialize(type,item,match_key,action,path)
21
21
  @type = type
22
- @item = item
22
+ @item = item.strip
23
23
  @match_key = match_key
24
24
  @action = action
25
+ @file_path = path
25
26
  end
26
27
 
27
28
  def set_line_n(line)
@@ -32,14 +33,15 @@ module Deal
32
33
  @file_path = path
33
34
  end
34
35
  def to_s
36
+
35
37
  s = []
36
38
  s.push '{'
37
- s.push "type:#{@type}" if @type
39
+ # s.push "type:#{@type}" if @type
38
40
  s.push "match_item:#{@item}" if @item
39
41
  s.push "match_key:#{@match_key}" if @match_key
40
- s.push "action:#{@action}" if @action
42
+ s.push "action:#{@action}" if @action && @action.length > 0
41
43
  s.push "file_path:#{@file_path}" if @file_path
42
- s.push "line_number:#{@line_n}" if @line_n
44
+ # s.push "line_number:#{@line_n}" if @line_n
43
45
  s.push '}'
44
46
 
45
47
  return s.join("\n")
@@ -99,7 +101,7 @@ module Deal
99
101
  end
100
102
  end
101
103
  if !JUDEG_ACTION.values.include? @judge_action
102
- logE "judge_action value [#{type}] is invalid"
104
+ logE "judge_action value [#{@judge_action}] is invalid"
103
105
  pass = false
104
106
  end
105
107
  if !pass
@@ -131,24 +133,25 @@ module Deal
131
133
  return true
132
134
  end
133
135
 
134
- def action(sign,line)
136
+ def action(sign,line,path=nil )
135
137
  if @judge_action == JUDEG_ACTION[:REPLACE]
136
138
  return @replace
137
139
  elsif @judge_action == JUDEG_ACTION[:REMOVE]
138
140
  return nil
139
141
  elsif @judge_action == JUDEG_ACTION[:ABORT]
140
- raise "
141
- find a error, do ABORT action:
142
- match key:#{sign.source}
143
- match item:#{line}
144
- "
142
+ error =[]
143
+ error.push "find a error, do ABORT action:"
144
+ error.push"match key:#{sign.source}"
145
+ error.push "match item:#{line}"
146
+ error.push "match path:#{path}"
147
+ raise error.join("\n")
145
148
  elsif @judge_action == JUDEG_ACTION[:REPORT]
146
149
  return line
147
150
  end
148
151
  end
149
152
  def judge_item(path)
150
153
  if !include_path(path)
151
- logW 'jump path'
154
+ logW 'jump path :'+path
152
155
  return
153
156
  end
154
157
 
@@ -196,8 +199,7 @@ module Deal
196
199
  for sign in @signs
197
200
  if sign.match? line
198
201
  action_tip = ''
199
- ret = action sign,line
200
- result.push ret
202
+ ret = action sign,line,path
201
203
  need_replace = true
202
204
  if ret
203
205
  lines.push ret
@@ -208,8 +210,9 @@ module Deal
208
210
  else
209
211
  action_tip = 'remove'
210
212
  end
211
- ret = DealResult.new('text',line,sign.source,action_tip)
213
+ ret = DealResult.new('text',line,sign.source,action_tip,path)
212
214
  ret.set_line_n lines.length
215
+ result.push ret
213
216
  end
214
217
  end
215
218
  if !need_replace
@@ -276,7 +279,7 @@ module Deal
276
279
  action_tip='remove files'
277
280
  FileUtils.rm_rf path
278
281
  end
279
- return results.push DealResult.new('path',path,sign.source,action_tip)
282
+ return results.push DealResult.new('path',nil ,sign.source,action_tip,path)
280
283
  end
281
284
  end
282
285
  return results
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kyle.zhou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-05 00:00:00.000000000 Z
11
+ date: 2021-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler