lupo 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +37 -0
- data/.rspec +4 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +17 -0
- data/CONTRIBUTING.md +11 -0
- data/Gemfile +12 -0
- data/Gemfile.devtools +67 -0
- data/LICENSE +20 -0
- data/README.md +64 -0
- data/Rakefile +6 -0
- data/config/devtools.yml +2 -0
- data/config/flay.yml +3 -0
- data/config/flog.yml +2 -0
- data/config/mutant.yml +3 -0
- data/config/reek.yml +103 -0
- data/config/rubocop.yml +78 -0
- data/config/yardstick.yml +2 -0
- data/lib/lupo.rb +106 -0
- data/lib/lupo/version.rb +6 -0
- data/lupo.gemspec +23 -0
- data/spec/lupo_spec.rb +54 -0
- data/spec/spec_helper.rb +30 -0
- metadata +105 -0
data/.gitignore
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## Rubinius
|
17
|
+
*.rbc
|
18
|
+
.rbx
|
19
|
+
|
20
|
+
## PROJECT::GENERAL
|
21
|
+
*.gem
|
22
|
+
coverage
|
23
|
+
profiling
|
24
|
+
turbulence
|
25
|
+
rdoc
|
26
|
+
pkg
|
27
|
+
tmp
|
28
|
+
doc
|
29
|
+
log
|
30
|
+
.yardoc
|
31
|
+
measurements
|
32
|
+
|
33
|
+
## BUNDLER
|
34
|
+
.bundle
|
35
|
+
Gemfile.lock
|
36
|
+
|
37
|
+
## PROJECT::SPECIFIC
|
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
lupo
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.9.3
|
data/.travis.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
language: ruby
|
2
|
+
before_install: gem install bundler
|
3
|
+
bundler_args: --without yard guard benchmarks
|
4
|
+
script: "bundle exec rake ci"
|
5
|
+
rvm:
|
6
|
+
- 1.9.3
|
7
|
+
- 2.0.0
|
8
|
+
- ruby-head
|
9
|
+
- rbx-19mode
|
10
|
+
matrix:
|
11
|
+
include:
|
12
|
+
- rvm: jruby-19mode
|
13
|
+
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
14
|
+
- rvm: jruby-head
|
15
|
+
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
16
|
+
allow_failures:
|
17
|
+
- rvm: ruby-head
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Contributing
|
2
|
+
------------
|
3
|
+
|
4
|
+
* If you want your code merged into the mainline, please discuss the proposed changes with me before doing any work on it.
|
5
|
+
* Fork the project.
|
6
|
+
* Make your feature addition or bug fix.
|
7
|
+
* Follow this [style guide](https://github.com/dkubb/styleguide).
|
8
|
+
* Add specs for it. This is important so I don't break it in a future version unintentionally. Tests must cover all branches within the code, and code must be fully covered.
|
9
|
+
* Commit, do not mess with Rakefile, version, or history. (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)
|
10
|
+
* Run "rake ci". This must pass and not show any regressions in the metrics for the code to be merged.
|
11
|
+
* Send me a pull request. Bonus points for topic branches.
|
data/Gemfile
ADDED
data/Gemfile.devtools
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
group :development do
|
4
|
+
gem 'rake', '~> 10.1.0'
|
5
|
+
gem 'rspec', '~> 2.14.1'
|
6
|
+
gem 'yard', '~> 0.8.7'
|
7
|
+
|
8
|
+
platform :rbx do
|
9
|
+
gem 'rubysl-singleton', '~> 2.0.0'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
group :yard do
|
14
|
+
gem 'kramdown', '~> 1.3.0'
|
15
|
+
end
|
16
|
+
|
17
|
+
group :guard do
|
18
|
+
gem 'guard', '~> 2.2.4'
|
19
|
+
gem 'guard-bundler', '~> 2.0.0'
|
20
|
+
gem 'guard-rspec', '~> 4.2.0'
|
21
|
+
gem 'guard-rubocop', '~> 1.0.0'
|
22
|
+
|
23
|
+
# file system change event handling
|
24
|
+
gem 'listen', '~> 2.4.0'
|
25
|
+
gem 'rb-fchange', '~> 0.0.6', require: false
|
26
|
+
gem 'rb-fsevent', '~> 0.9.3', require: false
|
27
|
+
gem 'rb-inotify', '~> 0.9.0', require: false
|
28
|
+
|
29
|
+
# notification handling
|
30
|
+
gem 'libnotify', '~> 0.8.0', require: false
|
31
|
+
gem 'rb-notifu', '~> 0.0.4', require: false
|
32
|
+
gem 'terminal-notifier-guard', '~> 1.5.3', require: false
|
33
|
+
end
|
34
|
+
|
35
|
+
group :metrics do
|
36
|
+
gem 'coveralls', '~> 0.7.0'
|
37
|
+
gem 'flay', '~> 2.4.0'
|
38
|
+
gem 'flog', '~> 4.2.0'
|
39
|
+
gem 'reek', '~> 1.3.2'
|
40
|
+
gem 'rubocop', '~> 0.15.0'
|
41
|
+
gem 'simplecov', '~> 0.8.2'
|
42
|
+
gem 'yardstick', '~> 0.9.7', git: 'https://github.com/dkubb/yardstick.git'
|
43
|
+
|
44
|
+
platforms :ruby_19, :ruby_20 do
|
45
|
+
gem 'mutant', '~> 0.3.0', git: 'https://github.com/mbj/mutant.git'
|
46
|
+
gem 'unparser', '~> 0.1.5', git: 'https://github.com/mbj/unparser.git'
|
47
|
+
gem 'yard-spellcheck', '~> 0.1.5'
|
48
|
+
end
|
49
|
+
|
50
|
+
platform :rbx do
|
51
|
+
gem 'json', '~> 1.8.1'
|
52
|
+
gem 'racc', '~> 1.4.10'
|
53
|
+
gem 'rubysl-logger', '~> 2.0.0'
|
54
|
+
gem 'rubysl-open-uri', '~> 2.0.0'
|
55
|
+
gem 'rubysl-prettyprint', '~> 2.0.2'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
group :benchmarks do
|
60
|
+
gem 'rbench', '~> 0.2.3'
|
61
|
+
end
|
62
|
+
|
63
|
+
platform :jruby do
|
64
|
+
group :jruby do
|
65
|
+
gem 'jruby-openssl', '~> 0.8.5'
|
66
|
+
end
|
67
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Martin Gamsjaeger (snusnu)
|
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
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# lupo
|
2
|
+
|
3
|
+
[][gem]
|
4
|
+
[][travis]
|
5
|
+
[][gemnasium]
|
6
|
+
[][codeclimate]
|
7
|
+
[][coveralls]
|
8
|
+
|
9
|
+
[gem]: https://rubygems.org/gems/lupo
|
10
|
+
[travis]: https://travis-ci.org/snusnu/lupo
|
11
|
+
[gemnasium]: https://gemnasium.com/snusnu/lupo
|
12
|
+
[codeclimate]: https://codeclimate.com/github/snusnu/lupo
|
13
|
+
[coveralls]: https://coveralls.io/r/snusnu/lupo
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
require 'lupo'
|
19
|
+
|
20
|
+
class TaskList
|
21
|
+
include Lupo.enumerable(:tasks)
|
22
|
+
|
23
|
+
def initialize(name, tasks)
|
24
|
+
@name, @tasks = name, tasks
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
list = TaskList.new('secret', %w[this and that])
|
29
|
+
|
30
|
+
list.each { |t| puts(t) } # => list
|
31
|
+
list.each.to_a # => ['this', 'and', 'that']
|
32
|
+
list.is_a?(Enumerable) # => true
|
33
|
+
list.methods.include?(:tasks) # => false
|
34
|
+
|
35
|
+
class ItemList
|
36
|
+
include Lupo.collection(:items)
|
37
|
+
end
|
38
|
+
|
39
|
+
list = ItemList.new(%w[this and that])
|
40
|
+
|
41
|
+
list.each { |i| puts(i) } # => list
|
42
|
+
list.each.to_a # => ['this', 'and', 'that']
|
43
|
+
list.is_a?(Enumerable) # => true
|
44
|
+
list.protected_methods.include?(:items) # => true
|
45
|
+
|
46
|
+
other = ItemList.new(%w[this and that])
|
47
|
+
|
48
|
+
# see equalizer for detailed docs
|
49
|
+
list.equal?(other) # => false
|
50
|
+
list.eql?(other) # => true
|
51
|
+
list == other # => true
|
52
|
+
```
|
53
|
+
|
54
|
+
## Credits
|
55
|
+
|
56
|
+
* [snusnu](https://github.com/snusnu)
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
|
61
|
+
|
62
|
+
## Copyright
|
63
|
+
|
64
|
+
Copyright © 2013 Martin Gamsjaeger (snusnu). See [LICENSE](LICENSE) for details.
|
data/Rakefile
ADDED
data/config/devtools.yml
ADDED
data/config/flay.yml
ADDED
data/config/flog.yml
ADDED
data/config/mutant.yml
ADDED
data/config/reek.yml
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
---
|
2
|
+
Attribute:
|
3
|
+
enabled: true
|
4
|
+
exclude: []
|
5
|
+
BooleanParameter:
|
6
|
+
enabled: true
|
7
|
+
exclude: []
|
8
|
+
ClassVariable:
|
9
|
+
enabled: true
|
10
|
+
exclude: []
|
11
|
+
ControlParameter:
|
12
|
+
enabled: true
|
13
|
+
exclude: []
|
14
|
+
DataClump:
|
15
|
+
enabled: true
|
16
|
+
exclude: []
|
17
|
+
max_copies: 2
|
18
|
+
min_clump_size: 2
|
19
|
+
DuplicateMethodCall:
|
20
|
+
enabled: true
|
21
|
+
exclude: []
|
22
|
+
max_calls: 1
|
23
|
+
allow_calls: []
|
24
|
+
FeatureEnvy:
|
25
|
+
enabled: true
|
26
|
+
exclude: []
|
27
|
+
IrresponsibleModule:
|
28
|
+
enabled: true
|
29
|
+
exclude: []
|
30
|
+
LongParameterList:
|
31
|
+
enabled: true
|
32
|
+
exclude: []
|
33
|
+
max_params: 1
|
34
|
+
overrides:
|
35
|
+
initialize:
|
36
|
+
max_params: 2
|
37
|
+
LongYieldList:
|
38
|
+
enabled: true
|
39
|
+
exclude: []
|
40
|
+
max_params: 1
|
41
|
+
NestedIterators:
|
42
|
+
enabled: true
|
43
|
+
exclude:
|
44
|
+
- Lupo#included # 2
|
45
|
+
max_allowed_nesting: 1
|
46
|
+
ignore_iterators: []
|
47
|
+
NilCheck:
|
48
|
+
enabled: true
|
49
|
+
exclude: []
|
50
|
+
RepeatedConditional:
|
51
|
+
enabled: true
|
52
|
+
exclude: []
|
53
|
+
max_ifs: 1
|
54
|
+
TooManyInstanceVariables:
|
55
|
+
enabled: true
|
56
|
+
exclude: []
|
57
|
+
max_instance_variables: 2
|
58
|
+
TooManyMethods:
|
59
|
+
enabled: true
|
60
|
+
exclude: []
|
61
|
+
max_methods: 2
|
62
|
+
TooManyStatements:
|
63
|
+
enabled: true
|
64
|
+
exclude: []
|
65
|
+
max_statements: 6
|
66
|
+
UncommunicativeMethodName:
|
67
|
+
enabled: true
|
68
|
+
exclude: []
|
69
|
+
reject:
|
70
|
+
- !ruby/regexp /^[a-z]$/
|
71
|
+
- !ruby/regexp /[0-9]$/
|
72
|
+
- !ruby/regexp /[A-Z]/
|
73
|
+
accept: []
|
74
|
+
UncommunicativeModuleName:
|
75
|
+
enabled: true
|
76
|
+
exclude: []
|
77
|
+
reject:
|
78
|
+
- !ruby/regexp /^.$/
|
79
|
+
- !ruby/regexp /[0-9]$/
|
80
|
+
accept: []
|
81
|
+
UncommunicativeParameterName:
|
82
|
+
enabled: true
|
83
|
+
exclude: []
|
84
|
+
reject:
|
85
|
+
- !ruby/regexp /^.$/
|
86
|
+
- !ruby/regexp /[0-9]$/
|
87
|
+
- !ruby/regexp /[A-Z]/
|
88
|
+
accept: []
|
89
|
+
UncommunicativeVariableName:
|
90
|
+
enabled: true
|
91
|
+
exclude: []
|
92
|
+
reject:
|
93
|
+
- !ruby/regexp /^.$/
|
94
|
+
- !ruby/regexp /[0-9]$/
|
95
|
+
- !ruby/regexp /[A-Z]/
|
96
|
+
accept: []
|
97
|
+
UnusedParameters:
|
98
|
+
enabled: true
|
99
|
+
exclude: []
|
100
|
+
UtilityFunction:
|
101
|
+
enabled: true
|
102
|
+
exclude: []
|
103
|
+
max_helper_calls: 0
|
data/config/rubocop.yml
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
AllCops:
|
2
|
+
Includes:
|
3
|
+
- '**/*.rake'
|
4
|
+
- 'Gemfile'
|
5
|
+
- 'Gemfile.devtools'
|
6
|
+
Excludes:
|
7
|
+
- '**/vendor/**'
|
8
|
+
- '**/benchmarks/**'
|
9
|
+
|
10
|
+
# Avoid parameter lists longer than five parameters.
|
11
|
+
ParameterLists:
|
12
|
+
Max: 2
|
13
|
+
CountKeywordArgs: true
|
14
|
+
|
15
|
+
# Avoid more than `Max` levels of nesting.
|
16
|
+
BlockNesting:
|
17
|
+
Max: 3
|
18
|
+
|
19
|
+
# Align with the style guide.
|
20
|
+
CollectionMethods:
|
21
|
+
PreferredMethods:
|
22
|
+
collect: 'map'
|
23
|
+
inject: 'reduce'
|
24
|
+
find: 'detect'
|
25
|
+
find_all: 'select'
|
26
|
+
|
27
|
+
# Do not force public/protected/private keyword to be indented at the same
|
28
|
+
# level as the def keyword. My personal preference is to outdent these keywords
|
29
|
+
# because I think when scanning code it makes it easier to identify the
|
30
|
+
# sections of code and visually separate them. When the keyword is at the same
|
31
|
+
# level I think it sort of blends in with the def keywords and makes it harder
|
32
|
+
# to scan the code and see where the sections are.
|
33
|
+
AccessModifierIndentation:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
# Limit line length
|
37
|
+
LineLength:
|
38
|
+
Max: 80
|
39
|
+
|
40
|
+
# Disable documentation checking until a class needs to be documented once
|
41
|
+
Documentation:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
# Do not favor modifier if/unless usage when you have a single-line body
|
45
|
+
IfUnlessModifier:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
# Allow case equality operator (in limited use within the specs)
|
49
|
+
CaseEquality:
|
50
|
+
Enabled: false
|
51
|
+
|
52
|
+
# Constants do not always have to use SCREAMING_SNAKE_CASE
|
53
|
+
ConstantName:
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
# Not all trivial readers/writers can be defined with attr_* methods
|
57
|
+
TrivialAccessors:
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
# Do not prefer do/end over {} for multiline blocks
|
61
|
+
Blocks:
|
62
|
+
Enabled: false
|
63
|
+
|
64
|
+
# Do not favor aligned parameters in method calls
|
65
|
+
AlignParameters:
|
66
|
+
Enabled: false
|
67
|
+
|
68
|
+
HashSyntax:
|
69
|
+
Enabled: false
|
70
|
+
|
71
|
+
SpaceInsideBrackets:
|
72
|
+
Enabled: false
|
73
|
+
|
74
|
+
Lambda:
|
75
|
+
Enabled: false # i personally like the look of multiline ->(arg) {} lambdas
|
76
|
+
|
77
|
+
AndOr:
|
78
|
+
Enabled: false # we agree to use and/or for control flow
|
data/lib/lupo.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'concord'
|
4
|
+
|
5
|
+
# Includes Enumerable and provides #each.
|
6
|
+
# Optionally includes Concord to provide
|
7
|
+
# #initialize and Equalizer for equality
|
8
|
+
# methods
|
9
|
+
class Lupo < Module
|
10
|
+
private_class_method :new
|
11
|
+
|
12
|
+
# Build a module providing #each, Enumerable and Concord
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
#
|
16
|
+
# class Collection
|
17
|
+
# include Lupo.enumerable(:entries)
|
18
|
+
#
|
19
|
+
# def initialize(entries)
|
20
|
+
# @entries = entries
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# collection = Collection.new([1,2,3])
|
25
|
+
#
|
26
|
+
# collection.each { |i| puts(i) } # => collection
|
27
|
+
# collection.each.to_a # => [1,2,3]
|
28
|
+
# collection.is_a?(Enumerable) # => true
|
29
|
+
#
|
30
|
+
# @param [#to_s] name
|
31
|
+
# the name of the enumerable
|
32
|
+
#
|
33
|
+
# @return [undefined]
|
34
|
+
#
|
35
|
+
# @api public
|
36
|
+
def self.enumerable(name)
|
37
|
+
new(name, [Enumerable])
|
38
|
+
end
|
39
|
+
|
40
|
+
# Build a module providing #each and Enumerable
|
41
|
+
#
|
42
|
+
# @example
|
43
|
+
#
|
44
|
+
# class Collection
|
45
|
+
# include Lupo.collection(:entries)
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# collection = Collection.new([1,2,3])
|
49
|
+
#
|
50
|
+
# collection.each { |i| puts(i) } # => collection
|
51
|
+
# collection.each.to_a # => [1,2,3]
|
52
|
+
# collection.is_a?(Enumerable) # => true
|
53
|
+
#
|
54
|
+
# other = Collection.new([1,2,3])
|
55
|
+
#
|
56
|
+
# # see equalizer for detailed docs
|
57
|
+
# collection.equal?(other) # => false
|
58
|
+
# collection.eql?(other) # => true
|
59
|
+
# collection == other # => true
|
60
|
+
#
|
61
|
+
# @param [#to_s] name
|
62
|
+
# the name of the enumerable
|
63
|
+
#
|
64
|
+
# @return [undefined]
|
65
|
+
#
|
66
|
+
# @api public
|
67
|
+
def self.collection(name)
|
68
|
+
new(name, [Enumerable, Concord.new(name)])
|
69
|
+
end
|
70
|
+
|
71
|
+
# Initialize a new instance
|
72
|
+
#
|
73
|
+
# @param [#to_s] name
|
74
|
+
# the name of the enumerable
|
75
|
+
#
|
76
|
+
# @param [#each] modules
|
77
|
+
# the modules to include into a host
|
78
|
+
#
|
79
|
+
# @return [undefined]
|
80
|
+
#
|
81
|
+
# @api private
|
82
|
+
def initialize(name, modules)
|
83
|
+
@modules, @body = modules, ->(&block) {
|
84
|
+
return to_enum unless block
|
85
|
+
instance_variable_get(:"@#{name}").each(&block)
|
86
|
+
self
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
# Define the #each method on the host and include modules
|
93
|
+
#
|
94
|
+
# @param [Object] host
|
95
|
+
# the hosting object
|
96
|
+
#
|
97
|
+
# @return [undefined]
|
98
|
+
#
|
99
|
+
# @api private
|
100
|
+
def included(host)
|
101
|
+
host.instance_exec(@modules, @body) do |modules, body|
|
102
|
+
include(*modules)
|
103
|
+
define_method(:each, &body)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end # Lupo
|
data/lib/lupo/version.rb
ADDED
data/lupo.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path('../lib/lupo/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "lupo"
|
7
|
+
gem.version = Lupo::VERSION.dup
|
8
|
+
gem.authors = [ 'Martin Gamsjaeger (snusnu)' ]
|
9
|
+
gem.email = [ 'gamsnjaga@gmail.com' ]
|
10
|
+
gem.description = 'Adds an #each method to your objects'
|
11
|
+
gem.summary = 'A module that installs an #each method and includes Enumerable'
|
12
|
+
gem.homepage = 'https://github.com/snusnu/lupo'
|
13
|
+
|
14
|
+
gem.require_paths = [ 'lib' ]
|
15
|
+
gem.files = `git ls-files`.split("\n")
|
16
|
+
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
17
|
+
gem.extra_rdoc_files = %w[LICENSE README.md CONTRIBUTING.md]
|
18
|
+
gem.license = 'MIT'
|
19
|
+
|
20
|
+
gem.add_dependency 'concord', '~> 0.1.4'
|
21
|
+
|
22
|
+
gem.add_development_dependency 'bundler', '~> 1.3.5'
|
23
|
+
end
|
data/spec/lupo_spec.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
shared_context 'lupo' do
|
6
|
+
subject { klass.new(entries) }
|
7
|
+
|
8
|
+
let(:entries) { [42] }
|
9
|
+
|
10
|
+
it 'provides an #each method' do
|
11
|
+
expect { |b| subject.each(&b) }.to yield_successive_args(*entries)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'includes Enumerable' do
|
15
|
+
expect(subject).to be_kind_of(Enumerable)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'works without a block' do
|
19
|
+
expect(subject.each).to be_instance_of(Enumerator)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns self from #each' do
|
23
|
+
expect(subject.each {}).to be(subject)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe Lupo do
|
28
|
+
context '.enumerable' do
|
29
|
+
include_context 'lupo'
|
30
|
+
|
31
|
+
let(:klass) do
|
32
|
+
Class.new do
|
33
|
+
include Lupo.enumerable(:entries)
|
34
|
+
def initialize(entries)
|
35
|
+
@entries = entries
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context '.collection' do
|
42
|
+
include_context 'lupo'
|
43
|
+
|
44
|
+
let(:klass) do
|
45
|
+
Class.new do
|
46
|
+
include Lupo.collection(:entries)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should include a concord instance' do
|
51
|
+
expect(klass.ancestors).to include(Concord.new(:entries))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
if ENV['COVERAGE'] == 'true'
|
4
|
+
require 'simplecov'
|
5
|
+
require 'coveralls'
|
6
|
+
|
7
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
8
|
+
SimpleCov::Formatter::HTMLFormatter,
|
9
|
+
Coveralls::SimpleCov::Formatter
|
10
|
+
]
|
11
|
+
|
12
|
+
SimpleCov.start do
|
13
|
+
command_name 'spec:unit'
|
14
|
+
add_filter 'config'
|
15
|
+
add_filter 'spec'
|
16
|
+
minimum_coverage 100
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'lupo'
|
21
|
+
require 'devtools/spec_helper'
|
22
|
+
|
23
|
+
RSpec.configure do |config|
|
24
|
+
config.expect_with :rspec do |c|
|
25
|
+
c.syntax = :expect
|
26
|
+
end
|
27
|
+
config.mock_with :rspec do |c|
|
28
|
+
c.syntax = :expect
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lupo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Martin Gamsjaeger (snusnu)
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-12-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: concord
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.1.4
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.1.4
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.3.5
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.3.5
|
46
|
+
description: ! 'Adds an #each method to your objects'
|
47
|
+
email:
|
48
|
+
- gamsnjaga@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files:
|
52
|
+
- LICENSE
|
53
|
+
- README.md
|
54
|
+
- CONTRIBUTING.md
|
55
|
+
files:
|
56
|
+
- .gitignore
|
57
|
+
- .rspec
|
58
|
+
- .ruby-gemset
|
59
|
+
- .ruby-version
|
60
|
+
- .travis.yml
|
61
|
+
- CONTRIBUTING.md
|
62
|
+
- Gemfile
|
63
|
+
- Gemfile.devtools
|
64
|
+
- LICENSE
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- config/devtools.yml
|
68
|
+
- config/flay.yml
|
69
|
+
- config/flog.yml
|
70
|
+
- config/mutant.yml
|
71
|
+
- config/reek.yml
|
72
|
+
- config/rubocop.yml
|
73
|
+
- config/yardstick.yml
|
74
|
+
- lib/lupo.rb
|
75
|
+
- lib/lupo/version.rb
|
76
|
+
- lupo.gemspec
|
77
|
+
- spec/lupo_spec.rb
|
78
|
+
- spec/spec_helper.rb
|
79
|
+
homepage: https://github.com/snusnu/lupo
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 1.8.23
|
101
|
+
signing_key:
|
102
|
+
specification_version: 3
|
103
|
+
summary: ! 'A module that installs an #each method and includes Enumerable'
|
104
|
+
test_files: []
|
105
|
+
has_rdoc:
|