rdl 1.0.1.rc1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rdl_query +2 -2
- data/lib/rdl/query.rb +38 -29
- data/rdl.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d70ef3cc3d6edbb1cf16a849e412dc465510a606
|
4
|
+
data.tar.gz: b544a1f441d5d2d5beaa023a435940b2ad332ddf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3004c7b0b1b13e4d507497bde17980ec35d80fece303666f07ceee739efeec81bc33a35e09283c222782f419ac2cfbc7d19e163d6988c485a764901e41a262d
|
7
|
+
data.tar.gz: 57246478d603a49ef56bc1dd5266ecdda6f8f8331149beb96651a4d4c30c81764feae526522e7c4c73d37e48003520b54946eef732099256df26120aad084bc6
|
data/bin/rdl_query
CHANGED
data/lib/rdl/query.rb
CHANGED
@@ -6,33 +6,25 @@ class RDL::Query
|
|
6
6
|
# method - method of self's class
|
7
7
|
def self.method_query(q)
|
8
8
|
klass = nil
|
9
|
-
klass_pref = nil
|
10
9
|
meth = nil
|
11
|
-
if q =~ /(.+)#(.+)/
|
10
|
+
if q =~ /(.+)#(.+)/ then
|
12
11
|
klass = $1
|
13
|
-
klass_pref = "#{klass}#"
|
14
12
|
meth = $2.to_sym
|
15
|
-
elsif q =~ /(.+)\.(.+)/
|
16
|
-
klass_pref = "#{$1}."
|
13
|
+
elsif q =~ /(.+)\.(.+)/ then
|
17
14
|
klass = RDL::Util.add_singleton_marker($1)
|
18
15
|
meth = $2.to_sym
|
19
|
-
else
|
20
|
-
klass = self.class.to_s
|
21
|
-
|
22
|
-
meth = q.to_sym
|
23
|
-
end
|
24
|
-
name = "#{klass_pref}#{meth}"
|
25
|
-
if RDL::Wrap.has_contracts?(klass, meth, :type)
|
26
|
-
return [name, RDL::Wrap.get_contracts(klass, meth, :type)]
|
27
|
-
else
|
28
|
-
raise "No type for #{name}"
|
16
|
+
# else
|
17
|
+
# klass = self.class.to_s
|
18
|
+
# meth = q.to_sym
|
29
19
|
end
|
20
|
+
return nil unless RDL::Wrap.has_contracts?(klass, meth, :type)
|
21
|
+
return RDL::Wrap.get_contracts(klass, meth, :type)
|
30
22
|
end
|
31
23
|
|
32
24
|
# Return an ordered list of all method types of a class. The query should be a class name.
|
33
25
|
def self.class_query(q)
|
34
26
|
klass = q.to_s
|
35
|
-
return
|
27
|
+
return nil unless $__rdl_contracts.has_key? klass
|
36
28
|
cls_meths = []
|
37
29
|
cls_klass = RDL::Util.add_singleton_marker(klass)
|
38
30
|
if $__rdl_contracts.has_key? cls_klass then
|
@@ -50,46 +42,63 @@ class RDL::Query
|
|
50
42
|
end
|
51
43
|
}
|
52
44
|
end
|
53
|
-
cls_meths.sort! { |p1,p2| p1[0] <=> p2[0] }
|
45
|
+
cls_meths.sort! { |p1, p2| p1[0] <=> p2[0] }
|
54
46
|
cls_meths.each { |m, t| m.insert(0, "self.") }
|
55
|
-
inst_meths.sort! { |p1,p2| p1[0] <=> p2[0] }
|
47
|
+
inst_meths.sort! { |p1, p2| p1[0] <=> p2[0] }
|
56
48
|
return cls_meths + inst_meths
|
57
49
|
end
|
58
50
|
|
59
|
-
#
|
51
|
+
# Returns sorted list of pairs [method name, type] matching query. The query should be a string containing a method type query.
|
60
52
|
def self.method_type_query(q)
|
61
53
|
q = $__rdl_parser.scan_str "#Q #{q}"
|
54
|
+
result = []
|
62
55
|
$__rdl_contracts.each { |klass, meths|
|
63
56
|
meths.each { |meth, kinds|
|
64
57
|
if kinds.has_key? :type then
|
65
58
|
kinds[:type].each { |t|
|
66
59
|
if q.match(t)
|
67
|
-
|
60
|
+
result << [RDL::Util.pretty_name(klass, meth), t]
|
68
61
|
end
|
69
62
|
}
|
70
63
|
end
|
71
64
|
}
|
72
65
|
}
|
66
|
+
result.sort! { |p1, p2| p1[0] <=> p2[0] }
|
67
|
+
return result
|
73
68
|
end
|
74
|
-
|
75
69
|
end
|
76
70
|
|
77
71
|
class Object
|
78
72
|
|
79
73
|
def rdl_query(q)
|
80
74
|
$__rdl_contract_switch.off {
|
81
|
-
if q =~ /^
|
82
|
-
|
83
|
-
typs.
|
84
|
-
puts "
|
85
|
-
|
75
|
+
if q =~ /^[A-Z]\w*(#|\.)([a-z_]\w*(!|\?|=)?|!|~|\+|\*\*|-|\*|\/|%|<<|>>|&|\||\^|<|<=|=>|>|==|===|!=|=~|!~|<=>|\[\]|\[\]=)$/
|
76
|
+
typs = RDL::Query.method_query(q)
|
77
|
+
if typs.nil? then
|
78
|
+
puts "No types for #{q}"
|
79
|
+
else
|
80
|
+
typs.each { |t|
|
81
|
+
puts "#{q}: #{t}"
|
82
|
+
}
|
83
|
+
end
|
86
84
|
elsif q =~ /^[A-Z]\w*$/
|
87
|
-
RDL::Query.class_query(q)
|
88
|
-
|
89
|
-
|
85
|
+
typs = RDL::Query.class_query(q)
|
86
|
+
if typs.nil? then
|
87
|
+
puts "No method types for #{q}"
|
88
|
+
else
|
89
|
+
typs.each { |m, t| puts "#{m}: #{t}"}
|
90
|
+
end
|
91
|
+
elsif q =~ /\(.*\)/
|
92
|
+
typs = RDL::Query.method_type_query(q)
|
93
|
+
if typs.empty? then
|
94
|
+
puts "No matching methods"
|
95
|
+
else
|
96
|
+
typs.each { |m, t| puts "#{m}: #{t}" }
|
97
|
+
end
|
90
98
|
else
|
91
99
|
raise "Don't know how to handle query"
|
92
100
|
end
|
101
|
+
nil
|
93
102
|
}
|
94
103
|
end
|
95
104
|
|
data/rdl.gemspec
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = 'rdl'
|
7
|
-
s.version = '1.
|
8
|
-
s.date = '2016-01-
|
7
|
+
s.version = '1.1.0'
|
8
|
+
s.date = '2016-01-03'
|
9
9
|
s.summary = 'Ruby type and contract system'
|
10
10
|
s.description = <<-EOF
|
11
11
|
RDL is a gem that allows contracts (pre- and postconditions) to be added to methods.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeffrey S. Foster
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-01-
|
14
|
+
date: 2016-01-03 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: require_all
|
@@ -173,9 +173,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
173
173
|
version: '0'
|
174
174
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
175
|
requirements:
|
176
|
-
- - "
|
176
|
+
- - ">="
|
177
177
|
- !ruby/object:Gem::Version
|
178
|
-
version:
|
178
|
+
version: '0'
|
179
179
|
requirements: []
|
180
180
|
rubyforge_project:
|
181
181
|
rubygems_version: 2.5.1
|