gnip-rule 0.1.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -2,3 +2,4 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 1.8.7
5
+ script: rspec spec
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,9 @@
1
+ When submitting pull requests, please do the following to make it easier to incorporate your changes:
2
+
3
+ * Include unit and/or functional specs that validate changes you're making.
4
+ * Rebase your changes onto the HEAD of my fork if you can do so cleanly.
5
+ * If submitting additional functionality, provide an example of how to use it.
6
+ * Please keep code style consistent with surrounding code.
7
+
8
+ ## Testing
9
+ You can run all tests by simply running `bundle exec rspec spec` from your favorite shell.
data/README.md CHANGED
@@ -1,35 +1,37 @@
1
- # gnip-rule
2
- Ruby library for working with the Gnip Rules API
1
+ # gnip-rule [![Build Status](https://secure.travis-ci.org/eriwen/gnip-rule.png)](http://travis-ci.org/eriwen/gnip-rule)
2
+ This gem simplifies the effort to add/delete/list rules using the [Gnip Rules API](http://support.gnip.com/customer/portal/articles/477713-rules-methods-documentation). It handles HTTP request/response and helps your rules conform to Gnip's restrictions.
3
3
 
4
4
  ## Installation
5
- Add the following to your `Gemfile`:
5
+ `gem install gnip-rule` or add the following to your `Gemfile`:
6
6
 
7
7
  ```ruby
8
- gem 'gnip-rule', '~> 0.1.1'
8
+ gem 'gnip-rule', '~> 0.2'
9
9
  ```
10
10
 
11
- ## Example
11
+ ## Usage
12
12
 
13
13
  ```ruby
14
14
  require 'gnip-rule'
15
15
 
16
- ruler = GnipRule::Client.new(GNIP_API_URL, GNIP_USERNAME, GNIP_PASSWORD)
16
+ rules = GnipRule::Client.new(API_URL, USERNAME, PASSWORD)
17
17
 
18
18
  # Add as a String, Rule, or Array of either
19
- ruler.add('foo')
20
- ruler.add('bar', 'tag')
21
- ruler.add(['foo', 'bar', 'baz'], 'tag')
22
- ruler.add(GnipRule::Rule.new('value', 'tag'))
23
- ruler.add([GnipRule::Rule.new('value', 'tag'), ruler.add(GnipRule::Rule.new('othervalue', 'othertag'))])
19
+ rules.add('foo')
20
+ rules.add('bar', 'tag')
21
+ rules.add(['foo', 'bar', 'baz'], 'tag')
22
+ rules.add(GnipRule::Rule.new('value', 'tag'))
23
+ rules.add([GnipRule::Rule.new('foo', 'bar'), GnipRule::Rule.new('baz', 'tag2')])
24
24
 
25
25
  # Same with delete
26
- ruler.delete('baz', 'tag')
27
- ruler.delete(['foo', 'bar'])
28
- ruler.delete(GnipRule::Rule.new('value', 'tag'))
26
+ rules.delete('baz', 'tag')
27
+ rules.delete(['foo', 'bar'])
28
+ rules.delete(GnipRule::Rule.new('value', 'tag'))
29
29
 
30
- # Get all ruler as Rule objects
31
- ruler.list()
30
+ # Get all rules
31
+ rules.list()
32
32
  ```
33
33
 
34
34
  ## License
35
- MIT License: http://www.opensource.org/licenses/mit-license.php
35
+ Licenced under the [MIT License](http://www.opensource.org/licenses/mit-license.php)
36
+
37
+ I provide this software free of charge. If you find it helpful, please endorse me on coderwall: [![endorse](http://api.coderwall.com/eriwen/endorsecount.png)](http://coderwall.com/eriwen)
@@ -49,16 +49,18 @@ module GnipRule
49
49
 
50
50
  protected
51
51
  def post(url, data)
52
+ err = nil
52
53
  Curl::Easy.http_post(url, data) do |curl|
53
54
  curl.http_auth_types = :basic
54
55
  curl.username = @username
55
56
  curl.password = @password
56
57
  curl.on_complete do |res|
57
58
  if res.response_code >= 400
58
- raise "Got #{res.response_code}; body: #{res.body_str}"
59
+ err = "Got #{res.response_code}; body: #{res.body_str}"
59
60
  end
60
61
  end
61
62
  end
63
+ raise err if err
62
64
  end
63
65
  end
64
66
  end
@@ -10,7 +10,6 @@ module GnipRule
10
10
  end
11
11
 
12
12
  def valid?
13
- # See http://docs.gnip.com/w/page/35663947/Power%20Track
14
13
  if contains_stop_word?(@value) || too_long?(@value) || contains_negated_or?(@value) || too_many_positive_terms?(@value) || contains_empty_source?(@value)
15
14
  return false
16
15
  end
@@ -1,3 +1,3 @@
1
1
  module GnipRule
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2'
3
3
  end
@@ -22,8 +22,6 @@ describe GnipRule::Client do
22
22
  Curl::Easy.should_receive(:http_post)
23
23
  subject.add('value', 'tag')
24
24
  end
25
-
26
- xit 'should raise an error if we got a 4xx or 5xx HTTP status'
27
25
  end
28
26
 
29
27
  describe '#delete' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gnip-rule
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: '0.2'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-19 00:00:00.000000000 Z
12
+ date: 2012-09-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -82,6 +82,7 @@ files:
82
82
  - .pryrc
83
83
  - .rvmrc
84
84
  - .travis.yml
85
+ - CONTRIBUTING.md
85
86
  - Gemfile
86
87
  - LICENSE
87
88
  - README.md