This commit is contained in:
Tommy Parnell
2015-05-17 01:49:07 -04:00
parent 1c2d3f2afd
commit 65b9177950
7 changed files with 71 additions and 28 deletions

View File

@@ -4,25 +4,27 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'NetrunnerDb/version'
Gem::Specification.new do |spec|
spec.name = "NetrunnerDb"
spec.name = 'NetrunnerDb'
spec.version = NetrunnerDb::VERSION
spec.authors = ["Tommy Parnell"]
spec.email = ["tparnell8@gmail.com"]
spec.authors = ['Tommy Parnell']
spec.email = ['tparnell8@gmail.com']
if spec.respond_to?(:metadata)
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
end
spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.}
spec.description = %q{TODO: Write a longer description or delete this line.}
spec.homepage = "TODO: Put your gem's website or public repo URL here."
spec.license = "MIT"
spec.summary = %q{Wrapper over NetrunnerDb API}
spec.description = %q{Wrapper over NetrunnerDb API}
spec.homepage = 'https://github.com/tparnell8/RNetrunnerDb'
spec.license = 'MIT'
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = "exe"
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.require_paths = ['lib']
spec.add_development_dependency "bundler", "~> 1.8"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency 'bundler', '~> 1.8'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency "minitest"
spec.add_development_dependency "vcr"
spec.add_development_dependency "webmock"
spec.add_dependency 'faraday'
spec.add_dependency 'json'
end

View File

@@ -1,8 +1,6 @@
# NetrunnerDb
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/NetrunnerDb`. To experiment with that code, run `bin/console` for an interactive prompt.
TODO: Delete this and the text above, and describe your gem
Simple wrapper over netrunnerDb API
## Installation
@@ -22,7 +20,12 @@ Or install it yourself as:
## Usage
TODO: Write usage instructions here
```ruby
res = NetrunnerDb::HttpHandler.get_cards
res = NetrunnerDb::HttpHandler.get_card(01001)
res = NetrunnerDb::HttpHandler.get_sets
res = NetrunnerDb::HttpHandler.get_set("cc")
```
## Development
@@ -32,8 +35,14 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
## Contributing
1. Fork it ( https://github.com/[my-github-username]/NetrunnerDb/fork )
1. Fork it ( https://github.com/tparnell8/RNetrunnerDb/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
## todo
* test things
* figure out ruby better
* who knows

View File

@@ -1,2 +1,6 @@
require "bundler/gem_tasks"
require 'rake/testtask'
Rake::TestTask.new do |t|
t.pattern = 'test/test_*.rb'
end

View File

@@ -1,5 +1,5 @@
require "NetrunnerDb/version"
require 'NetrunnerDb/version'
require 'NetrunnerDb/http_handler'
module NetrunnerDb
# Your code goes here...
end

View File

@@ -0,0 +1,31 @@
require 'faraday'
require 'json'
module NetrunnerDb
class HttpHandler
def self.process_request(url_param)
response = Faraday.get("http://netrunnerdb.com#{url_param}")
nil unless response.env['status'] == 200
JSON.parse(response.body)
end
def self.get_sets
return HttpHandler.process_request('/api/sets/')
end
def self.get_cards
return HttpHandler.process_request('/api/cards/')
end
def self.get_set(set_code)
return HttpHandler.process_request("/api/set/#{set_code}/")
end
def self.get_card(card_code)
return HttpHandler.process_request("/api/card/#{card_code}/")
end
def self.get_decklist(decklist_id)
return HttpHandler.process_request("/api/decklist/#{decklist_id}/")
end
end
end

View File

@@ -1,3 +1,3 @@
module NetrunnerDb
VERSION = "0.1.0"
VERSION = '0.1.0'
end

View File

@@ -1,11 +1,8 @@
require 'minitest_helper'
require_relative 'minitest_helper'
class TestNetrunnerDb < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::NetrunnerDb::VERSION
end
def test_it_does_something_useful
assert false
end
end