hackeroo 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +11 -0
- data/hackeroo.gemspec +26 -0
- data/lib/hackeroo.rb +40 -0
- data/lib/hackeroo/action/favorite.rb +19 -0
- data/lib/hackeroo/action/follow.rb +30 -0
- data/lib/hackeroo/action/list_member_added.rb +39 -0
- data/lib/hackeroo/action/mention.rb +46 -0
- data/lib/hackeroo/action/reply.rb +27 -0
- data/lib/hackeroo/action/retweet.rb +27 -0
- data/lib/hackeroo/action/tweet.rb +20 -0
- data/lib/hackeroo/api/arguments.rb +13 -0
- data/lib/hackeroo/api/artists.rb +22 -0
- data/lib/hackeroo/api/performances.rb +22 -0
- data/lib/hackeroo/api/search.rb +37 -0
- data/lib/hackeroo/api/stages.rb +22 -0
- data/lib/hackeroo/api/users.rb +27 -0
- data/lib/hackeroo/api/utils.rb +187 -0
- data/lib/hackeroo/artist.rb +7 -0
- data/lib/hackeroo/base.rb +125 -0
- data/lib/hackeroo/client.rb +73 -0
- data/lib/hackeroo/configurable.rb +87 -0
- data/lib/hackeroo/core_ext/enumerable.rb +10 -0
- data/lib/hackeroo/core_ext/kernel.rb +6 -0
- data/lib/hackeroo/cursor.rb +87 -0
- data/lib/hackeroo/default.rb +77 -0
- data/lib/hackeroo/error.rb +32 -0
- data/lib/hackeroo/error/bad_gateway.rb +11 -0
- data/lib/hackeroo/error/bad_request.rb +10 -0
- data/lib/hackeroo/error/client_error.rb +35 -0
- data/lib/hackeroo/error/configuration_error.rb +8 -0
- data/lib/hackeroo/error/decode_error.rb +9 -0
- data/lib/hackeroo/error/forbidden.rb +10 -0
- data/lib/hackeroo/error/gateway_timeout.rb +11 -0
- data/lib/hackeroo/error/identity_map_key_error.rb +9 -0
- data/lib/hackeroo/error/internal_server_error.rb +11 -0
- data/lib/hackeroo/error/not_acceptable.rb +10 -0
- data/lib/hackeroo/error/not_found.rb +10 -0
- data/lib/hackeroo/error/server_error.rb +28 -0
- data/lib/hackeroo/error/service_unavailable.rb +11 -0
- data/lib/hackeroo/error/too_many_requests.rb +12 -0
- data/lib/hackeroo/error/unauthorized.rb +10 -0
- data/lib/hackeroo/error/unprocessable_entity.rb +10 -0
- data/lib/hackeroo/media/photo.rb +21 -0
- data/lib/hackeroo/performance.rb +7 -0
- data/lib/hackeroo/rate_limit.rb +45 -0
- data/lib/hackeroo/response/parse_json.rb +25 -0
- data/lib/hackeroo/response/raise_error.rb +31 -0
- data/lib/hackeroo/stage.rb +7 -0
- data/lib/hackeroo/user.rb +7 -0
- data/lib/hackeroo/version.rb +18 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 48c32405067f991d0aa88ab8824c422dbe9e2954
|
4
|
+
data.tar.gz: d634c6384382f9f629f92396e001ae9de40d6cc0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f0402b3a4f4ab79c429e42ea266d831c1c8b7c008bf4071f400c8f6458692abff7abd9d5a55d90dda6c5b2184ad0849e55865032b5d0505d508eb27382d94b4b
|
7
|
+
data.tar.gz: 6042b25c77b6fb4a6adc6e8ca17ec6f48b5f9c3493d6d67cd99be6f133d4a1809bf0127ce9476df1c3f1d7cac709e872dd9d3ab9a6b9919afa9136ad826fb975
|
data/Rakefile
ADDED
data/hackeroo.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
# lib = File.expand_path('./lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'hackeroo/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.add_dependency 'faraday', ['~> 0.8', '< 0.10']
|
9
|
+
spec.add_dependency 'multi_json', '~> 1.0'
|
10
|
+
spec.add_dependency 'simple_oauth', '~> 0.2'
|
11
|
+
spec.add_development_dependency 'bundler', '~> 1.0'
|
12
|
+
spec.authors = ["Reza Jelveh"]
|
13
|
+
spec.description = %q{A Ruby interface to the Hackeroo API.}
|
14
|
+
spec.email = ['reza.jelveh@gmail.com']
|
15
|
+
spec.files = %w(Rakefile hackeroo.gemspec)
|
16
|
+
spec.files += Dir.glob("lib/**/*.rb")
|
17
|
+
spec.files += Dir.glob("spec/**/*")
|
18
|
+
spec.homepage = 'http://github.com/fishman/hackeroo'
|
19
|
+
spec.licenses = ['MIT']
|
20
|
+
spec.name = 'hackeroo'
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
spec.required_rubygems_version = '>= 1.3.5'
|
23
|
+
spec.summary = spec.description
|
24
|
+
spec.test_files = Dir.glob("spec/**/*")
|
25
|
+
spec.version = Hackeroo::Version
|
26
|
+
end
|
data/lib/hackeroo.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'hackeroo/default'
|
2
|
+
require 'hackeroo/client'
|
3
|
+
require 'hackeroo/configurable'
|
4
|
+
require 'hackeroo/rate_limit'
|
5
|
+
require 'hackeroo/performance'
|
6
|
+
require 'hackeroo/cursor'
|
7
|
+
|
8
|
+
module Hackeroo
|
9
|
+
class << self
|
10
|
+
include Hackeroo::Configurable
|
11
|
+
|
12
|
+
# Delegate to a Hackeroo::Client
|
13
|
+
#
|
14
|
+
# @return [Hackeroo::Client]
|
15
|
+
def client
|
16
|
+
@client = Hackeroo::Client.new(options) unless defined?(@client) && @client.hash == options.hash
|
17
|
+
@client
|
18
|
+
end
|
19
|
+
|
20
|
+
# Has a client been initialized on the Hackeroo module
|
21
|
+
#
|
22
|
+
# @return [Boolean]
|
23
|
+
def client?
|
24
|
+
!!@client
|
25
|
+
end
|
26
|
+
|
27
|
+
def respond_to_missing?(method_name, include_private=false); client.respond_to?(method_name, include_private); end if RUBY_VERSION >= "1.9"
|
28
|
+
def respond_to?(method_name, include_private=false); client.respond_to?(method_name, include_private) || super; end if RUBY_VERSION < "1.9"
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def method_missing(method_name, *args, &block)
|
33
|
+
return super unless client.respond_to?(method_name)
|
34
|
+
client.send(method_name, *args, &block)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Hackeroo.setup
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'twitter/action/tweet'
|
2
|
+
|
3
|
+
module Twitter
|
4
|
+
module Action
|
5
|
+
class Favorite < Twitter::Action::Tweet
|
6
|
+
attr_reader :target_objects
|
7
|
+
|
8
|
+
# A collection containing the favorited tweet
|
9
|
+
#
|
10
|
+
# @return [Array<Twitter::Tweet>]
|
11
|
+
def targets
|
12
|
+
@targets = Array(@attrs[:targets]).map do |tweet|
|
13
|
+
Twitter::Tweet.fetch_or_new(tweet)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'twitter/base'
|
2
|
+
require 'twitter/creatable'
|
3
|
+
|
4
|
+
module Twitter
|
5
|
+
module Action
|
6
|
+
class Follow < Twitter::Base
|
7
|
+
include Twitter::Creatable
|
8
|
+
attr_reader :max_position, :min_position, :target_objects
|
9
|
+
|
10
|
+
# A collection of users who followed a user
|
11
|
+
#
|
12
|
+
# @return [Array<Twitter::User>]
|
13
|
+
def sources
|
14
|
+
@sources = Array(@attrs[:sources]).map do |user|
|
15
|
+
Twitter::User.fetch_or_new(user)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# A collection containing the followed user
|
20
|
+
#
|
21
|
+
# @return [Array<Twitter::User>]
|
22
|
+
def targets
|
23
|
+
@targets = Array(@attrs[:targets]).map do |user|
|
24
|
+
Twitter::User.fetch_or_new(user)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'twitter/base'
|
2
|
+
require 'twitter/creatable'
|
3
|
+
|
4
|
+
module Twitter
|
5
|
+
module Action
|
6
|
+
class ListMemberAdded < Twitter::Base
|
7
|
+
include Twitter::Creatable
|
8
|
+
attr_reader :max_position, :min_position
|
9
|
+
|
10
|
+
# A collection of users who added a user to a list
|
11
|
+
#
|
12
|
+
# @return [Array<Twitter::User>]
|
13
|
+
def sources
|
14
|
+
@sources = Array(@attrs[:sources]).map do |user|
|
15
|
+
Twitter::User.fetch_or_new(user)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# A collection of lists that were added to
|
20
|
+
#
|
21
|
+
# @return [Array<Twitter::List>]
|
22
|
+
def target_objects
|
23
|
+
@target_objects = Array(@attrs[:target_objects]).map do |list|
|
24
|
+
Twitter::List.fetch_or_new(list)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# A collection of users who were added to a list
|
29
|
+
#
|
30
|
+
# @return [Array<Twitter::User>]
|
31
|
+
def targets
|
32
|
+
@targets = Array(@attrs[:targets]).map do |user|
|
33
|
+
Twitter::User.fetch_or_new(user)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'twitter/base'
|
2
|
+
require 'twitter/creatable'
|
3
|
+
|
4
|
+
module Twitter
|
5
|
+
module Action
|
6
|
+
class Mention < Twitter::Base
|
7
|
+
include Twitter::Creatable
|
8
|
+
attr_reader :max_position, :min_position
|
9
|
+
|
10
|
+
# A collection of users who mentioned a user
|
11
|
+
#
|
12
|
+
# @return [Array<Twitter::User>]
|
13
|
+
def sources
|
14
|
+
@sources = Array(@attrs[:sources]).map do |user|
|
15
|
+
Twitter::User.fetch_or_new(user)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# The user who mentioned a user
|
20
|
+
#
|
21
|
+
# @return [Twitter::User]
|
22
|
+
def source
|
23
|
+
@source = sources.first
|
24
|
+
end
|
25
|
+
|
26
|
+
# A collection of tweets that mention a user
|
27
|
+
#
|
28
|
+
# @return [Array<Twitter::Tweet>]
|
29
|
+
def target_objects
|
30
|
+
@target_objects = Array(@attrs[:target_objects]).map do |tweet|
|
31
|
+
Twitter::Tweet.fetch_or_new(tweet)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# A collection containing the mentioned user
|
36
|
+
#
|
37
|
+
# @return [Array<Twitter::User>]
|
38
|
+
def targets
|
39
|
+
@targets = Array(@attrs[:targets]).map do |user|
|
40
|
+
Twitter::User.fetch_or_new(user)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'twitter/action/tweet'
|
2
|
+
|
3
|
+
module Twitter
|
4
|
+
module Action
|
5
|
+
class Reply < Twitter::Action::Tweet
|
6
|
+
|
7
|
+
# A collection of tweets that reply to a user
|
8
|
+
#
|
9
|
+
# @return [Array<Twitter::Tweet>]
|
10
|
+
def target_objects
|
11
|
+
@target_objects = Array(@attrs[:target_objects]).map do |tweet|
|
12
|
+
Twitter::Tweet.fetch_or_new(tweet)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# A collection that contains the replied-to tweets
|
17
|
+
#
|
18
|
+
# @return [Array<Twitter::Tweet>]
|
19
|
+
def targets
|
20
|
+
@targets = Array(@attrs[:targets]).map do |tweet|
|
21
|
+
Twitter::Tweet.fetch_or_new(tweet)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'twitter/action/tweet'
|
2
|
+
|
3
|
+
module Twitter
|
4
|
+
module Action
|
5
|
+
class Retweet < Twitter::Action::Tweet
|
6
|
+
|
7
|
+
# A collection of retweets
|
8
|
+
#
|
9
|
+
# @return [Array<Twitter::Tweet>]
|
10
|
+
def target_objects
|
11
|
+
@target_objects = Array(@attrs[:target_objects]).map do |tweet|
|
12
|
+
Twitter::Tweet.fetch_or_new(tweet)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# A collection containing the retweeted user
|
17
|
+
#
|
18
|
+
# @return [Array<Twitter::User>]
|
19
|
+
def targets
|
20
|
+
@targets = Array(@attrs[:targets]).map do |user|
|
21
|
+
Twitter::User.fetch_or_new(user)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'twitter/base'
|
2
|
+
require 'twitter/creatable'
|
3
|
+
|
4
|
+
module Twitter
|
5
|
+
module Action
|
6
|
+
class Tweet < Twitter::Base
|
7
|
+
include Twitter::Creatable
|
8
|
+
attr_reader :max_position, :min_position
|
9
|
+
|
10
|
+
# @return [Array<Twitter::User>]
|
11
|
+
def sources
|
12
|
+
@sources = Array(@attrs[:sources]).map do |user|
|
13
|
+
Twitter::User.fetch_or_new(user)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
Status = Tweet
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'hackeroo/api/arguments'
|
2
|
+
require 'hackeroo/api/utils'
|
3
|
+
require 'hackeroo/core_ext/enumerable'
|
4
|
+
require 'hackeroo/error/not_found'
|
5
|
+
require 'hackeroo/artist'
|
6
|
+
|
7
|
+
module Hackeroo
|
8
|
+
module API
|
9
|
+
module Artists
|
10
|
+
include Hackeroo::API::Utils
|
11
|
+
MAX_USERS_PER_REQUEST = 100
|
12
|
+
|
13
|
+
def artists(*args)
|
14
|
+
arguments = Twitter::API::Arguments.new(args)
|
15
|
+
# merge_user!(arguments.options, user)
|
16
|
+
object_from_response(Hackeroo::Performance, :get, "/api/v1/artists.json", arguments.options)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'hackeroo/api/arguments'
|
2
|
+
require 'hackeroo/api/utils'
|
3
|
+
require 'hackeroo/core_ext/enumerable'
|
4
|
+
require 'hackeroo/error/not_found'
|
5
|
+
require 'hackeroo/performance'
|
6
|
+
|
7
|
+
module Hackeroo
|
8
|
+
module API
|
9
|
+
module Performances
|
10
|
+
include Hackeroo::API::Utils
|
11
|
+
MAX_USERS_PER_REQUEST = 100
|
12
|
+
|
13
|
+
def performances(*args)
|
14
|
+
arguments = Twitter::API::Arguments.new(args)
|
15
|
+
# merge_user!(arguments.options, user)
|
16
|
+
object_from_response(Hackeroo::Performance, :get, "/api/v1/performances.json", arguments.options)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'twitter/api/utils'
|
2
|
+
require 'twitter/search_results'
|
3
|
+
|
4
|
+
module Twitter
|
5
|
+
module API
|
6
|
+
module Search
|
7
|
+
include Twitter::API::Utils
|
8
|
+
|
9
|
+
# Returns tweets that match a specified query.
|
10
|
+
#
|
11
|
+
# @see https://dev.twitter.com/docs/api/1.1/get/search/tweets
|
12
|
+
# @see https://dev.twitter.com/docs/using-search
|
13
|
+
# @note Please note that Twitter's search service and, by extension, the Search API is not meant to be an exhaustive source of Tweets. Not all Tweets will be indexed or made available via the search interface.
|
14
|
+
# @rate_limited Yes
|
15
|
+
# @authentication Requires user context
|
16
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
17
|
+
# @param q [String] A search term.
|
18
|
+
# @param options [Hash] A customizable set of options.
|
19
|
+
# @option options [String] :geocode Returns tweets by users located within a given radius of the given latitude/longitude. The location is preferentially taking from the Geotagging API, but will fall back to their Twitter profile. The parameter value is specified by "latitude,longitude,radius", where radius units must be specified as either "mi" (miles) or "km" (kilometers). Note that you cannot use the near operator via the API to geocode arbitrary locations; however you can use this geocode parameter to search near geocodes directly.
|
20
|
+
# @option options [String] :lang Restricts tweets to the given language, given by an ISO 639-1 code.
|
21
|
+
# @option options [String] :locale Specify the language of the query you are sending (only ja is currently effective). This is intended for language-specific clients and the default should work in the majority of cases.
|
22
|
+
# @option options [String] :result_type Specifies what type of search results you would prefer to receive. Options are "mixed", "recent", and "popular". The current default is "mixed."
|
23
|
+
# @option options [Integer] :count The number of tweets to return per page, up to a maximum of 100.
|
24
|
+
# @option options [String] :until Optional. Returns tweets generated before the given date. Date should be formatted as YYYY-MM-DD.
|
25
|
+
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.
|
26
|
+
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
|
27
|
+
# @option options [Boolean, String, Integer] :include_entities The tweet entities node will be disincluded when set to false.
|
28
|
+
# @return [Twitter::SearchResults] Return tweets that match a specified query with search metadata
|
29
|
+
# @example Return tweets related to twitter
|
30
|
+
# Twitter.search('twitter')
|
31
|
+
def search(q, options={})
|
32
|
+
object_from_response(Twitter::SearchResults, :get, "/1.1/search/tweets.json", options.merge(:q => q))
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'hackeroo/api/arguments'
|
2
|
+
require 'hackeroo/api/utils'
|
3
|
+
require 'hackeroo/core_ext/enumerable'
|
4
|
+
require 'hackeroo/error/not_found'
|
5
|
+
require 'hackeroo/stage'
|
6
|
+
|
7
|
+
module Hackeroo
|
8
|
+
module API
|
9
|
+
module Stages
|
10
|
+
include Hackeroo::API::Utils
|
11
|
+
MAX_USERS_PER_REQUEST = 100
|
12
|
+
|
13
|
+
def stages(*args)
|
14
|
+
arguments = Twitter::API::Arguments.new(args)
|
15
|
+
# merge_user!(arguments.options, user)
|
16
|
+
object_from_response(Hackeroo::Performance, :get, "/api/v1/stages.json", arguments.options)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'hackeroo/api/arguments'
|
2
|
+
require 'hackeroo/api/utils'
|
3
|
+
require 'hackeroo/core_ext/enumerable'
|
4
|
+
require 'hackeroo/error/not_found'
|
5
|
+
require 'hackeroo/user'
|
6
|
+
|
7
|
+
module Hackeroo
|
8
|
+
module API
|
9
|
+
module Users
|
10
|
+
include Hackeroo::API::Utils
|
11
|
+
MAX_USERS_PER_REQUEST = 100
|
12
|
+
|
13
|
+
def update_delivery_device(device, options={})
|
14
|
+
object_from_response(Hackeroo::User, :post, "/1.1/account/update_delivery_device.json", options.merge(:device => device))
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def user(*args)
|
19
|
+
arguments = Twitter::API::Arguments.new(args)
|
20
|
+
# merge_user!(arguments.options, user)
|
21
|
+
object_from_response(Hackeroo::User, :get, "/api/v1/performances.json", arguments.options)
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|