multidiff 0.0.1 → 0.1.0

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
  SHA1:
3
- metadata.gz: d524c113d3bd8161f42ec01aaee73ada4dba99d4
4
- data.tar.gz: 2d1ecdcf106ccbc01dc0a2667b5a8f33f21d77b3
3
+ metadata.gz: d812370c102a82aedd3ae30a6c1102f29391f8bd
4
+ data.tar.gz: 4120193fd2c2d1bbb844bea137b3225a0579302f
5
5
  SHA512:
6
- metadata.gz: 4f63fea304d251e76ce1b875ad092d26eef565b06c8a193dc659c43c6500725742a6140cec9019fed6ac8e85bbcec15163bc6f3c965046437917f8c2608dddb3
7
- data.tar.gz: 39ba9a22c16dc08544cc4d8a0587b4bb52c85380d823b2054ca0733b635592633c218d7a5b228858ea52f74904855d7bb24f5fc08b4521cab8303dcc5112eaf9
6
+ metadata.gz: ff5c2c6113b1ba3d9f32e97e91f3d30ad4ad5aa2187eec64c9ba489b3fc2606e72fd624d863e41f502f8d1ac01e2b6df4d3aef313b5abee944760c74f7da1ff4
7
+ data.tar.gz: 5d65cb4cda0747750babc4605b818061c7cfd62241ab614d0ae6514c48237d5ea7bc542354b9eef193ae32ddcb764b1052305f066cadddd5390d4e954c55fe63
@@ -1,8 +1,13 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
+ - 2.1.0
5
+ - 2.2.0
4
6
  - 2.3.1
5
7
 
8
+ before_install:
9
+ - gem install bundler
10
+
6
11
  script:
7
12
  - bundle exec rubocop
8
13
  - bundle exec rspec
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ [![Gem Version](https://badge.fury.io/rb/multidiff.svg)](https://badge.fury.io/rb/multidiff)
1
2
  [![Build Status](https://secure.travis-ci.org/mpugach/multidiff.png?branch=master)](https://travis-ci.org/mpugach/multidiff)
2
3
  [![Code Climate](https://codeclimate.com/github/mpugach/multidiff/badges/gpa.svg)](https://codeclimate.com/github/mpugach/multidiff)
3
4
  [![Test Coverage](https://codeclimate.com/github/mpugach/multidiff/badges/coverage.svg)](https://codeclimate.com/github/mpugach/multidiff/coverage)
@@ -12,7 +13,7 @@ A simple wrapper for the [diff-lcs](https://github.com/halostatue/diff-lcs) to c
12
13
  Add this line to your application's Gemfile:
13
14
 
14
15
  ```ruby
15
- gem 'multidiff', github: 'mpugach/multidiff', tag: '0.0.1'
16
+ gem 'multidiff', github: 'mpugach/multidiff', tag: '0.1.0'
16
17
  ```
17
18
 
18
19
  And then execute:
@@ -25,17 +26,30 @@ Or install it yourself as:
25
26
 
26
27
  ## Usage
27
28
 
28
- TODO: Write usage instructions here
29
+ Run from command line
30
+
31
+ $ multidiff path/to/file_1.txt path/to/file_2.txt [path/to/file_3.txt ...]
32
+
33
+ Or from your app
34
+
35
+ require 'multidiff'
36
+
37
+ # To return Diff::LCS objects
38
+ Multidiff::Differ.diff([array_of_strings_1, array_of_strings_2, ...])
39
+
40
+ # To return array of strings
41
+ Multidiff::Differ.pretty_diff([array_of_strings_1, array_of_strings_2, ...])
42
+
29
43
 
30
44
  ## Development
31
45
 
32
- 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.
46
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
47
 
34
48
  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).
35
49
 
36
50
  ## Contributing
37
51
 
38
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rdiff. 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.
52
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mpugach/multidiff. 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.
39
53
 
40
54
 
41
55
  ## License
@@ -7,8 +7,12 @@ module Multidiff
7
7
  def self.diff(files)
8
8
  base = files.shift
9
9
 
10
- files.map do |file|
11
- Diff::LCS.sdiff(base, file).each_with_index.map do |change, line|
10
+ files.map { |file| Diff::LCS.sdiff(base, file) }
11
+ end
12
+
13
+ def self.pretty_diff(files)
14
+ diff(files).map do |changes|
15
+ changes.each_with_index.map do |change, line|
12
16
  text = if change.action == '!'
13
17
  "#{change.old_element}|#{change.new_element}"
14
18
  else
@@ -5,7 +5,7 @@ module Multidiff
5
5
 
6
6
  abort 'Nothing to compare' if data.count < 2
7
7
 
8
- puts Multidiff::Differ.diff(data).map { |diff| diff.join("\n") }.join("\n\n")
8
+ puts Multidiff::Differ.pretty_diff(data).map { |diff| diff.join("\n") }.join("\n\n")
9
9
  end
10
10
 
11
11
  class << self
@@ -1,5 +1,5 @@
1
1
  module Multidiff
2
2
  module Version
3
- STRING = '0.0.1'.freeze
3
+ STRING = '0.1.0'.freeze
4
4
  end
5
5
  end
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ['lib']
20
20
 
21
+ spec.required_ruby_version = '>= 2.1.0'
22
+
21
23
  spec.add_dependency 'diff-lcs', '~> 1.2'
22
24
 
23
25
  spec.add_development_dependency 'bundler', '~> 1.11'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multidiff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maksym Pugach
@@ -148,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
148
  requirements:
149
149
  - - ">="
150
150
  - !ruby/object:Gem::Version
151
- version: '0'
151
+ version: 2.1.0
152
152
  required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  requirements:
154
154
  - - ">="