epdiff 1.0.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby-win.yml +28 -0
- data/.github/workflows/ruby.yml +35 -0
- data/.rubocop.yml +31 -0
- data/Gemfile +3 -1
- data/LICENSE +20 -0
- data/README.md +24 -0
- data/Rakefile +19 -0
- data/bin/epdiff +5 -1
- data/epdiff.gemspec +20 -14
- data/lib/epdiff.rb +103 -39
- data/lib/epdiff/version.rb +4 -2
- data/test/fixtures/book_image.epub +0 -0
- data/test/fixtures/book_new.epub +0 -0
- data/test/fixtures/book_orig.epub +0 -0
- data/test/fixtures/sample_diff0.txt +22 -0
- data/test/fixtures/sample_diff1.txt +21 -0
- data/test/run_test.rb +12 -0
- data/test/test_epdiff.rb +39 -0
- data/test/test_helper.rb +9 -0
- metadata +133 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: eade3ce9735f322e276d9979f95bac249e6f1c97652c7ed81751aab53040822e
|
4
|
+
data.tar.gz: 17f524806a498fce7443f82b720130d532151d7cc0480fae467dede02dcf927b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d26b43c8660ce91b714fae6e4f9c9edaa1631d61b5f72ccad304179057e1923b3ac9d14ae80c4344fc70b0d754991a344f85103bdcc12f0cacab95775c598dae
|
7
|
+
data.tar.gz: 92a0d7cd8c8fee867a08b3fe390885903df627cb693431a10c67c6dcced232d390a397cec9021da48a7f8aed9e933614012ebf9682d03a5ebc96b570087e90d3
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: Ruby on Win
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
|
12
|
+
runs-on: windows-latest
|
13
|
+
strategy:
|
14
|
+
fail-fast: false
|
15
|
+
matrix:
|
16
|
+
ruby-version: ['2.5', '2.6', '2.7', '3.0']
|
17
|
+
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v2
|
20
|
+
- name: Set up Ruby
|
21
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
22
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
23
|
+
uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: ${{ matrix.ruby-version }}
|
26
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
27
|
+
- name: Run tests
|
28
|
+
run: bundle exec rake test # do not use rubucop on windows
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
strategy:
|
21
|
+
matrix:
|
22
|
+
ruby-version: ['2.5', '2.6', '2.7', '3.0']
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v2
|
26
|
+
- name: Set up Ruby
|
27
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
28
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
29
|
+
# uses: ruby/setup-ruby@v1
|
30
|
+
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby-version }}
|
33
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
34
|
+
- name: Run tests
|
35
|
+
run: bundle exec rake
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# inherit_from: .rubocop_todo.yml
|
2
|
+
AllCops:
|
3
|
+
NewCops: enable
|
4
|
+
TargetRubyVersion: 2.5
|
5
|
+
|
6
|
+
Gemspec/RequiredRubyVersion:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Metrics/AbcSize:
|
10
|
+
Max: 30
|
11
|
+
|
12
|
+
Metrics/ClassLength:
|
13
|
+
CountComments: false
|
14
|
+
Max: 117
|
15
|
+
|
16
|
+
Metrics/CyclomaticComplexity:
|
17
|
+
Max: 10
|
18
|
+
|
19
|
+
Metrics/MethodLength:
|
20
|
+
CountComments: false
|
21
|
+
Max: 40
|
22
|
+
|
23
|
+
Metrics/PerceivedComplexity:
|
24
|
+
Max: 20
|
25
|
+
|
26
|
+
Style/Documentation:
|
27
|
+
Exclude:
|
28
|
+
- 'test/**/*'
|
29
|
+
|
30
|
+
Layout/LineLength:
|
31
|
+
Max: 120
|
data/Gemfile
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Masayoshi Takahashi
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# epdiff
|
2
|
+
|
3
|
+
`epdiff` is a CLI tool to show diff of EPUB files.
|
4
|
+
|
5
|
+
## usage
|
6
|
+
|
7
|
+
$ epdiff <file1> <file2>
|
8
|
+
|
9
|
+
'file1' and 'file2' are EPUB files.
|
10
|
+
|
11
|
+
|
12
|
+
## Note on Patches/Pull Requests
|
13
|
+
|
14
|
+
* Fork the project.
|
15
|
+
* Make your feature addition or bug fix.
|
16
|
+
* Add tests for it. This is important so I don't break it in a
|
17
|
+
future version unintentionally.
|
18
|
+
* Commit, do not mess with rakefile, version, or history.
|
19
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
20
|
+
* Send me a pull request. Bonus points for topic branches.
|
21
|
+
|
22
|
+
## Copyright
|
23
|
+
|
24
|
+
Copyright (c) 2010 Masayoshi Takahashi. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/gem_tasks'
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << 'test'
|
8
|
+
t.libs << 'lib'
|
9
|
+
t.test_files = FileList['test/**/test_*.rb']
|
10
|
+
end
|
11
|
+
|
12
|
+
desc 'Check with rubocop'
|
13
|
+
task :rubocop do
|
14
|
+
require 'rubocop/rake_task'
|
15
|
+
RuboCop::RakeTask.new
|
16
|
+
rescue LoadError
|
17
|
+
warn 'rubocop not found'
|
18
|
+
end
|
19
|
+
|
20
|
+
task default: %i[test rubocop]
|
data/bin/epdiff
CHANGED
data/epdiff.gemspec
CHANGED
@@ -1,21 +1,27 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
4
|
+
require 'epdiff/version'
|
4
5
|
|
5
6
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
7
|
+
s.name = 'epdiff'
|
7
8
|
s.version = Epdiff::VERSION
|
8
|
-
s.authors = [
|
9
|
-
s.email = [
|
10
|
-
s.homepage =
|
11
|
-
s.summary =
|
12
|
-
s.description =
|
13
|
-
|
14
|
-
s.rubyforge_project = "epdiff"
|
9
|
+
s.authors = ['takahashim']
|
10
|
+
s.email = ['maki@rubycolor.org']
|
11
|
+
s.homepage = ''
|
12
|
+
s.summary = 'diff command for EPUB files.'
|
13
|
+
s.description = 'diff command for EPUB files.'
|
15
14
|
|
16
15
|
s.files = `git ls-files`.split("\n")
|
17
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.require_paths = [
|
20
|
-
s.add_runtime_dependency
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
18
|
+
s.require_paths = ['lib']
|
19
|
+
s.add_runtime_dependency 'pastel'
|
20
|
+
s.add_runtime_dependency 'rubyzip', '~> 2.3.0'
|
21
|
+
s.add_runtime_dependency 'tty-file'
|
22
|
+
s.add_development_dependency 'rake'
|
23
|
+
s.add_development_dependency 'rubocop'
|
24
|
+
s.add_development_dependency 'rubocop-performance'
|
25
|
+
s.add_development_dependency 'rubocop-rake'
|
26
|
+
s.add_development_dependency 'test-unit'
|
21
27
|
end
|
data/lib/epdiff.rb
CHANGED
@@ -1,43 +1,107 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'epdiff/version'
|
2
4
|
require 'optparse'
|
3
5
|
require 'tmpdir'
|
4
6
|
require 'fileutils'
|
5
7
|
require 'zip'
|
8
|
+
require 'pastel'
|
9
|
+
require 'tty/file'
|
10
|
+
|
11
|
+
# EPUB diff class
|
12
|
+
class Epdiff
|
13
|
+
TEXT_EXT = %w[xhtml html xml opf css txt].freeze
|
6
14
|
|
7
|
-
|
8
|
-
|
15
|
+
def self.execute(*args)
|
16
|
+
new.execute(*args)
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
@pastel = Pastel.new(enabled: true)
|
21
|
+
@green = @pastel.green.detach
|
22
|
+
@red = @pastel.red.detach
|
23
|
+
@cyan = @pastel.cyan.detach
|
24
|
+
@color = true
|
25
|
+
end
|
9
26
|
|
10
27
|
def unzip(filename, dir)
|
11
28
|
Zip::InputStream.open(filename) do |zio|
|
12
|
-
while
|
29
|
+
while entry = zio.get_next_entry # rubocop:disable Lint/AssignmentInCondition
|
30
|
+
next unless entry.file?
|
31
|
+
|
13
32
|
entry_filename = File.join(dir, entry.name)
|
14
33
|
FileUtils.mkdir_p File.dirname(entry_filename)
|
15
|
-
File.
|
16
|
-
|
34
|
+
File.binwrite(entry_filename, zio.read)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def show_diff(_file1, _file2, work_dir)
|
40
|
+
Dir.chdir(work_dir) do
|
41
|
+
files1 = Dir.glob('file1/**/*')
|
42
|
+
files2 = Dir.glob('file2/**/*')
|
43
|
+
files1_s = files1.map { |d| d.sub(%r{^file1/}, '') }
|
44
|
+
files2_s = files2.map { |d| d.sub(%r{^file2/}, '') }
|
45
|
+
files_common = files1_s & files2_s
|
46
|
+
files_common.each do |path|
|
47
|
+
if File.file?("file1/#{path}")
|
48
|
+
if text_file?("file1/#{path}")
|
49
|
+
text_diff(path, "file1/#{path}", "file2/#{path}")
|
50
|
+
else
|
51
|
+
binary_diff(path, "file1/#{path}", "file2/#{path}")
|
52
|
+
end
|
17
53
|
end
|
18
54
|
end
|
55
|
+
(files1_s - files2_s).each do |diff1|
|
56
|
+
@exit_code = 1
|
57
|
+
message = "DIFF: #{diff1} only exists in 1st.\n"
|
58
|
+
print @color ? @red.call(message) : message
|
59
|
+
end
|
60
|
+
(files2_s - files1_s).each do |diff2|
|
61
|
+
@exit_code = 1
|
62
|
+
message = "DIFF: #{diff2} only exists in 2nd.\n"
|
63
|
+
print @color ? @green.call(message) : message
|
64
|
+
end
|
19
65
|
end
|
20
66
|
end
|
21
67
|
|
22
|
-
def
|
68
|
+
def text_file?(path)
|
69
|
+
extname = File.extname(path).sub(/\A\./, '')
|
70
|
+
extname if TEXT_EXT.include?(extname)
|
71
|
+
end
|
23
72
|
|
24
|
-
|
25
|
-
|
26
|
-
|
73
|
+
def text_diff(_path, path1, path2)
|
74
|
+
diff = if @color
|
75
|
+
TTY::File.diff(path1, path2, verbose: false)
|
76
|
+
else
|
77
|
+
TTY::File.diff(path1, path2, verbose: false, color: nil)
|
78
|
+
end
|
27
79
|
|
28
|
-
|
29
|
-
opts.banner = "Usage: epdiff [options] [filename] [filename]\n"
|
80
|
+
return if diff == "No differences found\n" || diff.strip == ''
|
30
81
|
|
31
|
-
|
32
|
-
|
33
|
-
|
82
|
+
@exit_code = 1
|
83
|
+
print diff
|
84
|
+
end
|
34
85
|
|
35
|
-
|
36
|
-
|
37
|
-
|
86
|
+
def binary_diff(path, path1, path2)
|
87
|
+
content1 = File.binread(path1)
|
88
|
+
content2 = File.binread(path2)
|
89
|
+
|
90
|
+
return if content1 == content2
|
38
91
|
|
39
|
-
|
40
|
-
|
92
|
+
@exit_code = 1
|
93
|
+
message = "DIFF: #{path} has some differences.\n"
|
94
|
+
print @color ? @cyan.call(message) : message
|
95
|
+
end
|
96
|
+
|
97
|
+
def execute(*args)
|
98
|
+
tmpdir = work_dir = nil
|
99
|
+
|
100
|
+
options = OptionParser.new do |opts|
|
101
|
+
opts.banner = "Usage: epdiff [options] [filename] [filename]\n"
|
102
|
+
|
103
|
+
opts.on('-t', '--tmpdir DIR', 'Set tepmorary directory') do |dir|
|
104
|
+
tmpdir = dir
|
41
105
|
end
|
42
106
|
|
43
107
|
opts.on('-h', '--help', 'Show this help message') do
|
@@ -45,6 +109,10 @@ module Epdiff
|
|
45
109
|
exit
|
46
110
|
end
|
47
111
|
|
112
|
+
opts.on('-C', '--no-color', 'Not use color diff') do
|
113
|
+
@color = false
|
114
|
+
end
|
115
|
+
|
48
116
|
opts.on('-v', '--version', 'Show version number') do
|
49
117
|
puts Epdiff::VERSION
|
50
118
|
exit
|
@@ -52,35 +120,31 @@ module Epdiff
|
|
52
120
|
end
|
53
121
|
|
54
122
|
begin
|
55
|
-
|
56
|
-
opts.parse!(args)
|
123
|
+
options.parse!(args)
|
57
124
|
|
58
125
|
if args.size != 2
|
59
126
|
# invalid option
|
60
|
-
puts
|
127
|
+
puts options
|
61
128
|
exit
|
62
129
|
end
|
63
130
|
|
131
|
+
work_dir = tmpdir || Dir.mktmpdir
|
132
|
+
|
64
133
|
file1, file2 = *args
|
65
|
-
FileUtils.mkdir_p(
|
66
|
-
FileUtils.mkdir_p(
|
67
|
-
|
68
|
-
if unzip_path
|
69
|
-
%x("#{unzip_path}" "#{file1}" -d "#{tmpdir}/file1")
|
70
|
-
%x("#{unzip_path}" "#{file2}" -d "#{tmpdir}/file2")
|
71
|
-
else
|
72
|
-
unzip(file1, "#{tmpdir}/file1")
|
73
|
-
unzip(file2, "#{tmpdir}/file2")
|
74
|
-
end
|
134
|
+
FileUtils.mkdir_p("#{work_dir}/file1")
|
135
|
+
FileUtils.mkdir_p("#{work_dir}/file2")
|
75
136
|
|
76
|
-
|
77
|
-
|
78
|
-
end
|
137
|
+
unzip(file1, "#{work_dir}/file1")
|
138
|
+
unzip(file2, "#{work_dir}/file2")
|
79
139
|
|
80
|
-
|
140
|
+
@exit_code = 0
|
141
|
+
show_diff(file1, file2, work_dir)
|
142
|
+
|
143
|
+
@exit_code
|
144
|
+
rescue StandardError => e
|
81
145
|
warn e
|
82
|
-
|
146
|
+
ensure
|
147
|
+
FileUtils.rm_rf(work_dir) if work_dir && !tmpdir
|
83
148
|
end
|
84
149
|
end
|
85
|
-
|
86
150
|
end
|
data/lib/epdiff/version.rb
CHANGED
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,22 @@
|
|
1
|
+
--- file1/OEBPS/book.opf
|
2
|
+
+++ file2/OEBPS/book.opf
|
3
|
+
[36m@@ -17,6 +17,7 @@[0m
|
4
|
+
<item id="style-css" href="style.css" media-type="text/css"/>
|
5
|
+
<item id="titlepage-xhtml" href="titlepage.xhtml" media-type="application/xhtml+xml"/>
|
6
|
+
<item id="test1-xhtml" href="test1.xhtml" media-type="application/xhtml+xml"/>
|
7
|
+
[32m+ <item id="images-Hokusai_Setsubun_no_Oni-jpg" href="images/Hokusai_Setsubun_no_Oni.jpg" media-type="image/jpeg"/>[0m
|
8
|
+
</manifest>
|
9
|
+
<spine page-progression-direction="ltr">
|
10
|
+
<itemref idref="book" linear="no"/>
|
11
|
+
--- file1/OEBPS/test1.xhtml
|
12
|
+
+++ file2/OEBPS/test1.xhtml
|
13
|
+
[36m@@ -9,7 +9,7 @@[0m
|
14
|
+
</head>
|
15
|
+
<body>
|
16
|
+
<h1><a id="h1"></a><span class="secno">第1章 </span>test1</h1>
|
17
|
+
[31m-<p>this is a test EPUB file.</p>[0m
|
18
|
+
[32m+<p>this is a EPUB file to test <strong>epdiff</strong>.</p>[0m
|
19
|
+
</body>
|
20
|
+
</html>
|
21
|
+
[32mDIFF: OEBPS/images/Hokusai_Setsubun_no_Oni.jpg only exists in 2nd.
|
22
|
+
[0m
|
@@ -0,0 +1,21 @@
|
|
1
|
+
--- file1/OEBPS/book.opf
|
2
|
+
+++ file2/OEBPS/book.opf
|
3
|
+
@@ -17,6 +17,7 @@
|
4
|
+
<item id="style-css" href="style.css" media-type="text/css"/>
|
5
|
+
<item id="titlepage-xhtml" href="titlepage.xhtml" media-type="application/xhtml+xml"/>
|
6
|
+
<item id="test1-xhtml" href="test1.xhtml" media-type="application/xhtml+xml"/>
|
7
|
+
+ <item id="images-Hokusai_Setsubun_no_Oni-jpg" href="images/Hokusai_Setsubun_no_Oni.jpg" media-type="image/jpeg"/>
|
8
|
+
</manifest>
|
9
|
+
<spine page-progression-direction="ltr">
|
10
|
+
<itemref idref="book" linear="no"/>
|
11
|
+
--- file1/OEBPS/test1.xhtml
|
12
|
+
+++ file2/OEBPS/test1.xhtml
|
13
|
+
@@ -9,7 +9,7 @@
|
14
|
+
</head>
|
15
|
+
<body>
|
16
|
+
<h1><a id="h1"></a><span class="secno">第1章 </span>test1</h1>
|
17
|
+
-<p>this is a test EPUB file.</p>
|
18
|
+
+<p>this is a EPUB file to test <strong>epdiff</strong>.</p>
|
19
|
+
</body>
|
20
|
+
</html>
|
21
|
+
DIFF: OEBPS/images/Hokusai_Setsubun_no_Oni.jpg only exists in 2nd.
|
data/test/run_test.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
base_dir = File.expand_path('..', __dir__)
|
4
|
+
lib_dir = File.join(base_dir, 'lib')
|
5
|
+
test_dir = File.join(base_dir, 'test')
|
6
|
+
|
7
|
+
$LOAD_PATH.unshift(lib_dir)
|
8
|
+
|
9
|
+
require 'test/unit'
|
10
|
+
|
11
|
+
argv = ARGV || ['--max-diff-target-string-size=10000']
|
12
|
+
exit Test::Unit::AutoRunner.run(true, test_dir, argv)
|
data/test/test_epdiff.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'epdiff'
|
5
|
+
|
6
|
+
class EpdiffTest < Test::Unit::TestCase
|
7
|
+
def setup; end
|
8
|
+
|
9
|
+
def teardown; end
|
10
|
+
|
11
|
+
def test_ezpdiff_execute_color
|
12
|
+
out = $stdout
|
13
|
+
$stdout = StringIO.new
|
14
|
+
begin
|
15
|
+
Epdiff.new.execute(File.join(fixtures_dir, 'book_orig.epub'),
|
16
|
+
File.join(fixtures_dir, 'book_image.epub'))
|
17
|
+
result = $stdout.string
|
18
|
+
ensure
|
19
|
+
$stdout = out
|
20
|
+
end
|
21
|
+
expected = File.read(File.join(fixtures_dir, 'sample_diff0.txt'))
|
22
|
+
assert_equal expected, result
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_ezpdiff_execute_nocolor
|
26
|
+
out = $stdout
|
27
|
+
$stdout = StringIO.new
|
28
|
+
begin
|
29
|
+
Epdiff.new.execute('-C',
|
30
|
+
File.join(fixtures_dir, 'book_orig.epub'),
|
31
|
+
File.join(fixtures_dir, 'book_image.epub'))
|
32
|
+
result = $stdout.string
|
33
|
+
ensure
|
34
|
+
$stdout = out
|
35
|
+
end
|
36
|
+
expected = File.read(File.join(fixtures_dir, 'sample_diff1.txt'))
|
37
|
+
assert_equal expected, result
|
38
|
+
end
|
39
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,29 +1,127 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epdiff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- takahashim
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pastel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rubyzip
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
|
-
- - ~>
|
31
|
+
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
33
|
+
version: 2.3.0
|
20
34
|
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.3.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: tty-file
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-performance
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: test-unit
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
25
123
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
124
|
+
version: '0'
|
27
125
|
description: diff command for EPUB files.
|
28
126
|
email:
|
29
127
|
- maki@rubycolor.org
|
@@ -32,34 +130,54 @@ executables:
|
|
32
130
|
extensions: []
|
33
131
|
extra_rdoc_files: []
|
34
132
|
files:
|
35
|
-
- .
|
133
|
+
- ".github/workflows/ruby-win.yml"
|
134
|
+
- ".github/workflows/ruby.yml"
|
135
|
+
- ".gitignore"
|
136
|
+
- ".rubocop.yml"
|
36
137
|
- Gemfile
|
138
|
+
- LICENSE
|
139
|
+
- README.md
|
37
140
|
- Rakefile
|
38
141
|
- bin/epdiff
|
39
142
|
- epdiff.gemspec
|
40
143
|
- lib/epdiff.rb
|
41
144
|
- lib/epdiff/version.rb
|
145
|
+
- test/fixtures/book_image.epub
|
146
|
+
- test/fixtures/book_new.epub
|
147
|
+
- test/fixtures/book_orig.epub
|
148
|
+
- test/fixtures/sample_diff0.txt
|
149
|
+
- test/fixtures/sample_diff1.txt
|
150
|
+
- test/run_test.rb
|
151
|
+
- test/test_epdiff.rb
|
152
|
+
- test/test_helper.rb
|
42
153
|
homepage: ''
|
43
154
|
licenses: []
|
44
155
|
metadata: {}
|
45
|
-
post_install_message:
|
156
|
+
post_install_message:
|
46
157
|
rdoc_options: []
|
47
158
|
require_paths:
|
48
159
|
- lib
|
49
160
|
required_ruby_version: !ruby/object:Gem::Requirement
|
50
161
|
requirements:
|
51
|
-
- -
|
162
|
+
- - ">="
|
52
163
|
- !ruby/object:Gem::Version
|
53
164
|
version: '0'
|
54
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
166
|
requirements:
|
56
|
-
- -
|
167
|
+
- - ">="
|
57
168
|
- !ruby/object:Gem::Version
|
58
169
|
version: '0'
|
59
170
|
requirements: []
|
60
|
-
|
61
|
-
|
62
|
-
signing_key:
|
171
|
+
rubygems_version: 3.2.3
|
172
|
+
signing_key:
|
63
173
|
specification_version: 4
|
64
174
|
summary: diff command for EPUB files.
|
65
|
-
test_files:
|
175
|
+
test_files:
|
176
|
+
- test/fixtures/book_image.epub
|
177
|
+
- test/fixtures/book_new.epub
|
178
|
+
- test/fixtures/book_orig.epub
|
179
|
+
- test/fixtures/sample_diff0.txt
|
180
|
+
- test/fixtures/sample_diff1.txt
|
181
|
+
- test/run_test.rb
|
182
|
+
- test/test_epdiff.rb
|
183
|
+
- test/test_helper.rb
|