cirrocumulus 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.5
1
+ 0.4.6
data/cirrocumulus.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cirrocumulus}
8
- s.version = "0.4.5"
8
+ s.version = "0.4.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Anton Kosyakin"]
12
- s.date = %q{2011-10-25}
12
+ s.date = %q{2011-10-27}
13
13
  s.description = %q{Engine for building your own agents, providing you base functionality for loading ontologies, communicating with other agents and parsing FIPA-ACL messages}
14
14
  s.email = %q{deil@mneko.net}
15
15
  s.extra_rdoc_files = [
@@ -38,7 +38,26 @@ module RuleEngine
38
38
  log "retract: #{fact.inspect}"
39
39
  process() if !silent
40
40
  else
41
- puts "fact #{fact.inspect} not found"
41
+ #puts "fact #{fact.inspect} not found"
42
+ end
43
+ end
44
+
45
+ def replace(pattern, values)
46
+ log "replace: #{pattern.inspect} => #{values.inspect}"
47
+
48
+ data = match(pattern)
49
+ data.each do |match_data|
50
+ old_fact = pattern.clone
51
+ new_fact = pattern.clone
52
+ pattern.each_with_index do |item,i|
53
+ if match_data.include? item
54
+ old_fact[i] = match_data[item]
55
+ new_fact[i] = values.is_a?(Hash) ? values[item] : values
56
+ end
57
+ end
58
+
59
+ retract(old_fact, true)
60
+ assert(new_fact)
42
61
  end
43
62
  end
44
63
 
data/lib/test.rb CHANGED
@@ -26,6 +26,9 @@ end
26
26
  e = Test.new
27
27
  e.assert [:guest, "233bed174ab0802fd908f981d64d185b", :powered_off]
28
28
  e.assert [:guest, "233bed174ab0802fd908f981d64d185b", :running]
29
+ e.assert [:guest, "233bed174ab0802fd908f981d64d185b", :state, :powered_on]
30
+ e.replace [:guest, "233bed174ab0802fd908f981d64d185b", :state, :STATE], :powered_off
31
+
29
32
  p e.match [:guest, "233bed174ab0802fd908f981d64d185b", :running]
30
33
  gets
31
34
  exit(0)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cirrocumulus
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 5
10
- version: 0.4.5
9
+ - 6
10
+ version: 0.4.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Anton Kosyakin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-25 00:00:00 -04:00
18
+ date: 2011-10-27 00:00:00 +04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency