predicated 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,8 @@ require "predicated/from/ruby_code_string"
5
5
  module Predicated
6
6
 
7
7
  require_gem_version("ParseTree", "3.0.5", "parse_tree") if RUBY_VERSION < "1.9"
8
-
8
+ require "predicated/sexp_patch"
9
+
9
10
  class Predicate
10
11
 
11
12
  #hrm
@@ -35,44 +36,6 @@ module Predicated
35
36
  ruby_code_string.sub(/^def serializable\n /, "").sub(/\nend$/, "")
36
37
  end
37
38
  end
38
-
39
- #see http://gist.github.com/321038
40
- # # Monkey-patch to have Ruby2Ruby#translate with r2r >= 1.2.3, from
41
- # # http://seattlerb.rubyforge.org/svn/ruby2ruby/1.2.2/lib/ruby2ruby.rb
42
- class ::Ruby2Ruby < ::SexpProcessor
43
- def self.translate(klass_or_str, method = nil)
44
- sexp = ParseTree.translate(klass_or_str, method)
45
- unifier = Unifier.new
46
- unifier.processors.each do |p|
47
- p.unsupported.delete :cfunc # HACK
48
- end
49
- sexp = unifier.process(sexp)
50
- self.new.process(sexp)
51
- end
52
-
53
- #sconover - 7/2010 - monkey-patch
54
- #{1=>2}=={1=>2}
55
- #The right side was having its braces cut off because of
56
- #special handling of hashes within arglists within the seattlerb code.
57
- #I tried to fork r2r and add a test, but a lot of other tests
58
- #broke, and I just dont understand the test in ruby2ruby.
59
- #So I'm emailing the author...
60
- def process_hash(exp)
61
- result = []
62
- until exp.empty?
63
- lhs = process(exp.shift)
64
- rhs = exp.shift
65
- t = rhs.first
66
- rhs = process rhs
67
- rhs = "(#{rhs})" unless [:lit, :str].include? t # TODO: verify better!
68
39
 
69
- result << "#{lhs} => #{rhs}"
70
- end
71
-
72
- return "{ #{result.join(', ')} }"
73
- end
74
-
75
- end
76
-
77
40
  end
78
41
  end
@@ -5,6 +5,7 @@ module Predicated
5
5
 
6
6
  require_gem_version("ruby_parser", "2.0.4")
7
7
  require_gem_version("ruby2ruby", "1.2.4")
8
+ require "predicated/sexp_patch"
8
9
 
9
10
  class Predicate
10
11
  def self.from_ruby_code_string(ruby_predicate_string, context=binding())
@@ -0,0 +1,39 @@
1
+
2
+
3
+ #see http://gist.github.com/321038
4
+ # # Monkey-patch to have Ruby2Ruby#translate with r2r >= 1.2.3, from
5
+ # # http://seattlerb.rubyforge.org/svn/ruby2ruby/1.2.2/lib/ruby2ruby.rb
6
+ class ::Ruby2Ruby < ::SexpProcessor
7
+ def self.translate(klass_or_str, method = nil)
8
+ sexp = ParseTree.translate(klass_or_str, method)
9
+ unifier = Unifier.new
10
+ unifier.processors.each do |p|
11
+ p.unsupported.delete :cfunc # HACK
12
+ end
13
+ sexp = unifier.process(sexp)
14
+ self.new.process(sexp)
15
+ end
16
+
17
+ #sconover - 7/2010 - monkey-patch
18
+ #{1=>2}=={1=>2}
19
+ #The right side was having its braces cut off because of
20
+ #special handling of hashes within arglists within the seattlerb code.
21
+ #I tried to fork r2r and add a test, but a lot of other tests
22
+ #broke, and I just dont understand the test in ruby2ruby.
23
+ #So I'm emailing the author...
24
+ def process_hash(exp)
25
+ result = []
26
+ until exp.empty?
27
+ lhs = process(exp.shift)
28
+ rhs = exp.shift
29
+ t = rhs.first
30
+ rhs = process rhs
31
+ rhs = "(#{rhs})" unless [:lit, :str].include? t # TODO: verify better!
32
+
33
+ result << "#{lhs} => #{rhs}"
34
+ end
35
+
36
+ return "{ #{result.join(', ')} }"
37
+ end
38
+
39
+ end
@@ -1,3 +1,3 @@
1
1
  module Predicated
2
- VERSION = "0.2.0" unless defined?(Predicated::VERSION)
2
+ VERSION = "0.2.1" unless defined?(Predicated::VERSION)
3
3
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: predicated
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 21
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 2
8
- - 0
9
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Steve Conover
@@ -38,6 +39,7 @@ files:
38
39
  - lib/predicated/predicate.rb
39
40
  - lib/predicated/print.rb
40
41
  - lib/predicated/selectable.rb
42
+ - lib/predicated/sexp_patch.rb
41
43
  - lib/predicated/simple_templated_predicate.rb
42
44
  - lib/predicated/string_utils.rb
43
45
  - lib/predicated/to/arel.rb
@@ -88,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
90
  requirements:
89
91
  - - ">="
90
92
  - !ruby/object:Gem::Version
91
- hash: 2382763030672668207
93
+ hash: 3
92
94
  segments:
93
95
  - 0
94
96
  version: "0"
@@ -97,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
99
  requirements:
98
100
  - - ">="
99
101
  - !ruby/object:Gem::Version
100
- hash: 2382763030672668207
102
+ hash: 3
101
103
  segments:
102
104
  - 0
103
105
  version: "0"