redux 0.1.0 → 0.1.1
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 +5 -5
- data/.travis.yml +12 -10
- data/CHANGELOG.md +5 -1
- data/lib/redux.rb +7 -1
- data/lib/redux/version.rb +1 -1
- data/spec/redux_spec.rb +34 -0
- metadata +3 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 98651e24ce9d909608d0476295e8df39f241d1845a4f2d06f5db7472d5baaa49
|
|
4
|
+
data.tar.gz: 70bc25833730fc4d1ed3e8f85667689a86481b47cf29d298c5ec92d14a7825c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 83ad1074638bbb4fbc5835b6ec18451248513ed667123330f28fbe7d407dd532580af16dc3b4c35654392330d693e4d531e111e9837e2510256c1338082e292c
|
|
7
|
+
data.tar.gz: 11f327d227add4eca48f4e2b54a76f14789d796549aff089ca767ac8fee7e84d6ca20554f596aca94642174cb9540949db2375e4b3547d48287f0ef74ddcb7a3
|
data/.travis.yml
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
sudo: false
|
|
2
2
|
language: ruby
|
|
3
3
|
|
|
4
|
-
script: bundle exec ruby spec/redux_spec.rb
|
|
5
|
-
|
|
6
4
|
rvm:
|
|
7
|
-
-
|
|
5
|
+
- ruby-head
|
|
6
|
+
- 2.5.1
|
|
7
|
+
- 2.4.4
|
|
8
|
+
- 2.3.7
|
|
8
9
|
- 2.2
|
|
9
10
|
- 2.1
|
|
10
11
|
- 2.0
|
|
11
|
-
- ruby-head
|
|
12
|
-
- rbx-2
|
|
13
12
|
- jruby-head
|
|
14
|
-
- jruby-
|
|
15
|
-
|
|
16
|
-
cache:
|
|
17
|
-
- bundler
|
|
13
|
+
- jruby-9.1.16.0
|
|
18
14
|
|
|
19
|
-
|
|
15
|
+
matrix:
|
|
16
|
+
allow_failures:
|
|
17
|
+
- rvm: ruby-head
|
|
18
|
+
- rvm: jruby-head
|
|
19
|
+
- rvm: 2.2
|
|
20
|
+
- rvm: 2.1
|
|
21
|
+
- rvm: 2.0
|
|
20
22
|
# fast_finish: true
|
data/CHANGELOG.md
CHANGED
data/lib/redux.rb
CHANGED
|
@@ -5,7 +5,13 @@ module Redux
|
|
|
5
5
|
def self.combine_reducers(reducers)
|
|
6
6
|
->(state = {}, action){
|
|
7
7
|
reducers.reduce({}){ |next_state, (key, reducer)|
|
|
8
|
-
|
|
8
|
+
if state.key?(key)
|
|
9
|
+
next_state[key] = reducer.call(state[key], action)
|
|
10
|
+
else
|
|
11
|
+
next_state[key] = reducer.call(action)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
next_state
|
|
9
15
|
}
|
|
10
16
|
}
|
|
11
17
|
end
|
data/lib/redux/version.rb
CHANGED
data/spec/redux_spec.rb
CHANGED
|
@@ -55,5 +55,39 @@ describe Redux do
|
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
|
+
|
|
59
|
+
describe ".combine_reducers" do
|
|
60
|
+
it "combines reducers" do
|
|
61
|
+
potato_reducer = ->(state = 0, action) {
|
|
62
|
+
case action['type']
|
|
63
|
+
when "WORK"
|
|
64
|
+
state + 1
|
|
65
|
+
else
|
|
66
|
+
state
|
|
67
|
+
end
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
tomato_reducer = ->(state = 0, action) {
|
|
71
|
+
case action['type']
|
|
72
|
+
when "WORK"
|
|
73
|
+
state - 1
|
|
74
|
+
else
|
|
75
|
+
state
|
|
76
|
+
end
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
root_reducer = Redux.combine_reducers({potato: potato_reducer, tomato: tomato_reducer})
|
|
80
|
+
store = Redux::Store.new({}, &root_reducer)
|
|
81
|
+
store.dispatch "type" => "WORK"
|
|
82
|
+
|
|
83
|
+
assert_equal(
|
|
84
|
+
{
|
|
85
|
+
potato: 1,
|
|
86
|
+
tomato: -1,
|
|
87
|
+
},
|
|
88
|
+
store.state
|
|
89
|
+
)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
58
92
|
end
|
|
59
93
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: redux
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jan Lelis
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-08-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Tiny Redux implementation in Ruby.
|
|
14
14
|
email:
|
|
@@ -49,10 +49,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
49
49
|
version: '0'
|
|
50
50
|
requirements: []
|
|
51
51
|
rubyforge_project:
|
|
52
|
-
rubygems_version: 2.
|
|
52
|
+
rubygems_version: 2.7.6
|
|
53
53
|
signing_key:
|
|
54
54
|
specification_version: 4
|
|
55
55
|
summary: redux.rb
|
|
56
56
|
test_files:
|
|
57
57
|
- spec/redux_spec.rb
|
|
58
|
-
has_rdoc:
|