double_checker 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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +0 -0
- data/LICENSE +22 -0
- data/README.md +0 -0
- data/double_checker.gemspec +19 -0
- data/lib/double_checker/version.rb +5 -0
- data/lib/double_checker.rb +141 -0
- metadata +50 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e44cb495da4d9a1caa5d0d1aa0e3464a254392e3b5c9a2ecb2a0e95d68d5e017
|
|
4
|
+
data.tar.gz: 16308b676342c1763ceac2473995feea45d6140251e8bc14e9f23cc5ebb44280
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 6240ba0341e600a04426b69db9fba869ff33cfe5185184e10f44b10e84ac93ea0ec21711cdff2b9003495258631ccf457db9ab034d307c591e03b60c0ca094e8
|
|
7
|
+
data.tar.gz: fc96b604be315eb871879c1dae6052c2c000450071dd0b8135d74c48c6d20cf96ddd390b7544898b346a23c686157c7d3a93a8686b47bc5a54a8c37f7c0ed4d7
|
data/CHANGELOG.md
ADDED
|
File without changes
|
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Lokalise team, Ilya Bodrov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.expand_path('lib/double_checker/version', __dir__)
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'double_checker'
|
|
7
|
+
spec.version = DoubleChecker::VERSION
|
|
8
|
+
spec.authors = ['Alex Boyd']
|
|
9
|
+
spec.email = ['alex.boyd@gwu.edu']
|
|
10
|
+
spec.summary = 'Gem for comparing file overrides while using a Rails engine.'
|
|
11
|
+
spec.license = 'MIT'
|
|
12
|
+
spec.platform = Gem::Platform::RUBY
|
|
13
|
+
spec.required_ruby_version = '>= 2.7.0'
|
|
14
|
+
|
|
15
|
+
spec.files = Dir['README.md', 'LICENSE', 'CHANGELOG.md',
|
|
16
|
+
'lib/**/*.rb', 'lib/**/*.rake', 'double_checker.gemspec']
|
|
17
|
+
|
|
18
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
19
|
+
end
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
|
|
5
|
+
module DoubleChecker
|
|
6
|
+
class << self
|
|
7
|
+
attr_accessor :gem_path, :repo_path, :result_path
|
|
8
|
+
|
|
9
|
+
attr_writer :result_line_width
|
|
10
|
+
|
|
11
|
+
def config
|
|
12
|
+
yield self
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def result_line_width
|
|
16
|
+
@result_line_width || 50
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def folders_in_repo(relative_path)
|
|
20
|
+
full_path_array = Dir.glob("#{repo_path + relative_path}/**").select { |f| File.directory?(f) }
|
|
21
|
+
full_path_array.map { |fp| fp.split(repo_path).last }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def files_in_repo(relative_path)
|
|
25
|
+
full_path_array = Dir.glob("#{repo_path + relative_path}/**").reject { |f| File.directory?(f) }
|
|
26
|
+
full_path_array.map { |fp| fp.split(repo_path).last }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def folders_in_gem(relative_path)
|
|
30
|
+
full_path_array = Dir.glob("#{gem_path + relative_path}/**").select { |f| File.directory?(f) }
|
|
31
|
+
full_path_array.map { |fp| fp.split(gem_path).last }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def files_in_gem(relative_path)
|
|
35
|
+
full_path_array = Dir.glob("#{gem_path + relative_path}/**").reject { |f| File.directory?(f) }
|
|
36
|
+
full_path_array.map { |fp| fp.split(gem_path).last }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def folder_overlap(relative_path)
|
|
40
|
+
folders_in_gem(relative_path) & folders_in_repo(relative_path)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def file_overlap(relative_path)
|
|
44
|
+
files_in_gem(relative_path) & files_in_repo(relative_path)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def full_overlap_file_array(start_path = '', overlap_arr = [])
|
|
48
|
+
file_overlap(start_path).each do |path|
|
|
49
|
+
overlap_arr << path
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
folder_overlap(start_path).each do |path|
|
|
53
|
+
full_overlap_file_array(path, overlap_arr)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
overlap_arr
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def create_result_folder
|
|
60
|
+
FileUtils.mkdir_p(result_path)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def copy_gem_file(file_path)
|
|
64
|
+
FileUtils.cp((gem_path + file_path).to_s, "#{result_path}/#{file_path}/GEM_#{file_path.split('/').last}")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def copy_repo_file(file_path)
|
|
68
|
+
FileUtils.cp((repo_path + file_path).to_s, "#{result_path}/#{file_path}/REPO_#{file_path.split('/').last}")
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def create_line_array(file_path)
|
|
72
|
+
result_arr = []
|
|
73
|
+
File.foreach(file_path).with_index do |line, line_num|
|
|
74
|
+
result_arr << line.to_s.chomp
|
|
75
|
+
end
|
|
76
|
+
result_arr
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def lines_only_in_gem(file_path)
|
|
80
|
+
gem_line_arr = create_line_array(gem_path + file_path)
|
|
81
|
+
repo_line_arr = create_line_array(repo_path + file_path)
|
|
82
|
+
gem_line_arr - (gem_line_arr & repo_line_arr)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def lines_only_in_repo(file_path)
|
|
86
|
+
gem_line_arr = create_line_array(gem_path + file_path)
|
|
87
|
+
repo_line_arr = create_line_array(repo_path + file_path)
|
|
88
|
+
repo_line_arr - (gem_line_arr & repo_line_arr)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def create_comparision_file(file_path)
|
|
92
|
+
gem_line_arr = create_line_array(gem_path + file_path)
|
|
93
|
+
repo_line_arr = create_line_array(repo_path + file_path)
|
|
94
|
+
|
|
95
|
+
if gem_line_arr.length > repo_line_arr.length
|
|
96
|
+
(gem_line_arr.length - repo_line_arr.length).times do
|
|
97
|
+
repo_line_arr.append("")
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
zipped = repo_line_arr.zip(gem_line_arr)
|
|
102
|
+
|
|
103
|
+
max_length = 0
|
|
104
|
+
zipped.flatten.map do |line|
|
|
105
|
+
if !line.nil? && line.length > max_length
|
|
106
|
+
max_length = line.length
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
self.result_line_width = max_length
|
|
111
|
+
|
|
112
|
+
text_to_write = ""
|
|
113
|
+
|
|
114
|
+
header =
|
|
115
|
+
<<~EOS
|
|
116
|
+
#{" |" + " " * (self.result_line_width / 2)}REPO#{" " * (self.result_line_width / 2)}||#{" " * (self.result_line_width / 2)}GEM#{" " * (self.result_line_width / 2)}
|
|
117
|
+
#{"-" * (self.result_line_width * 2 + 10)}
|
|
118
|
+
EOS
|
|
119
|
+
|
|
120
|
+
text_to_write += header
|
|
121
|
+
|
|
122
|
+
zipped.each_with_index do |couplet,index|
|
|
123
|
+
text_to_write += "#{(index + 1).to_s.ljust(2, " ")} | #{couplet.first} #{" " * (self.result_line_width - couplet.first.length)} || #{couplet.last}"
|
|
124
|
+
text_to_write += "\n"
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
File.write(result_path + file_path + "/DIFF.txt", text_to_write)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def generate_result_folder
|
|
131
|
+
create_result_folder
|
|
132
|
+
|
|
133
|
+
full_overlap_file_array.each do |file_path|
|
|
134
|
+
FileUtils.mkdir_p("#{result_path}/#{file_path}")
|
|
135
|
+
copy_gem_file(file_path)
|
|
136
|
+
copy_repo_file(file_path)
|
|
137
|
+
create_comparision_file(file_path)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: double_checker
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Alex Boyd
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2023-10-26 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description:
|
|
14
|
+
email:
|
|
15
|
+
- alex.boyd@gwu.edu
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- CHANGELOG.md
|
|
21
|
+
- LICENSE
|
|
22
|
+
- README.md
|
|
23
|
+
- double_checker.gemspec
|
|
24
|
+
- lib/double_checker.rb
|
|
25
|
+
- lib/double_checker/version.rb
|
|
26
|
+
homepage:
|
|
27
|
+
licenses:
|
|
28
|
+
- MIT
|
|
29
|
+
metadata:
|
|
30
|
+
rubygems_mfa_required: 'true'
|
|
31
|
+
post_install_message:
|
|
32
|
+
rdoc_options: []
|
|
33
|
+
require_paths:
|
|
34
|
+
- lib
|
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: 2.7.0
|
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
|
+
requirements:
|
|
42
|
+
- - ">="
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: '0'
|
|
45
|
+
requirements: []
|
|
46
|
+
rubygems_version: 3.1.6
|
|
47
|
+
signing_key:
|
|
48
|
+
specification_version: 4
|
|
49
|
+
summary: Gem for comparing file overrides while using a Rails engine.
|
|
50
|
+
test_files: []
|