epdiff 2.0.0.rc1 → 2.0.0.rc2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eafa093559fc567ce2560dbfd67aa6f9b712374167063319a0270002c1b0fcd7
4
- data.tar.gz: 0a83e2294ad9e7058f9e386c16150141357596065455a08918d8d534cde40f3e
3
+ metadata.gz: 48f072768d70f69bb8390ee6fcb2b9261a2eee8df99084a7d162ec7cf0827ea5
4
+ data.tar.gz: 97a0b665572c96e42f72d3a0c27f15cab7354814bac786b93d44163b76ca899f
5
5
  SHA512:
6
- metadata.gz: 49e7e7a25ae0ba32eb883f7e97b5d21ebffbd254c28ccee7527026be7ba68cf59a31e0b974acd4d75e10a465cbe55e17fae63a71e58129602f7f802c9486a4ce
7
- data.tar.gz: 487381af5949d9f08889dc2a5f09c0974f277113368fd72aa2dc245bef4cc894583ce13842e0fe28773c055fe08cc42f6f4b0baa0e70ba7ad68dba915f8d3615
6
+ metadata.gz: '092f898933263c56d975e02cb50be1881e043817a79ddf7b54abf1c5a849ab0d259075048d03bab8ddf336a48b34a9dfb3b0efc5a38bb922a18949c9e358b4de'
7
+ data.tar.gz: 0f3f84ecae7a44c54e5b263969c4e64cb558d73ca1c167d39dea2211ed4fa24fe76fa28ed1f230b3b2c6b7f327b5839e610730dea5baf45eeff5c6e71afc18c2
@@ -18,4 +18,5 @@ Gem::Specification.new do |s|
18
18
  s.add_runtime_dependency "rubyzip", "~> 2.3.0"
19
19
  s.add_runtime_dependency "pastel"
20
20
  s.add_runtime_dependency "tty-file"
21
+ s.add_development_dependency "rake"
21
22
  end
@@ -19,6 +19,7 @@ class Epdiff
19
19
  @green = @pastel.green.detach
20
20
  @red = @pastel.red.detach
21
21
  @cyan = @pastel.cyan.detach
22
+ @color = true
22
23
  end
23
24
 
24
25
  def unzip(filename, dir)
@@ -50,10 +51,14 @@ class Epdiff
50
51
  end
51
52
  end
52
53
  (files1_s - files2_s).each do |diff1|
53
- print @red.call("DIFF: #{diff1} only exists in 1st.\n")
54
+ @exit_code = 1
55
+ message = "DIFF: #{diff1} only exists in 1st.\n"
56
+ print @color ? @red.call(message) : message
54
57
  end
55
58
  (files2_s - files1_s).each do |diff2|
56
- print @green.call("DIFF: #{diff2} only exists in 2nd.\n")
59
+ @exit_code = 1
60
+ message = "DIFF: #{diff2} only exists in 2nd.\n"
61
+ print @color ? @green.call(message) : message
57
62
  end
58
63
  end
59
64
  end
@@ -68,8 +73,9 @@ class Epdiff
68
73
  end
69
74
 
70
75
  def text_diff(_path, path1, path2)
71
- diff = TTY::File.diff(path1, path2, verbose: false)
72
- if diff != "No differences found\n"
76
+ diff = @color ? TTY::File.diff(path1, path2, verbose: false) : TTY::File.diff(path1, path2, verbose: false, color: nil)
77
+ if diff != "No differences found\n" && diff.strip != ""
78
+ @exit_code = 1
73
79
  print diff
74
80
  end
75
81
  end
@@ -78,7 +84,9 @@ class Epdiff
78
84
  content1 = File.binread(path1)
79
85
  content2 = File.binread(path2)
80
86
  if content1 != content2
81
- print @cyan.call("DIFF: #{path} has some differences.\n")
87
+ @exit_code = 1
88
+ message = "DIFF: #{path} has some differences.\n"
89
+ print @color ? @cyan.call(message) : message
82
90
  end
83
91
  end
84
92
 
@@ -95,19 +103,15 @@ class Epdiff
95
103
  tmpdir = dir
96
104
  end
97
105
 
98
- opts.on('--diff-command PATH', 'Specify diff command path') do |path|
99
- diff_path = path
100
- end
101
-
102
- opts.on('--unzip-command PATH', 'Specify unzip command path') do |path|
103
- unzip_path = path
104
- end
105
-
106
106
  opts.on('-h', '--help', 'Show this help message') do
107
107
  puts opts
108
108
  exit
109
109
  end
110
110
 
111
+ opts.on('-C', '--no-color', 'Not use color diff') do
112
+ @color = false
113
+ end
114
+
111
115
  opts.on('-v', '--version', 'Show version number') do
112
116
  puts Epdiff::VERSION
113
117
  exit
@@ -130,22 +134,12 @@ class Epdiff
130
134
  FileUtils.mkdir_p(work_dir+"/file1")
131
135
  FileUtils.mkdir_p(work_dir+"/file2")
132
136
 
133
- if unzip_path
134
- %x("#{unzip_path}" "#{file1}" -d "#{work_dir}/file1")
135
- %x("#{unzip_path}" "#{file2}" -d "#{work_dir}/file2")
136
- else
137
- unzip(file1, "#{work_dir}/file1")
138
- unzip(file2, "#{work_dir}/file2")
139
- end
140
-
141
- if diff_path
142
- IO.popen("'#{diff_path}' -r -u '#{work_dir}/file1' '#{work_dir}/file2'") do |io|
143
- print io.read.gsub(/#{Regexp.escape(work_dir)}/, "")
144
- end
145
- else
146
- show_diff(file1, file2, work_dir)
147
- end
137
+ unzip(file1, "#{work_dir}/file1")
138
+ unzip(file2, "#{work_dir}/file2")
148
139
 
140
+ @exit_code = 0
141
+ show_diff(file1, file2, work_dir)
142
+ exit(@exit_code)
149
143
  rescue => e
150
144
  warn e
151
145
  puts opts
@@ -1,3 +1,3 @@
1
1
  class Epdiff
2
- VERSION = "2.0.0.rc1"
2
+ VERSION = "2.0.0.rc2"
3
3
  end
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epdiff
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.rc1
4
+ version: 2.0.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - takahashim
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2021-01-25 00:00:00.000000000 Z
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
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'
55
69
  description: diff command for EPUB files.
56
70
  email:
57
71
  - maki@rubycolor.org
@@ -72,7 +86,7 @@ files:
72
86
  homepage: ''
73
87
  licenses: []
74
88
  metadata: {}
75
- post_install_message:
89
+ post_install_message:
76
90
  rdoc_options: []
77
91
  require_paths:
78
92
  - lib
@@ -87,8 +101,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
101
  - !ruby/object:Gem::Version
88
102
  version: 1.3.1
89
103
  requirements: []
90
- rubygems_version: 3.1.2
91
- signing_key:
104
+ rubygems_version: 3.2.3
105
+ signing_key:
92
106
  specification_version: 4
93
107
  summary: diff command for EPUB files.
94
108
  test_files: []