netica 0.0.19-java → 0.0.20-java
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -0
- data/lib/netica/active_network.rb +15 -1
- data/lib/netica/version.rb +1 -1
- data/spec/netica/active_network_spec.rb +17 -0
- metadata +1 -1
data/README.md
CHANGED
@@ -67,6 +67,10 @@ Then, re-read the value of the Belief node.
|
|
67
67
|
|
68
68
|
## Release Notes
|
69
69
|
|
70
|
+
### Version 0.0.20
|
71
|
+
|
72
|
+
Delete a stored network by token with ActiveNetwork#destroy_by_token.
|
73
|
+
|
70
74
|
### Version 0.0.19
|
71
75
|
|
72
76
|
Add `load_from_storage` parameter to ActiveNetwork#find so we can retrieve the state of a network in storage without instantiating it. Defaults to true.
|
@@ -116,12 +116,26 @@ module Netica
|
|
116
116
|
outcome[:deletion][:memory] = rejection.is_a?(Array)
|
117
117
|
end
|
118
118
|
|
119
|
-
if environment.redis && storage
|
119
|
+
if environment.redis && storage == true
|
120
120
|
outcome[:deletion][:redis] = (environment.redis.del(token) > 0)
|
121
121
|
end
|
122
122
|
outcome
|
123
123
|
end
|
124
|
+
|
125
|
+
# Destroy a saved network
|
126
|
+
#
|
127
|
+
# @return [Hash] outcome of deletion attempts per storage location
|
128
|
+
def self.destroy_by_token(token)
|
129
|
+
outcome = { token: token, deletion: { memory: nil, redis: nil}}
|
130
|
+
environment = Netica::Environment.instance
|
124
131
|
|
132
|
+
if environment.redis
|
133
|
+
outcome[:deletion][:redis] = (environment.redis.del(token) > 0)
|
134
|
+
end
|
135
|
+
|
136
|
+
outcome
|
137
|
+
end
|
138
|
+
|
125
139
|
# Load ActiveNetwork from a saved state
|
126
140
|
#
|
127
141
|
# @param hash [Hash] network state to be restored
|
data/lib/netica/version.rb
CHANGED
@@ -92,6 +92,23 @@ describe Netica::ActiveNetwork do
|
|
92
92
|
Netica::Environment.instance.active_networks.length.should eq(0)
|
93
93
|
end
|
94
94
|
end
|
95
|
+
|
96
|
+
describe "#destroy_by_token" do
|
97
|
+
context "A stored active network" do
|
98
|
+
it "should be deletable" do
|
99
|
+
@active_network.save
|
100
|
+
@active_network.destroy(true, false)
|
101
|
+
@redis.get(@active_network_token).should be_true
|
102
|
+
|
103
|
+
outcome = Netica::ActiveNetwork.destroy_by_token(@active_network_token)
|
104
|
+
outcome[:deletion][:memory].should be_nil
|
105
|
+
outcome[:deletion][:redis].should be_true
|
106
|
+
|
107
|
+
@redis.get(@active_network_token).should be_nil
|
108
|
+
Netica::Environment.instance.active_networks.length.should eq(0)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
95
112
|
end
|
96
113
|
end
|
97
114
|
end
|