npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@digitalnz/plug

v0.2.0

Published

A Rails engine to turn on/off features (Feature flipper).

Downloads

56

Readme

Plug Maintainability Test Coverage

A Rails engine to turn on/off features (Feature flipper).

Features

  • Manage features with notices
  • Manage site notices with themes

Prerequisites

  • Rails version 5 and above
  • MySQL

Getting Started

Add this line to your application's Gemfile:

gem 'plug'

Execute:

→ bundle

And run the install generator:

→ rails g plug:install
→ rails plug:install:migrations
→ rails db:migrate
→ rails s

Usage

Go to localhost:3000/plug and start creating features.

Use the provided method to check if the feature is enabled.

Plug.enabled?('my-awesome-feature-slug')

If you wanted to restrict routes, you can use Plug::Constraint class

Rails.application.routes.draw do
  resources :blog, constraint: Plug::Constraint.new('my-awesome-feature-slug')
end

Notices can be displayed using the Plug.notice method.

<%= Plug.notice('my-awesome-feature-slug') %>

If you have custom HTML for notice, you can pass a block.

<% Plug.notice('my-awesome-feature-slug') do |notice| %>
  <div class="alert">
    <p><%= notice %></p>
  </div>
<% end %>

Buttons

Add buttons to the config block to perform rake tasks from the plug dashboard

  config.buttons = [
    { label: 'Clear cache', task: 'tmp:cache:clear' }
  ]

Themes

Themes can be added in Site Notices. Themes are just string stored in the database. You still need to style the theme.

By default, we have default and dark in config/plug.rb. Below is an example on how you can utilise the theme string.

- theme_class = "site-notice--#{site_notice.theme}"

.site-notice{ class: theme_class }
  %p My site notice
// BEM
.site-notice {
  @include modifier('default') {
    ...
  }
  
  @include modifier('dark') {
    ...
  }
}

Creating new migrations

→ rails g migration MyAwesomeMigration
→ rails g model MyModel name:string slug:string:index
→ rails db:migrate
→ rails db:migrate RAILS_ENV=test
→ rake plug:install:migrations # Run this on the app to copy the new migrations

Running the tests

→ bundle exec rspec spec

Publishing to rubygems.org

Make sure to bump the version. Rubygems don't accept version overrides.

→ gem build plug.gemspec
→ gem push plug-<version>.gem

Publishing to npmjs.com

Make sure to match the version with the Rubygems version.

→ npm login
→ npm publish --access public

TODOs

  • Ability to disable all features using one button
  • Add screenshot
  • Allow block parameters for enabled? method
  • Versioning of features
  • History of feature activities

Questions/Issues?

File a new issue if you have questions or issues.

Contributing

  1. Fork it ( https://github.com/boost/digitalnz/fork )
  2. Create your feature branch (git checkout -b my-awesome-feature)
  3. Commit your changes (git commit -am 'Add my awesome feature!')
  4. Push to the branch (git push origin my-awesome-feature)
  5. Create a new Pull Request