-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tim Adler
committed
Feb 2, 2015
1 parent
8571bf0
commit 48ea469
Showing
28 changed files
with
426 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,3 @@ | ||
*.gem | ||
*.rbc | ||
/.config | ||
/coverage/ | ||
/InstalledFiles | ||
/pkg/ | ||
/spec/reports/ | ||
/test/tmp/ | ||
/test/version_tmp/ | ||
/tmp/ | ||
|
||
## Specific to RubyMotion: | ||
.dat* | ||
.repl_history | ||
build/ | ||
|
||
## Documentation cache and generated files: | ||
/.yardoc/ | ||
/_yardoc/ | ||
/doc/ | ||
/rdoc/ | ||
|
||
## Environment normalisation: | ||
/.bundle/ | ||
/lib/bundler/man/ | ||
|
||
# for a library or gem, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# Gemfile.lock | ||
# .ruby-version | ||
# .ruby-gemset | ||
|
||
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: | ||
.rvmrc | ||
bin | ||
coverage | ||
*.gem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
LineLength: | ||
Max: 999 | ||
Documentation: | ||
Enabled: false | ||
StringLiterals: | ||
Enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
source "https://rubygems.org" | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
giant_bomb_api (0.1) | ||
faraday | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
codeclimate-test-reporter (0.4.5) | ||
simplecov (>= 0.7.1, < 1.0.0) | ||
diff-lcs (1.2.5) | ||
docile (1.1.5) | ||
faraday (0.9.0) | ||
multipart-post (>= 1.2, < 3) | ||
multi_json (1.10.1) | ||
multipart-post (2.0.0) | ||
rake (10.1.1) | ||
rspec (3.1.0) | ||
rspec-core (~> 3.1.0) | ||
rspec-expectations (~> 3.1.0) | ||
rspec-mocks (~> 3.1.0) | ||
rspec-core (3.1.7) | ||
rspec-support (~> 3.1.0) | ||
rspec-expectations (3.1.2) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.1.0) | ||
rspec-mocks (3.1.3) | ||
rspec-support (~> 3.1.0) | ||
rspec-support (3.1.2) | ||
simplecov (0.9.1) | ||
docile (~> 1.1.0) | ||
multi_json (~> 1.0) | ||
simplecov-html (~> 0.8.0) | ||
simplecov-html (0.8.0) | ||
timecop (0.7.1) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
codeclimate-test-reporter | ||
giant_bomb_api! | ||
rake (~> 10.1.0) | ||
rspec (~> 3.0) | ||
timecop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,51 @@ | ||
<<<<<<< HEAD | ||
# giant_bomb_api | ||
======= | ||
# filter8 | ||
A unofficial ruby wrapper for Filter8 (http://filter8.com). An API to filter lots of stuff from texts, e.g. bad words. | ||
|
||
[](https://codeclimate.com/github/toadle/filter8) | ||
[](https://codeclimate.com/github/toadle/filter8) | ||
|
||
# Installation | ||
|
||
|
||
As you'd expect. Nothing special here: | ||
|
||
``` | ||
gem install filter8 | ||
``` | ||
|
||
# How to use | ||
|
||
## Configuration | ||
|
||
Before you use Filter8 you need to configure it: | ||
``` | ||
Filter8.configure do |config| | ||
config.api_key = "your filter8-api-key" | ||
config.api_secret = "your filter8-api-secret" | ||
end | ||
``` | ||
|
||
## Usage | ||
|
||
Simply send the content, you wish to filter with the filter-method: | ||
``` | ||
Filter8.filter("your content") | ||
``` | ||
|
||
If you want to change the **default-options** of filter8 (https://filter8.com/documentation), you can pass an optional options-hash with the filter-configuration: | ||
``` | ||
Filter8.filter("your content", blacklist: {enabled: true, locales: [:en, :de, :fr], tags: ["AsciiArt"]}) | ||
``` | ||
|
||
The **email** and **urls** filters are not yet supported. | ||
|
||
## Feedback | ||
Feedback and pull-request are always welcome. | ||
You can find the author via http://toadle.me | ||
|
||
## License | ||
The filter8-gem is released under the [MIT License](http://opensource.org/licenses/MIT). | ||
>>>>>>> initial commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require "bundler" | ||
require 'rspec/core/rake_task' | ||
|
||
task :default => :spec | ||
|
||
Bundler::GemHelper.install_tasks | ||
RSpec::Core::RakeTask.new :spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Gem::Specification.new do |s| | ||
s.name = "giant_bomb_api" | ||
s.version = "0.1" | ||
s.default_executable = "giantbomb" | ||
|
||
s.authors = ["Tim Adler"] | ||
s.date = %q{2015-02-01} | ||
s.description = %q{An unofficial ruby wrapper for the Giantbomb API (http://api.giantbomb.com). An API that provides structured data about videogames.} | ||
s.summary = s.description | ||
s.email = %q{mail (at) toadle (dot) me} | ||
s.license = "MIT" | ||
|
||
s.files = `git ls-files`.split("\n") | ||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
s.homepage = %q{https://github.com/toadle/giant_bomb_api} | ||
s.require_paths = ["lib"] | ||
s.rubygems_version = %q{1.6.2} | ||
|
||
s.add_dependency 'faraday' | ||
|
||
s.add_development_dependency 'rake', '~> 10.1.0' | ||
s.add_development_dependency 'rspec', '~> 3.0' | ||
s.add_development_dependency 'timecop' | ||
s.add_development_dependency 'codeclimate-test-reporter' | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require "giant_bomb_api/exception" | ||
require "giant_bomb_api/client" | ||
require "giant_bomb_api/request" | ||
require "giant_bomb_api/request/search" | ||
require "giant_bomb_api/resource" | ||
require "giant_bomb_api/resource/game" | ||
|
||
module GiantBombApi | ||
|
||
class Configuration | ||
attr_accessor :api_key | ||
end | ||
|
||
class << self | ||
attr_accessor :configuration | ||
end | ||
|
||
def self.raise_error(message) | ||
raise Exception.new message | ||
end | ||
|
||
def self.configure | ||
self.configuration ||= Configuration.new | ||
yield(configuration) | ||
|
||
@@client = nil | ||
end | ||
|
||
def self.search(query) | ||
client.send_request(Request::Search.new(query)) | ||
end | ||
|
||
def self.client | ||
raise_error "Configure GiantBombApi-module before using" if GiantBombApi.configuration.nil? | ||
raise_error "Configure 'api_key' first" if GiantBombApi.configuration.api_key.nil? | ||
|
||
@@client ||= Client.new(api_key: GiantBombApi.configuration.api_key) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'digest' | ||
require 'uri' | ||
require 'faraday' | ||
require 'json' | ||
|
||
module GiantBombApi | ||
class Client | ||
attr_accessor :api_key | ||
|
||
API_URL = 'http://api.giantbomb.com' | ||
|
||
def initialize(api_key: nil, options: {}) | ||
@api_key = api_key | ||
@options = options | ||
end | ||
|
||
def send_request(giant_bomb_api_request) | ||
conn = Faraday.new(:url => API_URL) do |faraday| | ||
faraday.request :url_encoded | ||
faraday.adapter Faraday.default_adapter | ||
end | ||
|
||
response = conn.get "#{API_ENDPOINT}", giant_bomb_api_request.request_params | ||
|
||
raise Exception.new("Status: #{response.status}): #{response.body}") if(response.status != GiantBomb::Response::Status::OK) | ||
|
||
JSON.parse(response.body) | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module GiantBombApi | ||
class Exception < StandardError | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module GiantBombApi | ||
class Request | ||
attr_accessor :params | ||
|
||
def initialize(endpoint, params) | ||
@params = params | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module GiantBombApi | ||
class Request::Search < GiantBombApi::Request | ||
ENDPOINT = '/search' | ||
|
||
def initialize(query, resources: [GiantBombApi::Resource::Game], limit: 100, page: 1) | ||
params = { | ||
query: query, | ||
resources: resources.map { |clazz| clazz.name.split('::').last.downcase }.join(','), | ||
limit: limit, | ||
page: page | ||
} | ||
super ENDPOINT, params | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module GiantBombApi | ||
class Resource | ||
|
||
private | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module GiantBombApi | ||
class Character < Resource | ||
|
||
private | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module GiantBombApi | ||
class Company < Resource | ||
|
||
private | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module GiantBombApi | ||
class Concept < Resource | ||
|
||
private | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module GiantBombApi | ||
class Franchise < Resource | ||
|
||
private | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module GiantBombApi | ||
class Resource::Game < GiantBombApi::Resource | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module GiantBombApi | ||
class Location < Resource | ||
|
||
private | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module GiantBombApi | ||
class Object < Resource | ||
|
||
private | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module GiantBombApi | ||
class Person < Resource | ||
|
||
private | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module GiantBombApi | ||
class Video < Resource | ||
|
||
private | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module GiantBombApi | ||
class Response | ||
attr_accessor :json | ||
|
||
def initialize(json) | ||
@json = json | ||
end | ||
|
||
end | ||
end |
Oops, something went wrong.