Closed frewsxcv closed 7 years ago
On a side note: thanks for making and maintaining contracts.ruby, it's an awesome project! 👌
@egonSchiele Any thoughts about dropping support for Ruby 1.8? It's been EOL and hasn't received security updates for a few years, so to me it feels like a safe decision. If you're onboard with that, I can open a new PR for that and then rebase this on top of that.
I like this 👍 I agree that we can drop support for Ruby 1.8.
can you merge master into this branch? ci should pass, and then I'll merge
Rebased.
Is that error related to my change here? https://github.com/egonSchiele/contracts.ruby/commit/8e6d4eec01bc64bff50192a63ac236ee34449401#diff-eacde0c7f8149b55a880ae5fdcd84b3aL7
Looks like the issue is, methods created using attr_*
don't have a source_location
, which makes sense since they are generated dynamically. This diff fixes ci:
diff --git a/lib/contracts/support.rb b/lib/contracts/support.rb
index 780455c..f3efa20 100644
--- a/lib/contracts/support.rb
+++ b/lib/contracts/support.rb
@@ -5,7 +5,11 @@ module Contracts
return method.method_position if method.is_a?(MethodReference)
file, line = method.source_location
- file + ":" + line.to_s
+ if file.nil? || line.nil?
+ ""
+ else
+ file + ":" + line.to_s
+ end
end
def method_name(method)
I can merge this branch and fix.
thank you!
More inportantly, thanks for maintaining this great library :)
This pull request adds a new module
Contracts::Attrs
containing three methods to assist in using contracts with object attributes:attr_reader_with_contract <symbol>..., <contract>
attr_reader
, validates contract upon 'getting'attr_writer_with_contract <symbol>..., <contract>
attr_writer
, validates contract upon 'setting'attr_accessor_with_contract <symbol>..., <contract>
attr_accessor
, validates contract upon 'getting' or 'setting'