flattr 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  coverage/*
6
+ doc/*
data/.rdoc_options ADDED
@@ -0,0 +1,16 @@
1
+ --- !ruby/object:RDoc::Options
2
+ encoding: UTF-8
3
+ static_path: []
4
+ rdoc_include:
5
+ - .
6
+ charset: UTF-8
7
+ exclude: !!null
8
+ hyperlink_all: false
9
+ line_numbers: false
10
+ main_page: !!null
11
+ markup: tomdoc
12
+ show_hash: false
13
+ tab_width: 8
14
+ title: !!null
15
+ visibility: :protected
16
+ webcvs: !!null
data/README.md CHANGED
@@ -1,14 +1,9 @@
1
- # Flattr API wrapper
1
+ # The Flattr Ruby Gem [![Build Status](https://secure.travis-ci.org/simon/flattr.png)](http://travis-ci.org/simon/flattr) [![Dependency Status](https://gemnasium.com/simon/flattr.png)](https://gemnasium.com/simon/flattr)
2
2
 
3
3
  This gem is a wrapper around the Flattr API. With the gem you can search things, add new thing and much more. If you want information about updates follow [@simongate](http://twitter.com/simongate) on twitter.
4
4
 
5
5
  [![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=smgt&url=https://github.com/simon/flattr&title=Flattr API gem&language=en_GB&tags=github&category=software)
6
6
 
7
- ## Build status
8
-
9
- [![Build
10
- Status](https://secure.travis-ci.org/simon/flattr.png)](http://travis-ci.org/simon/flattr)
11
-
12
7
  ## Installation
13
8
 
14
9
  Installation is easy, just install the gem with.
@@ -17,17 +12,18 @@ Installation is easy, just install the gem with.
17
12
 
18
13
  ### Dependencies
19
14
 
20
- * Faraday
21
- * multi_json
15
+ * [Faraday](https://github.com/technoweenie/faraday)
16
+ * [multi_json](https://github.com/intridea/multi_json)
22
17
 
23
18
  ## Usage
24
19
 
25
- To talk with all of Flattr API resources you need to [register a application](http://flattr.com/apps). This will give you a *client id* and a *client secret* whom you can exchange for a *access token*. The *access token* is then used to access the resources in the Flattr API that needs authentication. You can find more information about the API in [Flattr developer documents](http://developers.flattr.net/v2).
20
+ To talk with all of Flattr API resources you need to [register a application](http://flattr.com/apps). This will give you a `client id` and a `client secret` whom you can exchange for a `access token`. The `access token` is then used to access the resources in the Flattr API that needs authentication. You can find more information about the API in [Flattr developer documents](http://developers.flattr.net/api).
26
21
 
27
22
  ### Resources
28
23
 
29
24
  You can find documentation about available resources in the code.
30
25
 
26
+ * [flattrs](https://github.com/simon/flattr/blob/master/lib/flattr/client/flattrs.rb)
31
27
  * [things](https://github.com/simon/flattr/blob/master/lib/flattr/client/things.rb)
32
28
  * [users](https://github.com/simon/flattr/blob/master/lib/flattr/client/users.rb)
33
29
  * [categories](https://github.com/simon/flattr/blob/master/lib/flattr/client/categories.rb)
@@ -67,7 +63,9 @@ print 'code: '
67
63
  code = gets
68
64
 
69
65
  # Use the code and exchange it for a access_token
70
- flattr.get_access_token code
66
+ access_token = flattr.get_access_token code
67
+
68
+ puts access_token
71
69
 
72
70
  # You are now authorized! ;)
73
71
 
@@ -83,9 +81,8 @@ If you request a access token without any scopes you won't be able to flattr oth
83
81
 
84
82
  ## What needs to be done
85
83
 
86
- * Add error reporting
87
- * More tests are needed, coverage isn't that good
88
84
  * Add all the Flattr API resources
85
+ * More tests are needed, coverage isn't that good
89
86
 
90
87
  ## Supported Ruby Versions
91
88
 
data/flattr.gemspec CHANGED
@@ -17,8 +17,8 @@ Gem::Specification.new do |s|
17
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  s.require_paths = ["lib"]
19
19
 
20
- s.add_dependency 'faraday'
21
- s.add_dependency 'multi_json'
20
+ s.add_dependency 'faraday', '~> 0.7'
21
+ s.add_dependency 'multi_json', '~> 1.0'
22
22
 
23
23
  s.add_development_dependency 'json'
24
24
  s.add_development_dependency 'rake'
@@ -15,7 +15,13 @@ module Flattr
15
15
  #
16
16
  # @return [Boolean]
17
17
  def credentials?
18
- !credentials[:access_token].nil?
18
+ if credentials[:access_token]
19
+ true
20
+ elsif credentials[:client_id] && credentials[:client_secret]
21
+ true
22
+ else
23
+ false
24
+ end
19
25
  end
20
26
  end
21
27
  end
data/lib/flattr/client.rb CHANGED
@@ -16,6 +16,7 @@ module Flattr
16
16
  require 'flattr/client/things'
17
17
  require 'flattr/client/languages'
18
18
  require 'flattr/client/categories'
19
+ require 'flattr/client/flattrs'
19
20
 
20
21
  include Flattr::Connection
21
22
  include Flattr::Request
@@ -27,6 +28,7 @@ module Flattr
27
28
  include Flattr::Client::Things
28
29
  include Flattr::Client::Languages
29
30
  include Flattr::Client::Categories
31
+ include Flattr::Client::Flattrs
30
32
 
31
33
  attr_accessor *Config::VALID_OPTIONS_KEYS
32
34
 
@@ -45,13 +47,12 @@ module Flattr
45
47
  #
46
48
  # @return [Flattr::User]
47
49
  def current_user
48
- @current_user ||= Flattr::User.new(self.verify_credentials)
50
+ @current_user ||= self.user
49
51
  end
50
52
 
51
- def base64_encode str
53
+ def self.base64_encode str
52
54
  [str].pack("m9999").chomp
53
55
  end
54
56
 
55
-
56
57
  end
57
58
  end
@@ -0,0 +1,34 @@
1
+
2
+ module Flattr
3
+ class Client
4
+ module Flattrs
5
+
6
+ # Public: Flattr a thing
7
+ #
8
+ # thing - The id or URL of the thing you wan't to flattr
9
+ #
10
+ # Examples
11
+ #
12
+ # f = Flattr.new
13
+ # f.flattr(450287)
14
+ # # => true
15
+ #
16
+ # f = Flattr.new
17
+ # f.flattr('https://github.com/simon/flattr')
18
+ # # => true
19
+ #
20
+ # Returns a true if successful
21
+ # Raises Flattr::Error::Forbidden if your are not allowed to flattr the thing
22
+ # Raises Flattr::Error::NotFound if no thing were found
23
+ def flattr(thing)
24
+ if thing.is_a?(Fixnum) || !thing.match(/^\d+$/).nil?
25
+ flattr = post("/rest/v2/things/#{thing}/flattr")
26
+ else
27
+ flattr = post("/rest/v2/flattr", {:url => thing})
28
+ end
29
+ return true
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -15,12 +15,27 @@ module Flattr
15
15
  # #=> Flattr::Thing
16
16
  #
17
17
  # Returns the thing
18
- # Raises error on failure
18
+ # Raises Flattr::Error::NotFound on error
19
19
  def thing(id)
20
- thing = get("/rest/v2/things/#{id}")
20
+ thing = get("/rest/v2/things/#{id}?full")
21
21
  Flattr::Thing.new(thing)
22
22
  end
23
23
 
24
+ # Public: Fetch several things
25
+ #
26
+ # ids - a list of thing ids
27
+ #
28
+ # Examples
29
+ #
30
+ # f = Flattr.new
31
+ # f.things(450287,543896)
32
+ # #=> [Flattr::Thing, Flattr::Thing]
33
+ #
34
+ # Returns a Array with things
35
+ def things(*ids)
36
+ get("/rest/v2/things/#{ids.join(",")}?full").collect { |t| Flattr::Thing.new(t) }
37
+ end
38
+
24
39
  # Public: Create a thing
25
40
  #
26
41
  # url - URL you want to submit
@@ -33,10 +48,11 @@ module Flattr
33
48
  # :hidden - boolean toggling if thing should be hidden or not (optional).
34
49
  #
35
50
  # Returns new thing
36
- # Raises error on failure
51
+ # Raises Flattr::Error::BadRequest on validation error
52
+ # Raises Flattr::Error::NotFound if thing was not found
37
53
  def thing_new(url, opts = {})
38
54
  response = post("/rest/v2/things", opts.merge(:url => url))
39
- thing = get("/rest/v2/things/#{response[:id]}")
55
+ thing = thing(response["id"])
40
56
  Flattr::Thing.new(thing)
41
57
  end
42
58
 
@@ -52,7 +68,8 @@ module Flattr
52
68
  # :hidden - boolean toggling if thing should be hidden or not (optional).
53
69
  #
54
70
  # Returns updated thing
55
- # Raises Error on failure
71
+ # Raises Flattr::Error::BadRequest on validation error
72
+ # Raises Flattr::Error::NotFound if thing was not found
56
73
  def thing_update(id, opts = {})
57
74
  patch("/rest/v2/things/#{id}", opts)
58
75
  thing = get("/rest/v2/things/#{id}")
@@ -70,7 +87,7 @@ module Flattr
70
87
  # # => true
71
88
  #
72
89
  # Returns true if successful
73
- # Raises Error on failure
90
+ # Raises Flattr::Error::NotFound if thing was not found
74
91
  def thing_delete(id)
75
92
  thing = delete("/rest/v2/things/#{id}")
76
93
  if thing.nil? || thing == ""
@@ -80,21 +97,6 @@ module Flattr
80
97
  end
81
98
  end
82
99
 
83
- # Public: Flattr a thing
84
- #
85
- # id - id of the thing you want to flattr
86
- #
87
- # Example
88
- #
89
- # f = Flattr.new
90
- # f.thing_flattr(1)
91
- # # => true
92
- #
93
- # Returns true
94
- def thing_flattr(id)
95
- post("/rest/v2/things/#{id}/flattr")
96
- end
97
-
98
100
  # Public: Search things
99
101
  #
100
102
  # params - The Hash options used to configure search (default: {})
@@ -118,6 +120,7 @@ module Flattr
118
120
  #
119
121
  # Returns Flattr::Search
120
122
  def thing_search(params = {})
123
+ params.merge!({"full" => "full"})
121
124
  result = get("/rest/v2/things/search", params)
122
125
  Flattr::Search.new(result)
123
126
  end
@@ -147,6 +150,21 @@ module Flattr
147
150
  end
148
151
  end
149
152
 
153
+ # Public: Get flattrs on a thing
154
+ #
155
+ # id - id of thing
156
+ #
157
+ # Examples
158
+ #
159
+ # f = Flattr.new
160
+ # f.thing_flattrs(450287)
161
+ # # => [...]
162
+ #
163
+ # Returns a Array with flattrs
164
+ def thing_flattrs(id,params={})
165
+ get("/rest/v2/things/#{id}/flattrs",params)
166
+ end
167
+
150
168
  end
151
169
  end
152
170
  end
@@ -15,10 +15,13 @@ module Flattr
15
15
  # # => #<Flattr::User...
16
16
  #
17
17
  # Returns a Flattr::User if successful
18
- # Raises a ERROR on failure
18
+ # Raises Flattr::Error::NotFound if user not found
19
19
  def user(username=nil)
20
- user = username || self.current_user.username
21
- user = get("/rest/v2/users/#{user}")
20
+ if username.nil?
21
+ user = get("/rest/v2/user")
22
+ else
23
+ user = get("/rest/v2/users/#{username}")
24
+ end
22
25
  Flattr::User.new(user)
23
26
  end
24
27
 
@@ -33,7 +36,7 @@ module Flattr
33
36
  # # => [#<Flattr::Thing...
34
37
  #
35
38
  # Returns a Array with Flattr::User's inside if successful
36
- # Raises a ERROR on failure
39
+ # Raises a Flattr::Error::NotFound if user not found
37
40
  def user_things(username=nil, args={})
38
41
  user = username || self.current_user.username
39
42
  get("/rest/v2/users/#{user}/things", args).map do |thing|
@@ -52,7 +55,7 @@ module Flattr
52
55
  # # => [{"type" => "flattr"....
53
56
  #
54
57
  # Returns a Array with flattrs if successful
55
- # Raises a ERROR on failure
58
+ # Raises Flattr::Error::NotFound if user not found
56
59
  def user_flattrs(username=nil, args={})
57
60
  user = username || self.current_user.username
58
61
  get("/rest/v2/users/#{user}/flattrs").map do |flattr|
@@ -1,7 +1,9 @@
1
1
  require 'faraday'
2
2
  require 'flattr/core_ext/hash'
3
- require 'flattr/response/parse_json'
4
3
  require 'flattr/request/oauth2'
4
+ require 'flattr/response/parse_json'
5
+ require 'flattr/response/raise_client_error'
6
+ require 'flattr/response/raise_server_error'
5
7
 
6
8
  module Flattr
7
9
  module Connection
@@ -17,11 +19,14 @@ module Flattr
17
19
  :url => endpoint,
18
20
  }
19
21
  Faraday.new(default_options.deep_merge(connection_options)) do |builder|
20
- #builder.use Faraday::Request::Multipart
21
22
  builder.use Faraday::Request::JSON
22
23
  builder.use Faraday::Request::UrlEncoded
24
+
23
25
  builder.use Flattr::Request::FlattrOAuth2, credentials if credentials?
26
+ builder.use Flattr::Response::RaiseClientError
24
27
  builder.use Flattr::Response::ParseJson unless connection_options[:raw]
28
+ builder.use Flattr::Response::RaiseServerError
29
+
25
30
  builder.adapter(adapter)
26
31
  end
27
32
  end
@@ -0,0 +1,28 @@
1
+ module Flattr
2
+ # Custom error class for rescuing from all Flattr errors
3
+ class Error < StandardError
4
+ attr_reader :http_headers
5
+
6
+ # Private: Initializes a new Error object
7
+ #
8
+ # message - Error message
9
+ # http_headers - Hash with http_headers
10
+ #
11
+ # Returns a Flattr::Error
12
+ def initialize(message, http_headers)
13
+ @http_headers = Hash[http_headers]
14
+ super(message)
15
+ end
16
+
17
+ # @return [Integer]
18
+ def ratelimit_limit
19
+ @http_headers.values_at('x-ratelimit-limit', 'X-RateLimit-Limit').detect{|value| value}.to_i
20
+ end
21
+
22
+ # @return [Integer]
23
+ def ratelimit_remaining
24
+ @http_headers.values_at('x-ratelimit-remaining', 'X-RateLimit-Remaining').detect{|value| value}.to_i
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,7 @@
1
+ require 'flattr/error/server_error'
2
+
3
+ module Flattr
4
+ # Raised when Flattr returns the HTTP status code 502
5
+ class Error::BadGateway < Flattr::Error::ServerError
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'flattr/error/client_error'
2
+
3
+ module Flattr
4
+ # Raised when Flattr returns the HTTP status code 400
5
+ class Error::BadRequest < Flattr::Error::ClientError
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'flattr/error'
2
+
3
+ module Flattr
4
+ # Raised when Flattr returns a 4xx HTTP status code
5
+ class Error::ClientError < Flattr::Error
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'flattr/error/client_error'
2
+
3
+ module Flattr
4
+ # Raised when Flattr returns the HTTP status code 403
5
+ class Error::Forbidden < Flattr::Error::ClientError
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'flattr/error/server_error'
2
+
3
+ module Flattr
4
+ # Raised when Flattr returns the HTTP status code 500
5
+ class Error::InternalServerError < Flattr::Error::ServerError
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'flattr/error/client_error'
2
+
3
+ module Flattr
4
+ # Raised when Flattr returns the HTTP status code 406
5
+ class Error::NotAcceptable <Flattr::Error::ClientError
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'flattr/error/client_error'
2
+
3
+ module Flattr
4
+ # Raised when Flattr returns the HTTP status code 404
5
+ class Error::NotFound < Flattr::Error::ClientError
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'flattr/error'
2
+
3
+ module Flattr
4
+ # Raised when Flattr returns a 5xx HTTP status code
5
+ class Error::ServerError < Flattr::Error
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'flattr/error/client_error'
2
+
3
+ module Flattr
4
+ # Raised when Flattr returns the HTTP status code 401
5
+ class Error::Unauthorized < Flattr::Error::ClientError
6
+ end
7
+ end
data/lib/flattr/oauth2.rb CHANGED
@@ -4,8 +4,8 @@ module Flattr
4
4
  def authorize_url(opts = {})
5
5
 
6
6
  default_options = {
7
- :client_id => client_id,
8
- :client_secret => client_secret,
7
+ :client_id => client_id.strip,
8
+ :client_secret => client_secret.strip,
9
9
  :response_type => "code"
10
10
  }
11
11
 
@@ -26,11 +26,11 @@ module Flattr
26
26
 
27
27
  def get_access_token(code)
28
28
  response = post(token_endpoint, {
29
- :code => code,
29
+ :code => code.strip,
30
30
  :grant_type => 'authorization_code'
31
31
  },{
32
32
  :headers => {
33
- :authorization => "Basic #{base64_encode("#{client_id}:#{client_secret}")}"
33
+ :authorization => "Basic #{Flattr::Client.base64_encode("#{client_id}:#{client_secret}")}"
34
34
  }}
35
35
  )
36
36
  self.access_token = response['access_token']
@@ -17,7 +17,7 @@ module Flattr
17
17
  if @options[:access_token]
18
18
  "Bearer #{@options[:access_token]}"
19
19
  elsif @options[:client_id] && @options[:client_secret]
20
- "Basic #{base64_encode("#{@options[:client_id]}:#{@options[:client_secret]}")}"
20
+ "Basic #{Flattr::Client.base64_encode("#{@options[:client_id]}:#{@options[:client_secret]}")}"
21
21
  else
22
22
  nil
23
23
  end
@@ -14,7 +14,11 @@ module Flattr
14
14
  when 'false'
15
15
  false
16
16
  else
17
- ::MultiJson.decode(body)
17
+ begin
18
+ ::MultiJson.decode(body)
19
+ rescue
20
+ nil
21
+ end
18
22
  end
19
23
  end
20
24
 
@@ -0,0 +1,39 @@
1
+ require 'faraday'
2
+ require 'flattr/error/bad_request'
3
+ require 'flattr/error/forbidden'
4
+ require 'flattr/error/not_acceptable'
5
+ require 'flattr/error/not_found'
6
+ require 'flattr/error/unauthorized'
7
+
8
+ module Flattr
9
+ module Response
10
+ class RaiseClientError < Faraday::Response::Middleware
11
+
12
+ def on_complete(env)
13
+ case env[:status].to_i
14
+ when 400
15
+ raise Flattr::Error::BadRequest.new(error_body(env[:body]), env[:response_headers])
16
+ when 401
17
+ raise Flattr::Error::Unauthorized.new(error_body(env[:body]), env[:response_headers])
18
+ when 403
19
+ raise Flattr::Error::Forbidden.new(error_body(env[:body]), env[:response_headers])
20
+ when 404
21
+ raise Flattr::Error::NotFound.new(error_body(env[:body]), env[:response_headers])
22
+ when 406
23
+ raise Flattr::Error::NotAcceptable.new(error_body(env[:body]), env[:response_headers])
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def error_body(body)
30
+ if body.nil?
31
+ ''
32
+ elsif body['error']
33
+ body['error_description']
34
+ end
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,20 @@
1
+ require 'faraday'
2
+ require 'flattr/error/bad_gateway'
3
+ require 'flattr/error/internal_server_error'
4
+
5
+ module Flattr
6
+ module Response
7
+ class RaiseServerError < Faraday::Response::Middleware
8
+
9
+ def on_complete(env)
10
+ case env[:status].to_i
11
+ when 500
12
+ raise Flattr::Error::InternalServerError.new("Something is technically wrong.", env[:response_headers])
13
+ when 502
14
+ raise Flattr::Error::BadGateway.new("Flattr is down or being upgraded.", env[:response_headers])
15
+ end
16
+ end
17
+
18
+ end
19
+ end
20
+ end
data/lib/flattr/thing.rb CHANGED
@@ -5,10 +5,14 @@ module Flattr
5
5
 
6
6
  lazy_attr_reader :resource, :link, :id, :url, :language, :category,
7
7
  :hidden, :flattred, :tags, :flattrs, :description, :title,
8
- :last_flattr_at, :updated_at, :flattrs_current_period, :owner
8
+ :last_flattr_at, :updated_at, :image, :owner
9
9
 
10
10
  lazy_attr_writer :tags, :language, :category, :hidden, :description,
11
11
  :description, :title
12
12
 
13
+ def initialize(attrs={})
14
+ attrs['owner'] = Flattr::User.new attrs['owner'] if attrs['owner']
15
+ super attrs
16
+ end
13
17
  end
14
18
  end
@@ -8,12 +8,12 @@ module Flattr
8
8
 
9
9
  # @return [Integer]
10
10
  def self.minor
11
- 2
11
+ 3
12
12
  end
13
13
 
14
14
  # @return [Integer]
15
15
  def self.patch
16
- 3
16
+ 0
17
17
  end
18
18
 
19
19
  # @return [String, NilClass]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flattr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,33 +10,43 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-01-16 00:00:00.000000000Z
13
+ date: 2012-03-23 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
17
- requirement: &70335945795100 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
- - - ! '>='
20
+ - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: '0'
22
+ version: '0.7'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70335945795100
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '0.7'
26
31
  - !ruby/object:Gem::Dependency
27
32
  name: multi_json
28
- requirement: &70335945794620 !ruby/object:Gem::Requirement
33
+ requirement: !ruby/object:Gem::Requirement
29
34
  none: false
30
35
  requirements:
31
- - - ! '>='
36
+ - - ~>
32
37
  - !ruby/object:Gem::Version
33
- version: '0'
38
+ version: '1.0'
34
39
  type: :runtime
35
40
  prerelease: false
36
- version_requirements: *70335945794620
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '1.0'
37
47
  - !ruby/object:Gem::Dependency
38
48
  name: json
39
- requirement: &70335945794040 !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
40
50
  none: false
41
51
  requirements:
42
52
  - - ! '>='
@@ -44,10 +54,15 @@ dependencies:
44
54
  version: '0'
45
55
  type: :development
46
56
  prerelease: false
47
- version_requirements: *70335945794040
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
48
63
  - !ruby/object:Gem::Dependency
49
64
  name: rake
50
- requirement: &70335945793560 !ruby/object:Gem::Requirement
65
+ requirement: !ruby/object:Gem::Requirement
51
66
  none: false
52
67
  requirements:
53
68
  - - ! '>='
@@ -55,10 +70,15 @@ dependencies:
55
70
  version: '0'
56
71
  type: :development
57
72
  prerelease: false
58
- version_requirements: *70335945793560
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
59
79
  - !ruby/object:Gem::Dependency
60
80
  name: rdiscount
61
- requirement: &70335945793020 !ruby/object:Gem::Requirement
81
+ requirement: !ruby/object:Gem::Requirement
62
82
  none: false
63
83
  requirements:
64
84
  - - ! '>='
@@ -66,10 +86,15 @@ dependencies:
66
86
  version: '0'
67
87
  type: :development
68
88
  prerelease: false
69
- version_requirements: *70335945793020
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
70
95
  - !ruby/object:Gem::Dependency
71
96
  name: rspec
72
- requirement: &70335945792400 !ruby/object:Gem::Requirement
97
+ requirement: !ruby/object:Gem::Requirement
73
98
  none: false
74
99
  requirements:
75
100
  - - ! '>='
@@ -77,10 +102,15 @@ dependencies:
77
102
  version: '0'
78
103
  type: :development
79
104
  prerelease: false
80
- version_requirements: *70335945792400
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
81
111
  - !ruby/object:Gem::Dependency
82
112
  name: simplecov
83
- requirement: &70335945791660 !ruby/object:Gem::Requirement
113
+ requirement: !ruby/object:Gem::Requirement
84
114
  none: false
85
115
  requirements:
86
116
  - - ! '>='
@@ -88,10 +118,15 @@ dependencies:
88
118
  version: '0'
89
119
  type: :development
90
120
  prerelease: false
91
- version_requirements: *70335945791660
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
92
127
  - !ruby/object:Gem::Dependency
93
128
  name: webmock
94
- requirement: &70335945790720 !ruby/object:Gem::Requirement
129
+ requirement: !ruby/object:Gem::Requirement
95
130
  none: false
96
131
  requirements:
97
132
  - - ! '>='
@@ -99,7 +134,12 @@ dependencies:
99
134
  version: '0'
100
135
  type: :development
101
136
  prerelease: false
102
- version_requirements: *70335945790720
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
103
143
  description:
104
144
  email:
105
145
  - simon@smgt.me
@@ -109,21 +149,13 @@ extensions: []
109
149
  extra_rdoc_files: []
110
150
  files:
111
151
  - .gitignore
152
+ - .rdoc_options
112
153
  - .rspec
113
154
  - .travis.yml
114
155
  - Gemfile
115
156
  - LICENSE.md
116
157
  - README.md
117
158
  - Rakefile
118
- - example_app/Gemfile
119
- - example_app/app.rb
120
- - example_app/config.ru
121
- - example_app/local_config.example.yml
122
- - example_app/local_config.yml
123
- - example_app/views/index.haml
124
- - example_app/views/layout.haml
125
- - example_app/views/open_calls.haml
126
- - example_app/views/tests.haml
127
159
  - flattr.gemspec
128
160
  - lib/flattr.rb
129
161
  - lib/flattr/authenticatable.rb
@@ -131,17 +163,30 @@ files:
131
163
  - lib/flattr/category.rb
132
164
  - lib/flattr/client.rb
133
165
  - lib/flattr/client/categories.rb
166
+ - lib/flattr/client/flattrs.rb
134
167
  - lib/flattr/client/languages.rb
135
168
  - lib/flattr/client/things.rb
136
169
  - lib/flattr/client/users.rb
137
170
  - lib/flattr/config.rb
138
171
  - lib/flattr/connection.rb
139
172
  - lib/flattr/core_ext/hash.rb
173
+ - lib/flattr/error.rb
174
+ - lib/flattr/error/bad_gateway.rb
175
+ - lib/flattr/error/bad_request.rb
176
+ - lib/flattr/error/client_error.rb
177
+ - lib/flattr/error/forbidden.rb
178
+ - lib/flattr/error/internal_server_error.rb
179
+ - lib/flattr/error/not_acceptable.rb
180
+ - lib/flattr/error/not_found.rb
181
+ - lib/flattr/error/server_error.rb
182
+ - lib/flattr/error/unauthorized.rb
140
183
  - lib/flattr/language.rb
141
184
  - lib/flattr/oauth2.rb
142
185
  - lib/flattr/request.rb
143
186
  - lib/flattr/request/oauth2.rb
144
187
  - lib/flattr/response/parse_json.rb
188
+ - lib/flattr/response/raise_client_error.rb
189
+ - lib/flattr/response/raise_server_error.rb
145
190
  - lib/flattr/search.rb
146
191
  - lib/flattr/thing.rb
147
192
  - lib/flattr/user.rb
@@ -168,11 +213,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
213
  version: '0'
169
214
  requirements: []
170
215
  rubyforge_project: flattr
171
- rubygems_version: 1.8.10
216
+ rubygems_version: 1.8.18
172
217
  signing_key:
173
218
  specification_version: 3
174
219
  summary: Flattr API wrapper
175
220
  test_files:
176
221
  - spec/flattr_spec.rb
177
222
  - spec/helper.rb
178
- has_rdoc:
data/example_app/Gemfile DELETED
@@ -1,7 +0,0 @@
1
- source "http://rubygems.org"
2
- gem 'sinatra'
3
- gem 'haml'
4
-
5
- group :development do
6
- gem 'shotgun'
7
- end
data/example_app/app.rb DELETED
@@ -1,41 +0,0 @@
1
- require 'sinatra'
2
- $:.unshift File.expand_path('../../lib', __FILE__)
3
- require 'flattr'
4
- require 'haml'
5
-
6
- require 'yaml'
7
- local_config = YAML.load_file './local_config.yml'
8
-
9
- layout :default
10
- set :session, :enable
11
-
12
- before do
13
- puts " -- #{request.request_method.upcase} #{request.path_info} --"
14
- @flattr_client = Flattr.new(
15
- :client_id => local_config['client_id'],
16
- :client_secret => local_config['client_secret'],
17
- :authorize_endpoint => local_config['authorize_endpoint'],
18
- :token_endpoint => local_config['token_endpoint']
19
- )
20
- end
21
- get '/' do
22
- haml :index
23
- end
24
-
25
- get '/callback' do
26
- puts "callback params: #{params.inspect}"
27
- token = @flattr_client.get_access_token params["code"]
28
- puts "token is : #{token}"
29
- redirect '/tests'
30
- end
31
-
32
- get '/open_calls' do
33
- @user = @flattr_client.user('smgt')
34
- @categories = @flattr_client.categories
35
- @languages = @flattr_client.languages
36
- haml :open_calls
37
- end
38
-
39
- get '/tests' do
40
- haml :tests
41
- end
@@ -1,3 +0,0 @@
1
- require './app'
2
- use Rack::Logger
3
- run Sinatra::Application
@@ -1,4 +0,0 @@
1
- client_id: your client key
2
- client_secret: your client secret
3
- token_endpoint: https://flattr.com/oauth/token
4
- authorize_endpoint: https://flattr.com/oauth/authorize
@@ -1,4 +0,0 @@
1
- client_id: GqKAYw0cR0eBSIQIQDsQGm2cgJ0nVMls3VSRhJUZAZrix7QdB8U7lMasm0G8CRqw
2
- client_secret: D9dLIYA8NRhaPXdgWXd7AdqM4WKwD0T70WIyL9xoQEowrsCegGcGKsiEeT1IKKFA
3
- token_endpoint: https://flattr.local/oauth/token
4
- authorize_endpoint: https://flattr.local/oauth/authorize
@@ -1,2 +0,0 @@
1
- hello world, from a template!
2
- %a{:href => @flattr_client.authorize_path} authenticate
@@ -1,10 +0,0 @@
1
- !!! html5
2
- %html
3
- %head
4
- %link{:rel => "favicon", :src=>"/favicon.ico"}
5
- %title test app for the flattr gem
6
- %body
7
- =yield
8
-
9
-
10
-
@@ -1,12 +0,0 @@
1
- %p i got a lot of stuff, like
2
- %h2 user smgt
3
- %pre
4
- =@user.inspect.gsub(",","\n")
5
-
6
- %h2 categories
7
- %pre
8
- =@categories.inspect.gsub(",","\n")
9
-
10
- %h2 languages
11
- %pre
12
- =@languages.inspect.gsub(",","\n")
@@ -1 +0,0 @@
1
- hej jag är en testfil :)