Giter VIP home page Giter VIP logo

refocus-ruby's Introduction

Refocus

A ruby client library and CLI for Refocus.

Installation

Add this line to your application's Gemfile:

gem 'refocus'

And then execute:

$ bundle

Or install it yourself as:

$ gem install refocus

Usage

CLI

Usage:
    refocus [OPTIONS] SUBCOMMAND [ARG] ...

Parameters:
    SUBCOMMAND                    subcommand
    [ARG] ...                     subcommand arguments

Subcommands:
    samples:get                   Print a sample

Options:
    -h, --help                    print help

Library

Refocus will pick up REFOCUS_URL and REFOCUS_API_TOKEN environment vars if these are set. You can create a client like this in a pry or irb session, or in your ruby program:

require "refocus"

# Using env vars. This will fail if REFOCUS_URLand REFOCUS_API_TOKEN are unset:
refocus = Refocus.client

# Doing it yourself:
refocus = Refocus.client(url: "https://my.refocus.instance.com", token: "some-token-i-generated")

Subjects

You can manage subjects like this:

# Create a root subject (returns a hash):
refocus.subjects.create(name: "my-subject")

# Create a child subject (returns a hash):
refocus.subjects.create(parent: "my-subject", name: "child-subject")

# List all subjects (includes root subjects and children, in an array):
refocus.subjects.all

# Delete a child subject (returns a hash):
refocus.subjects.delete(name: "my-subject.child-subject")

Aspects

You can manage aspects like this:

# Create an aspect:
refocus.aspects.create(name: "my-aspect", "timeout" => "5m")

# Describe an aspect:
refocus.aspects.get(name: "my-aspect")

# Delete an aspect by name:
refocus.aspects.delete(name: "my-aspect")

Samples

You can manage samples like this:

# Instantiate the samples client
samples_client = refocus.samples   

# Create or update a sample:
samples_client.upsert(name: "my-subject.child-subject", aspect: "my-aspect", value: '100')

# Create or update a sample with a custom request body
request_body = {name: "my-subject.child-subject|my-aspect", value: '100', messageCode: '100%', messageBody: "Great Results!", relatedLinks: [{name:'example_1', url:'https://www.example_1.com'}]}
samples_client.upsert_custom_body(request_body)

# Describe a sample:
samples_client.get(subject: "my-subject", aspect: "my-aspect")

# List samples:
samples_client.list(limit: 50)

# Create or update samples in bulk:
samples_collector = samples_client.collector
samples_collector.add(name: "my-subject.child-subject", aspect: "my-aspect-1", value: '100')
samples_collector.add(name: "my-subject.child-subject", aspect: "my-aspect-2", message_code: '100%')
upsert_bulk_response = samples_collector.upsert_bulk

# Check the status of the previous upsert_bulk call
# job_id needs to be parsed from the initial bulk upsert response. e.g.,
job_id = upsert_bulk_response["jobId"]
upsert_bulk_status = samples_collector.check_status(job_id)

Lenses

Lenses are not supported at this time.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/heroku/refocus-ruby

refocus-ruby's People

Contributors

kkim-sf avatar sheax0r avatar

Stargazers

 avatar

Watchers

 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

Forkers

kkim-sf

refocus-ruby's Issues

Tests + rubocop

This project has no tests, no rubocop, and no travis integration. Add these things.

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.