Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.
/ gnip-rule Public archive

Ruby library for working with the Gnip Rules API

License

Notifications You must be signed in to change notification settings

singlebrook/gnip-rule

Repository files navigation

gnip-rule

This gem simplifies the effort to add/delete/list rules using the Gnip Rules API. It handles HTTP request/response and helps your rules conform to Gnip's restrictions.

Installation

gem install gnip-rule or add the following to your Gemfile:

gem 'gnip-rule'

Usage

require 'gnip-rule'

rules = GnipRule::Client.new(API_URL, USERNAME, PASSWORD)

# Add as a String, Rule, or Array of either
rules.add('foo')
rules.add('bar', 'tag')
rules.add(['foo', 'bar', 'baz'], 'tag')
rules.add(GnipRule::Rule.new('value', 'tag'))
rules.add([GnipRule::Rule.new('foo', 'bar'), GnipRule::Rule.new('baz', 'tag2')])

# Same with delete
rules.delete('baz', 'tag')
rules.delete(['foo', 'bar'])
rules.delete(GnipRule::Rule.new('value', 'tag'))

# Get all rules
rules_list = rules.list()
rules_list.each { |rule| rule.valid? }
jsonified = rules_list.map { |rule| rule.as_json `}
rules_tagged_foo = rules_list.select { |rule| rule.tag == 'foo' }

Compatibility

See .travis.yml for Ruby versions used in testing.

Contributing

Build Status Code Climate Coverage Status

When submitting pull requests, please do the following to make it easier to incorporate your changes:

  • Include unit and/or functional specs that validate changes you're making.
  • Rebase your changes onto the HEAD of my fork if you can do so cleanly.
  • If submitting additional functionality, provide an example of how to use it.
  • Please keep code style consistent with surrounding code.

Testing

You can run all tests by simply running bundle exec rake test from your favorite shell.

License

Licenced under the MIT License

@eriwen and @singlebrook wrote this software. It is provided free of charge. If you find it helpful, please endorse @eriwen on coderwall: endorse and check out Singlebrook.

About

Ruby library for working with the Gnip Rules API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages