differin 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +110 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/differin.gemspec +26 -0
- data/examples/file1.txt +4 -0
- data/examples/file2.txt +6 -0
- data/lib/differin.rb +52 -0
- data/lib/differin/diff.rb +53 -0
- data/lib/differin/engines/base.rb +29 -0
- data/lib/differin/engines/lcs.rb +50 -0
- data/lib/differin/engines/system.rb +15 -0
- data/lib/differin/exceptions.rb +14 -0
- data/lib/differin/file.rb +48 -0
- data/lib/differin/null.rb +18 -0
- data/lib/differin/renderers/array.rb +16 -0
- data/lib/differin/renderers/base.rb +23 -0
- data/lib/differin/renderers/hash.rb +10 -0
- data/lib/differin/renderers/json.rb +12 -0
- data/lib/differin/version.rb +4 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 10eb8045cd648d291502b0a6cd8eb6bbb130bb41
|
4
|
+
data.tar.gz: b87230296af679bfeb816e0e1dce9f19740ed430
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 10f03deb0ad5dd7cf088479060b557741e1f401b1de4c68f49411479d0718573c4bc88dc47a83a0e5b401559147341234884467d38cdbab3be8af9fdbc13c13e
|
7
|
+
data.tar.gz: 3ac81d3fc130ae0dbadd6d80259395d1b3f9c2f0c40c6d9cd372f7bd6d819502127939d0a96bde2ae5b921ffc4d55d345ff2728b32fd5ba51b92f822d5752600
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at andrew.emelianenko@dev-pro.net. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 andrew.emelianenko
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
# Differin
|
2
|
+
|
3
|
+
#### IMPORTANT: This GEM is created as test task and not ready for production yet.
|
4
|
+
|
5
|
+
**Differin** this is gem for showing diff between files. Differin has multiple Engines to process data and Renderers to show the results.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'differin', '~> 0.1.0'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install differin
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
~~~ruby
|
26
|
+
require 'differin'
|
27
|
+
|
28
|
+
diff = Differin::Diff.new('examples/file1.txt', 'examples/file2.txt')
|
29
|
+
diff.process
|
30
|
+
|
31
|
+
# or
|
32
|
+
|
33
|
+
Differin.diff('examples/file1.txt', 'examples/file2.txt')
|
34
|
+
~~~
|
35
|
+
|
36
|
+
Result of these commands:
|
37
|
+
~~~ruby
|
38
|
+
[
|
39
|
+
{
|
40
|
+
status: :modified,
|
41
|
+
lines: [1, 1],
|
42
|
+
values: ['Some', 'Another']
|
43
|
+
} ...
|
44
|
+
]
|
45
|
+
~~~
|
46
|
+
|
47
|
+
### Renderers
|
48
|
+
|
49
|
+
You can choose the Renderer for rendering processed data.
|
50
|
+
|
51
|
+
~~~ruby
|
52
|
+
diff = Differin::Diff.new('examples/file1.txt', 'examples/file2.txt')
|
53
|
+
|
54
|
+
# These commands run processing and render data as Array or JSON
|
55
|
+
diff.process(renderer: Differin::Renderers::Array)
|
56
|
+
diff.process(renderer: Differin::Renderers::JSON)
|
57
|
+
|
58
|
+
# This command just re-render already processed data
|
59
|
+
diff.render(Differin::Renderers::Array)
|
60
|
+
|
61
|
+
# Short version
|
62
|
+
Differin.diff('examples/file1.txt', 'examples/file2.txt', renderer: Differin::Renderers::JSON)
|
63
|
+
~~~
|
64
|
+
|
65
|
+
#### Available renderers
|
66
|
+
|
67
|
+
- `Differin::Renderers::Array`
|
68
|
+
- `Differin::Renderers::JSON`
|
69
|
+
- `Differin::Renderers::Hash`
|
70
|
+
- More renderers in section **Extensions**
|
71
|
+
|
72
|
+
### Engines
|
73
|
+
|
74
|
+
You can choose the Engine for file processing.
|
75
|
+
|
76
|
+
~~~ruby
|
77
|
+
diff = Differin::Diff.new('examples/file1.txt', 'examples/file2.txt')
|
78
|
+
|
79
|
+
diff.process(engine: Differin::Engines::LCS)
|
80
|
+
diff.process(engine: Differin::Engines::LCS, renderer: Differin::Renderers::Hash)
|
81
|
+
~~~
|
82
|
+
|
83
|
+
#### Available engines
|
84
|
+
|
85
|
+
- `Differin::Engines::LCS`
|
86
|
+
- More engines in section **Extensions**
|
87
|
+
|
88
|
+
## Extensions
|
89
|
+
|
90
|
+
**Differin is flexible.** You can easy create or just connect new **renderers** and **engines**.
|
91
|
+
|
92
|
+
#### Available renderers
|
93
|
+
|
94
|
+
- [Differin::Renderers::Text](http://github.com/MrEmelianenko/differin-renderers-text)
|
95
|
+
|
96
|
+
## Development
|
97
|
+
|
98
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
99
|
+
|
100
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
101
|
+
|
102
|
+
## Contributing
|
103
|
+
|
104
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/differin. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
105
|
+
|
106
|
+
|
107
|
+
## License
|
108
|
+
|
109
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
110
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'differin'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/differin.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'differin/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'differin'
|
8
|
+
spec.version = Differin::VERSION
|
9
|
+
spec.authors = ['Andrew Emelianenko']
|
10
|
+
spec.email = ['emelianenko.web@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Show diff of files'
|
13
|
+
spec.description = 'Diff files with multiple engines and renderers.'
|
14
|
+
spec.homepage = 'http://github.com/MrEmelianenko/differin'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
25
|
+
spec.add_development_dependency 'diff-lcs', '~> 1.2.5'
|
26
|
+
end
|
data/examples/file1.txt
ADDED
data/examples/file2.txt
ADDED
data/lib/differin.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
require 'differin/null'
|
3
|
+
require 'differin/exceptions'
|
4
|
+
require 'differin/file'
|
5
|
+
require 'differin/diff'
|
6
|
+
require 'differin/version'
|
7
|
+
require 'differin/engines/base'
|
8
|
+
require 'differin/engines/lcs'
|
9
|
+
require 'differin/engines/system'
|
10
|
+
require 'differin/renderers/base'
|
11
|
+
require 'differin/renderers/hash'
|
12
|
+
require 'differin/renderers/json'
|
13
|
+
require 'differin/renderers/array'
|
14
|
+
|
15
|
+
module Differin
|
16
|
+
# List of allowed extensions
|
17
|
+
ALLOWED_EXTENSIONS = %w(txt)
|
18
|
+
|
19
|
+
# List of allowed engines
|
20
|
+
ALLOWED_ENGINES = [
|
21
|
+
Differin::Engines::LCS,
|
22
|
+
Differin::Engines::System
|
23
|
+
]
|
24
|
+
|
25
|
+
# List of allowed renderers
|
26
|
+
ALLOWED_RENDERERS = [
|
27
|
+
Differin::Renderers::Hash,
|
28
|
+
Differin::Renderers::JSON,
|
29
|
+
Differin::Renderers::Array
|
30
|
+
]
|
31
|
+
|
32
|
+
# Line statuses
|
33
|
+
MODIFIED = :modified
|
34
|
+
ADDED = :added
|
35
|
+
REMOVED = :removed
|
36
|
+
EQUAL = :equal
|
37
|
+
|
38
|
+
class << self
|
39
|
+
def diff(file1, file2, options = {})
|
40
|
+
diff = Differin::Diff.new(file1, file2)
|
41
|
+
diff.process(options)
|
42
|
+
end
|
43
|
+
|
44
|
+
def engine_exists?(engine)
|
45
|
+
ALLOWED_ENGINES.include?(engine)
|
46
|
+
end
|
47
|
+
|
48
|
+
def renderer_exists?(renderer)
|
49
|
+
ALLOWED_RENDERERS.include?(renderer)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
module Differin
|
3
|
+
class Diff
|
4
|
+
# Getters
|
5
|
+
attr_reader :file1, :file2, :options
|
6
|
+
|
7
|
+
def initialize(file1, file2)
|
8
|
+
@file1 = Differin::File.new(file1)
|
9
|
+
@file2 = Differin::File.new(file2)
|
10
|
+
end
|
11
|
+
|
12
|
+
def process(options_outer = {})
|
13
|
+
load_options(options_outer)
|
14
|
+
|
15
|
+
self.engine = options[:engine].new(self)
|
16
|
+
engine.run
|
17
|
+
|
18
|
+
self.renderer = options[:renderer].new(self)
|
19
|
+
renderer.render
|
20
|
+
end
|
21
|
+
|
22
|
+
def result
|
23
|
+
engine.result
|
24
|
+
end
|
25
|
+
|
26
|
+
def render(as = nil)
|
27
|
+
return renderer.render if as.nil?
|
28
|
+
Differin.renderer_exists?(as) or fail Differin::InvalidRenderer
|
29
|
+
|
30
|
+
renderer = as.new(self)
|
31
|
+
renderer.render
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# Setters
|
37
|
+
attr_writer :file1, :file2, :options
|
38
|
+
|
39
|
+
# Getters/Setters
|
40
|
+
attr_accessor :engine, :renderer
|
41
|
+
|
42
|
+
def load_options(options_outer)
|
43
|
+
# noinspection RubyArgCount
|
44
|
+
self.options = {
|
45
|
+
engine: Differin::Engines::LCS,
|
46
|
+
renderer: Differin::Renderers::Hash
|
47
|
+
}.merge(options_outer)
|
48
|
+
|
49
|
+
Differin.engine_exists?(options[:engine]) or fail Differin::InvalidEngine
|
50
|
+
Differin.renderer_exists?(options[:renderer]) or fail Differin::InvalidRenderer
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
module Differin
|
3
|
+
module Engines
|
4
|
+
class Base
|
5
|
+
# Getters
|
6
|
+
attr_reader :diff, :result, :options
|
7
|
+
|
8
|
+
def initialize(diff, options = {})
|
9
|
+
@diff = diff
|
10
|
+
@result = Differin::NULL
|
11
|
+
@options = options
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
return result if result != Differin::NULL
|
16
|
+
self.result = run_engine
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
# Setters
|
22
|
+
attr_writer :diff, :result, :options
|
23
|
+
|
24
|
+
def run_engine
|
25
|
+
fail NotImplementedError
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
require 'diff-lcs'
|
3
|
+
|
4
|
+
module Differin
|
5
|
+
module Engines
|
6
|
+
class LCS < Differin::Engines::Base
|
7
|
+
private
|
8
|
+
|
9
|
+
# Getters/Setters
|
10
|
+
attr_accessor :sequence1, :sequence2, :engine_result
|
11
|
+
|
12
|
+
def run_engine
|
13
|
+
load_sequences
|
14
|
+
run_diff_lcs
|
15
|
+
convert_result
|
16
|
+
end
|
17
|
+
|
18
|
+
def load_sequences
|
19
|
+
self.sequence1 = diff.file1.lines
|
20
|
+
self.sequence2 = diff.file2.lines
|
21
|
+
end
|
22
|
+
|
23
|
+
def run_diff_lcs
|
24
|
+
self.engine_result = ::Diff::LCS.sdiff(sequence1, sequence2)
|
25
|
+
end
|
26
|
+
|
27
|
+
def convert_result
|
28
|
+
engine_result.map do |row|
|
29
|
+
row = row.to_a
|
30
|
+
|
31
|
+
{
|
32
|
+
status: map_status(row[0]),
|
33
|
+
lines: [row[1][0], row[2][0]],
|
34
|
+
values: [row[1][1], row[2][1]]
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Map statuses from LCS to Differin
|
40
|
+
def map_status(status)
|
41
|
+
{
|
42
|
+
Differin::MODIFIED => '!',
|
43
|
+
Differin::EQUAL => '=',
|
44
|
+
Differin::ADDED => '+',
|
45
|
+
Differin::REMOVED => '-'
|
46
|
+
}.key(status)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
module Differin
|
3
|
+
class BaseError < StandardError; end
|
4
|
+
|
5
|
+
# Files
|
6
|
+
class FileNotFound < Differin::BaseError; end
|
7
|
+
class InvalidFile < Differin::BaseError; end
|
8
|
+
|
9
|
+
# Engines
|
10
|
+
class InvalidEngine < Differin::BaseError; end
|
11
|
+
|
12
|
+
# Renderers
|
13
|
+
class InvalidRenderer < Differin::BaseError; end
|
14
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
module Differin
|
3
|
+
class File
|
4
|
+
# Getters
|
5
|
+
attr_reader :file
|
6
|
+
|
7
|
+
def initialize(file)
|
8
|
+
@file = load_file(file)
|
9
|
+
fail Differin::InvalidFile unless valid?
|
10
|
+
end
|
11
|
+
|
12
|
+
def filename
|
13
|
+
::File.basename(file.path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def extension
|
17
|
+
::File.extname(file.path).delete('.')
|
18
|
+
end
|
19
|
+
|
20
|
+
def lines
|
21
|
+
return @lines if defined?(@lines)
|
22
|
+
@lines = readlines
|
23
|
+
end
|
24
|
+
|
25
|
+
def valid?
|
26
|
+
return false unless ALLOWED_EXTENSIONS.include?(extension)
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
# Setters
|
33
|
+
attr_writer :file
|
34
|
+
|
35
|
+
def load_file(file)
|
36
|
+
return file if file.is_a?(::File)
|
37
|
+
fail Differin::FileNotFound unless ::File.exist?(file.to_s)
|
38
|
+
|
39
|
+
::File.open(file.to_s, 'r')
|
40
|
+
end
|
41
|
+
|
42
|
+
def readlines
|
43
|
+
file.readlines.map do |line|
|
44
|
+
line.delete("\r").delete("\n")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
module Differin
|
3
|
+
module Renderers
|
4
|
+
class Array < Differin::Renderers::Base
|
5
|
+
def render
|
6
|
+
diff.result.map do |row|
|
7
|
+
[
|
8
|
+
row[:status],
|
9
|
+
[row[:lines].first, row[:values].first],
|
10
|
+
[row[:lines].last, row[:values].last]
|
11
|
+
]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
module Differin
|
3
|
+
module Renderers
|
4
|
+
class Base
|
5
|
+
# Getters
|
6
|
+
attr_reader :diff, :options
|
7
|
+
|
8
|
+
def initialize(diff, options = {})
|
9
|
+
@diff = diff
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def render
|
14
|
+
fail NotImplementedError
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
# Setters
|
20
|
+
attr_writer :diff, :options
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: differin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Emelianenko
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: diff-lcs
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.2.5
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.2.5
|
69
|
+
description: Diff files with multiple engines and renderers.
|
70
|
+
email:
|
71
|
+
- emelianenko.web@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- CODE_OF_CONDUCT.md
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- differin.gemspec
|
87
|
+
- examples/file1.txt
|
88
|
+
- examples/file2.txt
|
89
|
+
- lib/differin.rb
|
90
|
+
- lib/differin/diff.rb
|
91
|
+
- lib/differin/engines/base.rb
|
92
|
+
- lib/differin/engines/lcs.rb
|
93
|
+
- lib/differin/engines/system.rb
|
94
|
+
- lib/differin/exceptions.rb
|
95
|
+
- lib/differin/file.rb
|
96
|
+
- lib/differin/null.rb
|
97
|
+
- lib/differin/renderers/array.rb
|
98
|
+
- lib/differin/renderers/base.rb
|
99
|
+
- lib/differin/renderers/hash.rb
|
100
|
+
- lib/differin/renderers/json.rb
|
101
|
+
- lib/differin/version.rb
|
102
|
+
homepage: http://github.com/MrEmelianenko/differin
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.4.8
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: Show diff of files
|
126
|
+
test_files: []
|