dry-logic 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 405fbdd05ed04c6abd40e6f4e0bc82798ce17463
4
- data.tar.gz: c0d6fb17709b8d8c69594e8fb38caa7161eee873
3
+ metadata.gz: e25000a6e80f51337190d6dc64bf1566bdcceafd
4
+ data.tar.gz: bfd9743a8aa9b6cc7f3bc95788120acfec5b9ee6
5
5
  SHA512:
6
- metadata.gz: b5efcddce3c685049908c67e33fdfc3b473ff173c313469c40169ef02332aaa18e1711e40eaf47b683c29dbe2e2d5dd25bd76fa9c8b53b05457661ac98966f52
7
- data.tar.gz: 89be8d68859d37e8969ca9ea650bea7ed9225dbc51f0911e5e66dc47df82f6560292879052dcb2906ff7e43d8a3c5f1f2ea2922317fbb82710487fc0cbfc9298
6
+ metadata.gz: fb98dba1f9b5c22af3dd9fe729193246cc2df3af90302cce7ab1c5b81d5c5f189192e25673aadbb82c8ac26eabb79054d496328ccbbab1d0b6340be0cccd7624
7
+ data.tar.gz: 590203f2b2e3788bf3d7e2d5039d445162060e0fa0a2b6978e7f17a33212e7b54fceb1d41e7aafa4ecfcee815a26eaf5756b2cdc68d0b6426f9f335937e2b54d
@@ -1,3 +1,11 @@
1
+ # v0.2.2 2016-03-30
2
+
3
+ ### Added
4
+
5
+ * `number?` predicate (fran-worley)
6
+
7
+ [Compare v0.2.1...v0.2.2](https://github.com/dryrb/dry-logic/compare/v0.2.1...v0.2.2)
8
+
1
9
  # v0.2.1 2016-03-20
2
10
 
3
11
  ### Fixed
data/Gemfile CHANGED
@@ -2,6 +2,10 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
+ group :test do
6
+ gem 'codeclimate-test-reporter', platform: :rbx
7
+ end
8
+
5
9
  group :tools do
6
10
  gem 'guard'
7
11
  gem 'guard-rspec'
@@ -56,6 +56,14 @@ module Dry
56
56
  input.is_a?(Time)
57
57
  end
58
58
 
59
+ predicate(:number?) do |input|
60
+ begin
61
+ true if Float(input)
62
+ rescue ArgumentError, TypeError
63
+ false
64
+ end
65
+ end
66
+
59
67
  predicate(:int?) do |input|
60
68
  input.is_a?(Fixnum)
61
69
  end
@@ -80,6 +88,14 @@ module Dry
80
88
  input.is_a?(Array)
81
89
  end
82
90
 
91
+ predicate(:odd?) do |input|
92
+ input.odd?
93
+ end
94
+
95
+ predicate(:even?) do |input|
96
+ input.even?
97
+ end
98
+
83
99
  predicate(:lt?) do |num, input|
84
100
  input < num
85
101
  end
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Logic
3
- VERSION = '0.2.1'.freeze
3
+ VERSION = '0.2.2'.freeze
4
4
  end
5
5
  end
@@ -1,3 +1,8 @@
1
+ if RUBY_ENGINE == "rbx"
2
+ require "codeclimate-test-reporter"
3
+ CodeClimate::TestReporter.start
4
+ end
5
+
1
6
  begin
2
7
  require 'byebug'
3
8
  rescue LoadError; end
@@ -0,0 +1,31 @@
1
+ require 'dry/logic/predicates'
2
+
3
+ RSpec.describe Dry::Logic::Predicates do
4
+ describe '#even?' do
5
+ let(:predicate_name) { :even? }
6
+
7
+ context 'when value is an odd int' do
8
+ let(:arguments_list) do
9
+ [
10
+ [13],
11
+ [1],
12
+ [1111]
13
+ ]
14
+ end
15
+
16
+ it_behaves_like 'a failing predicate'
17
+ end
18
+
19
+ context 'with value is an even int' do
20
+ let(:arguments_list) do
21
+ [
22
+ [0],
23
+ [2],
24
+ [2222]
25
+ ]
26
+ end
27
+
28
+ it_behaves_like 'a passing predicate'
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,37 @@
1
+ require 'dry/logic/predicates'
2
+
3
+ RSpec.describe Dry::Logic::Predicates do
4
+ describe '#number?' do
5
+ let(:predicate_name) { :number? }
6
+
7
+ context 'when value is numerical' do
8
+ let(:arguments_list) do
9
+ [
10
+ ["34"],
11
+ ["1.000004"],
12
+ ["0"],
13
+ [4],
14
+ ["-15.24"],
15
+ [-3.5]
16
+ ]
17
+ end
18
+
19
+ it_behaves_like 'a passing predicate'
20
+ end
21
+
22
+ context 'with value is not numerical' do
23
+ let(:arguments_list) do
24
+ [
25
+ [''],
26
+ ["-14px"],
27
+ ["10,150.00"],
28
+ [nil],
29
+ [:symbol],
30
+ [String]
31
+ ]
32
+ end
33
+
34
+ it_behaves_like 'a failing predicate'
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,31 @@
1
+ require 'dry/logic/predicates'
2
+
3
+ RSpec.describe Dry::Logic::Predicates do
4
+ describe '#odd?' do
5
+ let(:predicate_name) { :odd? }
6
+
7
+ context 'when value is an odd int' do
8
+ let(:arguments_list) do
9
+ [
10
+ [13],
11
+ [1],
12
+ [1111]
13
+ ]
14
+ end
15
+
16
+ it_behaves_like 'a passing predicate'
17
+ end
18
+
19
+ context 'with value is an even int' do
20
+ let(:arguments_list) do
21
+ [
22
+ [0],
23
+ [2],
24
+ [2222]
25
+ ]
26
+ end
27
+
28
+ it_behaves_like 'a failing predicate'
29
+ end
30
+ end
31
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-logic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-20 00:00:00.000000000 Z
11
+ date: 2016-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-container
@@ -138,6 +138,7 @@ files:
138
138
  - spec/unit/predicates/decimal_spec.rb
139
139
  - spec/unit/predicates/empty_spec.rb
140
140
  - spec/unit/predicates/eql_spec.rb
141
+ - spec/unit/predicates/even_spec.rb
141
142
  - spec/unit/predicates/exclusion_spec.rb
142
143
  - spec/unit/predicates/false_spec.rb
143
144
  - spec/unit/predicates/filled_spec.rb
@@ -153,6 +154,8 @@ files:
153
154
  - spec/unit/predicates/max_size_spec.rb
154
155
  - spec/unit/predicates/min_size_spec.rb
155
156
  - spec/unit/predicates/none_spec.rb
157
+ - spec/unit/predicates/number_spec.rb
158
+ - spec/unit/predicates/odd_spec.rb
156
159
  - spec/unit/predicates/size_spec.rb
157
160
  - spec/unit/predicates/str_spec.rb
158
161
  - spec/unit/predicates/time_spec.rb
@@ -188,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
191
  version: '0'
189
192
  requirements: []
190
193
  rubyforge_project:
191
- rubygems_version: 2.4.5.1
194
+ rubygems_version: 2.5.1
192
195
  signing_key:
193
196
  specification_version: 4
194
197
  summary: Predicate logic with rule composition
@@ -203,6 +206,7 @@ test_files:
203
206
  - spec/unit/predicates/decimal_spec.rb
204
207
  - spec/unit/predicates/empty_spec.rb
205
208
  - spec/unit/predicates/eql_spec.rb
209
+ - spec/unit/predicates/even_spec.rb
206
210
  - spec/unit/predicates/exclusion_spec.rb
207
211
  - spec/unit/predicates/false_spec.rb
208
212
  - spec/unit/predicates/filled_spec.rb
@@ -218,6 +222,8 @@ test_files:
218
222
  - spec/unit/predicates/max_size_spec.rb
219
223
  - spec/unit/predicates/min_size_spec.rb
220
224
  - spec/unit/predicates/none_spec.rb
225
+ - spec/unit/predicates/number_spec.rb
226
+ - spec/unit/predicates/odd_spec.rb
221
227
  - spec/unit/predicates/size_spec.rb
222
228
  - spec/unit/predicates/str_spec.rb
223
229
  - spec/unit/predicates/time_spec.rb