auser-aska 0.0.6 → 0.0.9
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.
- data/Rakefile +14 -2
- data/aska.gemspec +1 -1
- data/lib/aska.rb +9 -2
- data/spec/rules_spec.rb +4 -1
- metadata +1 -1
data/Rakefile
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "rake"
|
3
|
+
|
1
4
|
begin
|
2
5
|
require 'echoe'
|
3
6
|
Echoe.new("aska") do |p|
|
@@ -6,7 +9,7 @@ begin
|
|
6
9
|
p.summary = "The basics of an expert system"
|
7
10
|
p.url = "http://blog.citrusbyte.com"
|
8
11
|
p.dependencies = []
|
9
|
-
p.version = "0.0.
|
12
|
+
p.version = "0.0.9"
|
10
13
|
p.install_message =<<-EOM
|
11
14
|
|
12
15
|
Aska - Expert system basics
|
@@ -17,8 +20,15 @@ begin
|
|
17
20
|
EOM
|
18
21
|
p.include_rakefile = true
|
19
22
|
end
|
20
|
-
rescue
|
23
|
+
rescue LoadError => boom
|
24
|
+
puts "You are missing a dependency required for meta-operations on this gem."
|
25
|
+
puts "#{boom.to_s.capitalize}."
|
21
26
|
|
27
|
+
# if you still want tests when Echoe is not present
|
28
|
+
desc 'Run the test suite.'
|
29
|
+
task :test do
|
30
|
+
system "ruby -Ibin:lib:test some_tests_test.rb" # or whatever
|
31
|
+
end
|
22
32
|
end
|
23
33
|
|
24
34
|
namespace(:pkg) do
|
@@ -68,5 +78,7 @@ namespace(:pkg) do
|
|
68
78
|
desc "Release them gem to the gem server"
|
69
79
|
task :release => :prerelease do
|
70
80
|
`git push origin master`
|
81
|
+
`mv #{::File.expand_path(::File.dirname(__FILE__))}/pkg/*.gem #{::File.expand_path(::File.dirname(__FILE__))}/pkg/poolparty-latest.gem`
|
82
|
+
`git add pkg/poolparty-latest.gem -f`
|
71
83
|
end
|
72
84
|
end
|
data/aska.gemspec
CHANGED
data/lib/aska.rb
CHANGED
@@ -7,6 +7,7 @@ module Aska
|
|
7
7
|
def rules(name=:rules, arr=[])
|
8
8
|
returning look_up_rules(name) do |rs|
|
9
9
|
arr.each do |line|
|
10
|
+
next unless line
|
10
11
|
k = line[/(.+)[=\\\<\>](.*)/, 1].gsub(/\s+/, '')
|
11
12
|
v = line[/(.+)[=\\<>](.*)/, 2].gsub(/\s+/, '')
|
12
13
|
m = line[/[=\\<>]/, 0].gsub(/\s+/, '')
|
@@ -25,13 +26,13 @@ module Aska
|
|
25
26
|
attr_writer k.to_sym unless respond_to?("#{k}=".to_sym)
|
26
27
|
end
|
27
28
|
def look_up_rules(name)
|
28
|
-
defined_rules[name.to_sym] ||=
|
29
|
+
defined_rules[name.to_sym] ||= Rules.new
|
29
30
|
end
|
30
31
|
def are_rules?(name)
|
31
32
|
!look_up_rules(name).empty?
|
32
33
|
end
|
33
34
|
def aska_attr_accessors
|
34
|
-
|
35
|
+
@aska_attr_accessors ||= Rules.new
|
35
36
|
end
|
36
37
|
def defined_rules
|
37
38
|
@defined_rules ||= {}
|
@@ -101,4 +102,10 @@ module Aska
|
|
101
102
|
receiver.extend ClassMethods
|
102
103
|
receiver.send :include, InstanceMethods
|
103
104
|
end
|
105
|
+
|
106
|
+
class Rules < Array
|
107
|
+
def to_s
|
108
|
+
self.map {|r| v=r.keys.first;"'#{v} #{r[v][0]} #{r[v][1]}'"}.join(", ")
|
109
|
+
end
|
110
|
+
end
|
104
111
|
end
|
data/spec/rules_spec.rb
CHANGED
@@ -16,7 +16,10 @@ describe "Rules" do
|
|
16
16
|
@car.rules.class.should == Hash
|
17
17
|
end
|
18
18
|
it "should be able to look up the rules based on the name into an array" do
|
19
|
-
@car.names.class.should ==
|
19
|
+
@car.names.class.should == Aska::Rules
|
20
|
+
end
|
21
|
+
it "should be able to turn them into a string" do
|
22
|
+
@car.names.to_s.should == "'x > 0', 'y > 0', 'x > y'"
|
20
23
|
end
|
21
24
|
it "should be able to say that rules are defined when they are defined" do
|
22
25
|
@car.names.should_not be_nil
|