pretty_diff 0.8.1 → 0.9.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.
- data/VERSION +1 -1
- data/lib/pretty_diff/diff.rb +1 -1
- data/lib/pretty_diff/html_generators/diff_generator.rb +1 -16
- data/lib/pretty_diff/html_generators/line_generator.rb +7 -1
- data/lib/pretty_diff/html_generators/line_numbers_generator.rb +1 -2
- data/lib/pretty_diff/line.rb +17 -4
- data/pretty_diff.gemspec +29 -31
- metadata +6 -7
- data/.gitignore +0 -21
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0. | 
| 1 | 
            +
            0.9.1
         | 
    
        data/lib/pretty_diff/diff.rb
    CHANGED
    
    
| @@ -7,22 +7,7 @@ class PrettyDiff::DiffGenerator | |
| 7 7 | 
             
              end
         | 
| 8 8 |  | 
| 9 9 | 
             
              def generate
         | 
| 10 | 
            -
                 | 
| 11 | 
            -
                intro_html + chunks_html + outro_html
         | 
| 12 | 
            -
              end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
            private
         | 
| 15 | 
            -
             | 
| 16 | 
            -
              def intro_html
         | 
| 17 | 
            -
                %Q[]
         | 
| 18 | 
            -
              end
         | 
| 19 | 
            -
             | 
| 20 | 
            -
              def chunk_separator_html
         | 
| 21 | 
            -
                %Q[]
         | 
| 22 | 
            -
              end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
              def outro_html
         | 
| 25 | 
            -
                %Q[]
         | 
| 10 | 
            +
                diff.chunks.map{|c| c.to_html}.to_s
         | 
| 26 11 | 
             
              end
         | 
| 27 12 |  | 
| 28 13 | 
             
            end
         | 
| @@ -7,7 +7,9 @@ class PrettyDiff::LineGenerator | |
| 7 7 | 
             
              end
         | 
| 8 8 |  | 
| 9 9 | 
             
              def generate
         | 
| 10 | 
            -
                if line. | 
| 10 | 
            +
                if line.modified?
         | 
| 11 | 
            +
                  modified_html(content)
         | 
| 12 | 
            +
                elsif line.added?
         | 
| 11 13 | 
             
                  added_html(content)
         | 
| 12 14 | 
             
                elsif line.deleted?
         | 
| 13 15 | 
             
                  deleted_html(content)
         | 
| @@ -30,6 +32,10 @@ private | |
| 30 32 | 
             
                end
         | 
| 31 33 | 
             
              end
         | 
| 32 34 |  | 
| 35 | 
            +
              def modified_html(text)
         | 
| 36 | 
            +
                wrapper_html { %Q[<span class="gm">#{text}</span>] }
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 33 39 | 
             
              def added_html(text)
         | 
| 34 40 | 
             
                wrapper_html { %Q[<span class="gi">#{text}</span>] }
         | 
| 35 41 | 
             
              end
         | 
    
        data/lib/pretty_diff/line.rb
    CHANGED
    
    | @@ -3,6 +3,11 @@ | |
| 3 3 | 
             
            #
         | 
| 4 4 | 
             
            class PrettyDiff::Line #:nodoc:
         | 
| 5 5 |  | 
| 6 | 
            +
              INLINE_INSERT_START = /\{\+/
         | 
| 7 | 
            +
              INLINE_INSERT_END = /\+\}/
         | 
| 8 | 
            +
              INLINE_DELETE_START = /\[-/
         | 
| 9 | 
            +
              INLINE_DELETE_END = /-\]/
         | 
| 10 | 
            +
             | 
| 6 11 | 
             
              attr_reader :diff, :input
         | 
| 7 12 |  | 
| 8 13 | 
             
              def initialize(diff, input)
         | 
| @@ -16,10 +21,12 @@ class PrettyDiff::Line #:nodoc: | |
| 16 21 | 
             
              end
         | 
| 17 22 |  | 
| 18 23 | 
             
              # Prepare Line contents for injection into HTML structure.
         | 
| 19 | 
            -
              # Currently used for replacing Tab symbols with spaces.
         | 
| 20 | 
            -
              # Return a string.
         | 
| 21 24 | 
             
              def format
         | 
| 22 | 
            -
                input.gsub( | 
| 25 | 
            +
                input.gsub(INLINE_INSERT_START, '<ins>') \
         | 
| 26 | 
            +
                  .gsub(INLINE_INSERT_END, '</ins>') \
         | 
| 27 | 
            +
                  .gsub(INLINE_DELETE_START, '<del>') \
         | 
| 28 | 
            +
                  .gsub(INLINE_DELETE_END, '</del>') \
         | 
| 29 | 
            +
                  .gsub("\t", '  ')
         | 
| 23 30 | 
             
              end
         | 
| 24 31 |  | 
| 25 32 | 
             
              # Unified Diff sometimes emit a special line at the end of the file
         | 
| @@ -29,9 +36,11 @@ class PrettyDiff::Line #:nodoc: | |
| 29 36 | 
             
                input =~ /\/
         | 
| 30 37 | 
             
              end
         | 
| 31 38 |  | 
| 32 | 
            -
              # Return status of the Line. Can be :added, :deleted or :not_modified.
         | 
| 39 | 
            +
              # Return status of the Line. Can be :modified (for per-word diffing), :added, :deleted or :not_modified.
         | 
| 33 40 | 
             
              def status
         | 
| 34 41 | 
             
                case input
         | 
| 42 | 
            +
                when /(#{ INLINE_DELETE_START }|#{ INLINE_INSERT_START })/
         | 
| 43 | 
            +
                  :modified
         | 
| 35 44 | 
             
                when /^\+/
         | 
| 36 45 | 
             
                  :added
         | 
| 37 46 | 
             
                when /^\-/
         | 
| @@ -41,6 +50,10 @@ class PrettyDiff::Line #:nodoc: | |
| 41 50 | 
             
                end
         | 
| 42 51 | 
             
              end
         | 
| 43 52 |  | 
| 53 | 
            +
              def modified?
         | 
| 54 | 
            +
                status == :modified
         | 
| 55 | 
            +
              end
         | 
| 56 | 
            +
             | 
| 44 57 | 
             
              def added?
         | 
| 45 58 | 
             
                status == :added
         | 
| 46 59 | 
             
              end
         | 
    
        data/pretty_diff.gemspec
    CHANGED
    
    | @@ -1,59 +1,57 @@ | |
| 1 1 | 
             
            # Generated by jeweler
         | 
| 2 2 | 
             
            # DO NOT EDIT THIS FILE DIRECTLY
         | 
| 3 | 
            -
            # Instead, edit Jeweler::Tasks in Rakefile, and run  | 
| 3 | 
            +
            # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
         | 
| 4 4 | 
             
            # -*- encoding: utf-8 -*-
         | 
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 7 | 
             
              s.name = %q{pretty_diff}
         | 
| 8 | 
            -
              s.version = "0. | 
| 8 | 
            +
              s.version = "0.9.1"
         | 
| 9 9 |  | 
| 10 10 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 11 | 
             
              s.authors = ["Ilya Sabanin"]
         | 
| 12 | 
            -
              s.date = %q{ | 
| 12 | 
            +
              s.date = %q{2012-04-18}
         | 
| 13 13 | 
             
              s.description = %q{PrettyDiff is a highly customizable library for creating fully featured HTML
         | 
| 14 14 | 
             
                                   listings out of unified diff format strings.
         | 
| 15 15 | 
             
                                   Include copy/paste-safe line numbers and built-in syntax highlighting.}
         | 
| 16 16 | 
             
              s.email = %q{ilya.sabanin@gmail.com}
         | 
| 17 17 | 
             
              s.extra_rdoc_files = [
         | 
| 18 18 | 
             
                "LICENSE",
         | 
| 19 | 
            -
             | 
| 19 | 
            +
                "README.rdoc"
         | 
| 20 20 | 
             
              ]
         | 
| 21 21 | 
             
              s.files = [
         | 
| 22 22 | 
             
                ".document",
         | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
                 "test/line_test.rb"
         | 
| 23 | 
            +
                "LICENSE",
         | 
| 24 | 
            +
                "README.rdoc",
         | 
| 25 | 
            +
                "Rakefile",
         | 
| 26 | 
            +
                "VERSION",
         | 
| 27 | 
            +
                "lib/pretty_diff.rb",
         | 
| 28 | 
            +
                "lib/pretty_diff/chunk.rb",
         | 
| 29 | 
            +
                "lib/pretty_diff/diff.rb",
         | 
| 30 | 
            +
                "lib/pretty_diff/html_generators/chunk_generator.rb",
         | 
| 31 | 
            +
                "lib/pretty_diff/html_generators/diff_generator.rb",
         | 
| 32 | 
            +
                "lib/pretty_diff/html_generators/line_generator.rb",
         | 
| 33 | 
            +
                "lib/pretty_diff/html_generators/line_numbers_generator.rb",
         | 
| 34 | 
            +
                "lib/pretty_diff/line.rb",
         | 
| 35 | 
            +
                "lib/pretty_diff/line_numbers.rb",
         | 
| 36 | 
            +
                "pretty_diff.gemspec",
         | 
| 37 | 
            +
                "test/chunk_test.rb",
         | 
| 38 | 
            +
                "test/data/first.diff",
         | 
| 39 | 
            +
                "test/data/second.diff",
         | 
| 40 | 
            +
                "test/diff_test.rb",
         | 
| 41 | 
            +
                "test/helper.rb",
         | 
| 42 | 
            +
                "test/html_generator_test.rb",
         | 
| 43 | 
            +
                "test/line_test.rb"
         | 
| 45 44 | 
             
              ]
         | 
| 46 45 | 
             
              s.homepage = %q{http://github.com/isabanin/pretty_diff}
         | 
| 47 | 
            -
              s.rdoc_options = ["--charset=UTF-8"]
         | 
| 48 46 | 
             
              s.require_paths = ["lib"]
         | 
| 49 47 | 
             
              s.rubygems_version = %q{1.3.7}
         | 
| 50 48 | 
             
              s.summary = %q{Library for converting unified diff format into HTML listings.}
         | 
| 51 49 | 
             
              s.test_files = [
         | 
| 52 50 | 
             
                "test/chunk_test.rb",
         | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 51 | 
            +
                "test/diff_test.rb",
         | 
| 52 | 
            +
                "test/helper.rb",
         | 
| 53 | 
            +
                "test/html_generator_test.rb",
         | 
| 54 | 
            +
                "test/line_test.rb"
         | 
| 57 55 | 
             
              ]
         | 
| 58 56 |  | 
| 59 57 | 
             
              if s.respond_to? :specification_version then
         | 
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: pretty_diff
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 57
         | 
| 5 5 | 
             
              prerelease: false
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 | 
            -
              -  | 
| 8 | 
            +
              - 9
         | 
| 9 9 | 
             
              - 1
         | 
| 10 | 
            -
              version: 0. | 
| 10 | 
            +
              version: 0.9.1
         | 
| 11 11 | 
             
            platform: ruby
         | 
| 12 12 | 
             
            authors: 
         | 
| 13 13 | 
             
            - Ilya Sabanin
         | 
| @@ -15,7 +15,7 @@ autorequire: | |
| 15 15 | 
             
            bindir: bin
         | 
| 16 16 | 
             
            cert_chain: []
         | 
| 17 17 |  | 
| 18 | 
            -
            date:  | 
| 18 | 
            +
            date: 2012-04-18 00:00:00 -04:00
         | 
| 19 19 | 
             
            default_executable: 
         | 
| 20 20 | 
             
            dependencies: 
         | 
| 21 21 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -46,7 +46,6 @@ extra_rdoc_files: | |
| 46 46 | 
             
            - README.rdoc
         | 
| 47 47 | 
             
            files: 
         | 
| 48 48 | 
             
            - .document
         | 
| 49 | 
            -
            - .gitignore
         | 
| 50 49 | 
             
            - LICENSE
         | 
| 51 50 | 
             
            - README.rdoc
         | 
| 52 51 | 
             
            - Rakefile
         | 
| @@ -73,8 +72,8 @@ homepage: http://github.com/isabanin/pretty_diff | |
| 73 72 | 
             
            licenses: []
         | 
| 74 73 |  | 
| 75 74 | 
             
            post_install_message: 
         | 
| 76 | 
            -
            rdoc_options: 
         | 
| 77 | 
            -
             | 
| 75 | 
            +
            rdoc_options: []
         | 
| 76 | 
            +
             | 
| 78 77 | 
             
            require_paths: 
         | 
| 79 78 | 
             
            - lib
         | 
| 80 79 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement 
         |