KerbalStuff 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +17 -5
- data/lib/KerbalStuff.rb +21 -21
- metadata +2 -2
data/README.md
CHANGED
@@ -15,6 +15,13 @@ You can install the gem like this:
|
|
15
15
|
gem install kerbalstuff
|
16
16
|
|
17
17
|
|
18
|
+
## Updating
|
19
|
+
|
20
|
+
When a new update is released, you can update your gem like this:
|
21
|
+
|
22
|
+
gem update kerbalstuff
|
23
|
+
|
24
|
+
|
18
25
|
## Examples
|
19
26
|
|
20
27
|
Here are some examples of how you can use the wrapper.
|
@@ -26,11 +33,16 @@ require 'kerbalstuff' # Require the Gem
|
|
26
33
|
```ruby
|
27
34
|
ks = KerbalStuff # Initialize the wrapper
|
28
35
|
|
29
|
-
ks.
|
30
|
-
ks.
|
31
|
-
|
32
|
-
ks.
|
33
|
-
ks.
|
36
|
+
ks.search_mod(string) # will return a hash containing the search results
|
37
|
+
ks.search_user(string)
|
38
|
+
|
39
|
+
ks.user(string) # will return a hash containing information about the specified user
|
40
|
+
ks.mod(integer) # will return a hash containing information about the specified mod
|
41
|
+
|
42
|
+
ks.get_latest_version(integer) # will return a hash containing information about the last version released for the specified mod.
|
43
|
+
|
44
|
+
ks.get_basic_mod_info(integer) # will return a hash containing basic information about the mod - name, author, downloads, url, latest version
|
45
|
+
ks.get_basic_user_info(integer) # will return a hash containing basic information about the user - name, mods, irc nick, forum nick.
|
34
46
|
```
|
35
47
|
|
36
48
|
## Documentation
|
data/lib/KerbalStuff.rb
CHANGED
@@ -4,11 +4,11 @@ require 'uri'
|
|
4
4
|
|
5
5
|
module KerbalStuff
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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_url = "https://kerbalstuff.com/api/user/"
|
11
|
+
mod_url = "https://kerbalstuff.com/api/mod/"
|
12
12
|
|
13
13
|
def self.get_https_response(url)
|
14
14
|
@url = URI.parse(URI.escape(url))
|
@@ -26,8 +26,8 @@ module KerbalStuff
|
|
26
26
|
#
|
27
27
|
# @param query [String] the keyword/phrase to search for.
|
28
28
|
# @return [Hash] A parsed JSON output containing the mods which were found.
|
29
|
-
def self.
|
30
|
-
response = get_https_response("#{
|
29
|
+
def self.search_mod(query)
|
30
|
+
response = get_https_response("#{search_mod}#{query}")
|
31
31
|
JSON.parse(response.body)
|
32
32
|
end
|
33
33
|
|
@@ -35,8 +35,8 @@ module KerbalStuff
|
|
35
35
|
#
|
36
36
|
# @param query [String] the keyword/phrase to search for.
|
37
37
|
# @return [Hash] A parsed JSON output containing the users which were found.
|
38
|
-
def self.
|
39
|
-
response = get_https_response("#{
|
38
|
+
def self.search_user(query)
|
39
|
+
response = get_https_response("#{search_user}#{query}")
|
40
40
|
JSON.parse(response.body)
|
41
41
|
end
|
42
42
|
|
@@ -44,10 +44,10 @@ module KerbalStuff
|
|
44
44
|
#
|
45
45
|
# @param username [String] the username to retrieve its information.
|
46
46
|
# @return [Hash] A parsed JSON output containing the information about the user.
|
47
|
-
def self.
|
47
|
+
def self.user(username)
|
48
48
|
raise "username cannot be nil" unless username.length > 0
|
49
49
|
|
50
|
-
response = get_https_response("#{
|
50
|
+
response = get_https_response("#{user_url}#{username}")
|
51
51
|
JSON.parse(response.body)
|
52
52
|
end
|
53
53
|
|
@@ -55,21 +55,21 @@ module KerbalStuff
|
|
55
55
|
#
|
56
56
|
# @param id [Fixnum] the id to retrieve its information.
|
57
57
|
# @return [Hash] A parsed JSON output containing the information about the mod.
|
58
|
-
def self.
|
58
|
+
def self.mod(id)
|
59
59
|
raise "id cannot be nil" unless id.is_a?(Integer) and id > 0
|
60
60
|
|
61
|
-
response = get_https_response("#{
|
61
|
+
response = get_https_response("#{mod_url}#{id}")
|
62
62
|
JSON.parse(response.body)
|
63
63
|
end
|
64
64
|
|
65
|
-
# Retrieves the information about the
|
65
|
+
# Retrieves the information about the last released version of the specified mod.
|
66
66
|
#
|
67
67
|
# @param username [Fixnum] the id to retrieve information of its latest version released.
|
68
68
|
# @return [Hash] A parsed JSON output containing the information about the latest version released.
|
69
|
-
def self.
|
69
|
+
def self.get_latest_version(id)
|
70
70
|
raise "id cannot be nil" unless id.is_a?(Integer) and id > 0
|
71
71
|
|
72
|
-
response = get_https_response("#{
|
72
|
+
response = get_https_response("#{mod}#{id}/latest")
|
73
73
|
JSON.parse(response.body)
|
74
74
|
end
|
75
75
|
|
@@ -77,8 +77,8 @@ module KerbalStuff
|
|
77
77
|
#
|
78
78
|
# @param id [Fixnum] The id of the mod to retrieve information for.
|
79
79
|
# @return [Hash] A hash containing basic mod info.
|
80
|
-
def self.
|
81
|
-
oldHash =
|
80
|
+
def self.get_basic_mod_info(id)
|
81
|
+
oldHash = mod(id)
|
82
82
|
|
83
83
|
modHash = Hash.new()
|
84
84
|
modHash["name"] = oldHash["name"]
|
@@ -95,14 +95,14 @@ module KerbalStuff
|
|
95
95
|
#
|
96
96
|
# @param username [String] The user to gather information for.
|
97
97
|
# @return [Hash] A hash containing the basic user info.
|
98
|
-
def self.
|
99
|
-
oldHash =
|
98
|
+
def self.get_basic_user_info(string)
|
99
|
+
oldHash = user(string)
|
100
100
|
|
101
101
|
userHash = Hash.new()
|
102
102
|
userHash["username"] = oldHash["username"]
|
103
103
|
userHash["mods"] = oldHash["mods"]
|
104
104
|
userHash["ircNick"] = oldHash["ircNick"]
|
105
|
-
userHash["
|
105
|
+
userHash["forumusername"] = oldHash["forumusername"]
|
106
106
|
|
107
107
|
userHash
|
108
108
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: KerbalStuff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-09-
|
12
|
+
date: 2014-09-22 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A simple API wrapper for KerbalStuff
|
15
15
|
email: rockytvbr@gmail.com
|