KerbalStuff 0.1.3 → 0.1.4

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.
Files changed (3) hide show
  1. data/README.md +17 -5
  2. data/lib/KerbalStuff.rb +21 -21
  3. 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.SearchMod(string) # will return a JSON object containing the search results
30
- ks.SearchUser(string)
31
- ks.User(string) # will return a JSON object containing information about the specified user
32
- ks.Mod(integer) # will return a JSON object containing information about the specified mod
33
- ks.GetLatestVersion(integer) # will return a JSON object containing information about the last version released for the specified mod.
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
@@ -4,11 +4,11 @@ require 'uri'
4
4
 
5
5
  module KerbalStuff
6
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/"
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.SearchMod(query)
30
- response = get_https_response("#{SEARCH_MOD}#{query}")
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.SearchUser(query)
39
- response = get_https_response("#{SEARCH_USER}#{query}")
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.User(username)
47
+ def self.user(username)
48
48
  raise "username cannot be nil" unless username.length > 0
49
49
 
50
- response = get_https_response("#{USER}#{username}")
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.Mod(id)
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("#{MOD}#{id}")
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 slast released version of the specified mod.
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.GetLatestVersion(id)
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("#{MOD}#{id}/latest")
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.GetBasicModInfo(id)
81
- oldHash = Mod(id)
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.GetBasicUserInfo(string)
99
- oldHash = User(string)
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["forumUsername"] = oldHash["forumUsername"]
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.3
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-19 00:00:00.000000000 Z
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