README.md in rubype-0.2.2 vs README.md in rubype-0.2.3

- old
+ new

@@ -1,19 +1,21 @@ # Ruby + Type = Rubype +[![Gem Version](https://badge.fury.io/rb/rubype.svg)](http://badge.fury.io/rb/rubype) [![Build Status](https://travis-ci.org/gogotanaka/Rubype.svg?branch=develop)](https://travis-ci.org/gogotanaka/Rubype) [![Dependency Status](https://gemnasium.com/gogotanaka/Rubype.svg)](https://gemnasium.com/gogotanaka/Rubype) [![Code Climate](https://codeclimate.com/github/gogotanaka/Rubype/badges/gpa.svg)](https://codeclimate.com/github/gogotanaka/Rubype) + ```rb # Assert class of both args is Numeric and class of return is String def sum(x, y) (x + y).to_s end -typesig sum: [Numeric, Numeric => String] +typesig :sum, [Numeric, Numeric] => String # Assert first arg has method #to_i def sum(x, y) x.to_i + y end -typesig sum: [:to_i, Numeric => Numeric] +typesig :sum, [:to_i, Numeric] => Numeric ``` This gem brings you advantage of type without changing existing code's behavior. @@ -29,16 +31,16 @@ # ex1: Assert class of args and return class MyClass def sum(x, y) x + y end - typesig sum: [Numeric, Numeric => Numeric] + typesig :sum, [Numeric, Numeric] => Numeric def wrong_sum(x, y) 'string' end - typesig wrong_sum: [Numeric, Numeric => Numeric] + typesig :wrong_sum, [Numeric, Numeric] => Numeric end MyClass.new.sum(1, 2) #=> 3 @@ -52,11 +54,11 @@ # ex2: Assert object has specified method class MyClass def sum(x, y) x.to_i + y end - typesig sum: [:to_i, Numeric => Numeric] + typesig :sum, [:to_i, Numeric] => Numeric end MyClass.new.sum('1', 2) #=> 3 @@ -67,11 +69,11 @@ # ex3: You can use Any class, if you want class People def marry(people) # Your Ruby code as usual end - typesig marry: [People => Any] + typesig :marry, [People] => Any end People.new.marry(People.new) #=> no error @@ -86,11 +88,11 @@ # It's totally OK!! class MyClass def method_with_type(x, y) x + y end - typesig sum: [Numeric, Numeric => Numeric] + typesig :sum, [Numeric, Numeric] => Numeric def method_without_type(x, y) 'string' end end @@ -101,16 +103,16 @@ ```ruby class MyClass def foo(any_obj) 1 end - typesig foo: [Any => Numeric] + typesig :foo, [Any] => Numeric def sum(x, y) x.to_i + y end - typesig sum: [:to_i, Numeric => Numeric] + typesig :sum, [:to_i, Numeric] => Numeric end # It's totally OK!! MyClass.new.foo(1) # It's totally OK!! @@ -140,10 +142,14 @@ Commit your changes (`git commit -am 'Add some feature'`) $ bundle exec rake test - > 5 runs, 39 assertions, 0 failures, 0 errors, 0 skips + ...... + + Finished in 0.010961s, 547.3953 runs/s, 5017.7903 assertions/s. + + 6 runs, 55 assertions, 0 failures, 0 errors, 0 skips Push to the branch (`git push origin my-new-feature`) Create a new Pull Request to `develop` branch