Module: Flipper::UI

Defined in:
lib/flipper/ui.rb,
lib/flipper/ui/util.rb,
lib/flipper/ui/error.rb,
lib/flipper/ui/action.rb,
lib/flipper/ui/middleware.rb,
lib/flipper/ui/actions/file.rb,
lib/flipper/ui/actions/home.rb,
lib/flipper/ui/configuration.rb,
lib/flipper/ui/actions/export.rb,
lib/flipper/ui/actions/import.rb,
lib/flipper/ui/actions/feature.rb,
lib/flipper/ui/decorators/gate.rb,
lib/flipper/ui/actions/features.rb,
lib/flipper/ui/actions/settings.rb,
lib/flipper/ui/action_collection.rb,
lib/flipper/ui/decorators/feature.rb,
lib/flipper/ui/actions/actors_gate.rb,
lib/flipper/ui/actions/add_feature.rb,
lib/flipper/ui/actions/groups_gate.rb,
lib/flipper/ui/actions/boolean_gate.rb,
lib/flipper/ui/configuration/option.rb,
lib/flipper/ui/actions/percentage_of_time_gate.rb,
lib/flipper/ui/actions/percentage_of_actors_gate.rb

Defined Under Namespace

Modules: Actions, Decorators, Util Classes: Action, ActionCollection, Configuration, Middleware, Option

Constant Summary collapse

Error =

All flipper ui errors inherit from this.

Class.new(StandardError)
RequestMethodNotSupported =

Raised when a request method (get, post, etc.) is called for an action that does not know how to handle it.

Class.new(Error)

Class Method Summary collapse

Class Method Details

.app(flipper = nil, options = {}) {|builder| ... } ⇒ Object

Yields:

  • (builder)


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/flipper/ui.rb', line 21

def self.app(flipper = nil, options = {})
  env_key = options.fetch(:env_key, 'flipper')
  rack_protection_options = if options.key?(:rack_protection)
    options[:rack_protection]
  else
    {}
  end

  app = ->(_) { [200, { Rack::CONTENT_TYPE => 'text/html' }, ['']] }
  builder = Rack::Builder.new
  yield builder if block_given?

  # Only use Rack::Protection::AuthenticityToken if no other options are
  # provided. Should avoid some pain for some people. If any options are
  # provided then go whole hog and include all of Rack::Protection for
  # backwards compatibility.
  if rack_protection_options.empty?
    builder.use Rack::Protection::AuthenticityToken
  else
    builder.use Rack::Protection, rack_protection_options
  end

  builder.use Rack::MethodOverride
  builder.use Flipper::Middleware::SetupEnv, flipper, env_key: env_key
  builder.use Flipper::UI::Middleware, flipper: flipper, env_key: env_key
  builder.run app
  klass = self
  app = builder.to_app
  app.define_singleton_method(:inspect) { klass.inspect } # pretty rake routes output
  app
end

.configurationObject



58
59
60
# File 'lib/flipper/ui.rb', line 58

def self.configuration
  @configuration ||= ::Flipper::UI::Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Public: yields configuration instance for customizing UI text

Yields:



54
55
56
# File 'lib/flipper/ui.rb', line 54

def self.configure
  yield(configuration)
end

.rootObject



17
18
19
# File 'lib/flipper/ui.rb', line 17

def self.root
  @root ||= Pathname(__FILE__).dirname.expand_path.join('ui')
end