soul_points 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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
- Code borrows heavily from the heroku gem. Thanks to the heroku team for that.
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
 
@@ -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
- puts RestClient.post 'http://mysoulpoints.com/events', :event => { :value => args[0], :description => args[1] }, :auth_token => @credentials[:api_key], :accept => :json
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
@@ -1,3 +1,3 @@
1
1
  module SoulPoints
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
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.1
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-19 00:00:00 -07:00
13
+ date: 2011-02-20 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency