hackeroo 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +11 -0
  3. data/hackeroo.gemspec +26 -0
  4. data/lib/hackeroo.rb +40 -0
  5. data/lib/hackeroo/action/favorite.rb +19 -0
  6. data/lib/hackeroo/action/follow.rb +30 -0
  7. data/lib/hackeroo/action/list_member_added.rb +39 -0
  8. data/lib/hackeroo/action/mention.rb +46 -0
  9. data/lib/hackeroo/action/reply.rb +27 -0
  10. data/lib/hackeroo/action/retweet.rb +27 -0
  11. data/lib/hackeroo/action/tweet.rb +20 -0
  12. data/lib/hackeroo/api/arguments.rb +13 -0
  13. data/lib/hackeroo/api/artists.rb +22 -0
  14. data/lib/hackeroo/api/performances.rb +22 -0
  15. data/lib/hackeroo/api/search.rb +37 -0
  16. data/lib/hackeroo/api/stages.rb +22 -0
  17. data/lib/hackeroo/api/users.rb +27 -0
  18. data/lib/hackeroo/api/utils.rb +187 -0
  19. data/lib/hackeroo/artist.rb +7 -0
  20. data/lib/hackeroo/base.rb +125 -0
  21. data/lib/hackeroo/client.rb +73 -0
  22. data/lib/hackeroo/configurable.rb +87 -0
  23. data/lib/hackeroo/core_ext/enumerable.rb +10 -0
  24. data/lib/hackeroo/core_ext/kernel.rb +6 -0
  25. data/lib/hackeroo/cursor.rb +87 -0
  26. data/lib/hackeroo/default.rb +77 -0
  27. data/lib/hackeroo/error.rb +32 -0
  28. data/lib/hackeroo/error/bad_gateway.rb +11 -0
  29. data/lib/hackeroo/error/bad_request.rb +10 -0
  30. data/lib/hackeroo/error/client_error.rb +35 -0
  31. data/lib/hackeroo/error/configuration_error.rb +8 -0
  32. data/lib/hackeroo/error/decode_error.rb +9 -0
  33. data/lib/hackeroo/error/forbidden.rb +10 -0
  34. data/lib/hackeroo/error/gateway_timeout.rb +11 -0
  35. data/lib/hackeroo/error/identity_map_key_error.rb +9 -0
  36. data/lib/hackeroo/error/internal_server_error.rb +11 -0
  37. data/lib/hackeroo/error/not_acceptable.rb +10 -0
  38. data/lib/hackeroo/error/not_found.rb +10 -0
  39. data/lib/hackeroo/error/server_error.rb +28 -0
  40. data/lib/hackeroo/error/service_unavailable.rb +11 -0
  41. data/lib/hackeroo/error/too_many_requests.rb +12 -0
  42. data/lib/hackeroo/error/unauthorized.rb +10 -0
  43. data/lib/hackeroo/error/unprocessable_entity.rb +10 -0
  44. data/lib/hackeroo/media/photo.rb +21 -0
  45. data/lib/hackeroo/performance.rb +7 -0
  46. data/lib/hackeroo/rate_limit.rb +45 -0
  47. data/lib/hackeroo/response/parse_json.rb +25 -0
  48. data/lib/hackeroo/response/raise_error.rb +31 -0
  49. data/lib/hackeroo/stage.rb +7 -0
  50. data/lib/hackeroo/user.rb +7 -0
  51. data/lib/hackeroo/version.rb +18 -0
  52. metadata +157 -0
@@ -0,0 +1,21 @@
1
+ require 'twitter/identity'
2
+
3
+ module Twitter
4
+ module Media
5
+ class Photo < Twitter::Identity
6
+ attr_reader :display_url, :expanded_url, :indices, :media_url,
7
+ :media_url_https, :url
8
+
9
+ # Returns an array of photo sizes
10
+ #
11
+ # @return [Array<Twitter::Size>]
12
+ def sizes
13
+ @sizes ||= Array(@attrs[:sizes]).inject({}) do |object, (key, value)|
14
+ object[key] = Twitter::Size.fetch_or_new(value)
15
+ object
16
+ end
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,7 @@
1
+ require 'hackeroo/base'
2
+ require 'hackeroo/error/identity_map_key_error'
3
+
4
+ module Hackeroo
5
+ class Performance < Hackeroo::Base
6
+ end
7
+ end
@@ -0,0 +1,45 @@
1
+ module Hackeroo
2
+ class RateLimit
3
+ attr_reader :attrs
4
+ alias to_hash attrs
5
+
6
+ # @return [Hackeroo::RateLimit]
7
+ def initialize(attrs={})
8
+ @attrs = attrs
9
+ end
10
+
11
+ # @return [Integer]
12
+ def limit
13
+ limit = @attrs['x-rate-limit-limit']
14
+ limit.to_i if limit
15
+ end
16
+
17
+ # @return [Integer]
18
+ def remaining
19
+ remaining = @attrs['x-rate-limit-remaining']
20
+ remaining.to_i if remaining
21
+ end
22
+
23
+ # @return [Time]
24
+ def reset_at
25
+ reset = @attrs['x-rate-limit-reset']
26
+ Time.at(reset.to_i) if reset
27
+ end
28
+
29
+ # @return [Integer]
30
+ def reset_in
31
+ [(reset_at - Time.now).ceil, 0].max if reset_at
32
+ end
33
+ alias retry_after reset_in
34
+
35
+ # Update the attributes of a RateLimit
36
+ #
37
+ # @param attrs [Hash]
38
+ # @return [Hackeroo::RateLimit]
39
+ def update(attrs)
40
+ @attrs.update(attrs)
41
+ self
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,25 @@
1
+ require 'faraday'
2
+ require 'multi_json'
3
+
4
+ module Hackeroo
5
+ module Response
6
+ class ParseJson < Faraday::Response::Middleware
7
+
8
+ def parse(body)
9
+ case body
10
+ when /\A^\s*$\z/, nil
11
+ nil
12
+ else
13
+ MultiJson.decode(body, :symbolize_keys => true)
14
+ end
15
+ end
16
+
17
+ def on_complete(env)
18
+ if respond_to?(:parse)
19
+ env[:body] = parse(env[:body]) unless [204, 301, 302, 304].include?(env[:status])
20
+ end
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,31 @@
1
+ require 'faraday'
2
+ require 'hackeroo/error/bad_gateway'
3
+ require 'hackeroo/error/bad_request'
4
+ require 'hackeroo/error/forbidden'
5
+ require 'hackeroo/error/gateway_timeout'
6
+ require 'hackeroo/error/internal_server_error'
7
+ require 'hackeroo/error/not_acceptable'
8
+ require 'hackeroo/error/not_found'
9
+ require 'hackeroo/error/service_unavailable'
10
+ require 'hackeroo/error/too_many_requests'
11
+ require 'hackeroo/error/unauthorized'
12
+ require 'hackeroo/error/unprocessable_entity'
13
+
14
+ module Hackeroo
15
+ module Response
16
+ class RaiseError < Faraday::Response::Middleware
17
+
18
+ def on_complete(env)
19
+ status_code = env[:status].to_i
20
+ error_class = @klass.errors[status_code]
21
+ raise error_class.from_response(env) if error_class
22
+ end
23
+
24
+ def initialize(app, klass)
25
+ @klass = klass
26
+ super(app)
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,7 @@
1
+ require 'hackeroo/base'
2
+ require 'hackeroo/error/identity_map_key_error'
3
+
4
+ module Hackeroo
5
+ class Stage < Hackeroo::Base
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'hackeroo/base'
2
+ require 'hackeroo/error/identity_map_key_error'
3
+
4
+ module Hackeroo
5
+ class User < Hackeroo::Base
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ module Hackeroo
2
+ class Version
3
+ MAJOR = 0 unless defined? Hackeroo::Version::MAJOR
4
+ MINOR = 1 unless defined? Hackeroo::Version::MINOR
5
+ PATCH = 0 unless defined? Hackeroo::Version::PATCH
6
+ PRE = nil unless defined? Hackeroo::Version::PRE
7
+
8
+ class << self
9
+
10
+ # @return [String]
11
+ def to_s
12
+ [MAJOR, MINOR, PATCH, PRE].compact.join('.')
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hackeroo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Reza Jelveh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '0.8'
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '0.10'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.8'
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: '0.10'
33
+ - !ruby/object:Gem::Dependency
34
+ name: multi_json
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ~>
38
+ - !ruby/object:Gem::Version
39
+ version: '1.0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '1.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: simple_oauth
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '0.2'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ version: '0.2'
61
+ - !ruby/object:Gem::Dependency
62
+ name: bundler
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: '1.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ version: '1.0'
75
+ description: A Ruby interface to the Hackeroo API.
76
+ email:
77
+ - reza.jelveh@gmail.com
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - Rakefile
83
+ - hackeroo.gemspec
84
+ - lib/hackeroo.rb
85
+ - lib/hackeroo/action/reply.rb
86
+ - lib/hackeroo/action/favorite.rb
87
+ - lib/hackeroo/action/list_member_added.rb
88
+ - lib/hackeroo/action/mention.rb
89
+ - lib/hackeroo/action/follow.rb
90
+ - lib/hackeroo/action/tweet.rb
91
+ - lib/hackeroo/action/retweet.rb
92
+ - lib/hackeroo/base.rb
93
+ - lib/hackeroo/version.rb
94
+ - lib/hackeroo/stage.rb
95
+ - lib/hackeroo/client.rb
96
+ - lib/hackeroo/response/raise_error.rb
97
+ - lib/hackeroo/response/parse_json.rb
98
+ - lib/hackeroo/artist.rb
99
+ - lib/hackeroo/user.rb
100
+ - lib/hackeroo/core_ext/kernel.rb
101
+ - lib/hackeroo/core_ext/enumerable.rb
102
+ - lib/hackeroo/error/gateway_timeout.rb
103
+ - lib/hackeroo/error/bad_request.rb
104
+ - lib/hackeroo/error/decode_error.rb
105
+ - lib/hackeroo/error/configuration_error.rb
106
+ - lib/hackeroo/error/forbidden.rb
107
+ - lib/hackeroo/error/bad_gateway.rb
108
+ - lib/hackeroo/error/service_unavailable.rb
109
+ - lib/hackeroo/error/server_error.rb
110
+ - lib/hackeroo/error/too_many_requests.rb
111
+ - lib/hackeroo/error/client_error.rb
112
+ - lib/hackeroo/error/not_acceptable.rb
113
+ - lib/hackeroo/error/not_found.rb
114
+ - lib/hackeroo/error/internal_server_error.rb
115
+ - lib/hackeroo/error/identity_map_key_error.rb
116
+ - lib/hackeroo/error/unprocessable_entity.rb
117
+ - lib/hackeroo/error/unauthorized.rb
118
+ - lib/hackeroo/media/photo.rb
119
+ - lib/hackeroo/configurable.rb
120
+ - lib/hackeroo/api/users.rb
121
+ - lib/hackeroo/api/search.rb
122
+ - lib/hackeroo/api/stages.rb
123
+ - lib/hackeroo/api/performances.rb
124
+ - lib/hackeroo/api/arguments.rb
125
+ - lib/hackeroo/api/artists.rb
126
+ - lib/hackeroo/api/utils.rb
127
+ - lib/hackeroo/cursor.rb
128
+ - lib/hackeroo/rate_limit.rb
129
+ - lib/hackeroo/error.rb
130
+ - lib/hackeroo/default.rb
131
+ - lib/hackeroo/performance.rb
132
+ homepage: http://github.com/fishman/hackeroo
133
+ licenses:
134
+ - MIT
135
+ metadata: {}
136
+ post_install_message:
137
+ rdoc_options: []
138
+ require_paths:
139
+ - lib
140
+ required_ruby_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - '>='
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - '>='
148
+ - !ruby/object:Gem::Version
149
+ version: 1.3.5
150
+ requirements: []
151
+ rubyforge_project:
152
+ rubygems_version: 2.0.2
153
+ signing_key:
154
+ specification_version: 4
155
+ summary: A Ruby interface to the Hackeroo API.
156
+ test_files: []
157
+ has_rdoc: