diffyc32 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3c381a8c1a57a87e203023821e6264c7f858edad60cebf692d0f10880ef49275
4
+ data.tar.gz: b980b1c82b0b7370d5eaa4e4ef6bb276f2ad3f06a6b3aa81e24c8d46c5d241b8
5
+ SHA512:
6
+ metadata.gz: bcbffc87403b4ad31a9f152ccd243d73f64b0cc76fb3801876b4d4e7f082958aa4fed047067b4a64f339dcc6d1bb275eec614d67ae2345add67ba6cada8443fb
7
+ data.tar.gz: 36f957f3b6cd572b120786d9988193a024f8a26934968c66e59d313505c47bd666a6b26ed0fcbbf52d786c1fa1ffe228bea924062a2efe127fd544f021dd8c35
Binary file
@@ -0,0 +1,3 @@
1
+ �;}, ����q�A=|{3��Q�����<�c�T �*��`���fKtz����AP��� �i�C�`�5�Ϧ�N���3'px8l^���X`���k�5R�x�n@.���}ѕ�3&���κ��H�k�����w;W�]��\ch
2
+ 3�m������.�ar&�v$�G�6n5Q��u�8K�-D�mI��+W
3
+ .���G���L��N�O��0Q �@��4&:$�5 �:Jn
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: diffyc32.rb
4
+
5
+ require 'c32'
6
+ require 'rexle'
7
+ require 'diffy'
8
+
9
+
10
+ class DiffyC32
11
+ using ColouredText
12
+
13
+ def initialize(s1, s2)
14
+ html = Diffy::Diff.new(s1, s2).to_s(:html)
15
+
16
+ doc = Rexle.new(html)
17
+ a = doc.root.xpath('ul/li/*')
18
+ a2 = a.map do |e|
19
+ txt = case e.name.to_sym
20
+ when :del
21
+ colour_strong(e, :red)
22
+ ' - '.red + ' ' + e.plaintext
23
+ when :ins
24
+ colour_strong(e) {|x| x.light_green}
25
+ ' + '.green + ' ' + e.plaintext
26
+ when :span
27
+ ' ' + ' ' + e.plaintext
28
+ else
29
+ ' ' + ' ' + e.plaintext
30
+ end
31
+ end
32
+
33
+ @s = a2.join("\n")
34
+ end
35
+
36
+ def to_s()
37
+ @s
38
+ end
39
+
40
+ private
41
+
42
+ def colour_strong(e, colour=:magenta)
43
+
44
+ # check for strong element
45
+ strong = e.element('strong')
46
+
47
+ if strong then
48
+
49
+ strong.text = if block_given? then
50
+ yield(strong.text.to_s)
51
+ else
52
+ strong.text.to_s.send(colour.to_sym)
53
+ end
54
+
55
+ end
56
+
57
+ end
58
+ end
59
+
60
+ if __FILE__ == $0 then
61
+ string1, string2 = ARGV
62
+ puts DiffyC32.new(string1, string2).to_s
63
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: diffyc32
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
+ YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjAwOTExMTk1OTUwWhcN
15
+ MjEwOTExMTk1OTUwWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
+ cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDM5v+B
17
+ RQe6zRmci+QNm4Lw+lwTOGthPNUYIdZ7RLVKiqgzlASepDNoLqV2PabDuppvT0Vb
18
+ g/8AnrH728B2LkgE7XPSwGC7I91tYI7cNx+1L4f+N7kPtCPdY0Zq7ioKCiQzm9Fz
19
+ g9TCNuHnFPWXbJLDCCnFCjLUhVErUh1O2k2L00WBv+P0LA53THoxKuVV+q+wGm6k
20
+ Zo02qMK2tv2IYjiQtMUwqutJdZVqdJCLfxjMGV5pClKw5B8u4Kphq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WjVw7AsIOPl8Gwtq
37
+ -----END CERTIFICATE-----
38
+ date: 2020-09-11 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: c32
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.2.0
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.2'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 0.2.0
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '0.2'
60
+ - !ruby/object:Gem::Dependency
61
+ name: rexle
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '1.5'
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 1.5.8
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '1.5'
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 1.5.8
80
+ - !ruby/object:Gem::Dependency
81
+ name: diffy
82
+ requirement: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 3.4.0
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.4'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 3.4.0
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '3.4'
100
+ description:
101
+ email: james@jamesrobertson.eu
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - lib/diffyc32.rb
107
+ homepage: https://github.com/jrobertson/diffyc32
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubygems_version: 3.0.3
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Diffy with colour on the command-line.
130
+ test_files: []
Binary file