nifty-variants 1.0.0 → 1.0.1

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: 5574aca0890dc28da6736189ba3a749b06fd1590
4
- data.tar.gz: e47d15b310ff5461e757957c82484e16b6db4db9
3
+ metadata.gz: d8c0f1e4f41c20c0380c0d7f3860e34ee5448aa2
4
+ data.tar.gz: 678cc9e9c638aad57a41a65762f00cdc8b0c5ed8
5
5
  SHA512:
6
- metadata.gz: 10677127ef34f17ed0c9131bc2bb0cb95ae3bce6289b300792571d7250b509d3330c050d16e0c3b9ccc5fa8cd858a2e2084934efa033221945aecd54486cfa57
7
- data.tar.gz: ebd51fefa61f36f74d462cedbd25ce39a2f2f933852f7940ffdb0946eef7d45eb905b65e83a4414c5837dbdb861be293c4b6473eb13e564bd5611772036cb6d1
6
+ metadata.gz: ed773a89261f29e7a01022e1e0adc3a1f13280d06f6b090cff09872e02ebc96cbd4c172d650a1dfa88619555e3266f098a0fb645ea437cecf1ace73098dd4a8e
7
+ data.tar.gz: f921755d3db4e7147687888bca107eab034d9341585e0f4cc7bff019fecdcac813ac7f1ad54eeb338a07e045ab129ba2a7bd3be2056c20d3cde4a6c5e8280a53
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Nifty::Variants
2
2
 
3
+ [ ![Codeship Status for niftyn8/nifty-variants](https://codeship.com/projects/9585a190-5b48-0132-5f60-022e5ac315ca/status)](https://codeship.com/projects/50484)
4
+
3
5
  If you are familiar with variants from a nice language like Haskell try this.
4
6
 
5
7
  If you don't know what variants are [start here](http://youtu.be/ZQkIWWTygio)
@@ -32,7 +34,7 @@ class OrderDispatch
32
34
  def shipit!(order)
33
35
  cases order,
34
36
  digital: ->(o) { o.email! },
35
- delivery: ->(o) { o.deliver! }
37
+ delivery: ->(o) { o.deliver! },
36
38
  else: ->(o) { move_to_error_queue(o) }
37
39
  end
38
40
  end
@@ -1,5 +1,5 @@
1
1
  module Nifty
2
2
  module Variants
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
@@ -6,6 +6,7 @@ require 'nifty/variants/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "nifty-variants"
8
8
  spec.version = Nifty::Variants::VERSION
9
+ spec.required_ruby_version = '~> 2.1.0'
9
10
  spec.authors = ["Nate West"]
10
11
  spec.email = ["natescott.west@gmail.com"]
11
12
  spec.summary = %q{Variants in Ruby}
@@ -6,10 +6,9 @@ RSpec.describe Order do
6
6
  for_every(:order) { generate(:order) }
7
7
 
8
8
  it "returns a tuple-like variant" do
9
- o = order
10
- variant, *obj = o.to_variant
11
- expect(variant).to eq o.type
12
- expect(*obj).to eq o
9
+ variant, *obj = order.to_variant
10
+ expect(variant).to eq order.type
11
+ expect(*obj).to eq order
13
12
  end
14
13
  end
15
14
  end
@@ -29,10 +28,9 @@ RSpec.describe OrderDispatch do
29
28
  }
30
29
 
31
30
  it "returns the proper place" do
32
- o = order
33
- expected_place = o.send(method_for[o.type])
31
+ expected_place = order.send(method_for[order.type])
34
32
 
35
- expect(OrderDispatch.dispatch(o.to_variant)).to eq expected_place
33
+ expect(OrderDispatch.dispatch(order.to_variant)).to eq expected_place
36
34
  end
37
35
 
38
36
  it "raises an exception for unknown order types" do
@@ -15,20 +15,18 @@ RSpec.describe Nifty::Variants do
15
15
  end
16
16
 
17
17
  it "can take advantage of an else" do
18
- v = variant
19
18
  expect(
20
- cases v,
21
- else: ->(_) { v.first }
22
- ).to eq v.first
19
+ cases variant,
20
+ else: ->(_) { variant.first }
21
+ ).to eq variant.first
23
22
  end
24
23
 
25
24
  it "selects the correct variant match" do
26
- v = variant
27
25
  expect(
28
- cases v,
26
+ cases variant,
29
27
  generate(:key) => ->(*_) { false },
30
28
  generate(:key) => ->(*_) { false },
31
- v.first => ->(*_) { true }
29
+ variant.first => ->(*_) { true }
32
30
  ).to be true
33
31
  end
34
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nifty-variants
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate West
@@ -123,9 +123,9 @@ require_paths:
123
123
  - lib
124
124
  required_ruby_version: !ruby/object:Gem::Requirement
125
125
  requirements:
126
- - - ">="
126
+ - - "~>"
127
127
  - !ruby/object:Gem::Version
128
- version: '0'
128
+ version: 2.1.0
129
129
  required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  requirements:
131
131
  - - ">="