purdypatch 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/bin/purdypatch CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'purdypatch'
3
+ require 'purdypatch/cli'
4
4
 
5
5
  PurdyPatch::CLI.start(*ARGV)
@@ -87,18 +87,6 @@ private
87
87
 
88
88
  SMALLEST_EQUAL_OPERATION = 3
89
89
 
90
- OPENSOURCE_TRAC_URL = "http://trac.webkit.org/"
91
-
92
- OPENSOURCE_DIRS = Set.new %w[
93
- Examples
94
- LayoutTests
95
- PerformanceTests
96
- Source
97
- Tools
98
- WebKitLibraries
99
- Websites
100
- ]
101
-
102
90
  IMAGE_CHECKSUM_ERROR = "INVALID: Image lacks a checksum. This will fail with a MISSING error in run-webkit-tests. Always generate new png files using run-webkit-tests."
103
91
 
104
92
  def self.normalize_line_ending(s)
@@ -134,29 +122,6 @@ private
134
122
  end
135
123
  end
136
124
 
137
- def self.find_url_and_path(file_path)
138
- # Search file_path from the bottom up, at each level checking whether
139
- # we've found a directory we know exists in the source tree.
140
-
141
- dirname, basename = File.split(file_path)
142
- dirname.split(/\//).reverse.inject(basename) do |path, directory|
143
- path = directory + "/" + path
144
-
145
- return [OPENSOURCE_TRAC_URL, path] if OPENSOURCE_DIRS.include?(directory)
146
-
147
- path
148
- end
149
-
150
- [nil, file_path]
151
- end
152
-
153
- def self.linkifyFilename(filename)
154
- url, pathBeneathTrunk = find_url_and_path(filename)
155
-
156
- url.nil? ? filename : "<a href='#{url}browser/trunk/#{pathBeneathTrunk}'>#{filename}</a>"
157
- end
158
-
159
-
160
125
  HEADER =<<EOF
161
126
  <html>
162
127
  <head>
@@ -423,7 +388,7 @@ EOF
423
388
 
424
389
  def to_html
425
390
  str = "<div class='FileDiff'>\n"
426
- str += "<h1>#{PrettyPatch.linkifyFilename(@filename)}</h1>\n"
391
+ str += "<h1>#{@filename}</h1>\n"
427
392
  if @image then
428
393
  str += self.image_to_html
429
394
  elsif @git_image then
@@ -0,0 +1,44 @@
1
+ require 'mail'
2
+ require 'pathname'
3
+ require 'purdypatch/version'
4
+ require 'prettypatch/PrettyPatch'
5
+
6
+ module PurdyPatch
7
+ class CLI
8
+ def self.start(*args)
9
+ if args.empty?
10
+ puts "purdypatch expects one or more files created via `git format-patch --attach [ <since> | <revision range> ]`."
11
+ exit
12
+ end
13
+
14
+ args.each do |arg|
15
+ patch_mail_path = Pathname.new(arg)
16
+ next unless patch_mail_path.exist?
17
+
18
+ mail = Mail.read(patch_mail_path)
19
+ parts = mail.parts.dup
20
+ purdified = false
21
+ parts.each_with_index do |part, i|
22
+ next unless part.attachment? && part.content_type =~ %r(text/x-patch)
23
+
24
+ purdy_part = Mail::Part.new do
25
+ content_type 'text/html; charset=UTF-8'
26
+ body PrettyPatch.prettify(part.body.decoded)
27
+ end
28
+ mail.parts.insert(i, purdy_part)
29
+ mail.header['X-Formatter'] = "PurdyPatch-#{PurdyPatch::VERSION}"
30
+ purdified = true
31
+ end
32
+
33
+ if purdified
34
+ purdy_patch_mail_path = patch_mail_path.sub_ext('.purdypatch')
35
+ File.open(purdy_patch_mail_path, File::CREAT | File::TRUNC | File::RDWR) do |f|
36
+ f.write mail.to_s
37
+ end
38
+ puts %Q(Purdified patch email saved to "#{purdy_patch_mail_path}".)
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+ end
@@ -1,3 +1,3 @@
1
1
  module PurdyPatch
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/purdypatch.rb CHANGED
@@ -1,44 +1 @@
1
- require 'mail'
2
- require 'pathname'
3
1
  require 'purdypatch/version'
4
- require 'prettypatch/PrettyPatch'
5
-
6
- module PurdyPatch
7
- class CLI
8
- def self.start(*args)
9
- if args.empty?
10
- puts "purdypatch expects one or more files created via `git format-patch --attach [ <since> | <revision range> ]`."
11
- exit
12
- end
13
-
14
- args.each do |arg|
15
- patch_mail_path = Pathname.new(arg)
16
- next unless patch_mail_path.exist?
17
-
18
- mail = Mail.read(patch_mail_path)
19
- parts = mail.parts.dup
20
- purdified = false
21
- parts.each_with_index do |part, i|
22
- next unless part.attachment? && part.content_type =~ %r(text/x-patch)
23
-
24
- purdy_part = Mail::Part.new do
25
- content_type 'text/html; charset=UTF-8'
26
- body PrettyPatch.prettify(part.body.decoded)
27
- end
28
- mail.parts.insert(i, purdy_part)
29
- mail.header['X-Formatter'] = "PurdyPatch-#{PurdyPatch::VERSION}"
30
- purdified = true
31
- end
32
-
33
- if purdified
34
- purdy_patch_mail_path = patch_mail_path.sub_ext('.purdypatch')
35
- File.open(purdy_patch_mail_path, File::CREAT | File::TRUNC | File::RDWR) do |f|
36
- f.write mail.to_s
37
- end
38
- puts %Q(Purdified patch email saved to "#{purdy_patch_mail_path}".)
39
- end
40
-
41
- end
42
- end
43
- end
44
- end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: purdypatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -47,6 +47,7 @@ files:
47
47
  - lib/prettypatch/diff.rb
48
48
  - lib/prettypatch/prettify.rb
49
49
  - lib/purdypatch.rb
50
+ - lib/purdypatch/cli.rb
50
51
  - lib/purdypatch/version.rb
51
52
  - purdypatch.gemspec
52
53
  homepage: https://github.com/atnan/purdypatch