soul_points 0.0.1 → 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/README.md +12 -1
- data/lib/soul_points/client.rb +16 -2
- data/lib/soul_points/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,7 +1,18 @@
|
|
1
1
|
MySoulPoints API - Your morale, quantified.
|
2
2
|
===========================================
|
3
3
|
|
4
|
+
A lame client, but a decent CLI interface for mysoulpoints.com
|
5
|
+
|
4
6
|
Create your account at http://mysoulpoints.com
|
5
7
|
|
6
|
-
|
8
|
+
## Usage
|
9
|
+
$ gem install soul_points #use sudo if necessary
|
10
|
+
$ soul_points store_api_key YOUR_API_KEY #You can find it on your account page
|
11
|
+
$ soul_points show mcphat
|
12
|
+
$ soul_points gain 500 "Something amazing happened"
|
13
|
+
$ soul_points lose 50 "Stubbed my toe"
|
14
|
+
|
15
|
+
###### Thanks
|
16
|
+
Gem code borrowed heavily from the heroku gem.
|
17
|
+
Thanks to the heroku team for that.
|
7
18
|
|
data/lib/soul_points/client.rb
CHANGED
@@ -52,11 +52,25 @@ class SoulPoints::Client
|
|
52
52
|
def show( args )
|
53
53
|
subdomain = args[0]
|
54
54
|
soul_points = JSON.parse( RestClient.get 'http://' + subdomain + '.mysoulpoints.com', :accept => :json )
|
55
|
-
puts soul_points['soul_point']['current'].to_s + '/' + soul_points['soul_point']['max'].to_s
|
55
|
+
puts '(' + soul_points['soul_point']['current'].to_s + '/' + soul_points['soul_point']['max'].to_s + ') ' + sprintf( "%0.1f", ( soul_points['soul_point']['current'].to_f / soul_points['soul_point']['max'].to_f ) * 100 ) + "%"
|
56
|
+
end
|
57
|
+
|
58
|
+
def me( args )
|
59
|
+
me = JSON.parse( RestClient.get 'http://mysoulpoints.com/me.json?auth_token=' + @credentials[:api_key], :accept => :json )
|
60
|
+
puts me['email']
|
61
|
+
puts '(' + me['soul_points']['current'].to_s + '/' + me['soul_points']['max'].to_s + ') ' + sprintf( "%0.1f", ( me['soul_points']['current'].to_f / me['soul_points']['max'].to_f ) * 100 ) + "%"
|
56
62
|
end
|
57
63
|
|
58
64
|
def gain( args )
|
59
|
-
|
65
|
+
resp = RestClient.post 'http://mysoulpoints.com/events.json', :event => { :value => args[0], :description => args[1] }, :auth_token => @credentials[:api_key], :accept => :json
|
66
|
+
|
67
|
+
if args[0].to_i > 0
|
68
|
+
puts "You \033[1;32mgained\033[0m #{args[0].to_i.abs} soul points - \"#{args[1]}\"."
|
69
|
+
else
|
70
|
+
puts "You \033[1;31mlost\033[0m #{args[0].to_i.abs} soul points - \"#{args[1]}\"."
|
71
|
+
end
|
72
|
+
|
73
|
+
me(args)
|
60
74
|
end
|
61
75
|
|
62
76
|
# Pretty much just an alias for gain, with negative number
|
data/lib/soul_points/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: soul_points
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0
|
5
|
+
version: 0.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Forge Apps
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-02-
|
13
|
+
date: 2011-02-20 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|