Module: Predicated
- Defined in:
- lib/predicated/lib/predicated/from/callable_object.rb,
lib/predicated/lib/predicated/print.rb,
lib/predicated/lib/predicated/to/xml.rb,
lib/predicated/lib/predicated/to/arel.rb,
lib/predicated/lib/predicated/to/json.rb,
lib/predicated/lib/predicated/to/solr.rb,
lib/predicated/lib/predicated/version.rb,
lib/predicated/lib/predicated/evaluate.rb,
lib/predicated/lib/predicated/from/xml.rb,
lib/predicated/lib/predicated/constrain.rb,
lib/predicated/lib/predicated/from/json.rb,
lib/predicated/lib/predicated/gem_check.rb,
lib/predicated/lib/predicated/predicate.rb,
lib/predicated/lib/predicated/selectable.rb,
lib/predicated/lib/predicated/to/sentence.rb,
lib/predicated/lib/predicated/autogen_call.rb,
lib/predicated/lib/predicated/string_utils.rb,
lib/predicated/lib/predicated/from/url_part.rb,
lib/predicated/lib/predicated/from/ruby_code_string.rb,
lib/predicated/lib/predicated/simple_templated_predicate.rb
Overview
raise %
This will never work in ruby 1.9.
see blog.zenspider.com/2009/04/parsetree-eol.html
if RUBY_VERSION =~/^1.9/
raise %
You appear to be using ruby 1.8.7 and you don’t have an INLINEDIR environment variable set to a valid directory.
ParseTree (used by “from_callable_object”) uses RubyInline. RubyInline requires that the INLINEDIR environment variable point to a directory. The easiest thing to do is to just go create a directory somewhere - let’s say, ~/inlinedir, and point the INLINEDIR at it. In bash this would be:
mkdir ~/inlinedir export INLINEDIR=~/inlinedir
You’ll probably want to put this in .bash_profile too.
Sorry for the inconvenience. I hope the value you’ll get out of “from_callable_object” makes it all worth it.
if RUBY_VERSION==“1.8.7” && !ENV Procs and lambdas are “callable objects”
Defined Under Namespace
Modules: Conjunction, Container, ContainerToString, ContainerToXml, JsonStructToJsonStr, PrintSupport, Selectable, Shorthand, SimpleTemplatedShorthand, StringUtils, TreetopUrlPart Classes: And, AutogenCall, Binary, Call, Constraint, ConstraintCheckResult, Constraints, Equal, GreaterThan, GreaterThanOrEqualTo, LessThan, LessThanOrEqualTo, Not, Operation, Or, Placeholder, Predicate, Unary
Constant Summary collapse
- VERSION =
"0.1.0"- ALL_PREDICATE_CLASSES =
[ And, Or, Not, Equal, LessThan, GreaterThan, LessThanOrEqualTo, GreaterThanOrEqualTo ]
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.require_gem_version(gem_name, minimum_version, require_name = gem_name) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/predicated/lib/predicated/gem_check.rb', line 2 def self.require_gem_version(gem_name, minimum_version, require_name=gem_name) unless Gem.available?(gem_name, Gem::Requirement.create(">= #{minimum_version}")) raise %{ Gem: #{gem_name} >=#{minimum_version} Does not appear to be installed. Please install it. Predicated is built in a way that allows you to pick and choose which features to use. RubyGems has no way to specify optional dependencies, therefore I've made the decision not to have Predicated automatically depend into the various gems referenced in from/to "extensions". The cost here is that the gem install doesn't necessarily "just work" for you out of the box. But in return you get greater flexibility. Notably, rails/arel unfortunately has a hard dependency on Rails 3 activesupport, which requires ruby 1.8.7. By making from/to dependencies optional, those with no interest in arel can use Predicated in a wider variety of environments. For more discussion see: http://stackoverflow.com/questions/2993335/rubygems-optional-dependencies } end require require_name end |
Instance Method Details
#Predicate(&block) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/predicated/lib/predicated/predicate.rb', line 5 def Predicate(&block) result = nil Module.new do extend Shorthand result = instance_eval(&block) end result end |
#SimpleTemplatedPredicate(&block) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/predicated/lib/predicated/simple_templated_predicate.rb', line 5 def SimpleTemplatedPredicate(&block) result = nil Module.new do extend SimpleTemplatedShorthand result = instance_eval(&block) end result end |