has_integrations 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +80 -0
- data/lib/has_integrations.rb +3 -0
- data/lib/has_integrations/version.rb +3 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 76f150262170dca37ae271bc3c6baec4c9448675
|
4
|
+
data.tar.gz: 36f2bb088946682329c97f1ca651bd9c2188078c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bba00e1df35ea814279d62a07bf31c59fa7c0fbb92463e916958da03df0d1bfca12f4fa19b15b27c329c07ec9f57beb171ca3178647b64f70e3b8b630daf54c3
|
7
|
+
data.tar.gz: b54ae864e5a05498c3576b2931f948a0d40d340e14690bc2a640d5b036a3b6848da9b732232c9f11bd24ed19cc1a6cc86160adedb2029be1491cb224f7ffacd5
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 L. Preston Sego III
|
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,80 @@
|
|
1
|
+
# has_integrations
|
2
|
+
Rails gem for a pattern to manage 3rd party service integrations
|
3
|
+
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'has_integrations'
|
9
|
+
```
|
10
|
+
|
11
|
+
or
|
12
|
+
|
13
|
+
```bash
|
14
|
+
gem install has_integrations
|
15
|
+
```
|
16
|
+
|
17
|
+
Once the gem is installed, in your app, run
|
18
|
+
|
19
|
+
```bash
|
20
|
+
rails generate has_integrations:install
|
21
|
+
```
|
22
|
+
|
23
|
+
Which will set up the `Integration` Model and a migration for the `Integration` model.
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
class User < ApplicationRecord
|
29
|
+
# ...
|
30
|
+
|
31
|
+
has_many :integrations,
|
32
|
+
dependent: :destroy, extend: HasIntegrations,
|
33
|
+
as: :owner
|
34
|
+
|
35
|
+
# ...
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
### Working with Integrations
|
40
|
+
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
# Get Stripe Integration.
|
44
|
+
stripe_integration = user.integrations[:stripe]
|
45
|
+
|
46
|
+
# Set Stripe Integration.
|
47
|
+
# This will create and save a new integration
|
48
|
+
# if there wasn't already a stripe integration record.
|
49
|
+
user.integrations[:stripe] = { "livemode" => false, "stripe_user_id" => 1 }
|
50
|
+
|
51
|
+
# Check if an Integration exists.
|
52
|
+
user.integrations.has?(:stripe)
|
53
|
+
# => true or false
|
54
|
+
```
|
55
|
+
|
56
|
+
This gem assumes each owning object can only have one type of each integration.
|
57
|
+
|
58
|
+
|
59
|
+
## Configuration
|
60
|
+
|
61
|
+
In `config/initializers/has_integrations.rb`:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
HasIntegrations.encryption_key = 'my great key'
|
65
|
+
```
|
66
|
+
Used for `attr_encrypted` on the config column
|
67
|
+
|
68
|
+
## Validations
|
69
|
+
|
70
|
+
With the built in `Integration` class, you can monkey patch to add validations / whatever other logic.
|
71
|
+
|
72
|
+
## TODO
|
73
|
+
|
74
|
+
- Allow the generate to be passed an existing `Integration` class. This may be a weird config option, because the `Integration` class needs `kind`, `encrypted_config`, `owner_id`, and `owner_type` -- would all these columns need to be configurable?
|
75
|
+
|
76
|
+
## Contributing
|
77
|
+
|
78
|
+
- Fork
|
79
|
+
- Open a PR
|
80
|
+
- :-)
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: has_integrations
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- L. Preston Sego III
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
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: rubocop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
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: codeclimate-test-reporter
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: awesome_print
|
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-byebug
|
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: Rails gem for a pattern to manage 3rd party service integrations
|
98
|
+
email: LPSego3+dev@gmail.com
|
99
|
+
executables: []
|
100
|
+
extensions: []
|
101
|
+
extra_rdoc_files: []
|
102
|
+
files:
|
103
|
+
- LICENSE
|
104
|
+
- README.md
|
105
|
+
- lib/has_integrations.rb
|
106
|
+
- lib/has_integrations/version.rb
|
107
|
+
homepage: https://github.com/NullVoxPopuli/has_integrations
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata: {}
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '2.0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 2.5.1
|
128
|
+
signing_key:
|
129
|
+
specification_version: 4
|
130
|
+
summary: HasIntegrations-0.0.1
|
131
|
+
test_files: []
|