No commit activity in last 3 years
No release in over 3 years
Ruby library for working with the Gnip Rules API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.6
~> 2.2
~> 11.3
~> 3.5
~> 2.0

Runtime

< 3, >= 1.8
< 3, >= 1.6
 Project Readme

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.