daff 1.3.10 → 1.3.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 425637893a696548920c2edd95fe0e621a7929cc
4
- data.tar.gz: ca6c9dc71c6691a78569a9c51c3702a90a473870
3
+ metadata.gz: 739a1d0666d271b0dcda5352e570e60782fdcd46
4
+ data.tar.gz: 5b7b271027b61d93d375333ee64c8cb97cdb0e6c
5
5
  SHA512:
6
- metadata.gz: cd0e3829f082c790fae47e78c2e6ac5f4ed6e4fa7edaf8eaff4ae35201ad596b19a1aa8e114ccf06c02995a46f44999ef72f42b20ed8be4c73c397d3aba432e4
7
- data.tar.gz: b908cc698839b8cc67ab1b8067cf714e0afed37500f6f4bf493d9f895313c849bf8f041e57ee8c73681ce2ed5964fb3272b627c9e87933e99f709dfaab5fed5a
6
+ metadata.gz: 57b95822bde10babe60ca996b60f8e15fdce5eb730172dfe3f63a1a67e688667aa1169df8dfc0517442bafe4aab83c650bf7e5e6692c02720e9fd4194304c852
7
+ data.tar.gz: 0e07ba411d6973e678603e95842fb4a63b6cccfdfd181722f81e51a2c47303a777cac01a55ffddc43323bdb6c4c67804dea235c12396adc51c2271621810a6ca
@@ -26,6 +26,7 @@ module Coopy
26
26
  @count_like_a_spreadsheet = true
27
27
  @ignore_whitespace = false
28
28
  @ignore_case = false
29
+ @terminal_format = nil
29
30
  end
30
31
 
31
32
  attr_accessor :ordered
@@ -50,6 +51,7 @@ module Coopy
50
51
  attr_accessor :count_like_a_spreadsheet
51
52
  attr_accessor :ignore_whitespace
52
53
  attr_accessor :ignore_case
54
+ attr_accessor :terminal_format
53
55
 
54
56
  def filter(act,allow)
55
57
  if @acts == nil
@@ -25,6 +25,7 @@ module Coopy
25
25
  attr_accessor :css_output
26
26
  attr_accessor :fragment
27
27
  attr_accessor :flags
28
+ attr_accessor :cache_txt
28
29
  attr_accessor :mv
29
30
 
30
31
  def init
@@ -36,45 +37,49 @@ module Coopy
36
37
  @nested_output = false
37
38
  @order_set = false
38
39
  @order_preference = false
40
+ @strategy = nil
39
41
  @pretty = true
40
42
  @css_output = nil
41
43
  @fragment = false
42
44
  @flags = nil
45
+ @cache_txt = nil
43
46
  end
44
47
 
45
48
  def check_format(name)
46
49
  return @format_preference if @extern_preference
47
50
  ext = ""
48
- pt = name.rindex(".",nil || 0) || -1
49
- if pt >= 0
50
- begin
51
- _this = name[pt + 1..-1]
52
- ext = _this.downcase
53
- end
54
- case(ext)
55
- when "json"
56
- @format_preference = "json"
57
- when "ndjson"
58
- @format_preference = "ndjson"
59
- when "csv"
60
- @format_preference = "csv"
61
- @delim_preference = ","
62
- when "tsv"
63
- @format_preference = "csv"
64
- @delim_preference = "\t"
65
- when "ssv"
66
- @format_preference = "csv"
67
- @delim_preference = ";"
68
- when "sqlite3"
69
- @format_preference = "sqlite"
70
- when "sqlite"
71
- @format_preference = "sqlite"
72
- when "html","htm"
73
- @format_preference = "html"
74
- when "www"
75
- @format_preference = "www"
76
- else
77
- ext = ""
51
+ if name != nil
52
+ pt = name.rindex(".",nil || 0) || -1
53
+ if pt >= 0
54
+ begin
55
+ _this = name[pt + 1..-1]
56
+ ext = _this.downcase
57
+ end
58
+ case(ext)
59
+ when "json"
60
+ @format_preference = "json"
61
+ when "ndjson"
62
+ @format_preference = "ndjson"
63
+ when "csv"
64
+ @format_preference = "csv"
65
+ @delim_preference = ","
66
+ when "tsv"
67
+ @format_preference = "csv"
68
+ @delim_preference = "\t"
69
+ when "ssv"
70
+ @format_preference = "csv"
71
+ @delim_preference = ";"
72
+ when "sqlite3"
73
+ @format_preference = "sqlite"
74
+ when "sqlite"
75
+ @format_preference = "sqlite"
76
+ when "html","htm"
77
+ @format_preference = "html"
78
+ when "www"
79
+ @format_preference = "www"
80
+ else
81
+ ext = ""
82
+ end
78
83
  end
79
84
  end
80
85
  @nested_output = @format_preference == "json" || @format_preference == "ndjson"
@@ -192,7 +197,9 @@ module Coopy
192
197
  end
193
198
 
194
199
  def save_text(name,txt)
195
- if name != "-"
200
+ if name == nil
201
+ @cache_txt += txt
202
+ elsif name != "-"
196
203
  @io.save_content(name,txt)
197
204
  else
198
205
  @io.write_stdout(txt)
@@ -263,6 +270,24 @@ module Coopy
263
270
  output
264
271
  end
265
272
 
273
+ def run_diff(parent,a,b,flags,output)
274
+ ct = ::Coopy::Coopy.compare_tables3(parent,a,b,flags)
275
+ align = ct.align
276
+ td = ::Coopy::TableDiff.new(align,flags)
277
+ o = ::Coopy::SimpleTable.new(0,0)
278
+ os = ::Coopy::Tables.new(o)
279
+ td.hilite_with_nesting(os)
280
+ use_color = flags.terminal_format == "ansi"
281
+ if flags.terminal_format == nil
282
+ if (output == nil || output == "-") && (@output_format == "copy" || @output_format == "csv")
283
+ if @io != nil
284
+ use_color = @io.is_tty if @io.is_tty_known
285
+ end
286
+ end
287
+ end
288
+ self.save_tables(output,os,use_color)
289
+ end
290
+
266
291
  public
267
292
 
268
293
  def load_table(name)
@@ -472,16 +497,18 @@ module Coopy
472
497
 
473
498
  public
474
499
 
475
- def coopyhx(io)
500
+ def run(args,io = nil)
501
+ io = ::Coopy::TableIO.new if io == nil
502
+ if io == nil
503
+ puts "No system interface available"
504
+ return 1
505
+ end
476
506
  self.init
477
- args = io.args
478
- return ::Coopy::Coopy.keep_around if args[0] == "--keep"
507
+ @io = io
479
508
  more = true
480
509
  output = nil
481
510
  inplace = false
482
511
  git = false
483
- color = false
484
- no_color = false
485
512
  @flags = ::Coopy::CompareFlags.new
486
513
  @flags.always_show_header = true
487
514
  while(more)
@@ -570,12 +597,12 @@ module Coopy
570
597
  break
571
598
  elsif tag == "--color"
572
599
  more = true
573
- color = true
600
+ @flags.terminal_format = "ansi"
574
601
  args.slice!(i,1)
575
602
  break
576
603
  elsif tag == "--no-color"
577
604
  more = true
578
- no_color = true
605
+ @flags.terminal_format = "plain"
579
606
  args.slice!(i,1)
580
607
  break
581
608
  elsif tag == "--input-format"
@@ -744,19 +771,17 @@ module Coopy
744
771
  args.push(old_file)
745
772
  args.push(new_file)
746
773
  end
747
- tool = self
748
- tool.io = io
749
774
  parent = nil
750
775
  if args.length - offset >= 3
751
- parent = tool.load_table(args[offset])
776
+ parent = self.load_table(args[offset])
752
777
  offset+=1
753
778
  end
754
779
  aname = args[offset]
755
- a = tool.load_table(aname)
780
+ a = self.load_table(aname)
756
781
  b = nil
757
782
  if args.length - offset >= 2
758
783
  if cmd1 != "copy"
759
- b = tool.load_table(args[1 + offset])
784
+ b = self.load_table(args[1 + offset])
760
785
  else
761
786
  output = args[1 + offset]
762
787
  end
@@ -775,35 +800,23 @@ module Coopy
775
800
  @flags.unchanged_context = 0 if !@flags.ordered
776
801
  end
777
802
  @flags.allow_nested_cells = @nested_output
778
- ct1 = ::Coopy::Coopy.compare_tables3(parent,a,b,@flags)
779
- align = ct1.align
780
- td = ::Coopy::TableDiff.new(align,@flags)
781
- o = ::Coopy::SimpleTable.new(0,0)
782
- os = ::Coopy::Tables.new(o)
783
- td.hilite_with_nesting(os)
784
- use_color = color
785
- if !(color || no_color)
786
- if output == "-" && @output_format == "copy"
787
- use_color = io.is_tty if io.is_tty_known
788
- end
789
- end
790
- tool.save_tables(output,os,use_color)
803
+ self.run_diff(parent,a,b,@flags,output)
791
804
  elsif cmd1 == "patch"
792
805
  patcher = ::Coopy::HighlightPatch.new(a,b)
793
806
  patcher.apply
794
- tool.save_table(output,a)
807
+ self.save_table(output,a)
795
808
  elsif cmd1 == "merge"
796
809
  merger = ::Coopy::Merger.new(parent,a,b,@flags)
797
810
  conflicts = merger.apply
798
811
  ok = conflicts == 0
799
812
  io.write_stderr(_hx_str(conflicts) + " conflict" + _hx_str((((conflicts > 1) ? "s" : ""))) + "\n") if conflicts > 0
800
- tool.save_table(output,a)
813
+ self.save_table(output,a)
801
814
  elsif cmd1 == "trim"
802
- tool.save_table(output,a)
815
+ self.save_table(output,a)
803
816
  elsif cmd1 == "render"
804
817
  self.render_table(output,a)
805
818
  elsif cmd1 == "copy"
806
- tool.save_table(output,a)
819
+ self.save_table(output,a)
807
820
  end
808
821
  if ok
809
822
  return 0
@@ -812,11 +825,17 @@ module Coopy
812
825
  end
813
826
  end
814
827
 
828
+ def coopyhx(io)
829
+ args = io.args
830
+ return ::Coopy::Coopy.keep_around if args[0] == "--keep"
831
+ self.run(args,io)
832
+ end
833
+
815
834
 
816
835
  class << self
817
836
  attr_accessor :version
818
837
  end
819
- @version = "1.3.10"
838
+ @version = "1.3.16"
820
839
 
821
840
  def Coopy.diff_as_html(local,remote,flags = nil)
822
841
  comp = ::Coopy::TableComparisonState.new
@@ -832,9 +851,12 @@ module Coopy
832
851
  end
833
852
 
834
853
  def Coopy.diff_as_ansi(local,remote,flags = nil)
835
- o = ::Coopy::Coopy.diff(local,remote,flags)
836
- render = ::Coopy::TerminalDiffRender.new(flags)
837
- render.render(o)
854
+ tool = ::Coopy::Coopy.new(::Coopy::TableIO.new)
855
+ tool.cache_txt = ""
856
+ flags = ::Coopy::CompareFlags.new if flags == nil
857
+ tool.output_format = "csv"
858
+ tool.run_diff(flags.parent,local,remote,flags,nil)
859
+ tool.cache_txt
838
860
  end
839
861
 
840
862
  def Coopy.diff(local,remote,flags = nil)
@@ -294,6 +294,12 @@ module Coopy
294
294
  @view.to_s(self.get_datum(c))
295
295
  end
296
296
 
297
+ def get_string_null(c)
298
+ d = self.get_datum(c)
299
+ return nil if d == nil
300
+ @view.to_s(d)
301
+ end
302
+
297
303
  def apply_meta
298
304
  _g1 = @payload_col
299
305
  _g = @payload_top
@@ -413,7 +419,7 @@ module Coopy
413
419
  cact = @modifier[i]
414
420
  next if cact == "..."
415
421
  next if name == nil || name == ""
416
- txt = self.get_string(i)
422
+ txt = @csv.parse_cell(self.get_string_null(i))
417
423
  updated = false
418
424
  if @row_info.updated
419
425
  self.get_pre_string(txt)
@@ -427,8 +433,20 @@ module Coopy
427
433
  end
428
434
  end
429
435
  if updated
430
- rc.cond[name] = @cell_info.lvalue
431
- rc.val[name] = @cell_info.rvalue
436
+ begin
437
+ value = @csv.parse_cell(@cell_info.lvalue)
438
+ begin
439
+ value1 = value
440
+ rc.cond[name] = value1
441
+ end
442
+ end
443
+ begin
444
+ value2 = @csv.parse_cell(@cell_info.rvalue)
445
+ begin
446
+ value3 = value2
447
+ rc.val[name] = value3
448
+ end
449
+ end
432
450
  elsif code == "+++"
433
451
  rc.val[name] = txt if cact != "---"
434
452
  elsif cact != "+++" && cact != "---"
@@ -59,7 +59,7 @@ module Coopy
59
59
  k1 = _it2._next
60
60
  q += " and " if lst.length > val_len
61
61
  q += db.get_quoted_column_name(k1)
62
- q += " = ?"
62
+ q += " IS ?"
63
63
  lst.push(conds[k1])
64
64
  end
65
65
  if !db._begin(q,lst,[])
@@ -7,6 +7,10 @@ module Coopy
7
7
  def initialize
8
8
  end
9
9
 
10
+ def valid
11
+ true
12
+ end
13
+
10
14
  def get_content(name)
11
15
  ::Sys::Io::HxFile.get_content(name)
12
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daff
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.10
4
+ version: 1.3.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Smith
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-04 00:00:00.000000000 Z
12
+ date: 2016-04-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Diff and patch tables
15
15
  email: