Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chameleon-ruby

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chameleon-ruby

  • 0.1.6
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

chameleon-ruby

Gem Version CI

A Ruby gem for simple interactions with the Chameleon APIs

Your API Secret is generated on the Integrations page. The Full API documentation can be found on our Developer hub!


Quick start

gem 'chameleon-ruby' # in your Gemfile
require 'chameleon' # if needed

Usage and Examples

# configs/initializers/chameleon/rb
Chameleon.configure do |config|
  config.secret = ENV['CHAMELEON_SECRET']
end
##
# In a Background job when content is created / updated
#
Chameleon::SearchItem.index(uid, title: title, actions: actions)

##
# More options and inspiration for what you can do
#
# This example assumes you have a model in your database called `Document` but
#   this can be anything users can create in your system
#

uid = "documents:#{model.id}" # or "#{model.class.name.underscore}:#{model.id}"

title = model.name # the main unit of searchability; for a document this is the user generated title; for a
description = model.description # user generated description; may include tags or other identifying info about this content

actions = [{ kind: 'navigate', url: "/documents/#{model.id}/edit" }]                      # navigate to /documents/3327/edit when clicked
# or
actions = [{ kind: 'navigate', url: "/#{model.class.name.underscore}/#{model.id}/edit" }] # navigate to /documents/3327/edit when clicked

icon = { kind: 'uid', uid: 'cog' } # the icon displayed for this item from the Chameleon icon library
# or
icon = { kind: 'image', image_url: 'https://cdn-icons-png.flaticon.com/512/9908/9908192.png' } # the icon displayed for this item from a public url

##
# Index the content by uid
#
Chameleon::SearchItem.index(uid, title: title, actions: actions)

# Remove when deleted/archived in your system or no longer searchable
#
Chameleon::SearchItem.remove(uid)

##
# Add a user-generated description, if you have it
#
Chameleon::SearchItem.index(uid, title: title, description: description, actions: actions)

##
# Customize the icon from the Chameleon icon library
#
icon = { kind: 'uid', uid: 'cog' } # the icon displayed for this item from the Chameleon icon library
Chameleon::SearchItem.index(uid, title: title, actions: actions, icon: icon)

##
# To restrict content to a specific Chameleon user, set the profile_uids to just that single user
#   This is the only user that will be able to find this content
#
# Use cases:
#   - This document is only visible to the creator
#   - This design or prototype has not been shared yet
#   - A part of the users' onboarding that is not yet complete
#
Chameleon::SearchItem.index(uid, title: title, description: description, actions: actions, profile_uids: [user.id])

##
# Now to extend the Use case to a Document that the creator shares with their co-workers
#   This example assumes that Document has an array of User IDs (an ACL) to share with
#
Chameleon::SearchItem.index(uid, title: title, actions: actions, profile_uids: [user.id, *document.shared_to_user_ids])

##
# To restrict content to a specific Chameleon company, set the company_uids to just that single company
#   This is the only company that will be able to find this content -- all users in this company are able to search for it
#
# Use cases:
#   - This document is only visible to the Company/Account/Tenant of the creator
#   - This design or prototype has been published/shared to your Company
#   - A part of the company's onboarding that is not yet complete
#
Chameleon::SearchItem.index(uid, title: title, actions: actions, company_uids: [company.id])

##
# To restrict content to a specific Chameleon Segment, set the segment_ids to one or many Segments
#   Only current members of these Segments will be able to search for this content
#
# Use cases:
#   - This document is only visible to Company/Account/Tenant administrators (Segment is set to "roles contains admin")
#   - This page is only available to the Enterprise plan (Segment is set to is "plan is enterprise")
#   - An upsell prompt is only relevant for trialing users (Segment is set to "plan_status is trialing")
#
Chameleon::SearchItem.index(uid, title: title, actions: actions, segment_ids: [segment1_id, segment2_id])
Support

If you want to report a bug, or have ideas, feedback or questions about the gem itself, let us know via GitHub issues and the Chameleon team will do their best to provide a helpful answer. Or another to reach us is to Contact us in your dashboard.

License

The gem is available as open source under the terms of the MIT License.

Code of conduct

Everyone interacting in this project’s codebases and issue trackers is expected to follow the code of conduct.

Contribution guide

Pull requests are welcome!

FAQs

Package last updated on 23 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc