Coder Social home page Coder Social logo

feature's People

Contributors

adarsh avatar benjaminoakes avatar cherbst-2112 avatar crackofdusk avatar glaucocustodio avatar javidjamae avatar laertispappas avatar mauriciovieira avatar mgsnova avatar pmeskers avatar stevenwilkin avatar tommyh avatar will3216 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

feature's Issues

Testing with `Feature.run_with_activated(:feature_name)` has no effect under certain circumstances.

Howdy,

Given a feature.yml file with the following snippet:

test:
  features:
    feature_name: false

Using Feature.run_with_activated within a RSpec example like so:

it 'does something' do
  Feature.run_with_activated(:feature_name) do
    # The test, `feature_name` here is disabled. Expected it to be enabled even if `feature.yml` has it as `false` for the test environment.
    Feature.active? 'feature_name' # false
  end
end

does not actually run the code with feature_name active.

Any ideas?

Add auto_refresh

Add possibility to enable auto refresh of feature list. When enabled, before checking whether the feature is enabled or not, the list of features will be refreshed (e.g. from database, yamlconfig, ...).

Default should be current status, where you have to use refresh! explicitly.

Push new version to rubygems

Hey @mgsnova, any chance you could push a new version of this to rubygems? Would love to get access to active_features via a direct gem download.

Thanks!

Lazy refresh instead of refresh on set_repository

In a Rails app, when I do an asset:precompile, my initializers are loaded. When I'm setting the RedisRepository, the lib/feature.rb will call a refresh! when set_repository is called:

https://github.com/mgsnova/feature/blob/master/lib/feature.rb#L41

The problem here is that it will try to access Redis on initialization, but when we're doing asset:precompile, we don't have REDIS environment variables set.

I can work around this in our app doing something like this in my initializer:

begin
  Redis.current.ping
  Feature.set_repository(Feature::Repository::RedisRepository.new("feature_toggles"))
rescue Redis::CannotConnectError
  STDERR.puts "WARN: Could not connect to redis. This is OK in asset:precompile, but not in the live environment"
end

But... I think the better solution would be to not do a forced refresh when the repository is set, but rather do it lazily when any of the Feature methods are called for the first time. Thoughts?

Ability to access a list of all features

It would be very helpful in my application if I could get a list of all of the current features and their respective values for debugging purposes.

It looks like it might just be a matter of exposing @active_features but was curious if there might be a reason to not do this?

Maybe something as simple as: Feature.active_features that returns the hash of feature to value.

Will submit a pull request if this sounds reasonable. love this library.

The generator is not compatible with Rails 4

On Rails 4, app/models/feature_toggle.rb generated by rails g feature:install result in NoMethodError for attr_accessible.

Though you can avoid the error by adding protected_attributes gem which make attr_accessible available on Rails 4, IMO the generator should not add the attr_accessible :name, :active line when unavailable.


Please see a build result of my fork with additional integration tests against Rails 3 and 4.

With RAILS_VERSION=4, generated app/models/feature_toggle.rb result in NoMethodError for attr_accessible which is not provided in Rails 4 by default.

For more details about attr_accessible support in Rails 4, please see protected_attributes gem.

Can I use it to wrap alternative method implementations?

๐Ÿ‘‹ folks! is this a good or bad idea?

class MyClass
  Feature.without(:feature_name) do
    def my_method
      # implementation A
    end
  end
  Feature.with(:feature_name) do
    def my_method
      # implementation B
    end
  end
end

I thought about using the feature switcher inside the my_method method, but there may be other methods that only pertain to one or the other implementation such as:

class MyClass
  Feature.without(:feature_name) do
    def my_method
      # implementation A
      helper_method
    end
    def helper_method
      # some stuffs here. I only make sense in implementation A
    end
  end
  Feature.with(:feature_name) do
    def my_method
      # implementation B
    end
  end
end

Thoughts? And thanks!

Allow YamlRepository.new() to accept a hash?

Hi, I just found your feature gem and it looks like exactly what I need! I would like to have a different config for each environment though, like this:

development:
  features:
    feature_foo: true

test:
  features:
    feature_foo: true

production:
  features:
    feature_foo: false

This way I could have feature_foo on for development and my tests, but default it false in case we forget to disable it on deploy. We could easily do this if YamlRepository.new() accepted a hash:

config_for_env = YAML.load_file("#{Rails.root}/config/feature.yml")[Rails.env]
repo = Feature::Repository::YamlRepository.new(config_for_env)

What do you think? The code in YamlRepository#read_and_parse_file_data() should be able to refactor and support this easily, I'd be happy to send a pull request if this sounds like a good idea.

Pipe Fail Error

I have forked this gem
and included this line in my gemfile:

gem 'feature', :git => "https://github.com/<my-git-account>/feature.git"

if I run this command locally: bundle install --path vendor/bundle, I get this error:

#!/bin/bash -eo pipefail
bundle install --path vendor/bundle
Fetching gem metadata from http://rubygems.org/..........
Fetching https://github.com/<my-git-account>/feature.git

[!] There was an error while loading `feature.gemspec`: cannot load such file -- rake/packagetask
Does it try to require a relative path? That's been removed in Ruby 1.9. Bundler cannot continue.

 #  from /home/circleci/ocm/vendor/bundle/ruby/2.3.0/bundler/gems/feature-15536c16af54/feature.gemspec:1
 #  -------------------------------------------
 >  require 'rubygems/package_task'
 #  
 #  -------------------------------------------
Exited with code 14

Create a repository that uses environment variables

Hi there! We're currently enjoying this gem, and I was looking to contribute. I wanted to see if what I was thinking makes sense.

In our YAML files, most of our lines look like this: stripe: <%= ENV['STRIPE_ENABLED'] == "true" %>. I was wondering if there would be any interest/objection in having an EnvRepository that uses environment variables as the source of feature flagging. If so, I'll create a PR with that functionality.

Thanks for your contributions!

`next_migration_number': NotImplementedError

Hi,

Thanks for sharing this great gem :)

FYI, I'm getting the error next_migration_number': NotImplementedError whenever I run rails g feature:install.
Does it work for anyone?

Here is the log when ran on Rails 3.

$ bundle exec rails g feature:install
Faraday::Builder is now Faraday::RackBuilder.
   identical  config/initializers/feature.rb
   identical  app/models/feature_toggle.rb
PATH_TO_MY_PROJECT/vendor/bundle/ruby/2.1.0/gems/railties-3.2.17/lib/rails/generators/migration.rb:30:in `next_migration_number': NotImplementedError (NotImplementedError)
    from PATH_TO_MY_PROJECT/vendor/bundle/ruby/2.1.0/gems/railties-3.2.17/lib/rails/generators/migration.rb:49:in `migration_template'
    from PATH_TO_MY_PROJECT/vendor/bundle/ruby/2.1.0/gems/feature-1.0.0/lib/feature/generators/install_generator.rb:16:in `create_model_file'
    from PATH_TO_MY_PROJECT/vendor/bundle/ruby/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from PATH_TO_MY_PROJECT/vendor/bundle/ruby/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from PATH_TO_MY_PROJECT/vendor/bundle/ruby/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
    from PATH_TO_MY_PROJECT/vendor/bundle/ruby/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
    from PATH_TO_MY_PROJECT/vendor/bundle/ruby/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
    from PATH_TO_MY_PROJECT/vendor/bundle/ruby/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
    from PATH_TO_MY_PROJECT/vendor/bundle/ruby/2.1.0/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
    from PATH_TO_MY_PROJECT/vendor/bundle/ruby/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from PATH_TO_MY_PROJECT/vendor/bundle/ruby/2.1.0/gems/railties-3.2.17/lib/rails/generators.rb:171:in `invoke'
    from PATH_TO_MY_PROJECT/vendor/bundle/ruby/2.1.0/gems/railties-3.2.17/lib/rails/commands/generate.rb:12:in `<top (required)>'
    from PATH_TO_MY_PROJECT/vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:251:in `require'
    from PATH_TO_MY_PROJECT/vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:251:in `block in require'
    from PATH_TO_MY_PROJECT/vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:236:in `load_dependency'
    from PATH_TO_MY_PROJECT/vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:251:in `require'
    from PATH_TO_MY_PROJECT/vendor/bundle/ruby/2.1.0/gems/railties-3.2.17/lib/rails/commands.rb:29:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

ActiveRecord::ConnectionNotEstablished

Hi,

I'm getting the error with ActiveRecord, I don't use ActiveRecord in my application.
Is there any way to disable ActiveRecord in features gem?

Failure/Error: Unable to find matching line from backtrace
ActiveRecord::ConnectionNotEstablished:
ActiveRecord::ConnectionNotEstablished

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.