KerbalStuff 0.1.0
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.
- data/lib/KerbalStuff.rb +56 -0
- metadata +46 -0
data/lib/KerbalStuff.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
module KerbalStuff
|
6
|
+
|
7
|
+
API_URL = "https://kerbalstuff.com/api"
|
8
|
+
SEARCH_MOD = "https://kerbalstuff.com/api/search/mod?query="
|
9
|
+
SEARCH_USER = "https://kerbalstuff.com/api/search/user?query="
|
10
|
+
USER = "https://kerbalstuff.com/api/user/"
|
11
|
+
MOD = "https://kerbalstuff.com/api/mod/"
|
12
|
+
|
13
|
+
def self.get_https_response(url)
|
14
|
+
@url = URI.parse(url)
|
15
|
+
http = Net::HTTP.new(@url.host, @url.port)
|
16
|
+
http.use_ssl = true
|
17
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
18
|
+
|
19
|
+
request = Net::HTTP::Get.new(@url.request_uri)
|
20
|
+
|
21
|
+
response = http.request(request)
|
22
|
+
response
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.SearchMod(query)
|
26
|
+
response = get_https_response("#{SEARCH_MOD}#{query}")
|
27
|
+
JSON.parse(response.body)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.SearchUser(query)
|
31
|
+
response = get_https_response("#{SEARCH_USER}#{query}")
|
32
|
+
JSON.parse(response.body)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.User(username)
|
36
|
+
raise "username cannot be nil" unless username.length > 0
|
37
|
+
|
38
|
+
response = get_https_response("#{USER}#{username}")
|
39
|
+
JSON.parse(response.body)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.Mod(id)
|
43
|
+
raise "id cannot be nil" unless id.is_a?(Integer) and id > 0
|
44
|
+
|
45
|
+
response = get_https_response("#{MOD}#{id}")
|
46
|
+
JSON.parse(response.body)
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.GetLatestVersion(id)
|
50
|
+
raise "id cannot be nil" unless id.is_a?(Integer) and id > 0
|
51
|
+
|
52
|
+
response = get_https_response("#{MOD}#{id}/latest")
|
53
|
+
JSON.parse(response.body)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: KerbalStuff
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alexandre Oliveira
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-09-17 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A simple API wrapper for KerbalStuff
|
15
|
+
email: rockytvbr@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/KerbalStuff.rb
|
21
|
+
homepage: http://rubygems.org/gems/kerbalstuff
|
22
|
+
licenses:
|
23
|
+
- GPL
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 1.8.28
|
43
|
+
signing_key:
|
44
|
+
specification_version: 3
|
45
|
+
summary: KerbalStuff
|
46
|
+
test_files: []
|