redux 0.1.0 → 0.1.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
- SHA1:
3
- metadata.gz: 66fc20bcbea5c41bf52d66d27e937a091214b384
4
- data.tar.gz: dce5f96521e412ec2c8c263c8030527a9ae0cbba
2
+ SHA256:
3
+ metadata.gz: 98651e24ce9d909608d0476295e8df39f241d1845a4f2d06f5db7472d5baaa49
4
+ data.tar.gz: 70bc25833730fc4d1ed3e8f85667689a86481b47cf29d298c5ec92d14a7825c6
5
5
  SHA512:
6
- metadata.gz: fa75d7b37183c6d34b232effd09b24e25caef6014ca11ce3426dd1b81d083209faa1761fabe1e2920c58261fa4724dc9f705766d91437c00b864e057b4727184
7
- data.tar.gz: 8603465ba6c4c041f8e78c8defecc12223880f9467a0197e4151d82b00abfe458dd296b6638f06f1d7c9e69ece2763b723ed0e95cd0ce048ce36c3fdf367dd9b
6
+ metadata.gz: 83ad1074638bbb4fbc5835b6ec18451248513ed667123330f28fbe7d407dd532580af16dc3b4c35654392330d693e4d531e111e9837e2510256c1338082e292c
7
+ data.tar.gz: 11f327d227add4eca48f4e2b54a76f14789d796549aff089ca767ac8fee7e84d6ca20554f596aca94642174cb9540949db2375e4b3547d48287f0ef74ddcb7a3
@@ -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
- - 2.3.0
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-9000
15
-
16
- cache:
17
- - bundler
13
+ - jruby-9.1.16.0
18
14
 
19
- # matrix:
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
@@ -1,6 +1,10 @@
1
1
  ## CHANGELOG
2
2
 
3
+ ### 0.1.1
4
+
5
+ * Redux.combine_reducers
6
+
3
7
  ### 0.1.0
4
8
 
5
- * Inital release
9
+ * Initial release
6
10
 
@@ -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
- next_state[key] = reducer.call(state[key], action)
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
@@ -1,4 +1,4 @@
1
1
  module Redux
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.1.1".freeze
3
3
  end
4
4
 
@@ -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.0
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: 2016-02-01 00:00:00.000000000 Z
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.5.1
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: