pretty-diff 0.1.0 → 0.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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/pretty-diff.rb +14 -6
  3. data/pretty-diff.gemspec +2 -2
  4. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/lib/pretty-diff.rb CHANGED
@@ -55,7 +55,9 @@ module PrettyDiff
55
55
  defaults = {
56
56
  :remove_signs => false,
57
57
  :remove_leading_file_lines => false,
58
- :as_list_items => true
58
+ :as_list_items => true,
59
+ :list_style => 'ul',
60
+ :no_newline_warning => false
59
61
  }
60
62
 
61
63
  @options = defaults.merge options
@@ -72,7 +74,11 @@ module PrettyDiff
72
74
  # removes +'s and -'s and wraps the changed lines in either
73
75
  # ins or del html tags so it can be styles accordingly
74
76
  def to_html
75
- @lines.each_line.map do |line|
77
+ lines = @lines.each_line.map do |line|
78
+ line.chomp!
79
+ unless @options[:no_newline_warning]
80
+ next if line == ''
81
+ end
76
82
  if @options[:remove_leading_file_lines]
77
83
  if line =~ /\A[\+|-]{3}/
78
84
  next
@@ -81,14 +87,16 @@ module PrettyDiff
81
87
  if line !~ /\A[\+|-]{3}\s/ && line =~ /\A(\+|-)/
82
88
  tag = $~[0] == '-' ? 'del' : 'ins'
83
89
  line = line.gsub(/\A./, '') if @options[:remove_signs]
84
- line = "<#{tag}>#{line.chomp.gsub(/\s/,'&nbsp;')}</#{tag}>"
85
- else
86
- line.chomp
90
+ line = "<#{tag}>#{line.gsub(/\s/,'&nbsp;')}</#{tag}>"
87
91
  end
88
92
  if @options[:as_list_items]
89
- line = "<li class=\"#{tag}\">#{line}</li>"
93
+ line = "<li#{ " class=\"#{tag}\"" if tag }>#{line}</li>"
90
94
  end
91
95
  end.join("\n")
96
+ if @options[:list_style]
97
+ lines = "<#{@options[:list_style]}>\n#{lines}\n</#{@options[:list_style]}>"
98
+ end
99
+ return lines
92
100
  end
93
101
 
94
102
  end
data/pretty-diff.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pretty-diff}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["atom smith"]
12
- s.date = %q{2011-02-16}
12
+ s.date = %q{2011-02-17}
13
13
  s.description = %q{Uses the unix diff utility to create pretty html diffs from two files or two strings.}
14
14
  s.email = %q{re5etsmyth@gmail.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: pretty-diff
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - atom smith
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-16 00:00:00 -08:00
13
+ date: 2011-02-17 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -92,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - ">="
94
94
  - !ruby/object:Gem::Version
95
- hash: 4057240425778970248
95
+ hash: -696834190802314323
96
96
  segments:
97
97
  - 0
98
98
  version: "0"