concord 0.1.1 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/concord.rb +35 -40
- metadata +37 -49
- data/.gitignore +0 -4
- data/.rspec +0 -5
- data/.travis.yml +0 -18
- data/Changelog.md +0 -19
- data/Gemfile +0 -6
- data/Gemfile.devtools +0 -60
- data/Guardfile +0 -8
- data/LICENSE +0 -20
- data/README.md +0 -81
- data/Rakefile +0 -29
- data/concord.gemspec +0 -19
- data/config/flay.yml +0 -3
- data/config/flog.yml +0 -2
- data/config/mutant.yml +0 -2
- data/config/reek.yml +0 -90
- data/config/roodi.yml +0 -20
- data/config/yardstick.yml +0 -2
- data/spec/spec_helper.rb +0 -3
- data/spec/unit/concord/universal_spec.rb +0 -77
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 00e1baf3ada59ca39db75ee30475ab7f0cee4de044b7e3656f9de5265e7468a9
|
4
|
+
data.tar.gz: 709c2cce624598048899d5335dc45d1922caccb4aa9347bbf010477de9145496
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6e79d310bb26e6291a5935d1dbe5a91dce9cac422cd9922971b14dc5429e6c284aaa4f5777fc42a506599b79a0034275377d514f15c42b152282dc0651ffb551
|
7
|
+
data.tar.gz: 9211e15e7bf7ccfa4dd7c20f1768cf72c6362a82e0066a308c0342cae2eabd5ea29efed345c27ab0c0d5250b208a7c7f27e3d2e38b03fc1e8577778d6054f476
|
data/lib/concord.rb
CHANGED
@@ -5,6 +5,9 @@ require 'equalizer'
|
|
5
5
|
class Concord < Module
|
6
6
|
include Adamantium::Flat, Equalizer.new(:names)
|
7
7
|
|
8
|
+
# The maximum number of objects the hosting class is composed of
|
9
|
+
MAX_NR_OF_OBJECTS = 3
|
10
|
+
|
8
11
|
# Return names
|
9
12
|
#
|
10
13
|
# @return [Enumerable<Symbol>]
|
@@ -13,7 +16,7 @@ class Concord < Module
|
|
13
16
|
#
|
14
17
|
attr_reader :names
|
15
18
|
|
16
|
-
private
|
19
|
+
private
|
17
20
|
|
18
21
|
# Initialize object
|
19
22
|
#
|
@@ -22,68 +25,70 @@ private
|
|
22
25
|
# @api private
|
23
26
|
#
|
24
27
|
def initialize(*names)
|
25
|
-
if names.length >
|
26
|
-
|
28
|
+
if names.length > MAX_NR_OF_OBJECTS
|
29
|
+
fail "Composition of more than #{MAX_NR_OF_OBJECTS} objects is not allowed"
|
27
30
|
end
|
28
31
|
|
29
|
-
@names = names
|
32
|
+
@names, @module = names, Module.new
|
33
|
+
define_initialize
|
34
|
+
define_readers
|
35
|
+
define_equalizer
|
30
36
|
end
|
31
37
|
|
32
38
|
# Hook run when module is included
|
33
39
|
#
|
34
|
-
# @param [Class|Module] descendant
|
35
|
-
#
|
36
40
|
# @return [undefined]
|
37
41
|
#
|
38
42
|
# @api private
|
39
43
|
#
|
40
44
|
def included(descendant)
|
41
|
-
|
42
|
-
define_readers(descendant)
|
43
|
-
define_equalizer(descendant)
|
45
|
+
descendant.send(:include, @module)
|
44
46
|
end
|
45
47
|
|
46
48
|
# Define equalizer
|
47
49
|
#
|
48
|
-
# @param [Class|Module] descendant
|
49
|
-
#
|
50
50
|
# @return [undefined]
|
51
51
|
#
|
52
52
|
# @api private
|
53
53
|
#
|
54
|
-
def define_equalizer
|
55
|
-
|
54
|
+
def define_equalizer
|
55
|
+
@module.send(:include, Equalizer.new(*@names))
|
56
56
|
end
|
57
57
|
|
58
58
|
# Define readers
|
59
59
|
#
|
60
|
-
# @param [Class|Module] descendant
|
61
|
-
#
|
62
60
|
# @return [undefined]
|
63
61
|
#
|
64
62
|
# @api private
|
65
63
|
#
|
66
|
-
def define_readers
|
64
|
+
def define_readers
|
67
65
|
attribute_names = names
|
68
|
-
|
69
|
-
|
66
|
+
@module.class_eval do
|
67
|
+
attr_reader(*attribute_names)
|
68
|
+
protected(*attribute_names)
|
69
|
+
end
|
70
70
|
end
|
71
71
|
|
72
|
-
# Define
|
73
|
-
#
|
74
|
-
# @param [Class|Module] descendant
|
72
|
+
# Define initialize method
|
75
73
|
#
|
76
74
|
# @return [undefined]
|
77
75
|
#
|
78
76
|
# @api private
|
79
77
|
#
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
78
|
+
# rubocop:disable MethodLength
|
79
|
+
#
|
80
|
+
def define_initialize
|
81
|
+
ivars, size = instance_variable_names, names.size
|
82
|
+
@module.class_eval do
|
83
|
+
define_method :initialize do |*args|
|
84
|
+
args_size = args.size
|
85
|
+
if args_size != size
|
86
|
+
fail ArgumentError, "wrong number of arguments (#{args_size} for #{size})"
|
87
|
+
end
|
88
|
+
ivars.zip(args) { |ivar, arg| instance_variable_set(ivar, arg) }
|
89
|
+
end
|
90
|
+
private :initialize
|
91
|
+
end
|
87
92
|
end
|
88
93
|
|
89
94
|
# Return instance variable names
|
@@ -93,23 +98,13 @@ private
|
|
93
98
|
# @api private
|
94
99
|
#
|
95
100
|
def instance_variable_names
|
96
|
-
names.map { |name| "@#{name}" }
|
97
|
-
end
|
98
|
-
|
99
|
-
# Return param names
|
100
|
-
#
|
101
|
-
# @return [String]
|
102
|
-
#
|
103
|
-
# @api private
|
104
|
-
#
|
105
|
-
def argument_names
|
106
|
-
names.join(', ')
|
101
|
+
names.map { |name| "@#{name}" }
|
107
102
|
end
|
108
103
|
|
109
104
|
# Mixin for public attribute readers
|
110
105
|
class Public < self
|
111
106
|
|
112
|
-
# Hook called when module is included
|
107
|
+
# Hook called when module is included
|
113
108
|
#
|
114
109
|
# @param [Class,Module] descendant
|
115
110
|
#
|
metadata
CHANGED
@@ -1,98 +1,86 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: concord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Markus Schirp
|
9
|
-
autorequire:
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2020-09-10 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: adamantium
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.0
|
19
|
+
version: 0.2.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.0
|
26
|
+
version: 0.2.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: equalizer
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0.0.
|
33
|
+
version: 0.0.9
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.0.
|
40
|
+
version: 0.0.9
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: devtools
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.1.26
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.1.26
|
46
55
|
description: Helper for object composition
|
47
56
|
email:
|
48
|
-
- mbj@
|
57
|
+
- mbj@schirp-dso.com
|
49
58
|
executables: []
|
50
59
|
extensions: []
|
51
60
|
extra_rdoc_files: []
|
52
61
|
files:
|
53
|
-
- .gitignore
|
54
|
-
- .rspec
|
55
|
-
- .travis.yml
|
56
|
-
- Changelog.md
|
57
|
-
- Gemfile
|
58
|
-
- Gemfile.devtools
|
59
|
-
- Guardfile
|
60
|
-
- LICENSE
|
61
|
-
- README.md
|
62
|
-
- Rakefile
|
63
|
-
- concord.gemspec
|
64
|
-
- config/flay.yml
|
65
|
-
- config/flog.yml
|
66
|
-
- config/mutant.yml
|
67
|
-
- config/reek.yml
|
68
|
-
- config/roodi.yml
|
69
|
-
- config/yardstick.yml
|
70
62
|
- lib/concord.rb
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
post_install_message:
|
63
|
+
homepage: https://github.com/mbj/concord
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
76
68
|
rdoc_options: []
|
77
69
|
require_paths:
|
78
70
|
- lib
|
79
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
-
none: false
|
81
72
|
requirements:
|
82
|
-
- -
|
73
|
+
- - ">="
|
83
74
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
75
|
+
version: 1.9.3
|
85
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
-
none: false
|
87
77
|
requirements:
|
88
|
-
- -
|
78
|
+
- - ">="
|
89
79
|
- !ruby/object:Gem::Version
|
90
80
|
version: '0'
|
91
81
|
requirements: []
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
specification_version: 3
|
82
|
+
rubygems_version: 3.0.3
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
96
85
|
summary: Helper for object composition
|
97
86
|
test_files: []
|
98
|
-
has_rdoc:
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
script: 'bundle exec rake ci'
|
3
|
-
rvm:
|
4
|
-
- ree
|
5
|
-
- 1.8.7
|
6
|
-
- 1.9.2
|
7
|
-
- 1.9.3
|
8
|
-
- 2.0.0
|
9
|
-
- ruby-head
|
10
|
-
- jruby-18mode
|
11
|
-
- jruby-19mode
|
12
|
-
- jruby-head
|
13
|
-
- rbx-18mode
|
14
|
-
- rbx-19mode
|
15
|
-
notifications:
|
16
|
-
irc: "irc.freenode.org#datamapper"
|
17
|
-
email:
|
18
|
-
- mbj@seonic.net
|
data/Changelog.md
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# v0.1.1 2013-05-15
|
2
|
-
|
3
|
-
+ Add Concord::Public mixin defaulting to public attr_readers
|
4
|
-
|
5
|
-
# v0.1.0 2013-05-15
|
6
|
-
|
7
|
-
* [change] Set default attribute visibility to protected
|
8
|
-
|
9
|
-
# v0.0.3 2013-03-08
|
10
|
-
|
11
|
-
* [fix] 1.9.2 visibility problem
|
12
|
-
|
13
|
-
# v0.0.2 2013-03-07
|
14
|
-
|
15
|
-
* [change] remove unneded backports dependency
|
16
|
-
|
17
|
-
# v0.0.1 2013-03-06
|
18
|
-
|
19
|
-
* First public release!
|
data/Gemfile
DELETED
data/Gemfile.devtools
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
group :development do
|
4
|
-
gem 'rake', '~> 10.0.4'
|
5
|
-
gem 'rspec', '~> 2.13.0'
|
6
|
-
gem 'yard', '~> 0.8.6.1'
|
7
|
-
end
|
8
|
-
|
9
|
-
group :yard do
|
10
|
-
gem 'kramdown', '~> 1.0.1'
|
11
|
-
end
|
12
|
-
|
13
|
-
group :guard do
|
14
|
-
gem 'guard', '~> 1.8.0'
|
15
|
-
gem 'guard-bundler', '~> 1.0.0'
|
16
|
-
gem 'guard-rspec', '~> 2.5.4'
|
17
|
-
|
18
|
-
# file system change event handling
|
19
|
-
gem 'listen', '~> 1.0.2'
|
20
|
-
gem 'rb-fchange', '~> 0.0.6', :require => false
|
21
|
-
gem 'rb-fsevent', '~> 0.9.3', :require => false
|
22
|
-
gem 'rb-inotify', '~> 0.9.0', :require => false
|
23
|
-
|
24
|
-
# notification handling
|
25
|
-
gem 'libnotify', '~> 0.8.0', :require => false
|
26
|
-
gem 'rb-notifu', '~> 0.0.4', :require => false
|
27
|
-
gem 'terminal-notifier-guard', '~> 1.5.3', :require => false
|
28
|
-
end
|
29
|
-
|
30
|
-
group :metrics do
|
31
|
-
gem 'backports', '~> 3.3', '>= 3.3.0'
|
32
|
-
gem 'coveralls', '~> 0.6.6'
|
33
|
-
gem 'flay', '~> 2.2.0'
|
34
|
-
gem 'flog', '~> 4.0.0'
|
35
|
-
gem 'reek', '~> 1.3.1', :git => 'https://github.com/troessner/reek.git'
|
36
|
-
gem 'simplecov', '~> 0.7.1'
|
37
|
-
gem 'yardstick', '~> 0.9.6'
|
38
|
-
|
39
|
-
platforms :ruby_19 do
|
40
|
-
gem 'yard-spellcheck', '~> 0.1.5'
|
41
|
-
end
|
42
|
-
|
43
|
-
platforms :mri_19, :rbx do
|
44
|
-
gem 'mutant', '~> 0.2.20'
|
45
|
-
end
|
46
|
-
|
47
|
-
platforms :rbx do
|
48
|
-
gem 'pelusa', '~> 0.2.2'
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
group :benchmarks do
|
53
|
-
gem 'rbench', '~> 0.2.3'
|
54
|
-
end
|
55
|
-
|
56
|
-
platform :jruby do
|
57
|
-
group :jruby do
|
58
|
-
gem 'jruby-openssl', '~> 0.8.5'
|
59
|
-
end
|
60
|
-
end
|
data/Guardfile
DELETED
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2012 Markus Schirp
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
concord
|
2
|
-
=======
|
3
|
-
|
4
|
-
[![Build Status](https://secure.travis-ci.org/mbj/concord.png?branch=master)](http://travis-ci.org/mbj/concord)
|
5
|
-
[![Dependency Status](https://gemnasium.com/mbj/concord.png)](https://gemnasium.com/mbj/concord)
|
6
|
-
[![Code Climate](https://codeclimate.com/github/mbj/concord.png)](https://codeclimate.com/github/mbj/concord)
|
7
|
-
|
8
|
-
Library to transform this:
|
9
|
-
|
10
|
-
```ruby
|
11
|
-
class ComposedObject
|
12
|
-
include Equalizer.new(:foo, :bar)
|
13
|
-
|
14
|
-
# Return foo
|
15
|
-
#
|
16
|
-
# @return [Foo]
|
17
|
-
#
|
18
|
-
# @api private
|
19
|
-
#
|
20
|
-
attr_reader :foo
|
21
|
-
protected :foo
|
22
|
-
|
23
|
-
# Return bar
|
24
|
-
#
|
25
|
-
# @return [Bar]
|
26
|
-
#
|
27
|
-
# @api private
|
28
|
-
#
|
29
|
-
attr_reader :bar
|
30
|
-
protected :bar
|
31
|
-
|
32
|
-
# Initialize object
|
33
|
-
#
|
34
|
-
# @param [Foo] foo
|
35
|
-
# @param [Bar] bar
|
36
|
-
#
|
37
|
-
# @return [undefined]
|
38
|
-
#
|
39
|
-
# @api private
|
40
|
-
#
|
41
|
-
def initialize(foo, bar)
|
42
|
-
@foo, @bar = foo, bar
|
43
|
-
end
|
44
|
-
end
|
45
|
-
```
|
46
|
-
|
47
|
-
Into shorter and easier to parse by eyes:
|
48
|
-
|
49
|
-
```ruby
|
50
|
-
class ComposedObject
|
51
|
-
include Concord.new(:foo, :bar)
|
52
|
-
end
|
53
|
-
```
|
54
|
-
|
55
|
-
Sure the replacement is missing YARD docs, but IMHO it is better.
|
56
|
-
|
57
|
-
Installation
|
58
|
-
------------
|
59
|
-
|
60
|
-
Install the gem `concord` via your prefered method.
|
61
|
-
|
62
|
-
Credits
|
63
|
-
-------
|
64
|
-
|
65
|
-
* [mbj](https://github.com/mbj)
|
66
|
-
|
67
|
-
Contributing
|
68
|
-
-------------
|
69
|
-
|
70
|
-
* Fork the project.
|
71
|
-
* Make your feature addition or bug fix.
|
72
|
-
* Add tests for it. This is important so I don't break it in a
|
73
|
-
future version unintentionally.
|
74
|
-
* Commit, do not mess with Rakefile or version
|
75
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
76
|
-
* Send me a pull request. Bonus points for topic branches.
|
77
|
-
|
78
|
-
License
|
79
|
-
-------
|
80
|
-
|
81
|
-
See LICENSE
|
data/Rakefile
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'devtools'
|
2
|
-
Devtools.init_rake_tasks
|
3
|
-
|
4
|
-
class Rake::Task
|
5
|
-
def overwrite(&block)
|
6
|
-
@actions.clear
|
7
|
-
enhance(&block)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
Rake.application.load_imports
|
12
|
-
|
13
|
-
begin
|
14
|
-
require 'mutant'
|
15
|
-
rescue LoadError
|
16
|
-
end
|
17
|
-
|
18
|
-
mutant_present = defined?(Mutant)
|
19
|
-
|
20
|
-
allowed_versions = %w(mri-1.9.3 rbx-1.9.3)
|
21
|
-
|
22
|
-
if allowed_versions.include?(Devtools.rvm) and mutant_present and !ENV['DEVTOOLS_SELF']
|
23
|
-
Rake::Task['metrics:mutant'].overwrite do
|
24
|
-
status = Mutant::CLI.run(%W(--rspec-full -r ./spec/spec_helper.rb ::Concord))
|
25
|
-
unless status.zero?
|
26
|
-
fail "Not mutation covered :("
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/concord.gemspec
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = 'concord'
|
5
|
-
s.version = '0.1.1'
|
6
|
-
s.authors = ['Markus Schirp']
|
7
|
-
s.email = ['mbj@seonic.net']
|
8
|
-
s.homepage = 'https://github.com/mbj/composition'
|
9
|
-
s.summary = %q{Helper for object composition}
|
10
|
-
s.description = s.summary
|
11
|
-
|
12
|
-
s.files = `git ls-files`.split("\n")
|
13
|
-
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
14
|
-
s.executables = []
|
15
|
-
s.require_paths = ['lib']
|
16
|
-
|
17
|
-
s.add_dependency('adamantium', '~> 0.0.7')
|
18
|
-
s.add_dependency('equalizer', '~> 0.0.5')
|
19
|
-
end
|
data/config/flay.yml
DELETED
data/config/flog.yml
DELETED
data/config/mutant.yml
DELETED
data/config/reek.yml
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
UncommunicativeParameterName:
|
2
|
-
accept: []
|
3
|
-
exclude: []
|
4
|
-
enabled: true
|
5
|
-
reject:
|
6
|
-
- !ruby/regexp /^.$/
|
7
|
-
- !ruby/regexp /[0-9]$/
|
8
|
-
- !ruby/regexp /[A-Z]/
|
9
|
-
TooManyMethods:
|
10
|
-
max_methods: 14
|
11
|
-
enabled: true
|
12
|
-
exclude: []
|
13
|
-
max_instance_variables: 4
|
14
|
-
UncommunicativeMethodName:
|
15
|
-
accept: []
|
16
|
-
exclude: []
|
17
|
-
enabled: true
|
18
|
-
reject:
|
19
|
-
- !ruby/regexp /^[a-z]$/
|
20
|
-
- !ruby/regexp /[0-9]$/
|
21
|
-
- !ruby/regexp /[A-Z]/
|
22
|
-
LongParameterList:
|
23
|
-
max_params: 2
|
24
|
-
exclude: []
|
25
|
-
enabled: true
|
26
|
-
overrides: {}
|
27
|
-
FeatureEnvy:
|
28
|
-
exclude:
|
29
|
-
- Concord#define_readers
|
30
|
-
enabled: true
|
31
|
-
ClassVariable:
|
32
|
-
exclude: []
|
33
|
-
enabled: true
|
34
|
-
BooleanParameter:
|
35
|
-
exclude: []
|
36
|
-
enabled: true
|
37
|
-
IrresponsibleModule:
|
38
|
-
exclude: []
|
39
|
-
enabled: true
|
40
|
-
UncommunicativeModuleName:
|
41
|
-
accept: []
|
42
|
-
exclude: []
|
43
|
-
enabled: true
|
44
|
-
reject:
|
45
|
-
- !ruby/regexp /^.$/
|
46
|
-
- !ruby/regexp /[0-9]$/
|
47
|
-
NestedIterators:
|
48
|
-
ignore_iterators: []
|
49
|
-
exclude: []
|
50
|
-
enabled: true
|
51
|
-
max_allowed_nesting: 1
|
52
|
-
TooManyStatements:
|
53
|
-
max_statements: 5
|
54
|
-
exclude: []
|
55
|
-
enabled: true
|
56
|
-
DuplicateMethodCall:
|
57
|
-
allow_calls: []
|
58
|
-
exclude: []
|
59
|
-
enabled: true
|
60
|
-
max_calls: 1
|
61
|
-
UtilityFunction:
|
62
|
-
max_helper_calls: 0
|
63
|
-
exclude: []
|
64
|
-
enabled: true
|
65
|
-
Attribute:
|
66
|
-
exclude: []
|
67
|
-
enabled: false
|
68
|
-
UncommunicativeVariableName:
|
69
|
-
accept: []
|
70
|
-
exclude: []
|
71
|
-
enabled: true
|
72
|
-
reject:
|
73
|
-
- !ruby/regexp /^.$/
|
74
|
-
- !ruby/regexp /[0-9]$/
|
75
|
-
- !ruby/regexp /[A-Z]/
|
76
|
-
RepeatedConditional:
|
77
|
-
enabled: true
|
78
|
-
max_ifs: 1
|
79
|
-
DataClump:
|
80
|
-
exclude: []
|
81
|
-
enabled: true
|
82
|
-
max_copies: 0
|
83
|
-
min_clump_size: 2
|
84
|
-
ControlParameter:
|
85
|
-
exclude: []
|
86
|
-
enabled: true
|
87
|
-
LongYieldList:
|
88
|
-
max_params: 0
|
89
|
-
exclude: []
|
90
|
-
enabled: true
|
data/config/roodi.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
---
|
2
|
-
AbcMetricMethodCheck:
|
3
|
-
score: 25.1
|
4
|
-
AssignmentInConditionalCheck: { }
|
5
|
-
CaseMissingElseCheck: { }
|
6
|
-
ClassLineCountCheck: { line_count: 317 }
|
7
|
-
ClassNameCheck:
|
8
|
-
pattern: !ruby/regexp /\A(?:[A-Z]+|[A-Z][a-z](?:[A-Z]?[a-z])+)\z/
|
9
|
-
ClassVariableCheck: { }
|
10
|
-
CyclomaticComplexityBlockCheck: { complexity: 3 }
|
11
|
-
CyclomaticComplexityMethodCheck: { complexity: 4 }
|
12
|
-
EmptyRescueBodyCheck: { }
|
13
|
-
ForLoopCheck: { }
|
14
|
-
MethodLineCountCheck: { line_count: 14 }
|
15
|
-
MethodNameCheck:
|
16
|
-
pattern: !ruby/regexp /\A(?:[a-z\d](?:_?[a-z\d])+[?!=]?|\[\]=?|==|<=>|<<|[+*&|-])\z/
|
17
|
-
ModuleLineCountCheck: { line_count: 320 }
|
18
|
-
ModuleNameCheck:
|
19
|
-
pattern: !ruby/regexp /\A(?:[A-Z]+|[A-Z][a-z](?:[A-Z]?[a-z])+)\z/
|
20
|
-
ParameterNumberCheck: { parameter_count: 3 }
|
data/config/yardstick.yml
DELETED
data/spec/spec_helper.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Concord do
|
4
|
-
|
5
|
-
let(:class_under_test) do
|
6
|
-
Class.new do
|
7
|
-
include Concord.new(:foo, :bar)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
let(:instance_a) { class_under_test.new(foo, bar) }
|
12
|
-
let(:instance_b) { class_under_test.new(foo, bar) }
|
13
|
-
let(:instance_c) { class_under_test.new(foo, mock('Baz')) }
|
14
|
-
|
15
|
-
let(:foo) { mock('Foo') }
|
16
|
-
let(:bar) { mock('Bar') }
|
17
|
-
|
18
|
-
context 'initializer lines' do
|
19
|
-
unless Devtools.jruby?
|
20
|
-
it 'sets initializer correctly' do
|
21
|
-
klass = Class.new
|
22
|
-
# Nicer way to assert this?
|
23
|
-
klass.should_receive(:class_eval) do |code, file, line|
|
24
|
-
file.should eql(File.expand_path('../../../../lib/concord.rb', __FILE__))
|
25
|
-
line.should be(83)
|
26
|
-
end
|
27
|
-
klass.send(:include, Concord.new)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'visibiluty' do
|
33
|
-
it 'should set attribute readers to public' do
|
34
|
-
klass = Class.new
|
35
|
-
klass.send(:include, Concord.new(:foo))
|
36
|
-
klass.protected_instance_methods.map(&:to_sym).should == [:foo]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'attribute behavior' do
|
41
|
-
subject { instance_a }
|
42
|
-
|
43
|
-
specify { subject.send(:foo).should be(foo) }
|
44
|
-
specify { subject.send(:bar).should be(bar) }
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'equalization behavior' do
|
48
|
-
specify 'composed objects are equalized on attributes' do
|
49
|
-
instance_a.should == instance_b
|
50
|
-
instance_a.hash.should == instance_b.hash
|
51
|
-
instance_a.should eql(instance_b)
|
52
|
-
|
53
|
-
instance_a.should_not == instance_c
|
54
|
-
instance_a.should_not eql(instance_c)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'to much composition behavior' do
|
59
|
-
specify 'it raises an error' do
|
60
|
-
expect { Concord.new(:a, :b, :c, :d) }.to raise_error(RuntimeError, 'Composition of more than three objects is not allowed')
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context Concord::Public do
|
65
|
-
let(:class_under_test) do
|
66
|
-
Class.new do
|
67
|
-
include Concord::Public.new(:foo, :bar)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'should create public attr readers' do
|
72
|
-
object = class_under_test.new(:foo, :bar)
|
73
|
-
object.foo.should eql(:foo)
|
74
|
-
object.bar.should eql(:bar)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|