flattr 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in flattr.gemspec
4
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Simon Gate, Joel Hansson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a
4
+ copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included
12
+ in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # Flattr
2
+
3
+ This gem is a wrapper around version 2 of the [Flattr](http://flattr.com) [REST
4
+ API](http://developers.flattr.com/v2).
5
+
6
+ ## Build status
7
+
8
+ [![Build
9
+ Status](https://secure.travis-ci.org/simon/flattr.png)](http://travis-ci.org/simon/flattr)
10
+
11
+ ## Examples
12
+
13
+ ## Copyright
14
+
15
+ Copyright (c) 2011 Simon Gate, Joel Hansson. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,7 @@
1
+ source "http://rubygems.org"
2
+ gem 'sinatra'
3
+ gem 'haml'
4
+
5
+ group :development do
6
+ gem 'shotgun'
7
+ end
@@ -0,0 +1,41 @@
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
@@ -0,0 +1,3 @@
1
+ require './app'
2
+ use Rack::Logger
3
+ run Sinatra::Application
@@ -0,0 +1,4 @@
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
@@ -0,0 +1,4 @@
1
+ client_id: GqKAYw0cR0eBSIQIQDsQGm2cgJ0nVMls3VSRhJUZAZrix7QdB8U7lMasm0G8CRqw
2
+ client_secret: D9dLIYA8NRhaPXdgWXd7AdqM4WKwD0T70WIyL9xoQEowrsCegGcGKsiEeT1IKKFA
3
+ token_endpoint: https://flattr.local/oauth/token
4
+ authorize_endpoint: https://flattr.local/oauth/authorize
@@ -0,0 +1,2 @@
1
+ hello world, from a template!
2
+ %a{:href => @flattr_client.authorize_path} authenticate
@@ -0,0 +1,10 @@
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
+
@@ -0,0 +1,12 @@
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")
@@ -0,0 +1 @@
1
+ hej jag är en testfil :)
data/flattr.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "flattr/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "flattr"
7
+ s.version = Flattr::Version.to_s
8
+ s.authors = ["Simon Gate", "Joel Hansson"]
9
+ s.email = ["simon@smgt.me", "joel.hansson@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Write a gem summary}
12
+ s.description = %q{Write a gem description}
13
+
14
+ s.rubyforge_project = "flattr"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency 'faraday'
22
+ s.add_dependency 'multi_json'
23
+
24
+ # specify any dependencies here; for example:
25
+ # s.add_development_dependency "rspec"
26
+ # s.add_runtime_dependency "rest-client"
27
+ end
data/lib/flattr.rb ADDED
@@ -0,0 +1,22 @@
1
+ require "flattr/version"
2
+ require "flattr/client"
3
+ require "flattr/config"
4
+
5
+ module Flattr
6
+ extend Config
7
+ class << self
8
+
9
+ def new(options={})
10
+ Flattr::Client.new(options)
11
+ end
12
+
13
+ def method_missing(method, *args, &block)
14
+ return super unless new.respond_to?(method)
15
+ new.send(method, *args, &block)
16
+ end
17
+
18
+ def respond_to?(method, include_private=false)
19
+ new.respond_to?(method, include_private) || super(method, include_private)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ module Flattr
2
+ module Authenticatable
3
+ # Credentials hash
4
+ #
5
+ # @return [Hash]
6
+ def credentials
7
+ {
8
+ :client_id => client_id,
9
+ :client_secret => client_secret,
10
+ :access_token => access_token,
11
+ }
12
+ end
13
+
14
+ # Check whether credentials are present
15
+ #
16
+ # @return [Boolean]
17
+ def credentials?
18
+ !credentials[:access_token].nil?
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,55 @@
1
+ module Flattr
2
+ class Base
3
+
4
+ attr_accessor :attrs
5
+ alias :to_hash :attrs
6
+
7
+ # Define methods that retrieve the value from an initialized instance variable Hash, using the attribute as a key
8
+ #
9
+ # @overload self.lazy_attr_reader(attr)
10
+ # @param attr [Symbol]
11
+ # @overload self.lazy_attr_reader(attrs)
12
+ # @param attrs [Array<Symbol>]
13
+ def self.lazy_attr_reader(*attrs)
14
+ attrs.each do |attribute|
15
+ class_eval do
16
+ define_method attribute do
17
+ @attrs[attribute.to_s]
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ def self.lazy_attr_writer(*attrs)
24
+ attrs.each do |attribute|
25
+ class_eval do
26
+ define_method "#{attribute}=" do |a|
27
+ if @attrs[attribute.to_s] != a.to_s
28
+ @has_changed = true
29
+ @changes.push(attribute)
30
+ end
31
+ @attrs[attribute.to_s] = a.to_s
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ # Initializes a new Base object
38
+ #
39
+ # @param attrs [Hash]
40
+ # @return [Flattr::Base]
41
+ def initialize(attrs={})
42
+ @attrs = attrs.dup
43
+ end
44
+
45
+ # Initializes a new Base object
46
+ #
47
+ # @param method [String, Symbol] Message to send to the object
48
+ def [](method)
49
+ self.__send__(method.to_sym)
50
+ rescue NoMethodError
51
+ nil
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,7 @@
1
+ require "flattr/base"
2
+
3
+ module Flattr
4
+ class Category < Flattr::Base
5
+ lazy_attr_reader :id, :text
6
+ end
7
+ end
@@ -0,0 +1,51 @@
1
+ require 'flattr/config'
2
+ require 'flattr/connection'
3
+ require 'flattr/request'
4
+ require 'flattr/user'
5
+ require 'flattr/thing'
6
+ require 'flattr/language'
7
+ require 'flattr/category'
8
+ require 'flattr/version'
9
+ require 'flattr/oauth2'
10
+ require 'flattr/authenticatable'
11
+
12
+ module Flattr
13
+ class Client
14
+ require 'flattr/client/users'
15
+ require 'flattr/client/things'
16
+ require 'flattr/client/languages'
17
+ require 'flattr/client/categories'
18
+
19
+ include Flattr::Connection
20
+ include Flattr::Request
21
+
22
+ include Flattr::Authenticatable
23
+ include Flattr::OAuth2
24
+
25
+ include Flattr::Client::Users
26
+ include Flattr::Client::Things
27
+ include Flattr::Client::Languages
28
+ include Flattr::Client::Categories
29
+
30
+ attr_accessor *Config::VALID_OPTIONS_KEYS
31
+
32
+ # Initializes a new API object
33
+ #
34
+ # @param attrs [Hash]
35
+ # @return [Flattr::Client]
36
+ def initialize(attrs={})
37
+ attrs = Flattr.options.merge(attrs)
38
+ Config::VALID_OPTIONS_KEYS.each do |key|
39
+ instance_variable_set("@#{key}".to_sym, attrs[key])
40
+ end
41
+ end
42
+
43
+ # Returns the configured name or the name of the authenticated user
44
+ #
45
+ # @return [Flattr::User]
46
+ def current_user
47
+ @current_user ||= Flattr::User.new(self.verify_credentials)
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,22 @@
1
+ require 'flattr/category'
2
+
3
+ module Flattr
4
+ class Client
5
+ module Categories
6
+
7
+ def categories
8
+ @categories ||= get('/rest/v2/categories').map do |category|
9
+ Flattr::Category.new(category)
10
+ end
11
+ end
12
+
13
+ def category(id)
14
+ categories.select do |category|
15
+ category.id == id
16
+ end.first
17
+ end
18
+
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,15 @@
1
+ require 'flattr/language'
2
+
3
+ module Flattr
4
+ class Client
5
+ module Languages
6
+
7
+ def languages
8
+ get("/rest/v2/languages").map do |language|
9
+ Flattr::Language.new(language)
10
+ end
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,41 @@
1
+ require 'flattr/thing'
2
+
3
+ module Flattr
4
+ class Client
5
+ module Things
6
+
7
+ def thing(id)
8
+ thing = get("/rest/v2/things/#{id}")
9
+ Flattr::Thing.new(thing)
10
+ end
11
+
12
+ def thing_new(url, opts = {})
13
+ response = post("/rest/v2/things", opts.merge(:url => url))
14
+ thing = get("/rest/v2/things/#{response[:id]}")
15
+ Flattr::Thing.new(thing)
16
+ end
17
+
18
+ def thing_update(id, opts = {})
19
+ patch("/rest/v2/things/#{id}", opts)
20
+ thing = get("/rest/v2/things/#{id}")
21
+ Flattr::Thing.new(thing)
22
+ end
23
+
24
+ def thing_delete(id)
25
+ thing = delete("/rest/v2/things/#{id}")
26
+ true
27
+ end
28
+
29
+ def search(query = {})
30
+ result = get("/rest/v2/things/search")
31
+ result
32
+ end
33
+
34
+ def lookup(url)
35
+ thing = get("/rest/v2/things/lookup/?q=#{url}")
36
+ Flattr::Thing.new(thing)
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,16 @@
1
+ require 'flattr/user'
2
+
3
+ module Flattr
4
+ class Client
5
+ module Users
6
+
7
+ def user(username=nil)
8
+ user = username || self.current_user.username
9
+ user = get("/rest/v2/users/#{user}")
10
+ Flattr::User.new(user)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,90 @@
1
+ require 'flattr/version'
2
+
3
+ module Flattr
4
+ # Defines constants and methods related to configuration
5
+ module Config
6
+
7
+ # The HTTP connection adapter that will be used to connect if none is set
8
+ DEFAULT_ADAPTER = :net_http
9
+
10
+ # The Faraday connection options if none is set
11
+ DEFAULT_CONNECTION_OPTIONS = {}
12
+
13
+ # The client key if none is set
14
+ DEFAULT_CLIENT_ID = nil
15
+
16
+ # The consumer secret if none is set
17
+ DEFAULT_CLIENT_SECRET = nil
18
+
19
+ # The endpoint that will be used to connect if none is set
20
+ #
21
+ DEFAULT_ENDPOINT = 'https://api.flattr.com'
22
+
23
+ DEFAULT_AUTHORIZE_ENDPOINT = 'https://flattr.com/oauth/authorize'
24
+ DEFAULT_TOKEN_ENDPOINT = 'https://flattr.com/oauth/token'
25
+
26
+ # The gateway server if none is set
27
+ DEFAULT_GATEWAY = nil
28
+
29
+ # The access token if none is set
30
+ DEFAULT_ACCESS_TOKEN = nil
31
+
32
+ # The proxy server if none is set
33
+ DEFAULT_PROXY = nil
34
+
35
+ # The value sent in the 'User-Agent' header if none is set
36
+ DEFAULT_USER_AGENT = "Flattr Ruby Gem #{Flattr::Version}"
37
+
38
+ # An array of valid keys in the options hash when configuring a {Flattr::Client}
39
+ VALID_OPTIONS_KEYS = [
40
+ :adapter,
41
+ :connection_options,
42
+ :client_id,
43
+ :client_secret,
44
+ :endpoint,
45
+ :authorize_endpoint,
46
+ :token_endpoint,
47
+ :gateway,
48
+ :access_token,
49
+ :proxy,
50
+ :user_agent,
51
+ ]
52
+
53
+ attr_accessor *VALID_OPTIONS_KEYS
54
+
55
+ # When this module is extended, set all configuration options to their default values
56
+ def self.extended(base)
57
+ base.reset
58
+ end
59
+
60
+ # Convenience method to allow configuration options to be set in a block
61
+ def configure
62
+ yield self
63
+ self
64
+ end
65
+
66
+ # Create a hash of options and their values
67
+ def options
68
+ options = {}
69
+ VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}
70
+ options
71
+ end
72
+
73
+ # Reset all configuration options to defaults
74
+ def reset
75
+ self.adapter = DEFAULT_ADAPTER
76
+ self.connection_options = DEFAULT_CONNECTION_OPTIONS
77
+ self.client_id = DEFAULT_CLIENT_ID
78
+ self.client_secret = DEFAULT_CLIENT_SECRET
79
+ self.endpoint = DEFAULT_ENDPOINT
80
+ self.authorize_endpoint = DEFAULT_AUTHORIZE_ENDPOINT
81
+ self.token_endpoint = DEFAULT_TOKEN_ENDPOINT
82
+ self.gateway = DEFAULT_GATEWAY
83
+ self.access_token = DEFAULT_ACCESS_TOKEN
84
+ self.proxy = DEFAULT_PROXY
85
+ self.user_agent = DEFAULT_USER_AGENT
86
+ self
87
+ end
88
+
89
+ end
90
+ end
@@ -0,0 +1,30 @@
1
+ require 'faraday'
2
+ require 'flattr/core_ext/hash'
3
+ require 'flattr/response/parse_json'
4
+ require 'flattr/request/oauth2'
5
+
6
+ module Flattr
7
+ module Connection
8
+ private
9
+ def connection(options={})
10
+ default_options = {
11
+ :headers => {
12
+ :accept => 'application/json',
13
+ :user_agent => user_agent,
14
+ },
15
+ :proxy => proxy,
16
+ :ssl => {:verify => false},
17
+ :url => options.fetch(:endpoint, endpoint),
18
+ }
19
+ Faraday.new(default_options.deep_merge(connection_options)) do |builder|
20
+ #builder.use Faraday::Request::Multipart
21
+ builder.use Faraday::Request::JSON
22
+ builder.use Faraday::Request::UrlEncoded
23
+ builder.use Flattr::Request::FlattrOAuth2, credentials if credentials?
24
+ builder.use Flattr::Response::ParseJson unless options[:raw]
25
+ builder.adapter(adapter)
26
+ end
27
+ end
28
+ end
29
+ end
30
+
@@ -0,0 +1,20 @@
1
+ class Hash
2
+
3
+ # Merges self with another hash, recursively
4
+ #
5
+ # @param hash [Hash] The hash to merge
6
+ # @return [Hash]
7
+ def deep_merge(hash)
8
+ target = self.dup
9
+ hash.keys.each do |key|
10
+ if hash[key].is_a?(Hash) && self[key].is_a?(Hash)
11
+ target[key] = target[key].deep_merge(hash[key])
12
+ next
13
+ end
14
+ target[key] = hash[key]
15
+ end
16
+ target
17
+ end
18
+
19
+
20
+ end
@@ -0,0 +1,7 @@
1
+ require "flattr/base"
2
+
3
+ module Flattr
4
+ class Language < Flattr::Base
5
+ lazy_attr_reader :id, :text
6
+ end
7
+ end
@@ -0,0 +1,32 @@
1
+ module Flattr
2
+ module OAuth2
3
+
4
+ def authorize_path(opts = {})
5
+
6
+ default_options = {
7
+ :client_id => client_id,
8
+ :client_secret => client_secret,
9
+ :response_type => "code"
10
+ }
11
+
12
+ opts = default_options.merge(opts)
13
+
14
+ if !opts[:scope].nil?
15
+ if opts[:scope].is_a?(Array)
16
+ opts[:scope] = opts[:scope].join(",")
17
+ end
18
+ end
19
+
20
+ query_string = %w(response_type client_id redirect_uri scope state).collect do |key|
21
+ "#{key.to_s}=#{opts[key.to_sym]}" if opts[key.to_sym]
22
+ end.compact.join("&")
23
+
24
+ "#{authorize_endpoint}/?#{query_string}"
25
+ end
26
+
27
+ def get_access_token(code)
28
+ post(token_endpoint, {:code => code, :grant_type => 'authorization_code'}, options)
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,46 @@
1
+ module Flattr
2
+ # Defines HTTP request methods
3
+ module Request
4
+ # Perform an HTTP DELETE request
5
+ def delete(path, params={}, options={})
6
+ request(:delete, path, params, options)
7
+ end
8
+
9
+ # Perform an HTTP GET request
10
+ def get(path, params={}, options={})
11
+ request(:get, path, params, options)
12
+ end
13
+
14
+ # Perform an HTTP POST request
15
+ def post(path, params={}, options={})
16
+ request(:post, path, params, options)
17
+ end
18
+
19
+ # Perform an HTTP PUT request
20
+ def put(path, params={}, options={})
21
+ request(:put, path, params, options)
22
+ end
23
+
24
+ # Perform an HTTP PATCH request
25
+ def patch(path, params={}, options={})
26
+ request(:patch, path, params, options)
27
+ end
28
+ private
29
+
30
+ # Perform an HTTP request
31
+ def request(method, path, params, options)
32
+ response = connection(options).send(method) do |request|
33
+ case method.to_sym
34
+ when :get, :delete
35
+ request.url(path, params)
36
+ when :post, :put, :patch
37
+ request.path = path
38
+ request.body = params unless params.empty?
39
+ end
40
+ end
41
+ options[:raw] ? response : response.body
42
+ end
43
+
44
+ end
45
+ end
46
+
@@ -0,0 +1,32 @@
1
+ module Flattr
2
+ module Request
3
+ class FlattrOAuth2 < Faraday::Middleware
4
+
5
+ def call(env)
6
+ if authorization_header
7
+ env[:request_headers]['Authorization'] = authorization_header
8
+ end
9
+ @app.call(env)
10
+ end
11
+
12
+ def initialize(app, options)
13
+ @app, @options = app, options
14
+ end
15
+
16
+ def authorization_header
17
+ if @options[:access_token]
18
+ "Bearer #{@options[:access_token]}"
19
+ elsif @options[:client_id] && @options[:client_secret]
20
+ "Basic #{base64_encode("#{@options[:client_id]}:#{@options[:client_secret]}")}"
21
+ else
22
+ nil
23
+ end
24
+ end
25
+
26
+ def base64_encode str
27
+ [str].pack("m9999").chomp
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,23 @@
1
+ require 'faraday'
2
+ require 'multi_json'
3
+
4
+ module Flattr
5
+ module Response
6
+ class ParseJson < Faraday::Response::Middleware
7
+
8
+ def parse(body)
9
+ case body
10
+ when ''
11
+ nil
12
+ when 'true'
13
+ true
14
+ when 'false'
15
+ false
16
+ else
17
+ ::MultiJson.decode(body)
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,14 @@
1
+ require 'flattr/base'
2
+
3
+ module Flattr
4
+ class Thing < Flattr::Base
5
+
6
+ lazy_attr_reader :resource, :link, :id, :url, :language, :category,
7
+ :hidden, :flattred, :tags, :flattrs, :description, :title,
8
+ :last_flattr_at, :updated_at, :flattrs_current_period, :owner
9
+
10
+ lazy_attr_writer :tags, :language, :category, :hidden, :description,
11
+ :description, :title
12
+
13
+ end
14
+ end
@@ -0,0 +1,8 @@
1
+ require 'flattr/base'
2
+
3
+ module Flattr
4
+ class User < Flattr::Base
5
+ lazy_attr_reader :username, :email, :firstname, :lastname, :city, :zip,
6
+ :province, :cellphone, :avatar, :about, :country, :resource, :link
7
+ end
8
+ end
@@ -0,0 +1,30 @@
1
+ module Flattr
2
+ class Version
3
+
4
+ # @return [Integer]
5
+ def self.major
6
+ 0
7
+ end
8
+
9
+ # @return [Integer]
10
+ def self.minor
11
+ 2
12
+ end
13
+
14
+ # @return [Integer]
15
+ def self.patch
16
+ 1
17
+ end
18
+
19
+ # @return [String, NilClass]
20
+ def self.pre
21
+ nil
22
+ end
23
+
24
+ # @return [String]
25
+ def self.to_s
26
+ [major, minor, patch, pre].compact.join('.')
27
+ end
28
+
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flattr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Simon Gate
9
+ - Joel Hansson
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2011-12-10 00:00:00.000000000Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: faraday
17
+ requirement: &70096099213560 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *70096099213560
26
+ - !ruby/object:Gem::Dependency
27
+ name: multi_json
28
+ requirement: &70096099213060 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *70096099213060
37
+ description: Write a gem description
38
+ email:
39
+ - simon@smgt.me
40
+ - joel.hansson@gmail.com
41
+ executables: []
42
+ extensions: []
43
+ extra_rdoc_files: []
44
+ files:
45
+ - .gitignore
46
+ - Gemfile
47
+ - LICENSE.md
48
+ - README.md
49
+ - Rakefile
50
+ - example_app/Gemfile
51
+ - example_app/app.rb
52
+ - example_app/config.ru
53
+ - example_app/local_config.example.yml
54
+ - example_app/local_config.yml
55
+ - example_app/views/index.haml
56
+ - example_app/views/layout.haml
57
+ - example_app/views/open_calls.haml
58
+ - example_app/views/tests.haml
59
+ - flattr.gemspec
60
+ - lib/flattr.rb
61
+ - lib/flattr/authenticatable.rb
62
+ - lib/flattr/base.rb
63
+ - lib/flattr/category.rb
64
+ - lib/flattr/client.rb
65
+ - lib/flattr/client/categories.rb
66
+ - lib/flattr/client/languages.rb
67
+ - lib/flattr/client/things.rb
68
+ - lib/flattr/client/users.rb
69
+ - lib/flattr/config.rb
70
+ - lib/flattr/connection.rb
71
+ - lib/flattr/core_ext/hash.rb
72
+ - lib/flattr/language.rb
73
+ - lib/flattr/oauth2.rb
74
+ - lib/flattr/request.rb
75
+ - lib/flattr/request/oauth2.rb
76
+ - lib/flattr/response/parse_json.rb
77
+ - lib/flattr/thing.rb
78
+ - lib/flattr/user.rb
79
+ - lib/flattr/version.rb
80
+ homepage: ''
81
+ licenses: []
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project: flattr
100
+ rubygems_version: 1.8.10
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: Write a gem summary
104
+ test_files: []