favorites 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +27 -0
- data/LICENSE +21 -0
- data/README.md +1 -0
- data/favorites.gemspec +22 -0
- data/lib/favorites.rb +15 -0
- data/lib/favorites/version.rb +4 -0
- data/spec/favorites_spec.rb +34 -0
- data/spec/spec_helper.rb +8 -0
- metadata +68 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 098fbe8a3a5c4e6a43e15e9f43b641d9aa8e5ebf
|
4
|
+
data.tar.gz: 447c770a57e550219b8bac3a3c155aef7aa93e2f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 032d6e2cc3b21a6af170d2378a65b4098b39ab534f45138ec1fcb5acf08f1dfde412421eb8c20dad9eab730b78917e0968aafe173a0673b2b59a350fc5c0bd29
|
7
|
+
data.tar.gz: 0285fdb5585c14ee525c608c00281c9b4998188bdf2972b2e7d3ed3201085f0d31a23a135718c663f7ea051f4e9e936b6746dabd463d85cf23c2d3c62aeee826
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
favorites (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.3)
|
10
|
+
rspec (2.11.0)
|
11
|
+
rspec-core (~> 2.11.0)
|
12
|
+
rspec-expectations (~> 2.11.0)
|
13
|
+
rspec-mocks (~> 2.11.0)
|
14
|
+
rspec-core (2.11.1)
|
15
|
+
rspec-expectations (2.11.3)
|
16
|
+
diff-lcs (~> 1.1.3)
|
17
|
+
rspec-mocks (2.11.3)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
favorites!
|
24
|
+
rspec (~> 2.11.0)
|
25
|
+
|
26
|
+
BUNDLED WITH
|
27
|
+
1.13.6
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 Chris Doyle
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# favorites
|
data/favorites.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/favorites/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "favorites"
|
6
|
+
|
7
|
+
gem.authors = ["Chris Doyle"]
|
8
|
+
gem.email = ["chris@arches.io"]
|
9
|
+
gem.email = "chris@arches.io"
|
10
|
+
|
11
|
+
gem.description = "Favorites lets you access specific ActiveRecord objects with a shortcut"
|
12
|
+
gem.summary = "Favorites lets you access specific ActiveRecord objects with a shortcut"
|
13
|
+
gem.homepage = "http://github.com/arches/favorites"
|
14
|
+
gem.version = Favorites::VERSION
|
15
|
+
gem.license = 'MIT'
|
16
|
+
|
17
|
+
gem.files = `git ls-files`.split($\)
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
|
21
|
+
gem.add_development_dependency 'rspec', '~> 2.11.0'
|
22
|
+
end
|
data/lib/favorites.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Favorites
|
2
|
+
def self.included(base)
|
3
|
+
base.extend(ClassMethods)
|
4
|
+
end
|
5
|
+
|
6
|
+
module ClassMethods
|
7
|
+
def favorite(finder, shortcuts)
|
8
|
+
singleton = (class << self; self; end)
|
9
|
+
|
10
|
+
shortcuts.each do |name, value|
|
11
|
+
singleton.send(:define_method, name, lambda{ send("find_by_#{finder}", value) })
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Favorites do
|
4
|
+
|
5
|
+
class Foo
|
6
|
+
include Favorites
|
7
|
+
|
8
|
+
favorite :email, {
|
9
|
+
chris: "chris@arches.io",
|
10
|
+
joe: "joe@joe.io",
|
11
|
+
}
|
12
|
+
|
13
|
+
favorite :name, {
|
14
|
+
bob: "bob name",
|
15
|
+
sally: "sally name",
|
16
|
+
}
|
17
|
+
|
18
|
+
def self.find_by_email(email)
|
19
|
+
"#{email} finder"
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.find_by_name(name)
|
23
|
+
"#{name} finder"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "delegates to finder methods for each favorite" do
|
28
|
+
Foo.chris.should == "chris@arches.io finder"
|
29
|
+
Foo.joe.should == "joe@joe.io finder"
|
30
|
+
|
31
|
+
Foo.bob.should == "bob name finder"
|
32
|
+
Foo.sally.should == "sally name finder"
|
33
|
+
end
|
34
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: favorites
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Doyle
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.11.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.11.0
|
27
|
+
description: Favorites lets you access specific ActiveRecord objects with a shortcut
|
28
|
+
email: chris@arches.io
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- Gemfile
|
34
|
+
- Gemfile.lock
|
35
|
+
- LICENSE
|
36
|
+
- README.md
|
37
|
+
- favorites.gemspec
|
38
|
+
- lib/favorites.rb
|
39
|
+
- lib/favorites/version.rb
|
40
|
+
- spec/favorites_spec.rb
|
41
|
+
- spec/spec_helper.rb
|
42
|
+
homepage: http://github.com/arches/favorites
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata: {}
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 2.4.5.1
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: Favorites lets you access specific ActiveRecord objects with a shortcut
|
66
|
+
test_files:
|
67
|
+
- spec/favorites_spec.rb
|
68
|
+
- spec/spec_helper.rb
|