unleash-incognia 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 274bb820b751368f97fe5c99fb5640ea819e3e9388cbe7eacd1a76bc80e7d607
4
+ data.tar.gz: c994e063522e2f6824afd21b6a657143bf326c980b4ba019954236473ef0198b
5
+ SHA512:
6
+ metadata.gz: 9fc5d9a1aa9a8439baa2e4e9d9291d9a091430ca1d7beddb10a80bcf3ffc4d9d925474f29f43303b762502f83b8c4e76bb3aa6cfbc072a2c1f105055ade37f27
7
+ data.tar.gz: 20ac01a6942fcc79d08f1b113aac82e35622b4b9073f3f02014a2af0e866c5877ede1ec3db2cbe2027ecb21008517d903d8f80bcac4fceb9c1e614f7a3a5eaa8
@@ -0,0 +1,5 @@
1
+ # These owners will be the default owners for everything in
2
+ # the repo. Unless a later match takes precedence,
3
+ # @global-owner1 and @global-owner2 will be requested for
4
+ # review when someone opens a pull request.
5
+ * @julianalucena @ottony
@@ -0,0 +1,18 @@
1
+ name: Test
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.0.0
14
+ - name: Run tests
15
+ run: |
16
+ gem install bundler -v 2.2.3
17
+ bundle install
18
+ bundle exec rake spec
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *~
2
+ .rspec_status
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in unleash-incognia.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 13.0"
7
+
8
+ gem "rspec", "~> 3.0"
9
+ gem 'pry'
data/Gemfile.lock ADDED
@@ -0,0 +1,44 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ unleash-incognia (0.1.0)
5
+ unleash (~> 3.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ coderay (1.1.3)
11
+ diff-lcs (1.4.4)
12
+ method_source (1.0.0)
13
+ murmurhash3 (0.1.6)
14
+ pry (0.14.1)
15
+ coderay (~> 1.1)
16
+ method_source (~> 1.0)
17
+ rake (13.0.6)
18
+ rspec (3.10.0)
19
+ rspec-core (~> 3.10.0)
20
+ rspec-expectations (~> 3.10.0)
21
+ rspec-mocks (~> 3.10.0)
22
+ rspec-core (3.10.1)
23
+ rspec-support (~> 3.10.0)
24
+ rspec-expectations (3.10.1)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.10.0)
27
+ rspec-mocks (3.10.2)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.10.0)
30
+ rspec-support (3.10.2)
31
+ unleash (3.2.5)
32
+ murmurhash3 (~> 0.1.6)
33
+
34
+ PLATFORMS
35
+ x86_64-linux
36
+
37
+ DEPENDENCIES
38
+ pry
39
+ rake (~> 13.0)
40
+ rspec (~> 3.0)
41
+ unleash-incognia!
42
+
43
+ BUNDLED WITH
44
+ 2.2.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Incognia
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Unleash::Incognia
2
+
3
+ This gem contains our Unleash custom strategies.
4
+
5
+ ## Installation
6
+
7
+ You must set up [Unleash Ruby SDK](https://github.com/Unleash/unleash-client-ruby) in order to use these custom strategies.
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'unleash-incognia', '~> 0.1'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install unleash-incognia
22
+
23
+ ## Usage
24
+
25
+ You must set up [Unleash Ruby SDK](https://github.com/Unleash/unleash-client-ruby) in order to use these custom strategies.
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/unleash-incognia.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'unleash/incognia'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require 'pry'
10
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ module Unleash
2
+ module Incognia
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ require_relative 'incognia/version'
2
+
3
+ require 'unleash/strategy/base'
4
+ require 'unleash/strategy/member'
5
+ require 'unleash/strategy/email_domain'
6
+ require 'unleash/strategy/organization'
7
+
8
+ module Unleash
9
+ module Incognia ; end
10
+ end
@@ -0,0 +1,27 @@
1
+ module Unleash
2
+ module Strategy
3
+ class EmailDomain < Base
4
+ PARAM = 'emailDomains'.freeze
5
+
6
+ def name
7
+ 'EmailDomain'
8
+ end
9
+
10
+ # requires: params['emailDomains'], context.properties.user_email,
11
+ def is_enabled?(params = {}, context = nil)
12
+ return false unless params.is_a?(Hash) && params.key?(PARAM)
13
+ return false unless params.fetch(PARAM, nil).is_a? String
14
+ return false unless context.class.name == 'Unleash::Context'
15
+ return false unless context.properties.fetch(:user_email, nil)
16
+
17
+ user_email = context.properties.fetch(:user_email)
18
+ user_email_domain = user_email.split('@').last
19
+
20
+ params[PARAM]
21
+ .split(',')
22
+ .map(&:strip)
23
+ .include?(user_email_domain)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,30 @@
1
+ module Unleash
2
+ module Strategy
3
+ class Member < Base
4
+ PARAM = 'memberIds'.freeze
5
+
6
+ def name
7
+ 'Member'
8
+ end
9
+
10
+ # requires: params['memberIds'], context.properties.organization_id,
11
+ # context.properties.user_id
12
+ def is_enabled?(params = {}, context = nil)
13
+ return false unless params.is_a?(Hash) && params.key?(PARAM)
14
+ return false unless params.fetch(PARAM, nil).is_a? String
15
+ return false unless context.class.name == 'Unleash::Context'
16
+ return false unless context.properties.fetch(:user_id, nil)
17
+ return false unless context.properties.fetch(:organization_id, nil)
18
+
19
+ user_id = context.properties.fetch(:user_id)
20
+ organization_id = context.properties.fetch(:organization_id)
21
+ member_id = "#{user_id}##{organization_id}"
22
+
23
+ params[PARAM]
24
+ .split(',')
25
+ .map(&:strip)
26
+ .include?(member_id)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,26 @@
1
+ module Unleash
2
+ module Strategy
3
+ class Organization < Base
4
+ PARAM = 'organizationIds'.freeze
5
+
6
+ def name
7
+ 'Organization'
8
+ end
9
+
10
+ # requires: params['organizationIds'], context.properties.organization_id,
11
+ def is_enabled?(params = {}, context = nil)
12
+ return false unless params.is_a?(Hash) && params.key?(PARAM)
13
+ return false unless params.fetch(PARAM, nil).is_a? String
14
+ return false unless context.class.name == 'Unleash::Context'
15
+ return false unless context.properties.fetch(:organization_id, nil)
16
+
17
+ organization_id = context.properties.fetch(:organization_id)
18
+
19
+ params[PARAM]
20
+ .split(',')
21
+ .map(&:strip)
22
+ .include?(organization_id.to_s)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ require_relative "lib/unleash/incognia/version"
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "unleash-incognia"
5
+ spec.version = Unleash::Incognia::VERSION
6
+ spec.authors = ["Juliana Lucena"]
7
+ spec.email = ["juliana.lucena@incognia.com"]
8
+
9
+ spec.summary = "Extends Unleash Ruby client with Incognia strategies."
10
+ spec.description = "Extends Unleash Ruby client with Incognia strategies."
11
+ spec.homepage = "https://github.com/inloco/unleash-incognia/"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
16
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
17
+ end
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "unleash", "~> 3.2"
23
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unleash-incognia
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Juliana Lucena
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-10-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: unleash
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ description: Extends Unleash Ruby client with Incognia strategies.
28
+ email:
29
+ - juliana.lucena@incognia.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".github/CODEOWNERS"
35
+ - ".github/workflows/main.yml"
36
+ - ".gitignore"
37
+ - Gemfile
38
+ - Gemfile.lock
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - bin/console
43
+ - bin/setup
44
+ - lib/unleash/incognia.rb
45
+ - lib/unleash/incognia/version.rb
46
+ - lib/unleash/strategy/email_domain.rb
47
+ - lib/unleash/strategy/member.rb
48
+ - lib/unleash/strategy/organization.rb
49
+ - unleash-incognia.gemspec
50
+ homepage: https://github.com/inloco/unleash-incognia/
51
+ licenses:
52
+ - MIT
53
+ metadata: {}
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 2.3.0
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubygems_version: 3.2.3
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: Extends Unleash Ruby client with Incognia strategies.
73
+ test_files: []