flagsToggle 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 269f026548cd2bbaaa202abd125e695135c7cb34
4
+ data.tar.gz: 63c0a287f08011acf6e158338813f9542b59467a
5
+ SHA512:
6
+ metadata.gz: 75c9a2a1a4e123c93b9a58764877ebfdb648c3aaa978892c93f740981d8fd4a7a45f6082e10c6ae54e86e5356d71375c390061216913baf1c9a9b13873fed6d9
7
+ data.tar.gz: 3db83544135b6975d88ac6c09ca3e3c90b0a270f5fcad2dfa15f28bb3e5350f33dfa11bcacff524e6a3584a9e77b35784b507f5ed87d9ff7194f2152f91313e2
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'FlagsToggle/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "flagsToggle"
8
+ spec.version = FlagsToggle::VERSION
9
+ spec.authors = ["Osman Perviz"]
10
+ spec.email = ["osmanperviz@gmail.com"]
11
+
12
+ if spec.respond_to?(:metadata)
13
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
14
+ end
15
+
16
+ spec.summary = %q{A flagsToggle is a branching point that your code can utilize to determine whether or not a feature should be made available to one or more customers.}
17
+ spec.description = %q{flagsToggle provides a declarative, layered way of enabling and disabling application functionality at run-time}
18
+ spec.homepage = "https://github.com/osmanperviz/FeatureFlags"
19
+ spec.license = "MIT"
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.8"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec"
28
+ spec.add_development_dependency 'pry'
29
+ end
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in FlagsToggle.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Osman Perviz
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,76 @@
1
+ # featureToggle
2
+ A flagsToggle is a branching point that your code can utilize to determine whether or not a feature should be made available to one or more customers.This simple gem allow you to enable a feature for a specific set of users, or just your team for them to try it out before it's rolled out for everyone.
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+
8
+ gem 'featureToggle'
9
+
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install featureToggle
18
+
19
+ ## Usage
20
+ Run "rake flags_toggle_config" command will generate under AppRoot/config/initializers/Flags.rb file.All configuration will be placed in this file.You may also specify a Rails environment to use a new feature (eg. in all environments, but not in production):
21
+
22
+ * This will generate file like this:
23
+
24
+ FeatureSettings.config do |config|
25
+
26
+ config.app_id = 'Some_id'
27
+ config.enable_some_feature = true
28
+ config.desktop_subdomain = 'Some default subdomain'
29
+
30
+ if Rails.env.production?
31
+ config.app_id = 'Production_id'
32
+ config.enable_some_feature = false
33
+ config.desktop_subdomain = 'www'
34
+ end
35
+
36
+ if Rails.env.development?
37
+ end
38
+
39
+ if Rails.env.staging?
40
+ config.desktop_subdomain = 'staging'
41
+ end
42
+ end
43
+
44
+ If your value is a boolean(PREDICATE) you will access them with question mark at the end:
45
+
46
+ Feature.config.test_value? # true/false
47
+
48
+ If you value is string or number(NON PREDICATE) you will access on normal(Regular) way:
49
+
50
+ Feature.config.app_id # some string or number
51
+
52
+ ## Use Feature in your production code
53
+
54
+ desktop_subdomain = Feature.config.desktop_subdomain # eg. 'www'
55
+
56
+ or
57
+
58
+ if Flags.config.enable_some_feature? do
59
+ #do something
60
+ end
61
+
62
+ ## Environment variable overriding
63
+ In flagsToggle gem environment variable automatically override you custom configuration.
64
+
65
+
66
+ ## Contributing
67
+
68
+ * Fork the project.
69
+
70
+ * Make your feature addition or bug fix.
71
+
72
+ * Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
73
+
74
+ ## License
75
+
76
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "FlagsToggle"
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
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/config/flags.rb ADDED
@@ -0,0 +1,18 @@
1
+ FeatureSettings.config do |config|
2
+ #config.test_value = true
3
+
4
+
5
+ if Rails.env.production?
6
+ #config.test_value = false
7
+ end
8
+
9
+ if Rails.env.development?
10
+
11
+ end
12
+
13
+ if Rails.env.test?
14
+
15
+ end
16
+
17
+
18
+ end
@@ -0,0 +1,15 @@
1
+ require "FlagsToggle/version"
2
+ require "FlagsToggle/feature_settings"
3
+ require "FlagsToggle/configuration"
4
+ require 'FlagsToggle/railtie' if defined?(Rails)
5
+
6
+ module Flags
7
+ class << self
8
+ attr_accessor :config
9
+
10
+ def config
11
+ @config ||= Configuration.new()
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,31 @@
1
+ module Flags
2
+ class Configuration
3
+
4
+ def initialize()
5
+ binding.pry
6
+ attributes = FeatureSettings.get_attributes
7
+ attributes.each do |key,value|
8
+ add_attr(key, value)
9
+ end
10
+
11
+ override_with_envairments
12
+ freeze
13
+ end
14
+
15
+ private
16
+
17
+ def add_attr(name, value)
18
+ self.class.send(:attr_accessor, name)
19
+ self.send("#{name}=",value)
20
+ self.class.send(:alias_method,"#{name.to_sym}?",name) if [true, false].include? value
21
+ self.class.send(:private,name.to_sym) if [true, false].include? value
22
+ end
23
+
24
+ def override_with_envairments
25
+ ENV.to_hash.each do |key,value|
26
+ self.send("#{key.downcase.to_sym}=",value) if self.respond_to?(key.downcase.to_sym)
27
+ end
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,30 @@
1
+ module FeatureSettings
2
+
3
+ class << self
4
+
5
+ def configure
6
+ yield(self)
7
+ end
8
+
9
+ def method_missing(m, *args, &block)
10
+ name = m.to_s
11
+ aname = name.sub("=","")
12
+
13
+ self.class.module_eval do
14
+ attr_accessor aname
15
+ end
16
+ send name, args.first unless aname == name
17
+ end
18
+
19
+ def get_attributes
20
+ attrs = Hash.new
21
+ instance_variables.each do |var|
22
+ str = var.to_s.gsub /^@/, ''
23
+ if respond_to? "#{str}="
24
+ attrs[str.to_sym] = instance_variable_get var
25
+ end
26
+ end
27
+ attrs
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,9 @@
1
+ require "FlagsToggle"
2
+ module Flags
3
+ class Railtie < Rails::Railtie
4
+ railtie_name :Flags
5
+ rake_tasks do
6
+ load 'tasks/flags_toggle_config.rake'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module FlagsToggle
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,5 @@
1
+ desc 'Create flags toggle config class file'
2
+
3
+ task :flags_toggle_config do
4
+ copy_file("#{Gem.loaded_specs["FlagsToggle"].full_gem_path}/config/flags.rb","config/initializers/flags.rb")
5
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flagsToggle
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Osman Perviz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
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: pry
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
+ description: flagsToggle provides a declarative, layered way of enabling and disabling
70
+ application functionality at run-time
71
+ email:
72
+ - osmanperviz@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - CODE_OF_CONDUCT.md
81
+ - FlagsToggle.gemspec
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/setup
88
+ - config/flags.rb
89
+ - lib/FlagsToggle.rb
90
+ - lib/FlagsToggle/configuration.rb
91
+ - lib/FlagsToggle/feature_settings.rb
92
+ - lib/FlagsToggle/railtie.rb
93
+ - lib/FlagsToggle/version.rb
94
+ - lib/tasks/flags_toggle_config.rake
95
+ homepage: https://github.com/osmanperviz/FeatureFlags
96
+ licenses:
97
+ - MIT
98
+ metadata:
99
+ allowed_push_host: https://rubygems.org
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 2.4.5.1
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: A flagsToggle is a branching point that your code can utilize to determine
120
+ whether or not a feature should be made available to one or more customers.
121
+ test_files: []
122
+ has_rdoc: