tenantify-sneakers 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.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +2 -0
- data/lib/tenantify/sneakers.rb +8 -0
- data/lib/tenantify/sneakers/version.rb +7 -0
- data/lib/tenantify/sneakers/worker.rb +26 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/tenantify/sneakers/worker_spec.rb +37 -0
- data/tenantify-sneakers.gemspec +27 -0
- metadata +142 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 130505381236b1eb7026a60bb3e6b0935f10bbc0
|
|
4
|
+
data.tar.gz: c6e32b8695e3117f71a43f3d4110af926775c249
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 731f72801dd165ae507a3a00f77008d9324f8e9bbce0d6129aea7edeb3e99984527b8b268df0a7eeae58968e40797b342b5c3d71948dd5066978a5d6797358bf
|
|
7
|
+
data.tar.gz: 75d959fc759fa6625d3dbc8a549f721cd95950a205ed114546586b5ee35e29408c654fc8425536b489899e62906e9c5cb00032e42bbb627e95f06c217ab5485d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2015 Jaime Cabot Campins
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Tenantify::Sneakers
|
|
2
|
+
|
|
3
|
+
Gem to make [Sneakers](https://github.com/jondot/sneakers) work with the [Tenantify](https://github.com/qustodian/tenantify) gem.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'tenantify-sneakers'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
This gem provides a `Tenantify::Sneakers::Worker` module to be used instead
|
|
20
|
+
of `Sneakers::Worker`, that executes the `#work` (or `#work_with_params`) method
|
|
21
|
+
in the context of a particular tenant.
|
|
22
|
+
|
|
23
|
+
The tenant name must be stored in the `:tenant` header of the message metadata.
|
|
24
|
+
|
|
25
|
+
To create a tenantified Sneakers worker:
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
require 'tenantify/sneakers'
|
|
29
|
+
|
|
30
|
+
class Worker
|
|
31
|
+
prepend Tenantify::Sneakers::Worker
|
|
32
|
+
|
|
33
|
+
def work msg
|
|
34
|
+
# do work...
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
*IMPORTANT:* For the gem to work you must *prepend* the `Tenantify::Sneakers::Worker`
|
|
40
|
+
on the class where you are defining the `#work` or `#work_with_params` method.
|
|
41
|
+
If you prepend the `Tenantify::Sneakers::Worker` to a class and then you inherit from
|
|
42
|
+
that class and define the `#work` method on the child class, the gem is not going to
|
|
43
|
+
work.
|
|
44
|
+
|
|
45
|
+
## Contributing
|
|
46
|
+
|
|
47
|
+
1. Fork it ( https://github.com/[my-github-username]/tenantify-sneakers/fork )
|
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
51
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'tenantify'
|
|
2
|
+
require 'sneakers'
|
|
3
|
+
|
|
4
|
+
module Tenantify
|
|
5
|
+
module Sneakers
|
|
6
|
+
module Worker
|
|
7
|
+
|
|
8
|
+
def self.prepended klass
|
|
9
|
+
klass.send(:include, ::Sneakers::Worker)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def work_with_params msg, delivery_info, metadata
|
|
13
|
+
tenant = metadata.headers.fetch 'tenant'
|
|
14
|
+
|
|
15
|
+
Tenantify.using tenant do
|
|
16
|
+
if defined?(super)
|
|
17
|
+
super
|
|
18
|
+
else
|
|
19
|
+
work(msg)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'pry'
|
|
2
|
+
|
|
3
|
+
RSpec.configure do |config|
|
|
4
|
+
|
|
5
|
+
config.expect_with :rspec do |expectations|
|
|
6
|
+
# Best error messages on chained expectations
|
|
7
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
config.mock_with :rspec do |mocks|
|
|
11
|
+
# Prevents you from stubbing a method that does not exist on a real object
|
|
12
|
+
mocks.verify_partial_doubles = true
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
config.disable_monkey_patching!
|
|
16
|
+
config.order = :random
|
|
17
|
+
|
|
18
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'tenantify/sneakers/worker'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Tenantify::Sneakers::Worker do
|
|
4
|
+
|
|
5
|
+
let(:target) { double 'target' }
|
|
6
|
+
|
|
7
|
+
let :test_class do
|
|
8
|
+
Class.new do
|
|
9
|
+
prepend Tenantify::Sneakers::Worker
|
|
10
|
+
|
|
11
|
+
def initialize target
|
|
12
|
+
@target = target
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def work msg
|
|
16
|
+
@target.tenant(Tenantify.current)
|
|
17
|
+
:ack
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
subject { test_class.new target }
|
|
23
|
+
|
|
24
|
+
let(:message) { "the message" }
|
|
25
|
+
let(:delivery_info) { double 'delivery_info' }
|
|
26
|
+
let(:metadata) { double 'metadata', :headers => {'tenant' => "the_tenant"} }
|
|
27
|
+
|
|
28
|
+
describe '#work' do
|
|
29
|
+
it 'properly sets the tenant' do
|
|
30
|
+
expect(target).to receive(:tenant).
|
|
31
|
+
with("the_tenant")
|
|
32
|
+
|
|
33
|
+
subject.work_with_params(message, delivery_info, metadata)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'tenantify/sneakers/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "tenantify-sneakers"
|
|
8
|
+
spec.version = Tenantify::Sneakers::VERSION
|
|
9
|
+
spec.authors = ["Jaime Cabot Campins"]
|
|
10
|
+
spec.email = ["jcabot@gmail.com"]
|
|
11
|
+
spec.summary = %q{Provides some tools to work with the tenantify gem and sneakers}
|
|
12
|
+
spec.homepage = ""
|
|
13
|
+
spec.license = "MIT"
|
|
14
|
+
|
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
18
|
+
spec.require_paths = ["lib"]
|
|
19
|
+
|
|
20
|
+
spec.add_runtime_dependency "tenantify"
|
|
21
|
+
spec.add_runtime_dependency "sneakers"
|
|
22
|
+
|
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
25
|
+
spec.add_development_dependency "rspec"
|
|
26
|
+
spec.add_development_dependency "pry"
|
|
27
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: tenantify-sneakers
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Jaime Cabot Campins
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-01-25 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: tenantify
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - '>='
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - '>='
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: sneakers
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - '>='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - '>='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: bundler
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ~>
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1.6'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ~>
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1.6'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rake
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ~>
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '10.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ~>
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '10.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rspec
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - '>='
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - '>='
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: pry
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - '>='
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - '>='
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
description:
|
|
98
|
+
email:
|
|
99
|
+
- jcabot@gmail.com
|
|
100
|
+
executables: []
|
|
101
|
+
extensions: []
|
|
102
|
+
extra_rdoc_files: []
|
|
103
|
+
files:
|
|
104
|
+
- .gitignore
|
|
105
|
+
- .rspec
|
|
106
|
+
- Gemfile
|
|
107
|
+
- LICENSE.txt
|
|
108
|
+
- README.md
|
|
109
|
+
- Rakefile
|
|
110
|
+
- lib/tenantify/sneakers.rb
|
|
111
|
+
- lib/tenantify/sneakers/version.rb
|
|
112
|
+
- lib/tenantify/sneakers/worker.rb
|
|
113
|
+
- spec/spec_helper.rb
|
|
114
|
+
- spec/tenantify/sneakers/worker_spec.rb
|
|
115
|
+
- tenantify-sneakers.gemspec
|
|
116
|
+
homepage: ''
|
|
117
|
+
licenses:
|
|
118
|
+
- MIT
|
|
119
|
+
metadata: {}
|
|
120
|
+
post_install_message:
|
|
121
|
+
rdoc_options: []
|
|
122
|
+
require_paths:
|
|
123
|
+
- lib
|
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
|
+
requirements:
|
|
126
|
+
- - '>='
|
|
127
|
+
- !ruby/object:Gem::Version
|
|
128
|
+
version: '0'
|
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
|
+
requirements:
|
|
131
|
+
- - '>='
|
|
132
|
+
- !ruby/object:Gem::Version
|
|
133
|
+
version: '0'
|
|
134
|
+
requirements: []
|
|
135
|
+
rubyforge_project:
|
|
136
|
+
rubygems_version: 2.2.2
|
|
137
|
+
signing_key:
|
|
138
|
+
specification_version: 4
|
|
139
|
+
summary: Provides some tools to work with the tenantify gem and sneakers
|
|
140
|
+
test_files:
|
|
141
|
+
- spec/spec_helper.rb
|
|
142
|
+
- spec/tenantify/sneakers/worker_spec.rb
|