swapi 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/swapi.rb +51 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8a9bb329af69a0667085cf9be7d8f73149bdd300
|
4
|
+
data.tar.gz: 894692f637ff716388cb939c158e5b77c1794216
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b30fc267d1a3444b94887c7bf8e8ac530f1e4afee5e4694851e089edcac709cc95a0bcb1f9bafc92e18f7e5e591e82c83675d388144463a3eb7a325e2981d7f6
|
7
|
+
data.tar.gz: 7a3b29865d5072df3d9ecf8d9e8ffdacfb511facd6e33386771732221aaea1d3f92c9ad81eb17192873092df40c799852e7e85a3618a01aff24b1cfb1708925c
|
data/lib/swapi.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
module Swapi
|
4
|
+
class << self
|
5
|
+
BASE_URL = 'http://swapi.co/api'
|
6
|
+
PLANETS = 'planets'
|
7
|
+
PEOPLE = 'people'
|
8
|
+
STARSHIPS = 'starships'
|
9
|
+
VEHICLES = 'vehicles'
|
10
|
+
SPECIES = 'species'
|
11
|
+
FILMS = 'films'
|
12
|
+
|
13
|
+
def get_all type
|
14
|
+
get type
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_planet planet_id
|
18
|
+
get PLANETS, planet_id
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_person people_id
|
22
|
+
get PEOPLE, people_id
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_starship starship_id
|
26
|
+
get STARSHIPS, starship_id
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_vehicle vehicle_id
|
30
|
+
get VEHICLES, vehicle_id
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_species species_id
|
34
|
+
get SPECIES, species_id
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_film film_id
|
38
|
+
get FILMS, film_id
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def get type, id = ''
|
44
|
+
response = execute_request("#{type}/#{id}")
|
45
|
+
end
|
46
|
+
|
47
|
+
def execute_request uri
|
48
|
+
response = open("#{BASE_URL}/#{uri}").read
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: swapi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ezequiel Maraschio
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-22 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A Ruby helper library for swapi.co - the Star Wars API
|
14
|
+
email: ezequiel.maraschio@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/swapi.rb
|
20
|
+
homepage: https://github.com/emaraschio/swapi-ruby
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.2.2
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Swapi
|
44
|
+
test_files: []
|