equatable 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f4686bc5781675b06cad4c4479ead3c786731eeb
4
+ data.tar.gz: d31b12f2ead5f8b02b4e141a379f2c47c534fad7
5
+ SHA512:
6
+ metadata.gz: 78dff5b3c98ee0bfba57d3c96b12d5a2b5434b0c72a5168afa0713a36464e7e50bc0fdee611d2308089692f41f033a3223004fad39eb54d1cc67a0946860fde3
7
+ data.tar.gz: 7d24be6e59e61d5a7a563c87d450e464c57cfbcd7731e61450990c7f2a122253fdc7501323342c16ac31bd04919da8170799e9b2ea31764e72eded6fbc573086
@@ -0,0 +1 @@
1
+ equatable
@@ -0,0 +1 @@
1
+ 2.0.0
@@ -1,20 +1,32 @@
1
1
  language: ruby
2
2
  before_install:
3
3
  - gem install bundler
4
+ script: "bundle exec rake ci"
4
5
  rvm:
5
6
  - 1.8.7
6
7
  - 1.9.2
7
8
  - 1.9.3
9
+ - 2.0.0
10
+ - 2.1.0
8
11
  - ruby-head
9
12
  - jruby-18mode
10
13
  - jruby-19mode
14
+ - jruby-20mode
15
+ - jruby-21mode
11
16
  - rbx-18mode
12
17
  - rbx-19mode
13
- - ree
18
+ - rbx-2
14
19
  - jruby-head
15
20
  matrix:
16
21
  allow_failures:
17
22
  - rvm: ruby-head
18
- - rvm: jruby-head
19
23
  - rvm: jruby-19mode
24
+ - rvm: jruby-20mode
25
+ - rvm: jruby-21mode
26
+ - rvm: jruby-head
27
+ - rvm: rbx-18mode
20
28
  - rvm: rbx-19mode
29
+ - rvm: rbx-2
30
+ fast_finish: true
31
+ branches:
32
+ only: master
data/Gemfile CHANGED
@@ -1,3 +1,9 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ group :development do
6
+ gem 'rake', '~> 10.1.0'
7
+ gem 'rspec', '~> 2.12.0'
8
+ gem 'yard', '~> 0.8.7'
9
+ end
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Equatable
2
- [![Gem Version](https://badge.fury.io/rb/equatable.png)](http://badge.fury.io/rb/equatable) [![Build Status](https://secure.travis-ci.org/peter-murach/equatable.png?branch=master)][travis] [![Code Climate](https://codeclimate.com/badge.png)][codeclimate]
2
+ [![Gem Version](https://badge.fury.io/rb/equatable.png)](http://badge.fury.io/rb/equatable) [![Build Status](https://secure.travis-ci.org/peter-murach/equatable.png?branch=master)][travis] [![Code Climate](https://codeclimate.com/github/peter-murach/equatable.png)][codeclimate]
3
3
 
4
4
  [travis]: http://travis-ci.org/peter-murach/equatable
5
5
  [codeclimate]: https://codeclimate.com/github/peter-murach/equatable
@@ -27,33 +27,32 @@ Or install it yourself as:
27
27
  It is assumed that your objects are value objects and the only values that affect equality comparison are the ones specified by your attribute readers. Each attribute reader should be a significant field in determining objects values.
28
28
 
29
29
  ```ruby
30
- class Value
31
- include Equatable
30
+ class Value
31
+ include Equatable
32
32
 
33
- attr_reader :value
33
+ attr_reader :value
34
34
 
35
- def initialize(value)
36
- @value = value
37
- end
35
+ def initialize(value)
36
+ @value = value
38
37
  end
38
+ end
39
39
 
40
- val1 = Value.new(11)
41
- val2 = Value.new(11)
42
- val3 = Value.new(13)
40
+ val1 = Value.new(11)
41
+ val2 = Value.new(11)
42
+ val3 = Value.new(13)
43
43
 
44
- val1 == val2 # => true
45
- val1.hash == val2.hash # => true
46
- val1 eql? val2 # => true
47
-
48
- val1 == val3 # => false
49
- val1.hash == val3.hash # => false
50
- val1 eql? val3 # => false
44
+ val1 == val2 # => true
45
+ val1.hash == val2.hash # => true
46
+ val1 eql? val2 # => true
51
47
 
48
+ val1 == val3 # => false
49
+ val1.hash == val3.hash # => false
50
+ val1 eql? val3 # => false
52
51
  ```
53
52
 
54
53
  It is important that the attribute readers should allow for performing deterministic computations on class instances. Therefore you should avoid specifying attributes that depend on unreliable resources like IP address that require network access.
55
54
 
56
- Note that adding a extra attr reader to a subclass will violate the equivalence contract.
55
+ Note that adding an extra attribute reader to a subclass will violate the equivalence contract.
57
56
 
58
57
  ## Contributing
59
58
 
@@ -65,4 +64,4 @@ Note that adding a extra attr reader to a subclass will violate the equivalence
65
64
 
66
65
  ## Copyright
67
66
 
68
- Copyright (c) 2012-2013 Piotr Murach. See LICENSE for further details.
67
+ Copyright (c) 2012-2014 Piotr Murach. See LICENSE for further details.
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.unshift File.expand_path('../lib', __FILE__)
1
+ # encoding: utf-8
2
+
3
3
  require "bundler/gem_tasks"
4
4
  require "rspec/core/rake_task"
5
5
 
@@ -10,3 +10,6 @@ end
10
10
  FileList['tasks/**/*.rake'].each { |task| import task }
11
11
 
12
12
  task :default => [:spec]
13
+
14
+ desc 'Run all specs'
15
+ task :ci => %w[ spec ]
@@ -17,7 +17,5 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.add_development_dependency 'rspec'
21
- gem.add_development_dependency 'rake'
22
- gem.add_development_dependency 'yard'
20
+ gem.add_development_dependency "bundler", "~> 1.5"
23
21
  end
@@ -1,10 +1,9 @@
1
- # -*- encoding: utf-8 -*-
1
+ # encoding: utf-8
2
2
 
3
- require "equatable/version"
3
+ require 'equatable/version'
4
4
 
5
5
  # Make it easy to define equality and hash methods.
6
6
  module Equatable
7
-
8
7
  # Hook into module inclusion.
9
8
  #
10
9
  # @param [Module] base
@@ -87,7 +86,9 @@ module Equatable
87
86
  define_method(:compare?) do |comparator, other|
88
87
  klass = self.class
89
88
  attrs = klass.comparison_attrs || []
90
- attrs.all? { |attr| send(attr).send(comparator, other.send(attr)) }
89
+ attrs.all? do |attr|
90
+ other.respond_to?(attr) && send(attr).send(comparator, other.send(attr))
91
+ end
91
92
  end
92
93
  end
93
94
 
@@ -99,7 +100,7 @@ module Equatable
99
100
  define_method(:hash) do
100
101
  klass = self.class
101
102
  attrs = klass.comparison_attrs || []
102
- ([klass] + attrs.map { |attr| send(attr)}).hash
103
+ ([klass] + attrs.map { |attr| send(attr) }).hash
103
104
  end
104
105
  end
105
106
 
@@ -118,8 +119,8 @@ module Equatable
118
119
  end
119
120
  end
120
121
 
122
+ # The equality methods
121
123
  module Methods
122
-
123
124
  # Compare two objects for equality based on their value
124
125
  # and being an instance of the given class.
125
126
  #
@@ -143,8 +144,7 @@ module Equatable
143
144
  #
144
145
  # @api public
145
146
  def ==(other)
146
- kind_of?(other.class) && compare?(__method__, other)
147
+ is_a?(other.class) && compare?(__method__, other)
147
148
  end
148
-
149
149
  end # Methods
150
150
  end # Equatable
@@ -1,5 +1,5 @@
1
- # -*- encoding: utf-8 -*-
1
+ # encoding: utf-8
2
2
 
3
3
  module Equatable
4
- VERSION = "0.3.0"
4
+ VERSION = '0.4.0'
5
5
  end
@@ -64,6 +64,12 @@ describe Equatable, '#==' do
64
64
  end
65
65
  end
66
66
 
67
+ context 'with an object with a different interface' do
68
+ let(:other) { Object.new }
69
+
70
+ it { should be_false }
71
+ end
72
+
67
73
  context 'with an object of another class' do
68
74
  let(:other) { Class.new.new }
69
75
 
metadata CHANGED
@@ -1,49 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: equatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
- prerelease:
4
+ version: 0.4.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Piotr Murach
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-03 00:00:00.000000000 Z
11
+ date: 2014-08-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: rspec
16
- requirement: &2160139560 !ruby/object:Gem::Requirement
17
- none: false
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: '1.5'
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *2160139560
25
- - !ruby/object:Gem::Dependency
26
- name: rake
27
- requirement: &2160138980 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :development
34
- prerelease: false
35
- version_requirements: *2160138980
36
- - !ruby/object:Gem::Dependency
37
- name: yard
38
- requirement: &2160138280 !ruby/object:Gem::Requirement
39
- none: false
22
+ version_requirements: !ruby/object:Gem::Requirement
40
23
  requirements:
41
- - - ! '>='
24
+ - - ~>
42
25
  - !ruby/object:Gem::Version
43
- version: '0'
44
- type: :development
45
- prerelease: false
46
- version_requirements: *2160138280
26
+ version: '1.5'
47
27
  description: Allows ruby objects to implement equality comparison and inspection methods.
48
28
  By including this module, a class indicates that its instances have explicit general
49
29
  contracts for `hash`, `==` and `eql?` methods.
@@ -55,7 +35,8 @@ extra_rdoc_files: []
55
35
  files:
56
36
  - .gitignore
57
37
  - .rspec
58
- - .rvmrc
38
+ - .ruby-gemset
39
+ - .ruby-version
59
40
  - .travis.yml
60
41
  - Gemfile
61
42
  - LICENSE.txt
@@ -71,27 +52,26 @@ files:
71
52
  - spec/spec_helper.rb
72
53
  homepage: http://github.com/peter-murach/equatable
73
54
  licenses: []
55
+ metadata: {}
74
56
  post_install_message:
75
57
  rdoc_options: []
76
58
  require_paths:
77
59
  - lib
78
60
  required_ruby_version: !ruby/object:Gem::Requirement
79
- none: false
80
61
  requirements:
81
- - - ! '>='
62
+ - - '>='
82
63
  - !ruby/object:Gem::Version
83
64
  version: '0'
84
65
  required_rubygems_version: !ruby/object:Gem::Requirement
85
- none: false
86
66
  requirements:
87
- - - ! '>='
67
+ - - '>='
88
68
  - !ruby/object:Gem::Version
89
69
  version: '0'
90
70
  requirements: []
91
71
  rubyforge_project:
92
- rubygems_version: 1.8.10
72
+ rubygems_version: 2.0.3
93
73
  signing_key:
94
- specification_version: 3
74
+ specification_version: 4
95
75
  summary: Allows ruby objects to implement equality comparison and inspection methods.
96
76
  test_files:
97
77
  - spec/equatable/eql_spec.rb
data/.rvmrc DELETED
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- environment_id="ruby-1.9.3-p0@equatable"
4
-
5
- #
6
- # First we attempt to load the desired environment directly from the environment
7
- # file. This is very fast and efficient compared to running through the entire
8
- # CLI and selector. If you want feedback on which environment was used then
9
- # insert the word 'use' after --create as this triggers verbose mode.
10
- #
11
- if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
12
- && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
13
- then
14
- \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
15
-
16
- if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
17
- then
18
- . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
19
- fi
20
- else
21
- # If the environment file has not yet been created, use the RVM CLI to select.
22
- if ! rvm --create "$environment_id"
23
- then
24
- echo "Failed to create RVM environment '${environment_id}'."
25
- return 1
26
- fi
27
- fi
28
-
29
- if [[ $- == *i* ]] # check for interactive shells
30
- then
31
- echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
32
- else
33
- echo "Using: $GEM_HOME" # don't use colors in interactive shells
34
- fi