cmpfs-ruby 0.2.0 → 0.2.1.1

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.
@@ -1,89 +1,87 @@
1
1
 
2
- #require 'xqsr3'
3
-
4
2
  require 'fileutils'
5
3
  require 'stringio'
6
4
 
5
+
7
6
  module CmpFS
8
7
  module Compare
9
8
  module Binary
10
9
 
11
10
  module Internal_
12
11
 
13
- def self.determine_param_type_ p
14
-
15
- case p
16
- when ::IO, ::StringIO
12
+ def self.determine_param_type_ p
17
13
 
18
- return :io
19
- when ::String
14
+ case p
15
+ when ::IO, ::StringIO
20
16
 
21
- return :path
22
- else
17
+ return :io
18
+ when ::String
23
19
 
24
- return :path if p.respond_to?(:to_str)
20
+ return :path
21
+ else
25
22
 
26
- return nil
27
- end
28
- end
23
+ return :path if p.respond_to?(:to_str)
29
24
 
30
- def self.compare_binary_files_ lhs_path, rhs_path, options
25
+ return nil
26
+ end
27
+ end
31
28
 
32
- FileUtils.compare_file lhs_path, rhs_path
33
- end
29
+ def self.compare_binary_files_ lhs_path, rhs_path, options
34
30
 
35
- def self.compare_binary_streams_ lhs_stm, rhs_stm, options
31
+ FileUtils.compare_file lhs_path, rhs_path
32
+ end
36
33
 
37
- FileUtils.compare_stream lhs_stm, rhs_stm
38
- end
34
+ def self.compare_binary_streams_ lhs_stm, rhs_stm, options
39
35
 
40
- def self.compare_binary_ lhs, rhs, options
36
+ FileUtils.compare_stream lhs_stm, rhs_stm
37
+ end
41
38
 
39
+ def self.compare_binary_ lhs, rhs, options
42
40
 
43
- lhs_type = self.determine_param_type_ lhs
44
- rhs_type = self.determine_param_type_ rhs
41
+ lhs_type = self.determine_param_type_ lhs
42
+ rhs_type = self.determine_param_type_ rhs
45
43
 
46
- raise ArgumentError, "lhs is of unsupported type '#{lhs.class}'" unless lhs_type
47
- raise ArgumentError, "rhs is of unsupported type '#{rhs.class}'" unless rhs_type
44
+ raise ArgumentError, "lhs is of unsupported type '#{lhs.class}'" unless lhs_type
45
+ raise ArgumentError, "rhs is of unsupported type '#{rhs.class}'" unless rhs_type
48
46
 
49
- if lhs_type == rhs_type
47
+ if lhs_type == rhs_type
50
48
 
51
- case lhs_type
52
- when :io
49
+ case lhs_type
50
+ when :io
53
51
 
54
- return self.compare_binary_streams_ lhs, rhs, options
55
- when :path
52
+ return self.compare_binary_streams_ lhs, rhs, options
53
+ when :path
56
54
 
57
- return self.compare_binary_files_ lhs, rhs, options
58
- end
59
- else
55
+ return self.compare_binary_files_ lhs, rhs, options
56
+ end
57
+ else
60
58
 
61
- case lhs_type
62
- when :io
59
+ case lhs_type
60
+ when :io
63
61
 
64
- if :path == rhs_type
62
+ if :path == rhs_type
65
63
 
66
- File.open(rhs, 'rb') do |rhs_f|
64
+ File.open(rhs, 'rb') do |rhs_f|
67
65
 
68
- return self.compare_binary_streams_ lhs, rhs_f, options
69
- end
70
- end
71
- when :path
66
+ return self.compare_binary_streams_ lhs, rhs_f, options
67
+ end
68
+ end
69
+ when :path
72
70
 
73
- if :path == lhs_type
71
+ if :path == lhs_type
74
72
 
75
- File.open(lhs, 'rb') do |lhs_f|
73
+ File.open(lhs, 'rb') do |lhs_f|
76
74
 
77
- return self.compare_binary_streams_ lhs_f, rhs, options
78
- end
79
- end
80
- end
81
- end
75
+ return self.compare_binary_streams_ lhs_f, rhs, options
76
+ end
77
+ end
78
+ end
79
+ end
82
80
 
83
- warn "#{__method__}: incompatible types (#{lhs.type}, #{rhs.type})"
81
+ warn "#{__method__}: incompatible types (#{lhs.type}, #{rhs.type})"
84
82
 
85
- nil
86
- end
83
+ nil
84
+ end
87
85
 
88
86
  end # module Internal_
89
87
 
@@ -91,6 +89,6 @@ end # module Binary
91
89
  end # module Compare
92
90
  end # module CmpFS
93
91
 
94
- # ############################## end of file ############################# #
95
92
 
93
+ # ############################## end of file ############################# #
96
94
 
@@ -1,159 +1,156 @@
1
1
 
2
- #require 'xqsr3'
3
-
4
2
  require 'fileutils'
5
3
  require 'stringio'
6
4
 
5
+
7
6
  module CmpFS
8
7
  module Compare
9
8
  module Text
10
9
 
11
10
  module Internal_
12
11
 
13
- def self.determine_param_type_ p
14
-
15
- case p
16
- when ::IO, ::StringIO
12
+ def self.determine_param_type_ p
17
13
 
18
- return :io
19
- when ::String
14
+ case p
15
+ when ::IO, ::StringIO
20
16
 
21
- return :path
22
- else
17
+ return :io
18
+ when ::String
23
19
 
24
- return :path if p.respond_to?(:to_str)
20
+ return :path
21
+ else
25
22
 
26
- return nil
27
- end
28
- end
23
+ return :path if p.respond_to?(:to_str)
29
24
 
30
- def self.next_line_or_nil_ en, options
25
+ return nil
26
+ end
27
+ end
31
28
 
32
- trimming_lines = options[:trim_lines]
33
- skipping_blanks = options[:skip_blank_lines]
29
+ def self.next_line_or_nil_ en, options
34
30
 
35
- num_read = 0
31
+ skipping_blanks = options[:skip_blank_lines]
32
+ trimming_lines = options[:trim_lines]
36
33
 
37
- begin
34
+ num_read = 0
38
35
 
39
- loop do
36
+ begin
40
37
 
41
- line = en.next
38
+ loop do
42
39
 
43
- num_read += 1
40
+ line = en.next
44
41
 
45
- line = line.strip if trimming_lines
42
+ num_read += 1
46
43
 
47
- if line.empty? && skipping_blanks
44
+ line = line.strip if trimming_lines
48
45
 
49
- next
50
- end
46
+ if line.empty? && skipping_blanks
51
47
 
52
- return [ line, num_read ]
53
- end
54
- rescue StopIteration
48
+ next
49
+ end
55
50
 
56
- end
51
+ return [ line, num_read ]
52
+ end
53
+ rescue StopIteration
57
54
 
58
- return [ nil, num_read ]
59
- end
55
+ end
60
56
 
61
- def self.compare_text_files_ lhs_path, rhs_path, options
57
+ return [ nil, num_read ]
58
+ end
62
59
 
63
- File.open(lhs_path, 'r') do |lhs_stm|
60
+ def self.compare_text_files_ lhs_path, rhs_path, options
64
61
 
65
- File.open(rhs_path, 'r') do |rhs_stm|
62
+ File.open(lhs_path, 'r') do |lhs_stm|
66
63
 
67
- self.compare_text_streams_ lhs_stm, rhs_stm, options.merge(no_rewind: true)
68
- end
69
- end
70
- end
64
+ File.open(rhs_path, 'r') do |rhs_stm|
71
65
 
72
- def self.compare_text_streams_ lhs_stm, rhs_stm, options
66
+ self.compare_text_streams_ lhs_stm, rhs_stm, options.merge(no_rewind: true)
67
+ end
68
+ end
69
+ end
73
70
 
74
- lhs_en = lhs_stm.each_line
75
- rhs_en = rhs_stm.each_line
71
+ def self.compare_text_streams_ lhs_stm, rhs_stm, options
76
72
 
77
- unless options[:no_rewind]
73
+ lhs_en = lhs_stm.each_line
74
+ rhs_en = rhs_stm.each_line
78
75
 
79
- lhs_en.rewind if lhs_stm.respond_to?(:rewind)
80
- rhs_en.rewind if rhs_stm.respond_to?(:rewind)
81
- end
76
+ unless options[:no_rewind]
82
77
 
83
- lhs_ix = 0
84
- rhs_ix = 0
78
+ lhs_en.rewind if lhs_stm.respond_to?(:rewind)
79
+ rhs_en.rewind if rhs_stm.respond_to?(:rewind)
80
+ end
85
81
 
86
- loop do
82
+ lhs_ix = 0
83
+ rhs_ix = 0
87
84
 
88
- lhs_ln, lhs_nr = self.next_line_or_nil_ lhs_en, options
89
- rhs_ln, rhs_nr = self.next_line_or_nil_ rhs_en, options
85
+ loop do
90
86
 
91
- if lhs_ln != rhs_ln
87
+ lhs_ln, lhs_nr = self.next_line_or_nil_ lhs_en, options
88
+ rhs_ln, rhs_nr = self.next_line_or_nil_ rhs_en, options
92
89
 
93
- return false
94
- else
90
+ if lhs_ln != rhs_ln
95
91
 
96
- return true if lhs_ln.nil?
97
- end
98
- end
92
+ return false
93
+ else
99
94
 
100
- return true
101
- end
95
+ return true if lhs_ln.nil?
96
+ end
97
+ end
102
98
 
103
- def self.compare_text_ lhs, rhs, options
99
+ return true
100
+ end
104
101
 
105
- lhs_type = self.determine_param_type_ lhs
106
- rhs_type = self.determine_param_type_ rhs
102
+ def self.compare_text_ lhs, rhs, options
107
103
 
108
- raise ArgumentError, "lhs is of unsupported type '#{lhs.class}'" unless lhs_type
109
- raise ArgumentError, "rhs is of unsupported type '#{rhs.class}'" unless rhs_type
104
+ lhs_type = self.determine_param_type_ lhs
105
+ rhs_type = self.determine_param_type_ rhs
110
106
 
111
- if lhs_type == rhs_type
107
+ raise ArgumentError, "lhs is of unsupported type '#{lhs.class}'" unless lhs_type
108
+ raise ArgumentError, "rhs is of unsupported type '#{rhs.class}'" unless rhs_type
112
109
 
113
- case lhs_type
114
- when :io
110
+ if lhs_type == rhs_type
115
111
 
116
- return self.compare_text_streams_ lhs, rhs, options
117
- when :path
112
+ case lhs_type
113
+ when :io
118
114
 
119
- return self.compare_text_files_ lhs, rhs, options
120
- end
121
- else
115
+ return self.compare_text_streams_ lhs, rhs, options
116
+ when :path
122
117
 
123
- case lhs_type
124
- when :io
118
+ return self.compare_text_files_ lhs, rhs, options
119
+ end
120
+ else
125
121
 
126
- if :path == rhs_type
122
+ case lhs_type
123
+ when :io
127
124
 
128
- File.open(rhs, 'r') do |rhs_f|
125
+ if :path == rhs_type
129
126
 
130
- return self.compare_text_streams_ lhs, rhs_f, options
131
- end
132
- end
133
- when :path
127
+ File.open(rhs, 'r') do |rhs_f|
134
128
 
135
- if :path == lhs_type
129
+ return self.compare_text_streams_ lhs, rhs_f, options
130
+ end
131
+ end
132
+ when :path
136
133
 
137
- File.open(lhs, 'r') do |lhs_f|
134
+ if :path == lhs_type
138
135
 
139
- return self.compare_text_streams_ lhs_f, rhs, options
140
- end
141
- end
142
- end
143
- end
136
+ File.open(lhs, 'r') do |lhs_f|
144
137
 
145
- warn "#{__method__}: incompatible types (#{lhs.type}, #{rhs.type})"
138
+ return self.compare_text_streams_ lhs_f, rhs, options
139
+ end
140
+ end
141
+ end
142
+ end
146
143
 
147
- nil
148
- end
144
+ warn "#{__method__}: incompatible types (#{lhs.type}, #{rhs.type})"
149
145
 
146
+ nil
147
+ end
150
148
  end # module Internal_
151
149
 
152
150
  end # module Text
153
151
  end # module Compare
154
152
  end # module CmpFS
155
153
 
156
- # ############################## end of file ############################# #
157
-
158
154
 
155
+ # ############################## end of file ############################# #
159
156
 
data/lib/cmpfs/compare.rb CHANGED
@@ -1,16 +1,17 @@
1
1
 
2
2
  # ######################################################################## #
3
- # File: cmpfs/version.rb
3
+ # File: cmpfs/version.rb
4
4
  #
5
- # Purpose: Version for cmpfs.Ruby library
5
+ # Purpose: Version for cmpfs.Ruby library
6
6
  #
7
- # Created: 1st March 2019
8
- # Updated: 13th March 2019
7
+ # Created: 1st March 2019
8
+ # Updated: 1st April 2024
9
9
  #
10
- # Home: http://github.com/synesissoftware/cmpfs.Ruby
10
+ # Home: http://github.com/synesissoftware/cmpfs.Ruby
11
11
  #
12
- # Author: Matthew Wilson
12
+ # Author: Matthew Wilson
13
13
  #
14
+ # Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
14
15
  # Copyright (c) 2019, Matthew Wilson and Synesis Software
15
16
  # All rights reserved.
16
17
  #
@@ -46,12 +47,13 @@
46
47
 
47
48
  if RUBY_VERSION >= '2'
48
49
 
49
- require 'cmpfs/compare/api_2'
50
+ require 'cmpfs/compare/api_2'
50
51
  else
51
52
 
52
- require 'cmpfs/compare/api_1_9'
53
+ require 'cmpfs/compare/api_1_9'
53
54
  end
54
55
 
56
+
55
57
  =begin
56
58
  =end
57
59
 
@@ -73,32 +75,32 @@ module CmpFS
73
75
  #
74
76
  module Compare
75
77
 
76
- def self.extended receiver
78
+ def self.extended receiver
77
79
 
78
- receiver.class_eval do
80
+ receiver.class_eval do
79
81
 
80
- extend CmpFS_Compare_Methods
81
- end
82
+ extend CmpFS_Compare_Methods
83
+ end
82
84
 
83
- $stderr.puts "#{receiver} extended by #{CmpFS_Compare_Methods}" if $DEBUG
84
- end
85
+ $stderr.puts "#{receiver} extended by #{CmpFS_Compare_Methods}" if $DEBUG
86
+ end
85
87
 
86
- def self.included receiver
88
+ def self.included receiver
87
89
 
88
- receiver.class_eval do
90
+ receiver.class_eval do
89
91
 
90
- include CmpFS_Compare_Methods
91
- end
92
+ include CmpFS_Compare_Methods
93
+ end
92
94
 
93
- $stderr.puts "#{receiver} included #{CmpFS_Compare_Methods}" if $DEBUG
94
- end
95
+ $stderr.puts "#{receiver} included #{CmpFS_Compare_Methods}" if $DEBUG
96
+ end
95
97
 
96
- extend CmpFS_Compare_Methods
97
- include CmpFS_Compare_Methods
98
+ extend CmpFS_Compare_Methods
99
+ include CmpFS_Compare_Methods
98
100
 
99
101
  end # module Compare
100
102
  end # module CmpFS
101
103
 
102
- # ############################## end of file ############################# #
103
104
 
105
+ # ############################## end of file ############################# #
104
106
 
data/lib/cmpfs/version.rb CHANGED
@@ -1,16 +1,17 @@
1
1
 
2
2
  # ######################################################################## #
3
- # File: cmpfs/version.rb
3
+ # File: cmpfs/version.rb
4
4
  #
5
- # Purpose: Version for cmpfs.Ruby library
5
+ # Purpose: Version for cmpfs.Ruby library
6
6
  #
7
- # Created: 1st March 2019
8
- # Updated: 13th March 2019
7
+ # Created: 1st March 2019
8
+ # Updated: 1st April 2024
9
9
  #
10
- # Home: http://github.com/synesissoftware/cmpfs.Ruby
10
+ # Home: http://github.com/synesissoftware/cmpfs.Ruby
11
11
  #
12
- # Author: Matthew Wilson
12
+ # Author: Matthew Wilson
13
13
  #
14
+ # Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
14
15
  # Copyright (c) 2019, Matthew Wilson and Synesis Software
15
16
  # All rights reserved.
16
17
  #
@@ -49,23 +50,23 @@
49
50
 
50
51
  module CmpFS
51
52
 
52
- # Current version of the cmpfs.Ruby library
53
- VERSION = '0.2.0'
53
+ # Current version of the cmpfs.Ruby library
54
+ VERSION = '0.2.1.1'
54
55
 
55
- private
56
- VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
57
- public
58
- # Major version of the cmpfs.Ruby library
59
- VERSION_MAJOR = VERSION_PARTS_[0] # :nodoc:
60
- # Minor version of the cmpfs.Ruby library
61
- VERSION_MINOR = VERSION_PARTS_[1] # :nodoc:
62
- # Revision version of the cmpfs.Ruby library
63
- VERSION_PATCH = VERSION_PARTS_[2] # :nodoc:
56
+ private
57
+ VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
58
+ public
59
+ # Major version of the cmpfs.Ruby library
60
+ VERSION_MAJOR = VERSION_PARTS_[0] # :nodoc:
61
+ # Minor version of the cmpfs.Ruby library
62
+ VERSION_MINOR = VERSION_PARTS_[1] # :nodoc:
63
+ # Revision version of the cmpfs.Ruby library
64
+ VERSION_PATCH = VERSION_PARTS_[2] # :nodoc:
64
65
 
65
- VERSION_REVISION = VERSION_PATCH # :nodoc:
66
+ VERSION_REVISION = VERSION_PATCH # :nodoc:
66
67
 
67
68
  end # module CmpFS
68
69
 
69
- # ############################## end of file ############################# #
70
70
 
71
+ # ############################## end of file ############################# #
71
72
 
data/lib/cmpfs.rb CHANGED
@@ -11,6 +11,7 @@
11
11
  #
12
12
  # Author: Matthew Wilson
13
13
  #
14
+ # Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
14
15
  # Copyright (c) 2019, Matthew Wilson and Synesis Software
15
16
  # All rights reserved.
16
17
  #
@@ -53,25 +54,28 @@ require 'cmpfs/version'
53
54
  ## Root module for *cmpfs*
54
55
  module CmpFS
55
56
 
56
- def self.extended receiver
57
+ def self.extended receiver
57
58
 
58
- receiver.class_eval do
59
+ receiver.class_eval do
59
60
 
60
- extend CmpFS::Compare
61
- end
61
+ extend CmpFS::Compare
62
+ end
62
63
 
63
- $stderr.puts "#{receiver} extended by #{CmpFS}" if $DEBUG
64
- end
64
+ $stderr.puts "#{receiver} extended by #{CmpFS}" if $DEBUG
65
+ end
65
66
 
66
- def self.included receiver
67
+ def self.included receiver
67
68
 
68
- receiver.class_eval do
69
+ receiver.class_eval do
69
70
 
70
- include CmpFS::Compare
71
- end
71
+ include CmpFS::Compare
72
+ end
72
73
 
73
- $stderr.puts "#{receiver} included #{CmpFS}" if $DEBUG
74
- end
74
+ $stderr.puts "#{receiver} included #{CmpFS}" if $DEBUG
75
+ end
75
76
 
76
77
  end # module CmpFS
77
78
 
79
+
80
+ # ############################## end of file ############################# #
81
+