tweets 0.0.1.pre2 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,36 +0,0 @@
1
- =begin
2
- = Tweets
3
-
4
- Tweets provides lists of twitter updates based on the supplied string.
5
-
6
- Build: http://github.com/james-turner/tweets
7
- Gem: https://rubygems.org/gems/tweets
8
- Wiki: http://github.com/james-turner/tweets/wiki
9
-
10
- == Installation
11
-
12
- The latest release is available on rubygems.
13
- gem install tweets
14
-
15
- == Require
16
-
17
- To use tweets:
18
- require 'tweets'
19
-
20
- == Usage
21
-
22
- The tweets method is available on all strings
23
- and will return you an array of the latest twitter
24
- status updates
25
-
26
- It couldn't be simpler
27
- "justin bieber".tweets
28
- =>
29
- ["justin bieber is the best",
30
- "i love justin bieber",
31
- "wow, love the latest justin bieber track"
32
- ]
33
-
34
- = COPYRIGHT
35
- Copyright 2011 J. Turner <copyright@phpninjas.co.uk>.
36
- =end
@@ -0,0 +1,21 @@
1
+ require 'open-uri'
2
+ require 'json'
3
+
4
+ module Tweets
5
+ module Extensions
6
+ module String
7
+
8
+ # tweets => []
9
+ #
10
+ #
11
+ def tweets
12
+ tweets = []
13
+ search = URI.escape(self.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
14
+ json = JSON.parse open("http://search.twitter.com/search.json?q=#{search}").read.to_s
15
+
16
+ tweets = json["results"].map { |result| result["text"] } unless json.has_key? "error"
17
+ tweets
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ # tweets => ["one","two","three",...]
2
+ #
3
+ #
4
+ # Includes the tweets string extension
5
+ # inside the String ruby class via mixin
6
+ #
7
+ class String
8
+ include Tweets::Extensions::String
9
+ end
data/lib/tweets.rb CHANGED
@@ -1,50 +1,5 @@
1
- require 'open-uri'
2
- require 'json'
1
+ require 'tweets/extensions'
2
+ require 'tweets/string'
3
3
 
4
- module Tweets
5
- module Extensions
6
- module String
7
4
 
8
- # Retrieve the latest tweets defined by the string version of yourself.
9
- #
10
- # Example:
11
- # >> "justin bieber".tweets
12
- # => ["the bieb is amazing!", "moar beeb plox", ...]
13
- #
14
- # >> "@user".tweets
15
- # => ["@user you are amazing", ...]
16
- #
17
- # >> "#tag"
18
- # => ["#tag is the most cool twitter tag evah ya!", ...]
19
- #
20
- #
21
- # The string can contain the syntax that is allowed in
22
- # any of the twitter search
23
- # @see https://dev.twitter.com/docs/using-search
24
- #
25
- # Arguments:
26
- # language: (String)
27
- def tweets
28
- search = URI.escape(self.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
29
5
 
30
- begin
31
- json = JSON.parse open("http://search.twitter.com/search.json?q=#{search}").read.to_s
32
- json["results"].map { |result| result["text"] } unless json.has_key? "error" || []
33
- rescue SocketError
34
- # no socket connection.
35
- raise SocketError, "Could not connect to the twitter search api. Check your internet connection."
36
- rescue JSON::ParserError
37
- # not json?
38
- raise JSON::ParserError, "The response received from twitter was not JSON. Check your internet connection."
39
- end
40
- end
41
- end
42
- end
43
- end
44
-
45
- # In you go!
46
- #
47
- # Includes the tweets string extension
48
- # inside the String ruby class via mixin
49
- #
50
- String.send :include, Tweets::Extensions::String
data/spec/tweets_spec.rb CHANGED
@@ -1,20 +0,0 @@
1
- $:.unshift "#{File.dirname(__FILE__)}/../lib"
2
- require 'tweets'
3
- require 'tweets/version'
4
- require 'rspec'
5
-
6
- describe "tweets" do
7
-
8
- it "should give me a list" do
9
-
10
- "justin bieber".tweets.should be_a_kind_of Array
11
-
12
- end
13
-
14
- it "version should be in a major.minor.patch.build format" do
15
-
16
- Tweets.version.should match /(\d\.){,3}(\w)/
17
-
18
- end
19
-
20
- end
metadata CHANGED
@@ -1,27 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tweets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre2
5
- prerelease: 6
4
+ version: 0.0.1
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - James Turner
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-13 00:00:00.000000000Z
12
+ date: 2011-10-11 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: Tweet finder for strings
15
- email:
15
+ email: james.turner.phpninja@gmail.com
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - lib/tweets/version.rb
20
+ - README.rdoc
21
21
  - lib/tweets.rb
22
22
  - spec/tweets_spec.rb
23
- - README.rdoc
24
- homepage: http://github.com/james-turner/tweets
23
+ - lib/tweets/extensions.rb
24
+ - lib/tweets/string.rb
25
+ homepage: ''
25
26
  licenses: []
26
27
  post_install_message:
27
28
  rdoc_options: []
@@ -32,13 +33,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
32
33
  requirements:
33
34
  - - ! '>='
34
35
  - !ruby/object:Gem::Version
35
- version: 1.9.2
36
+ version: '0'
36
37
  required_rubygems_version: !ruby/object:Gem::Requirement
37
38
  none: false
38
39
  requirements:
39
- - - ! '>'
40
+ - - ! '>='
40
41
  - !ruby/object:Gem::Version
41
- version: 1.3.1
42
+ version: '0'
42
43
  requirements: []
43
44
  rubyforge_project: tweets
44
45
  rubygems_version: 1.8.10
@@ -1,13 +0,0 @@
1
- module Tweets
2
- module Version
3
- MAJOR = 0
4
- MINOR = 0
5
- PATCH = 1
6
- BUILD = "pre2"
7
- STRING = [MAJOR, MINOR, PATCH, BUILD].join('.')
8
- end
9
-
10
- def self.version
11
- return Version::STRING
12
- end
13
- end