receptacle 0.3.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +64 -0
- data/.rubocop.yml +5 -4
- data/CHANGELOG.md +7 -0
- data/Dangerfile +9 -4
- data/Gemfile +5 -4
- data/Guardfile +5 -4
- data/README.md +1 -1
- data/Rakefile +11 -18
- data/bin/console +3 -3
- data/examples/simple_repo.rb +16 -15
- data/lib/receptacle.rb +4 -3
- data/lib/receptacle/errors.rb +1 -0
- data/lib/receptacle/interface_methods.rb +5 -3
- data/lib/receptacle/method_cache.rb +2 -1
- data/lib/receptacle/method_delegation.rb +11 -6
- data/lib/receptacle/registration.rb +3 -2
- data/lib/receptacle/test_support.rb +2 -1
- data/lib/receptacle/version.rb +2 -1
- data/performance/benchmark.rb +21 -20
- data/performance/profile.rb +9 -8
- data/performance/speed_receptacle.rb +10 -9
- data/receptacle.gemspec +24 -24
- metadata +61 -50
- data/.travis.yml +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1f7323081fe278e72a9e8c7fd361196e11ec0dd4b7bc6db33f7bdccd7dd9fdac
|
4
|
+
data.tar.gz: 0700021212c9301e956e89456ebbbc2dfd3d681fa9be444ba83914591461dfa6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18a674c448d529d3a0297bb20b87835200abd54f596b0b7bc6b8722aa42af9f0e6356edb86a7b8eb3a0a0a40adc2315a0f24ac07e38fcd762ab7cb9ec2f8cb74
|
7
|
+
data.tar.gz: 787b73997a3f6c1d350a94791f3169d364a318e2932948e6772deec4476c60ef3d462b8b34a19dddb422ee171d9f04f1d34711248d0d94c5ac7e650d4d1c9cdb
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Ruby CircleCI 2.0 configuration file
|
2
|
+
#
|
3
|
+
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
4
|
+
#
|
5
|
+
|
6
|
+
version: 2
|
7
|
+
|
8
|
+
common_steps: &common_steps
|
9
|
+
- checkout
|
10
|
+
- run: gem update --system
|
11
|
+
- restore_cache:
|
12
|
+
key: gem-cache-{{ .Branch }}-{{ checksum "Gemfile" }}
|
13
|
+
- run:
|
14
|
+
name: install dependencies
|
15
|
+
command: |
|
16
|
+
gem update bundler
|
17
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
18
|
+
- save_cache:
|
19
|
+
key: gem-cache-{{ .Branch }}-{{ checksum "Gemfile" }}
|
20
|
+
paths:
|
21
|
+
- vendor/bundle
|
22
|
+
- run: bundle exec danger
|
23
|
+
- run: bundle exec rake test
|
24
|
+
|
25
|
+
jobs:
|
26
|
+
ruby-2.4:
|
27
|
+
docker:
|
28
|
+
- image: circleci/ruby:2.4
|
29
|
+
steps:
|
30
|
+
*common_steps
|
31
|
+
ruby-2.5:
|
32
|
+
docker:
|
33
|
+
- image: circleci/ruby:2.5
|
34
|
+
steps:
|
35
|
+
*common_steps
|
36
|
+
ruby-2.6:
|
37
|
+
docker:
|
38
|
+
- image: circleci/ruby:2.6
|
39
|
+
steps:
|
40
|
+
*common_steps
|
41
|
+
jruby-9.2:
|
42
|
+
docker:
|
43
|
+
- image: circleci/jruby:9.2
|
44
|
+
environment:
|
45
|
+
JRUBY_OPTS: '--dev'
|
46
|
+
steps:
|
47
|
+
*common_steps
|
48
|
+
jruby-9.2-indy:
|
49
|
+
docker:
|
50
|
+
- image: circleci/jruby:9.2
|
51
|
+
environment:
|
52
|
+
JRUBY_OPTS: '-Xcompile.invokedynamic=true'
|
53
|
+
steps:
|
54
|
+
*common_steps
|
55
|
+
|
56
|
+
workflows:
|
57
|
+
version: 2
|
58
|
+
build:
|
59
|
+
jobs:
|
60
|
+
- ruby-2.4
|
61
|
+
- ruby-2.5
|
62
|
+
- ruby-2.6
|
63
|
+
- jruby-9.2
|
64
|
+
- jruby-9.2-indy
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
require: rt_rubocop_defaults
|
2
|
+
|
1
3
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
4
|
+
TargetRubyVersion: 2.4
|
5
|
+
Exclude:
|
6
|
+
- Dangerfile
|
3
7
|
|
4
8
|
Metrics/LineLength:
|
5
9
|
Max: 99
|
@@ -21,6 +25,3 @@ Metrics/ClassLength:
|
|
21
25
|
Metrics/MethodLength:
|
22
26
|
Exclude:
|
23
27
|
- test/*
|
24
|
-
|
25
|
-
Style/Documentation:
|
26
|
-
Enabled: false
|
data/CHANGELOG.md
CHANGED
data/Dangerfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# -------------------------------------------------------------------------
|
2
4
|
# Has any changes happened inside the actual library code?
|
3
|
-
#
|
5
|
+
# -------------------------------------------------------------------------
|
4
6
|
has_app_changes = !git.modified_files.grep(/lib/).empty?
|
5
7
|
has_test_changes = !git.modified_files.grep(/test/).empty?
|
6
8
|
is_version_bump = git.modified_files.sort == ["CHANGELOG.md", "lib/receptacle/version.rb"].sort
|
@@ -10,7 +12,10 @@ if has_app_changes && !has_test_changes && !is_version_bump
|
|
10
12
|
end
|
11
13
|
|
12
14
|
if !git.modified_files.include?("CHANGELOG.md") && has_app_changes
|
13
|
-
fail(
|
15
|
+
fail(<<~MSG)
|
16
|
+
Please include a CHANGELOG entry.
|
17
|
+
You can find it at [CHANGELOG.md](https://github.com/andreaseger/receptacle/blob/master/CHANGELOG.md).
|
18
|
+
MSG
|
14
19
|
message "Note, we hard-wrap at 80 chars and use 2 spaces after the last line."
|
15
20
|
end
|
16
21
|
|
@@ -23,4 +28,4 @@ warn("Big PR") if git.lines_of_code > 500
|
|
23
28
|
commit_lint.check warn: :all, disable: [:subject_cap]
|
24
29
|
|
25
30
|
# rubocop
|
26
|
-
rubocop.lint
|
31
|
+
rubocop.lint force_exclusion: true
|
data/Gemfile
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
3
4
|
|
4
5
|
gemspec
|
5
6
|
|
6
7
|
group :development, :test do
|
7
|
-
gem
|
8
|
-
gem
|
9
|
-
gem
|
8
|
+
gem "danger"
|
9
|
+
gem "danger-commit_lint"
|
10
|
+
gem "danger-rubocop"
|
10
11
|
end
|
data/Guardfile
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
# A sample Guardfile
|
3
4
|
# More info at https://github.com/guard/guard#readme
|
4
5
|
|
@@ -20,11 +21,11 @@ group :red_green_refactor, halt_on_fail: true do
|
|
20
21
|
# with Minitest::Unit
|
21
22
|
watch(%r{^test/(.*)\/?test_(.*)\.rb$})
|
22
23
|
# watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
23
|
-
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) {
|
24
|
-
watch(%r{^test/test_helper\.rb$}) {
|
25
|
-
watch(%r{^test/fixture\.rb$}) {
|
24
|
+
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { "test" }
|
25
|
+
watch(%r{^test/test_helper\.rb$}) { "test" }
|
26
|
+
watch(%r{^test/fixture\.rb$}) { "test" }
|
26
27
|
end
|
27
|
-
guard :rubocop, all_on_start: false, cli: [
|
28
|
+
guard :rubocop, all_on_start: false, cli: ["--auto-correct"] do
|
28
29
|
watch(/.+\.rb$/)
|
29
30
|
watch(%r{(?:.+/)?\.rubocop\.yml%}) { |m| File.dirname(m[0]) }
|
30
31
|
end
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/receptacle.svg)](https://badge.fury.io/rb/receptacle)
|
4
4
|
[![Gem Downloads](https://img.shields.io/gem/dt/receptacle.svg)](https://rubygems.org/gems/receptacle)
|
5
|
-
[![
|
5
|
+
[![CircleCI](https://circleci.com/gh/andreaseger/receptacle.svg?style=svg)](https://circleci.com/gh/andreaseger/receptacle)
|
6
6
|
[![codecov](https://codecov.io/gh/andreaseger/receptacle/branch/master/graph/badge.svg)](https://codecov.io/gh/andreaseger/receptacle)
|
7
7
|
|
8
8
|
## About
|
data/Rakefile
CHANGED
@@ -1,25 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
4
5
|
|
5
6
|
Rake::TestTask.new(:test) do |t|
|
6
|
-
t.libs <<
|
7
|
-
t.libs <<
|
8
|
-
t.test_files = FileList[
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
9
10
|
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
task :install do
|
17
|
-
require 'rubocop_runner'
|
18
|
-
RubocopRunner.install
|
19
|
-
end
|
20
|
-
end
|
21
|
-
rescue LoadError
|
22
|
-
p 'rubocop not installed'
|
23
|
-
end
|
12
|
+
require "rubocop/rake_task"
|
13
|
+
RuboCop::RakeTask.new
|
14
|
+
|
15
|
+
require "rubocop_runner/rake_task"
|
16
|
+
RubocopRunner::RakeTask.new
|
24
17
|
|
25
18
|
task default: :test
|
data/bin/console
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require "bundler/setup"
|
5
|
+
require "receptacle"
|
6
6
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
9
9
|
|
10
|
-
require
|
10
|
+
require "pry"
|
11
11
|
Pry.start
|
data/examples/simple_repo.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
+
require "bundler/inline"
|
4
5
|
gemfile true do
|
5
|
-
source
|
6
|
-
gem
|
7
|
-
gem
|
6
|
+
source "https://rubygems.org"
|
7
|
+
gem "receptacle", "~>0.3"
|
8
|
+
gem "mongo"
|
8
9
|
end
|
9
|
-
require
|
10
|
+
require "irb"
|
10
11
|
|
11
12
|
# a simple struct to act as business entity
|
12
13
|
User = Struct.new(:id, :name)
|
@@ -18,7 +19,7 @@ module Connection
|
|
18
19
|
|
19
20
|
def initialize
|
20
21
|
::Mongo::Logger.logger.level = Logger::INFO
|
21
|
-
@client = ::Mongo::Client.new([
|
22
|
+
@client = ::Mongo::Client.new(["127.0.0.1:27017"], database: "receptacle")
|
22
23
|
client[:users].delete_many # empty collection
|
23
24
|
end
|
24
25
|
attr_reader :client
|
@@ -45,7 +46,7 @@ module Repository
|
|
45
46
|
class Mongo
|
46
47
|
def find(id:)
|
47
48
|
mongo_to_model(collection.find(_id: id).first)
|
48
|
-
rescue
|
49
|
+
rescue StandardError
|
49
50
|
nil
|
50
51
|
end
|
51
52
|
|
@@ -61,7 +62,7 @@ module Repository
|
|
61
62
|
private
|
62
63
|
|
63
64
|
def mongo_to_model(doc)
|
64
|
-
::User.new(doc[
|
65
|
+
::User.new(doc["_id"], doc["name"])
|
65
66
|
end
|
66
67
|
|
67
68
|
def collection
|
@@ -100,21 +101,21 @@ end
|
|
100
101
|
# configure the repository and use it
|
101
102
|
Repository::User.strategy Repository::User::Strategy::InMemory
|
102
103
|
|
103
|
-
user = Repository::User.create(name:
|
104
|
-
print
|
104
|
+
user = Repository::User.create(name: "foo")
|
105
|
+
print "created user: "
|
105
106
|
p user
|
106
|
-
print
|
107
|
+
print "find user by id: "
|
107
108
|
p Repository::User.find(id: user.id)
|
108
109
|
|
109
110
|
# switching to mongo and we see it's using a different store but keeps the same interface
|
110
111
|
Repository::User.strategy Repository::User::Strategy::Mongo
|
111
112
|
|
112
|
-
print
|
113
|
+
print "search same user in other strategy: "
|
113
114
|
p Repository::User.find(id: user.id)
|
114
115
|
#-> nil
|
115
116
|
|
116
|
-
user = Repository::User.create(name:
|
117
|
-
print
|
117
|
+
user = Repository::User.create(name: "foo mongo")
|
118
|
+
print "create new user: "
|
118
119
|
p user
|
119
|
-
print
|
120
|
+
print "find new user by id: "
|
120
121
|
p Repository::User.find(id: user.id)
|
data/lib/receptacle.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
2
|
+
|
3
|
+
require "receptacle/version"
|
4
|
+
require "receptacle/interface_methods"
|
5
|
+
require "receptacle/method_delegation"
|
5
6
|
|
6
7
|
module Receptacle
|
7
8
|
module Repo
|
data/lib/receptacle/errors.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require
|
2
|
+
|
3
|
+
require "receptacle/registration"
|
4
|
+
require "receptacle/errors"
|
4
5
|
|
5
6
|
module Receptacle
|
6
7
|
module InterfaceMethods
|
7
|
-
RESERVED_METHOD_NAMES = Set.new(%i
|
8
|
+
RESERVED_METHOD_NAMES = Set.new(%i[wrappers mediate strategy delegate_to_strategy])
|
8
9
|
private_constant :RESERVED_METHOD_NAMES
|
9
10
|
|
10
11
|
# registers a method_name for the to be mediated or forwarded to the configured strategy
|
@@ -12,6 +13,7 @@ module Receptacle
|
|
12
13
|
# @param method_name [String] name of method to register
|
13
14
|
def mediate(method_name)
|
14
15
|
raise Errors::ReservedMethodName if RESERVED_METHOD_NAMES.include?(method_name)
|
16
|
+
|
15
17
|
Registration.repositories[self].methods << method_name
|
16
18
|
end
|
17
19
|
alias delegate_to_strategy mediate
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Receptacle
|
3
4
|
# Cache describing which strategy and wrappers need to be applied for this method
|
4
5
|
# @api private
|
@@ -16,7 +17,7 @@ module Receptacle
|
|
16
17
|
# @return [Integer] arity of strategy method according to https://ruby-doc.org/core-2.3.3/Method.html#method-i-arity
|
17
18
|
attr_reader :arity
|
18
19
|
|
19
|
-
def initialize(method_name:, strategy:, wrappers:)
|
20
|
+
def initialize(method_name:, strategy:, wrappers:)
|
20
21
|
@strategy = strategy
|
21
22
|
@before_method_name = :"before_#{method_name}"
|
22
23
|
@after_method_name = :"after_#{method_name}"
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
2
|
+
|
3
|
+
require "receptacle/method_cache"
|
4
|
+
require "receptacle/registration"
|
5
|
+
require "receptacle/errors"
|
5
6
|
|
6
7
|
module Receptacle
|
7
8
|
# module which enables a repository to mediate methods dynamically to wrappers and strategy
|
@@ -39,10 +40,11 @@ module Receptacle
|
|
39
40
|
def __build_method_call_cache(method_name)
|
40
41
|
config = Registration.repositories[self]
|
41
42
|
|
42
|
-
raise Errors::NotConfigured
|
43
|
+
raise Errors::NotConfigured.new(repo: self) if config.strategy.nil?
|
44
|
+
|
43
45
|
MethodCache.new(
|
44
|
-
strategy:
|
45
|
-
wrappers:
|
46
|
+
strategy: config.strategy,
|
47
|
+
wrappers: config.wrappers,
|
46
48
|
method_name: method_name
|
47
49
|
)
|
48
50
|
end
|
@@ -93,6 +95,7 @@ module Receptacle
|
|
93
95
|
end
|
94
96
|
ret = high_arity ? yield(*args) : yield(args)
|
95
97
|
return ret if method_cache.skip_after_wrappers?
|
98
|
+
|
96
99
|
__run_after_wrappers(wrappers, method_cache.after_method_name, args, ret, high_arity)
|
97
100
|
end
|
98
101
|
|
@@ -105,6 +108,7 @@ module Receptacle
|
|
105
108
|
def __run_before_wrappers(wrappers, method_name, args, high_arity = false)
|
106
109
|
wrappers.each do |wrapper|
|
107
110
|
next unless wrapper.respond_to?(method_name)
|
111
|
+
|
108
112
|
args = if high_arity
|
109
113
|
wrapper.public_send(method_name, *args)
|
110
114
|
else
|
@@ -124,6 +128,7 @@ module Receptacle
|
|
124
128
|
def __run_after_wrappers(wrappers, method_name, args, return_value, high_arity = false)
|
125
129
|
wrappers.reverse_each do |wrapper|
|
126
130
|
next unless wrapper.respond_to?(method_name)
|
131
|
+
|
127
132
|
return_value = if high_arity
|
128
133
|
wrapper.public_send(method_name, return_value, *args)
|
129
134
|
else
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Receptacle
|
3
4
|
module TestSupport
|
4
5
|
# with_strategy
|
@@ -7,7 +8,7 @@ module Receptacle
|
|
7
8
|
#
|
8
9
|
# can be used in rspec like this
|
9
10
|
#
|
10
|
-
# require 'receptacle/test_support'
|
11
|
+
# require 'receptacle/test_support'
|
11
12
|
# RSpec.configure do |c|
|
12
13
|
# c.include Receptacle::TestSupport
|
13
14
|
# end
|
data/lib/receptacle/version.rb
CHANGED
data/performance/benchmark.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "bundler/inline"
|
3
4
|
|
4
5
|
gemfile false do
|
5
|
-
source
|
6
|
-
gem
|
7
|
-
gem
|
6
|
+
source "https://rubygems.org"
|
7
|
+
gem "benchmark-ips"
|
8
|
+
gem "receptacle", path: "./.."
|
8
9
|
end
|
9
10
|
|
10
|
-
require_relative
|
11
|
+
require_relative "speed_receptacle"
|
11
12
|
|
12
13
|
Speed.strategy(Speed::Strategy::One)
|
13
14
|
Speed.wrappers [Speed::Wrappers::W1,
|
@@ -17,28 +18,28 @@ Speed.wrappers [Speed::Wrappers::W1,
|
|
17
18
|
Speed::Wrappers::W5,
|
18
19
|
Speed::Wrappers::W6]
|
19
20
|
|
20
|
-
print
|
21
|
+
print "w/ wrappers"
|
21
22
|
Benchmark.ips do |x|
|
22
|
-
x.warmup = 10 if RUBY_ENGINE ==
|
23
|
-
x.report(
|
24
|
-
x.report(
|
25
|
-
x.report(
|
26
|
-
x.report(
|
27
|
-
x.report(
|
28
|
-
x.report(
|
29
|
-
x.report(
|
23
|
+
x.warmup = 10 if RUBY_ENGINE == "jruby"
|
24
|
+
x.report("a: 2x around, 1x before, 1x after") { Speed.a(1) }
|
25
|
+
x.report("b: 1x around, 1x before, 1x after") { Speed.b(1) }
|
26
|
+
x.report("c: 1x before, 1x after") { Speed.c(1) }
|
27
|
+
x.report("d: 1x after") { Speed.d(1) }
|
28
|
+
x.report("e: 1x before") { Speed.e(1) }
|
29
|
+
x.report("f: 1x around") { Speed.f(1) }
|
30
|
+
x.report("g: no wrappers") { Speed.g(1) }
|
30
31
|
end
|
31
32
|
|
32
33
|
Speed.wrappers []
|
33
|
-
print
|
34
|
+
print "method dispatching w/ wrappers"
|
34
35
|
Benchmark.ips do |x|
|
35
|
-
x.warmup = 10 if RUBY_ENGINE ==
|
36
|
-
x.report(
|
37
|
-
x.report(
|
38
|
-
x.report(
|
36
|
+
x.warmup = 10 if RUBY_ENGINE == "jruby"
|
37
|
+
x.report("via receptacle") { Speed.a(:foo) }
|
38
|
+
x.report("direct via public_send") { Speed::Strategy::One.new.public_send(:a, :foo) }
|
39
|
+
x.report("direct via method-method") do
|
39
40
|
m = Speed::Strategy::One.new.method(:a)
|
40
41
|
m.call(:foo)
|
41
42
|
end
|
42
|
-
x.report(
|
43
|
+
x.report("direct method-call") { Speed::Strategy::One.new.a(:foo) }
|
43
44
|
x.compare!
|
44
45
|
end
|
data/performance/profile.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
|
+
|
3
4
|
# run with --profile.api in JRUBY_OPTS
|
4
|
-
require
|
5
|
-
require
|
6
|
-
PROFILE_NAME =
|
5
|
+
require "bundler/inline"
|
6
|
+
require "jruby/profiler"
|
7
|
+
PROFILE_NAME = "receptacle"
|
7
8
|
|
8
9
|
gemfile false do
|
9
|
-
source
|
10
|
-
gem
|
10
|
+
source "https://rubygems.org"
|
11
|
+
gem "receptacle", path: "./.."
|
11
12
|
end
|
12
|
-
require_relative
|
13
|
+
require_relative "speed_receptacle"
|
13
14
|
|
14
15
|
Speed.strategy(Speed::Strategy::One)
|
15
16
|
Speed.wrappers [Speed::Wrappers::W1,
|
@@ -32,8 +33,8 @@ profile_data = JRuby::Profiler.profile do
|
|
32
33
|
end
|
33
34
|
|
34
35
|
profile_printer = JRuby::Profiler::GraphProfilePrinter.new(profile_data)
|
35
|
-
profile_printer.printProfile(File.open("#{PROFILE_NAME}.graph.profile",
|
36
|
+
profile_printer.printProfile(File.open("#{PROFILE_NAME}.graph.profile", "w+"))
|
36
37
|
profile_printer.printProfile(STDOUT)
|
37
38
|
|
38
39
|
profile_printer = JRuby::Profiler::FlatProfilePrinter.new(profile_data)
|
39
|
-
profile_printer.printProfile(File.open("#{PROFILE_NAME}.flat.profile",
|
40
|
+
profile_printer.printProfile(File.open("#{PROFILE_NAME}.flat.profile", "w+"))
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "receptacle"
|
3
4
|
module Speed
|
4
5
|
include Receptacle::Repo
|
5
6
|
mediate :a
|
@@ -29,7 +30,7 @@ module Speed
|
|
29
30
|
args
|
30
31
|
end
|
31
32
|
|
32
|
-
def after_a(return_values,
|
33
|
+
def after_a(return_values, _args)
|
33
34
|
return_values
|
34
35
|
end
|
35
36
|
|
@@ -37,7 +38,7 @@ module Speed
|
|
37
38
|
args
|
38
39
|
end
|
39
40
|
|
40
|
-
def after_f(return_values,
|
41
|
+
def after_f(return_values, _args)
|
41
42
|
return_values
|
42
43
|
end
|
43
44
|
end
|
@@ -48,7 +49,7 @@ module Speed
|
|
48
49
|
args
|
49
50
|
end
|
50
51
|
|
51
|
-
def after_a(return_values,
|
52
|
+
def after_a(return_values, _args)
|
52
53
|
return_values
|
53
54
|
end
|
54
55
|
|
@@ -57,7 +58,7 @@ module Speed
|
|
57
58
|
args
|
58
59
|
end
|
59
60
|
|
60
|
-
def after_b(return_values,
|
61
|
+
def after_b(return_values, _args)
|
61
62
|
return_values
|
62
63
|
end
|
63
64
|
end
|
@@ -72,11 +73,11 @@ module Speed
|
|
72
73
|
end
|
73
74
|
|
74
75
|
class W4
|
75
|
-
def after_a(return_values,
|
76
|
+
def after_a(return_values, _args)
|
76
77
|
return_values
|
77
78
|
end
|
78
79
|
|
79
|
-
def after_d(return_value,
|
80
|
+
def after_d(return_value, _args)
|
80
81
|
return_value
|
81
82
|
end
|
82
83
|
end
|
@@ -86,13 +87,13 @@ module Speed
|
|
86
87
|
args
|
87
88
|
end
|
88
89
|
|
89
|
-
def after_c(return_value,
|
90
|
+
def after_c(return_value, _args)
|
90
91
|
return_value
|
91
92
|
end
|
92
93
|
end
|
93
94
|
|
94
95
|
class W6
|
95
|
-
def after_b(return_value,
|
96
|
+
def after_b(return_value, _args)
|
96
97
|
return_value
|
97
98
|
end
|
98
99
|
|
data/receptacle.gemspec
CHANGED
@@ -1,38 +1,38 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
# frozen_string_literal: true
|
3
|
-
|
2
|
+
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require
|
5
|
+
require "receptacle/version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name =
|
8
|
+
spec.name = "receptacle"
|
9
9
|
spec.version = Receptacle::VERSION
|
10
|
-
spec.authors = [
|
11
|
-
spec.email = [
|
10
|
+
spec.authors = ["Andreas Eger"]
|
11
|
+
spec.email = ["dev@eger-andreas.de"]
|
12
12
|
|
13
|
-
spec.summary =
|
14
|
-
spec.description =
|
15
|
-
spec.homepage =
|
16
|
-
spec.license =
|
13
|
+
spec.summary = "repository pattern"
|
14
|
+
spec.description = "provides functionality for the repository or strategy pattern"
|
15
|
+
spec.homepage = "https://github.com/andreaseger/receptacle"
|
16
|
+
spec.license = "MIT"
|
17
17
|
|
18
|
-
spec.required_ruby_version =
|
18
|
+
spec.required_ruby_version = "~> 2.4"
|
19
19
|
|
20
20
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
21
21
|
f.match(%r{^(test|spec|features)/})
|
22
22
|
end
|
23
|
-
spec.bindir =
|
23
|
+
spec.bindir = "exe"
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
-
spec.require_paths = [
|
25
|
+
spec.require_paths = ["lib"]
|
26
26
|
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_development_dependency
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency
|
37
|
-
spec.add_development_dependency
|
27
|
+
spec.add_development_dependency "bundler", ">= 1.13", "< 3"
|
28
|
+
spec.add_development_dependency "codecov"
|
29
|
+
spec.add_development_dependency "guard"
|
30
|
+
spec.add_development_dependency "guard-minitest"
|
31
|
+
spec.add_development_dependency "guard-rubocop"
|
32
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
33
|
+
spec.add_development_dependency "pry"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rt_rubocop_defaults", ">= 1.0.2", "< 2"
|
36
|
+
spec.add_development_dependency "rubocop_runner", "~> 2.0"
|
37
|
+
spec.add_development_dependency "simplecov", "~> 0.13"
|
38
38
|
end
|
metadata
CHANGED
@@ -1,59 +1,65 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: receptacle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Eger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.13'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3'
|
20
23
|
type: :development
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '1.13'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
34
|
+
name: codecov
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
39
|
+
version: '0'
|
34
40
|
type: :development
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
|
-
- - "
|
44
|
+
- - ">="
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
46
|
+
version: '0'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
48
|
+
name: guard
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
|
-
- - "
|
51
|
+
- - ">="
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
53
|
+
version: '0'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
|
-
- - "
|
58
|
+
- - ">="
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
60
|
+
version: '0'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
62
|
+
name: guard-minitest
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - ">="
|
@@ -67,103 +73,109 @@ dependencies:
|
|
67
73
|
- !ruby/object:Gem::Version
|
68
74
|
version: '0'
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
76
|
+
name: guard-rubocop
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
73
|
-
- - "
|
79
|
+
- - ">="
|
74
80
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
81
|
+
version: '0'
|
76
82
|
type: :development
|
77
83
|
prerelease: false
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
79
85
|
requirements:
|
80
|
-
- - "
|
86
|
+
- - ">="
|
81
87
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
88
|
+
version: '0'
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
90
|
+
name: minitest
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
86
92
|
requirements:
|
87
93
|
- - "~>"
|
88
94
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
95
|
+
version: '5.0'
|
90
96
|
type: :development
|
91
97
|
prerelease: false
|
92
98
|
version_requirements: !ruby/object:Gem::Requirement
|
93
99
|
requirements:
|
94
100
|
- - "~>"
|
95
101
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
102
|
+
version: '5.0'
|
97
103
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
104
|
+
name: pry
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|
100
106
|
requirements:
|
101
|
-
- - "
|
107
|
+
- - ">="
|
102
108
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0
|
109
|
+
version: '0'
|
104
110
|
type: :development
|
105
111
|
prerelease: false
|
106
112
|
version_requirements: !ruby/object:Gem::Requirement
|
107
113
|
requirements:
|
108
|
-
- - "
|
114
|
+
- - ">="
|
109
115
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0
|
116
|
+
version: '0'
|
111
117
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
118
|
+
name: rake
|
113
119
|
requirement: !ruby/object:Gem::Requirement
|
114
120
|
requirements:
|
115
|
-
- - "
|
121
|
+
- - "~>"
|
116
122
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
123
|
+
version: '10.0'
|
118
124
|
type: :development
|
119
125
|
prerelease: false
|
120
126
|
version_requirements: !ruby/object:Gem::Requirement
|
121
127
|
requirements:
|
122
|
-
- - "
|
128
|
+
- - "~>"
|
123
129
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
130
|
+
version: '10.0'
|
125
131
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
132
|
+
name: rt_rubocop_defaults
|
127
133
|
requirement: !ruby/object:Gem::Requirement
|
128
134
|
requirements:
|
129
135
|
- - ">="
|
130
136
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
137
|
+
version: 1.0.2
|
138
|
+
- - "<"
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '2'
|
132
141
|
type: :development
|
133
142
|
prerelease: false
|
134
143
|
version_requirements: !ruby/object:Gem::Requirement
|
135
144
|
requirements:
|
136
145
|
- - ">="
|
137
146
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
147
|
+
version: 1.0.2
|
148
|
+
- - "<"
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '2'
|
139
151
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
152
|
+
name: rubocop_runner
|
141
153
|
requirement: !ruby/object:Gem::Requirement
|
142
154
|
requirements:
|
143
|
-
- - "
|
155
|
+
- - "~>"
|
144
156
|
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
157
|
+
version: '2.0'
|
146
158
|
type: :development
|
147
159
|
prerelease: false
|
148
160
|
version_requirements: !ruby/object:Gem::Requirement
|
149
161
|
requirements:
|
150
|
-
- - "
|
162
|
+
- - "~>"
|
151
163
|
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
164
|
+
version: '2.0'
|
153
165
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
166
|
+
name: simplecov
|
155
167
|
requirement: !ruby/object:Gem::Requirement
|
156
168
|
requirements:
|
157
|
-
- - "
|
169
|
+
- - "~>"
|
158
170
|
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
171
|
+
version: '0.13'
|
160
172
|
type: :development
|
161
173
|
prerelease: false
|
162
174
|
version_requirements: !ruby/object:Gem::Requirement
|
163
175
|
requirements:
|
164
|
-
- - "
|
176
|
+
- - "~>"
|
165
177
|
- !ruby/object:Gem::Version
|
166
|
-
version: '0'
|
178
|
+
version: '0.13'
|
167
179
|
description: provides functionality for the repository or strategy pattern
|
168
180
|
email:
|
169
181
|
- dev@eger-andreas.de
|
@@ -171,10 +183,10 @@ executables: []
|
|
171
183
|
extensions: []
|
172
184
|
extra_rdoc_files: []
|
173
185
|
files:
|
186
|
+
- ".circleci/config.yml"
|
174
187
|
- ".dir-locals.el"
|
175
188
|
- ".gitignore"
|
176
189
|
- ".rubocop.yml"
|
177
|
-
- ".travis.yml"
|
178
190
|
- CHANGELOG.md
|
179
191
|
- CODE_OF_CONDUCT.md
|
180
192
|
- Dangerfile
|
@@ -210,15 +222,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
210
222
|
requirements:
|
211
223
|
- - "~>"
|
212
224
|
- !ruby/object:Gem::Version
|
213
|
-
version: '2.
|
225
|
+
version: '2.4'
|
214
226
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
227
|
requirements:
|
216
228
|
- - ">="
|
217
229
|
- !ruby/object:Gem::Version
|
218
230
|
version: '0'
|
219
231
|
requirements: []
|
220
|
-
|
221
|
-
rubygems_version: 2.6.11
|
232
|
+
rubygems_version: 3.0.2
|
222
233
|
signing_key:
|
223
234
|
specification_version: 4
|
224
235
|
summary: repository pattern
|
data/.travis.yml
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
cache: bundler
|
3
|
-
rvm:
|
4
|
-
- 2.1.10
|
5
|
-
- 2.2.6
|
6
|
-
- 2.3.4
|
7
|
-
- 2.4.1
|
8
|
-
- jruby-9.1.12.0
|
9
|
-
jdk:
|
10
|
-
- oraclejdk8
|
11
|
-
env:
|
12
|
-
- "JRUBY_OPTS='--dev --debug'"
|
13
|
-
- "JRUBY_OPTS='-Xcompile.invokedynamic=true --debug'"
|
14
|
-
matrix:
|
15
|
-
exclude:
|
16
|
-
- rvm: 2.1.10
|
17
|
-
jdk: oraclejdk8
|
18
|
-
env: "JRUBY_OPTS='-Xcompile.invokedynamic=true --debug'"
|
19
|
-
- rvm: 2.2.6
|
20
|
-
jdk: oraclejdk8
|
21
|
-
env: "JRUBY_OPTS='-Xcompile.invokedynamic=true --debug'"
|
22
|
-
- rvm: 2.3.4
|
23
|
-
jdk: oraclejdk8
|
24
|
-
env: "JRUBY_OPTS='-Xcompile.invokedynamic=true --debug'"
|
25
|
-
- rvm: 2.4.1
|
26
|
-
jdk: oraclejdk8
|
27
|
-
env: "JRUBY_OPTS='-Xcompile.invokedynamic=true --debug'"
|
28
|
-
allow_failures:
|
29
|
-
- rvm: jruby-9.1.12.0
|
30
|
-
jdk: oraclejdk8
|
31
|
-
env: "JRUBY_OPTS='-Xcompile.invokedynamic=true --debug'"
|
32
|
-
before_install:
|
33
|
-
- gem update --system
|
34
|
-
- gem install bundler -v 1.15.1
|
35
|
-
before_script:
|
36
|
-
- bundle exec danger
|