paraduct 0.0.2 → 0.0.3.beta2

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,21 +1,25 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9
4
- - 2.0
5
- - 2.1
6
- - 2.2
7
- - ruby-head
3
+ - 1.9
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
7
+ - ruby-head
8
8
  bundler_args: --jobs=2
9
9
  before_script:
10
- - export CODECLIMATE_REPO_TOKEN=bfa8a7ca9d8e18e9cad7593885aa11477a3c4b6b53f70f6be8ce60f470b48770
10
+ - export CODECLIMATE_REPO_TOKEN=bfa8a7ca9d8e18e9cad7593885aa11477a3c4b6b53f70f6be8ce60f470b48770
11
+ - export VERBOSE=1
12
+ - export COVERAGE=true
11
13
  script:
12
- - VERBOSE=1 bundle exec rspec
14
+ - bundle exec rspec
13
15
  branches:
14
16
  only:
15
- - master
17
+ - master
16
18
  notifications:
17
19
  email: false
20
+ slack:
21
+ secure: Va597DRHkMl8/mcoquZ0cNcR0GbJ+kbrXDMDnkiF8S7+xtsAXG3iQB9/Z3zOjF73wXmBjYWuawhcHiKD15atS1UN3xXCfguS26eANsnG+NsU8VXzY5wRW7G+Y4YpkACh4j2YLWlFqgffHgkJ+hM/OGtwnJPA6pSPXoJ7DS48lEs=
18
22
  matrix:
19
23
  allow_failures:
20
- - rvm: 2.2
21
- - rvm: ruby-head
24
+ - rvm: 2.2
25
+ - rvm: ruby-head
data/CHANGELOG.md CHANGED
@@ -1,6 +1,9 @@
1
1
  ## master
2
2
  [full changelog](http://github.com/sue445/paraduct/compare/v0.0.2...master)
3
3
 
4
+ * relax exclude definition
5
+ * https://github.com/sue445/paraduct/pull/74
6
+
4
7
  ## v0.0.2
5
8
  [full changelog](http://github.com/sue445/paraduct/compare/v0.0.1...v0.0.2)
6
9
 
@@ -26,11 +26,18 @@ module Paraduct
26
26
 
27
27
  def self.reject(product_variables, exclude_variables)
28
28
  product_variables.inject([]) do |rejected_product_variables, variables|
29
- rejected_product_variables << variables unless exclude_variables.include?(variables)
29
+ rejected_product_variables << variables unless exclude_variables.any?{ |exclude| partial_match?(variables, exclude) }
30
30
  rejected_product_variables
31
31
  end
32
32
  end
33
33
 
34
+ def self.partial_match?(parent_hash, child_hash)
35
+ child_hash.each do |k, v|
36
+ return false unless parent_hash[k] == v
37
+ end
38
+ true
39
+ end
40
+
34
41
  def self.product_array(array)
35
42
  first_values = array.shift
36
43
  if array.empty?
@@ -1,3 +1,3 @@
1
1
  module Paraduct
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3.beta2"
3
3
  end
data/paraduct.gemspec CHANGED
@@ -19,10 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "activesupport", ">= 4.0.0"
22
- spec.add_dependency "colorize"
23
- spec.add_dependency "rsync"
24
- spec.add_dependency "thor"
25
- spec.add_dependency "thread"
22
+ spec.add_dependency "colorize" , "~> 0.7.3"
23
+ spec.add_dependency "rsync" , "~> 1.0.9"
24
+ spec.add_dependency "thor" , "~> 0.19.1"
25
+ spec.add_dependency "thread" , "~> 0.1.4"
26
26
 
27
27
  spec.add_development_dependency "bundler", ">= 1.5"
28
28
  spec.add_development_dependency "codeclimate-test-reporter"
@@ -63,24 +63,72 @@ describe Paraduct::VariableConverter do
63
63
 
64
64
  let(:product_variables) do
65
65
  [
66
- {"ruby" => "1.9", "database" => "mysql" , "rails" => "3.2"},
67
- {"ruby" => "2.0", "database" => "mysql" , "rails" => "3.2"},
68
- {"ruby" => "2.1", "database" => "mysql" , "rails" => "3.2"},
66
+ { "ruby" => "1.9", "database" => "mysql" , "rails" => "3.2" },
67
+ { "ruby" => "2.0", "database" => "mysql" , "rails" => "3.2" },
68
+ { "ruby" => "2.1", "database" => "mysql" , "rails" => "3.2" },
69
69
  ]
70
70
  end
71
71
 
72
- let(:exclude_variables) do
73
- [
74
- {"rails" => "3.2", "ruby" => "2.0", "database" => "mysql"},
75
- ]
72
+ context "with perfect matching" do
73
+ let(:exclude_variables) do
74
+ [
75
+ { "rails" => "3.2", "ruby" => "2.0", "database" => "mysql" },
76
+ ]
77
+ end
78
+
79
+ it do
80
+ should contain_exactly(
81
+ { "ruby" => "1.9", "database" => "mysql", "rails" => "3.2" },
82
+ { "ruby" => "2.1", "database" => "mysql", "rails" => "3.2" },
83
+ )
84
+ end
76
85
  end
77
86
 
78
- it {
79
- should contain_exactly(
80
- {"ruby" => "1.9", "database" => "mysql" , "rails" => "3.2"},
81
- {"ruby" => "2.1", "database" => "mysql" , "rails" => "3.2"},
82
- )
83
- }
87
+ context "with partial matching" do
88
+ let(:exclude_variables) do
89
+ [
90
+ { "ruby" => "1.9" },
91
+ ]
92
+ end
93
+
94
+ it do
95
+ should contain_exactly(
96
+ { "ruby" => "2.0", "database" => "mysql", "rails" => "3.2" },
97
+ { "ruby" => "2.1", "database" => "mysql", "rails" => "3.2" },
98
+ )
99
+ end
100
+ end
84
101
  end
85
102
 
103
+ describe "#partial_match?" do
104
+ subject{ Paraduct::VariableConverter.partial_match?(parent_hash, child_hash) }
105
+
106
+ context "with parent_hash == child_hash" do
107
+ let(:parent_hash){ { a: 1, b: 2, c: 3 } }
108
+ let(:child_hash) { { a: 1, b: 2, c: 3 } }
109
+
110
+ it{ should be true }
111
+ end
112
+
113
+ context "with parent_hash > child_hash" do
114
+ let(:parent_hash){ { a: 1, b: 2, c: 3 } }
115
+ let(:child_hash) { { a: 1, c: 3 } }
116
+
117
+ it{ should be true }
118
+ end
119
+
120
+ context "with parent_hash > child_hash, but value is not same" do
121
+ let(:parent_hash){ { a: 1, b: 2, c: 3 } }
122
+ let(:child_hash) { { a: 1, c: 4 } }
123
+
124
+ it{ should be false }
125
+ end
126
+
127
+ context "with parent_hash < child_hash" do
128
+ let(:parent_hash){ { a: 1, b: 2, c: 3 } }
129
+ let(:child_hash) { { a: 1, c: 3, d: 4 } }
130
+
131
+ it{ should be false }
132
+ end
133
+ end
86
134
  end
data/spec/spec_helper.rb CHANGED
@@ -1,14 +1,16 @@
1
- require 'simplecov'
2
- require 'coveralls'
3
- require 'codeclimate-test-reporter'
4
-
5
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6
- CodeClimate::TestReporter::Formatter,
7
- Coveralls::SimpleCov::Formatter
8
- ]
9
- SimpleCov.start do
10
- %w(/bin/ /vendor/ /spec/).each do |ignore_path|
11
- add_filter(ignore_path)
1
+ if ENV["COVERAGE"]
2
+ require 'simplecov'
3
+ require 'coveralls'
4
+ require 'codeclimate-test-reporter'
5
+
6
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
+ CodeClimate::TestReporter::Formatter,
8
+ Coveralls::SimpleCov::Formatter
9
+ ]
10
+ SimpleCov.start do
11
+ %w(/bin/ /vendor/ /spec/).each do |ignore_path|
12
+ add_filter(ignore_path)
13
+ end
12
14
  end
13
15
  end
14
16
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paraduct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3.beta2
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - sue445
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-06 00:00:00.000000000 Z
12
+ date: 2014-12-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -32,65 +32,65 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ! '>='
35
+ - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: '0'
37
+ version: 0.7.3
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ! '>='
43
+ - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: '0'
45
+ version: 0.7.3
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rsync
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ! '>='
51
+ - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: '0'
53
+ version: 1.0.9
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ! '>='
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 1.0.9
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: thor
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
- - - ! '>='
67
+ - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: '0'
69
+ version: 0.19.1
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
- - - ! '>='
75
+ - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: '0'
77
+ version: 0.19.1
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: thread
80
80
  requirement: !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
83
- - - ! '>='
83
+ - - ~>
84
84
  - !ruby/object:Gem::Version
85
- version: '0'
85
+ version: 0.1.4
86
86
  type: :runtime
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
- - - ! '>='
91
+ - - ~>
92
92
  - !ruby/object:Gem::Version
93
- version: '0'
93
+ version: 0.1.4
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: bundler
96
96
  requirement: !ruby/object:Gem::Requirement
@@ -386,16 +386,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
386
386
  version: '0'
387
387
  segments:
388
388
  - 0
389
- hash: -858746175039195430
389
+ hash: -487541919658723627
390
390
  required_rubygems_version: !ruby/object:Gem::Requirement
391
391
  none: false
392
392
  requirements:
393
- - - ! '>='
393
+ - - ! '>'
394
394
  - !ruby/object:Gem::Version
395
- version: '0'
396
- segments:
397
- - 0
398
- hash: -858746175039195430
395
+ version: 1.3.1
399
396
  requirements: []
400
397
  rubyforge_project:
401
398
  rubygems_version: 1.8.23.2