• Stars
    star
    174
  • Rank 219,104 (Top 5 %)
  • Language
    Ruby
  • License
    Other
  • Created about 14 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Feature Sliders for Rails

What

Arturo provides feature sliders for Rails. It lets you turn features on and off just like feature flippers, but offers more fine-grained control. It supports deploying features only for a given percentage of your users and whitelisting and blacklisting users based on any criteria you can express in Ruby.

The selection is deterministic. So if a user has a feature on Monday, the user will still have it on Tuesday (unless you decrease the feature's deployment percentage or change its white- or blacklist settings).

A quick example

Trish, a developer is working on a new feature: a live feed of recent postings in the user's city that shows up in the user's sidebar. First, she uses Arturo's view helpers to control who sees the sidebar widget:

<%# in app/views/layout/_sidebar.html.erb: %>
  <% if_feature_enabled(:live_postings) do %>
  <div class='widget'>
    <h3>Recent Postings</h3>
    <ol id='live_postings'>
    </ol>
  </div>
<% end %>

Then Trish writes some Javascript that will poll the server for recent postings and put them in the sidebar widget:

// in public/javascript/live_postings.js:
$(function() {
  var livePostingsList = $('#live_postings');
  if (livePostingsList.length > 0) {
    var updatePostingsList = function() {
      livePostingsList.load('/listings/recent');
      setTimeout(updatePostingsList, 30);
    }
    updatePostingsList();
  }
});

Trish uses Arturo's Controller filters to control who has access to the feature:

# in app/controllers/postings_controller:
class PostingsController < ApplicationController
  require_feature :live_postings, only: :recent
  # ...
end

Trish then deploys this code to production. Nobody will see the feature yet, since it's not on for anyone. (In fact, the feature doesn't yet exist in the database, which is the same as being deployed to 0% of users.) A week later, when the company is ready to start deploying the feature to a few people, the product manager, Vijay, signs in to their site and navigates to /features, adds a new feature called "live_postings" and sets its deployment percentage to 3%. After a few days, the operations team decides that the increase in traffic is not going to overwhelm their servers, and Vijay can bump the deployment percentage up to 50%. A few more days go by and they clean up the last few bugs they found with the "live_postings" feature and deploy it to all users.

Installation

gem 'arturo'

Configuration

In Rails

Run the generators:

rails g arturo:migration
rails g arturo:initializer
rails g arturo:routes
rails g arturo:assets

Run the migration:

rake db:migrate

Edit the generated migration as necessary

Edit the configuration

Initializer

Open up the newly-generated config/initializers/arturo_initializer.rb. There are configuration options for the following:

CSS

Open up the newly-generated public/stylesheets/arturo_customizations.css. You can add any overrides you like to the feature configuration page styles here. Do not edit public/stylesheets/arturo.css as that file may be overwritten in future updates to Arturo.

In other frameworks

Arturo is a Rails engine. I want to promote reuse on other frameworks by extracting key pieces into mixins, though this isn't done yet. Open an issue and I'll be happy to work with you on support for your favorite framework.

Deep-Dive

Logging

You can provide a logger in order to inspect Arturo usage. A potential implementation for Rails would be:

Arturo.logger = Rails.logger

Admin Permissions

Arturo::FeatureManagement#may_manage_features? is a method that is run in the context of a Controller or View instance. It should return true if and only if the current user may manage permissions. The default implementation is as follows:

current_user.present? && current_user.admin?

You can change the implementation in config/initializers/arturo_initializer.rb. A reasonable implementation might be

Arturo.permit_management do
  signed_in? && current_user.can?(:manage_features)
end

Feature Recipients

Clients of Arturo may want to deploy new features on a per-user, per-project, per-account, or other basis. For example, it is likely Twitter deployed "#newtwitter" on a per-user basis. Conversely, Facebook -- at least in its early days -- may have deployed features on a per-university basis. It wouldn't make much sense to deploy a feature to one user of a Basecamp project but not to others, so 37Signals would probably want a per-project or per-account basis.

Arturo::FeatureAvailability#feature_recipient is intended to support these many use cases. It is a method that returns the current "thing" (a user, account, project, university, ...) that is a member of the category that is the basis for deploying new features. It should return an Object that responds to #id.

The default implementation simply returns current_user. Like Arturo::FeatureManagement#may_manage_features?, this method can be configured in config/initializers/arturo_initializer.rb. If you want to deploy features on a per-account basis, a reasonable implementation might be

Arturo.feature_recipient do
  current_account
end

or

Arturo.feature_recipient do
  current_user.account
end

If the block returns nil, the feature will be disabled.

Whitelists & Blacklists

Whitelists and blacklists allow you to control exactly which users or accounts will have a feature. For example, if all premium users should have the :awesome feature, place the following in config/initializers/arturo_initializer.rb:

Arturo::Feature.whitelist(:awesome) do |user|
  user.account.premium?
end

If, on the other hand, no users on the free plan should have the :awesome feature, place the following in config/initializers/arturo_initializer.rb:

Arturo::Feature.blacklist(:awesome) do |user|
  user.account.free?
end

If you want to whitelist or blacklist large groups of features at once, you can move the feature argument into the block:

Arturo::Feature.whitelist do |feature, user|
  user.account.has?(feature.to_sym)
end

Feature Conditionals

All that configuration is just a waste of time if Arturo didn't modify the behavior of your application based on feature availability. There are a few ways to do so.

Controller Filters

If an action should only be available to those with a feature enabled, use a before filter. The following will raise a 403 Forbidden error for every action within BookHoldsController that is invoked by a user who does not have the :hold_book feature.

class BookHoldsController < ApplicationController
  require_feature :hold_book
end

require_feature accepts as a second argument a Hash that it passes on to before_action, so you can use :only and :except to specify exactly which actions are filtered.

If you want to customize the page that is rendered on 403 Forbidden responses, put the view in RAILS_ROOT/app/views/arturo/features/forbidden.html.erb. Rails will check there before falling back on Arturo's forbidden page.

Conditional Evaluation

Both controllers and views have access to the if_feature_enabled? and feature_enabled? methods. The former is used like so:

<% if_feature_enabled?(:reserve_table) %>
  <%= link_to 'Reserve a table', new_restaurant_reservation_path(:restaurant_id => @restaurant) %>
<% end %>

The latter can be used like so:

def widgets_for_sidebar
  widgets = []
  widgets << twitter_widget if feature_enabled?(:twitter_integration)
  ...
  widgets
end

Rack Middleware

require 'arturo'
use Arturo::Middleware, feature: :my_feature

Outside a Controller

If you want to check availability outside of a controller or view (really outside of something that has Arturo::FeatureAvailability mixed in), you can ask either

Arturo.feature_enabled_for?(:foo, recipient)

or the slightly fancier

Arturo.foo_enabled_for?(recipient)

Both check whether the foo feature exists and is enabled for recipient.

Caching

Note: Arturo has support for caching Feature lookups, but doesn't yet integrate with Rails's caching. This means you should be very careful when caching actions or pages that involve feature detection as you will get strange behavior when a user who has access to a feature requests a page just after one who does not (and vice versa).

To enable caching Feature lookups, mix Arturo::FeatureCaching into Arturo::Feature and set the cache_ttl. This is best done in an initializer:

Arturo::Feature.extend(Arturo::FeatureCaching)
Arturo::Feature.cache_ttl = 10.minutes

You can also warm the cache on startup:

Arturo::Feature.warm_cache!

This will pre-fetch all Features and put them in the cache.

To use the current cache state when you can't fetch updates from origin:

Arturo::Feature.extend_cache_on_failure = true

The following is the intended support for integration with view caching:

Both the require_feature before filter and the if_feature_enabled block evaluation automatically append a string based on the feature's last_modified timestamp to cache keys that Rails generates. Thus, you don't have to worry about expiring caches when you increase a feature's deployment percentage. See Arturo::CacheSupport for more information.

The Name

Arturo gets its name from Professor Maximillian Arturo on Sliders.

Quality Metrics

Build Status

Code Quality

More Repositories

1

android-floating-action-button

Floating Action Button for Android based on Material Design specification
Java
6,374
star
2

maxwell

Maxwell's daemon, a mysql-to-json kafka producer
Java
3,989
star
3

cross-storage

Cross domain local storage, with permissions
JavaScript
2,190
star
4

samson

Web interface for deployments, with plugin architecture and kubernetes support
Ruby
1,446
star
5

ruby-kafka

A Ruby client library for Apache Kafka
Ruby
1,269
star
6

helm-secrets

DEPRECATED A helm plugin that help manage secrets with Git workflow and store them anywhere
Shell
1,159
star
7

curly

The Curly template language allows separating your logic from the structure of your HTML templates.
Ruby
594
star
8

biz

Time calculations using business hours.
Ruby
488
star
9

racecar

Racecar: a simple framework for Kafka consumers in Ruby
Ruby
486
star
10

zendesk_api_client_rb

Official Ruby Zendesk API Client
Ruby
387
star
11

dropbox-api

Dropbox API Ruby Client
Ruby
362
star
12

zendesk_api_client_php

Official Zendesk API v2 client library for PHP
PHP
335
star
13

stronger_parameters

Type checking and type casting of parameters for Action Pack
Ruby
297
star
14

active_record_shards

Support for sharded databases and replicas for ActiveRecord
Ruby
250
star
15

delivery_boy

A simple way to publish messages to Kafka from Ruby applications
Ruby
238
star
16

android-db-commons

Some common utilities for ContentProvider/ContentResolver/Cursor and other db-related android stuff
Java
223
star
17

radar

High level API and backend for writing web apps that use push messaging
JavaScript
221
star
18

sunshine-conversations-web

The Smooch Web SDK will add live web messaging to your website or web app.
212
star
19

demo_apps

HTML
179
star
20

belvedere

An image picker library for Android
Java
146
star
21

zendesk_jwt_sso_examples

Examples using JWT for Zendesk SSO
Ruby
142
star
22

sunshine-conversations-ios

Smooch
Objective-C
122
star
23

laika

Log, test, intercept and modify Apollo Client's operations
TypeScript
122
star
24

prop

Puts a cork in their requests
Ruby
117
star
25

zendesk_sdk_ios

Zendesk Mobile SDK for iOS
Objective-C
117
star
26

zopim-chat-web-sdk-sample-app

Zendesk Chat Web SDK sample app developed using React
JavaScript
98
star
27

copenhagen_theme

The default theme for Zendesk Guide
Handlebars
98
star
28

app_scaffold

A scaffold for developers to build ZAF v2 apps
JavaScript
90
star
29

node-publisher

A zero-configuration release automation tool for Node packages inspired by create-react-app and Travis CI.
JavaScript
75
star
30

zendesk_apps_tools

Ruby
74
star
31

zendesk_app_framework_sdk

The Zendesk App Framework (ZAF) SDK is a JavaScript library that simplifies cross-frame communication between iframed apps and the Zendesk App Framework
JavaScript
72
star
32

ios_sdk_demo_apps

This repository contains sample iOS code and applications which use our SDKs
Swift
64
star
33

zendesk_sdk_chat_ios

Mobile Chat SDK for iOS
Objective-C
63
star
34

kamcaptcha

A captcha plugin for Rails
Ruby
63
star
35

zcli

A command-line tool for Zendesk
TypeScript
62
star
36

linksf

A mobile website to connect those in need in to services that can help them
JavaScript
62
star
37

sdk_demo_app_android

This is Remember The Date, an Android demo app for our Mobile SDK. All docs available on developer.zendesk.com
Java
61
star
38

property_sets

A way to store attributes in a side table.
Ruby
51
star
39

go-httpclerk

A simple HTTP request/response logger for Go supporting multiple formatters.
Go
51
star
40

android-schema-utils

Android library for simplifying database schema and migrations management.
Java
48
star
41

android_sdk_demo_apps

This repository contains sample android code and applications which use our SDKs
Java
46
star
42

statsd-logger

StatsD + Datadog APM logging server for development - standalone or embedded
Go
44
star
43

sunshine-conversations-android

Smooch Android SDK
42
star
44

support_sdk_ios

Zendesk Support SDK for iOS
Objective-C
37
star
45

react-native-sunshine-conversations

React Native wrapper for Smooch.io
Java
36
star
46

docker-logs-tail

Docker Logs Tail simultaneously tails logs for all running Docker containers, interleaving them in the command line output
JavaScript
35
star
47

call_center

Ruby
34
star
48

curlybars

Handlebars.js compatible templating library in Ruby
Ruby
34
star
49

kasket

A caching layer for ActiveRecord. Puts a cap on your queries!
Ruby
33
star
50

ruby_memprofiler_pprof

Experimental memory profiler for Ruby that emits pprof files.
C
33
star
51

method_struct

Ruby
33
star
52

samlr

Clean room implementation of SAML for Ruby
Ruby
31
star
53

sdk_demo_app_ios

This is Remember The Date, an iOS demo app for our Mobile SDK. All docs available on developer.zendesk.com
Objective-C
31
star
54

volunteer_portal

An event calendar focused on tracking and reporting volunteering opportunities
JavaScript
29
star
55

classic_asp_jwt

A JWT implementation in Classic ASP
ASP
29
star
56

basecrm-ruby

Base CRM API Client
Ruby
29
star
57

ultragrep

the grep that greps the hardest.
C
28
star
58

chariot-tooltips

A javascript library for creating on screen step by step tutorials.
JavaScript
26
star
59

clj-headlights

Clojure on Beam
Clojure
26
star
60

sunshine-conversations-javascript

Javascript API for Sunshine Conversations
JavaScript
26
star
61

android-autoprovider

Utility for creating ContentProviders without boilerplate and with heavy customization options.
Java
25
star
62

basecrm-php

Base CRM API client, PHP edition
PHP
24
star
63

migration_tools

Rake tasks for Rails that add groups to migrations
Ruby
23
star
64

large_object_store

Store large objects in memcache or others by slicing them.
Ruby
22
star
65

term-check

A GitHub app which runs checks for flagged terminology in GitHub repos
Go
22
star
66

basecrm-python

BaseCRM API Client for Python
Python
22
star
67

sdk_unity_plugin

This repository contains a unity plugin which wraps the Zendesk support SDKs
Objective-C
22
star
68

jazon

Test assertions on JSONs have never been easier
Java
21
star
69

ipcluster

Node.js master/worker clustering module for sticky session load balancing using IPTABLES
JavaScript
21
star
70

sunshine-conversations-python

Smooch API Library for Python
Python
21
star
71

cloudwatch-logger

Connects standard input to Amazon CloudWatch Logs
Go
20
star
72

forger

Android library for populating the ContentProvider with test data.
Java
19
star
73

radar_client

High level API and backend for writing web apps that use push messaging
JavaScript
19
star
74

double_doc

Write documentation with your code, to keep them in sync, ideal for public API docs.
Ruby
18
star
75

pakkr

Python pipeline utility library
Python
18
star
76

chat_sdk_ios

Zendesk Chat SDK
Objective-C
18
star
77

goship

Utility that helps find, connect and copy to particular cloud resources using configured providers
Go
18
star
78

url_builder_app

A Zendesk App to help you generate links for agents.
JavaScript
18
star
79

sunshine-conversations-api-quickstart-example

Sample code to get started with the Smooch REST APIs
JavaScript
17
star
80

sunshine-conversations-desk

A sample business system built with Meteor and the Smooch API
CSS
17
star
81

apt-s3

apt method for private S3 buckets
Go
17
star
82

api_client

HTTP API Client Builder
Ruby
16
star
83

zendesk_apps_support

Ruby
16
star
84

iron_bank

An opinionated Ruby interface to the Zuora REST API
Ruby
15
star
85

private_gem

Keeps your private gems private
Ruby
15
star
86

active_record_host_pool

Connect to multiple databases using one ActiveRecord connection
Ruby
15
star
87

sdk_messaging_ios

The Zendesk Messaging SDK
Objective-C
14
star
88

rate_my_app_ios

An open source version of the Rate My App feature from 1.x versions of the Support SDK.
Swift
14
star
89

input_sanitizer

A gem to sanitize hash of incoming data
Ruby
14
star
90

sunshine-conversations-conversation-extension-examples

A series of examples using Smooch conversation extensions
HTML
14
star
91

scala-flow

A lightweight library intended to make developing Google DataFlow jobs in Scala easier.
Scala
14
star
92

punchabunch

Punchabunch: A highly concurrent, easily configurable SSH local-forwarding proxy
Go
14
star
93

zendesk-jira-plugin

Java
13
star
94

sunshine-conversations-ruby

Smooch API Library for Ruby
Ruby
13
star
95

samson_secret_puller

kubernetes sidecar and app to publish secrets to a containerized app.
Ruby
13
star
96

sqlitemaster

Android library for getting existing db schema information from sqlite_master table.
Java
13
star
97

sunshine-conversations-wordpress

PHP
13
star
98

predictive_load

Ruby
12
star
99

sunshine-conversations-api-spec

Sunshine Conversations OpenAPI Specification for v2+
12
star
100

zombie_record

A soft-delete library
Ruby
12
star