pact-csv 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4ed4d58d80f4c4b79b16ec49e1b71529433023b2
4
+ data.tar.gz: 60d029010e07c00613a1c5d8b16cd9a4baf4f49a
5
+ SHA512:
6
+ metadata.gz: ecaa26f51d45014946705951c3aab6dd26bb7c5d76d6a4d28f3adc56aa6972ba22ac49ddcf404a2e14b2a9fd26714a011089490dbe576241caa3a0f859c74fa9
7
+ data.tar.gz: ee4c5369a77148f406de54d996bbb25ec65299ef361fa1465dafa55c4f2025a4376301c23ce19d889c97aaab078bf7a4c665d507933cafc291d584db44fbb104
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pact-csv.gemspec
4
+ gemspec
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pact-csv (0.0.1.alpha)
5
+ cucumber
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ builder (3.2.2)
11
+ cucumber (1.3.8)
12
+ builder (>= 2.1.2)
13
+ diff-lcs (>= 1.1.3)
14
+ gherkin (~> 2.12.1)
15
+ multi_json (>= 1.7.5, < 2.0)
16
+ multi_test (>= 0.0.2)
17
+ diff-lcs (1.2.5)
18
+ gherkin (2.12.1)
19
+ multi_json (~> 1.3)
20
+ multi_json (1.10.1)
21
+ multi_test (0.0.2)
22
+ rake (10.3.2)
23
+ rspec (3.0.0)
24
+ rspec-core (~> 3.0.0)
25
+ rspec-expectations (~> 3.0.0)
26
+ rspec-mocks (~> 3.0.0)
27
+ rspec-core (3.0.2)
28
+ rspec-support (~> 3.0.0)
29
+ rspec-expectations (3.0.2)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.0.0)
32
+ rspec-mocks (3.0.2)
33
+ rspec-support (~> 3.0.0)
34
+ rspec-support (3.0.2)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ bundler (~> 1.6)
41
+ pact-csv!
42
+ rake
43
+ rspec (~> 3.0)
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Beth
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # Pact::Csv
2
+
3
+ Provides CSV support for the Pact gem.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'pact-csv'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install pact-csv
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ require 'pact'
23
+ require 'pact/csv'
24
+
25
+ Pact.configure do | config |
26
+
27
+ # Maybe do this automatically?
28
+ config.register_body_differ /csv/, Pact::CSV::Differ
29
+ config.register_diff_formatter /csv/, Pact::CSV::DiffFormatter
30
+
31
+ end
32
+
33
+ ```
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it ( https://github.com/[my-github-username]/pact-csv/fork )
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create a new Pull Request
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -0,0 +1,9 @@
1
+ require "pact/csv/version"
2
+ require "pact/csv/differ"
3
+ require "pact/csv/diff_formatter"
4
+
5
+ module Pact
6
+ module CSV
7
+
8
+ end
9
+ end
@@ -0,0 +1,27 @@
1
+ module Pact
2
+ module CSV
3
+
4
+ class DiffFormatter
5
+
6
+ attr_reader :diff, :colour
7
+ def initialize diff, options = {}
8
+ @diff = diff
9
+ @colour = options.fetch(:colour, false)
10
+ end
11
+
12
+ def self.call diff, options = {colour: Pact.configuration.color_enabled}
13
+ new(diff, options).call
14
+ end
15
+
16
+ def call
17
+ diff.join("\n")
18
+ end
19
+
20
+ private
21
+
22
+
23
+
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,39 @@
1
+ require 'cucumber'
2
+
3
+ module Pact
4
+ module CSV
5
+
6
+ class Differ
7
+
8
+ attr_reader :expected, :actual, :options
9
+ def initialize expected, actual, options = {}
10
+ @expected = expected
11
+ @actual = actual
12
+ @options = options
13
+ puts caller.join("\n")
14
+ end
15
+
16
+ def self.call expected, actual, options = {}
17
+ new(expected, actual, options).call
18
+ end
19
+
20
+ def call
21
+ expected_data = ::CSV.parse(expected, headers: true)
22
+ actual_data = ::CSV.parse(actual, headers: true)
23
+ compare(expected_data, actual_data, options)
24
+ end
25
+ def compare(expected, actual, options)
26
+ expected_table = Cucumber::Ast::Table.new(expected.map(&:to_hash))
27
+ actual_table = Cucumber::Ast::Table.new(actual.map(&:to_hash))
28
+ errors = []
29
+ begin
30
+ p options
31
+ expected_table.diff!(actual_table, surplus_col: options["allow_unexpected_keys"])
32
+ rescue => e
33
+ errors = [e.table]
34
+ end
35
+ errors
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,5 @@
1
+ module Pact
2
+ module CSV
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pact/csv/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pact-csv"
8
+ spec.version = Pact::CSV::VERSION
9
+ spec.authors = ["Martin Mauch"]
10
+ spec.email = ["martin.mauch@gmail.com"]
11
+ spec.summary = %q{Provides CSV support for the Pact gem}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "cucumber"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+ require 'pact/csv/diff_formatter'
3
+
4
+ module Pact
5
+ module CSV
6
+
7
+ describe DiffFormatter do
8
+
9
+ describe ".call" do
10
+
11
+ context "when color_enabled is true" do
12
+ it "formats the diff nicely with color"
13
+
14
+ end
15
+
16
+ context "when color_enabled is false" do
17
+ it "formats the diff nicely without color"
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require 'pact/csv/differ'
3
+
4
+ module Pact
5
+ module CSV
6
+
7
+ describe Differ do
8
+
9
+ describe ".call" do
10
+
11
+ it "returns the diff between two CSV documents"
12
+
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+ end
File without changes
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pact-csv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Martin Mauch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cucumber
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description:
70
+ email:
71
+ - martin.mauch@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".rspec"
77
+ - Gemfile
78
+ - Gemfile.lock
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - lib/pact/csv.rb
83
+ - lib/pact/csv/diff_formatter.rb
84
+ - lib/pact/csv/differ.rb
85
+ - lib/pact/csv/version.rb
86
+ - pact-csv.gemspec
87
+ - spec/lib/pact/xml/diff_formatter_spec.rb
88
+ - spec/lib/pact/xml/differ_spec.rb
89
+ - spec/spec_helper.rb
90
+ homepage: ''
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.2.2
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Provides CSV support for the Pact gem
114
+ test_files:
115
+ - spec/lib/pact/xml/diff_formatter_spec.rb
116
+ - spec/lib/pact/xml/differ_spec.rb
117
+ - spec/spec_helper.rb