tipjoy 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
data/lib/tipjoy.rb CHANGED
@@ -1,5 +1,33 @@
1
1
  module Tipjoy
2
2
  TIPJOY_BASE_URL = "http://tipjoy.com"
3
+
4
+ def self.log!(logger=Logger.new(true))
5
+ self.logger = logger
6
+ end
7
+
8
+ def self.logger
9
+ @logger ||= Logger.new
10
+ end
11
+
12
+ def self.logger=(l)
13
+ @logger = l
14
+ end
15
+
16
+ class Logger
17
+ attr_accessor :on
18
+
19
+ def initialize(on=false)
20
+ self.on = on
21
+ end
22
+
23
+ def info(msg)
24
+ puts msg if self.on?
25
+ end
26
+
27
+ def on?
28
+ self.on
29
+ end
30
+ end
3
31
  end
4
32
 
5
33
  require File.dirname(__FILE__) + "/../init"
@@ -21,9 +21,11 @@ module Tipjoy
21
21
  end
22
22
 
23
23
  def tipjoy_request(method, url, data={})
24
+ Tipjoy.logger.info("requesting via #{method} " + url + "with args " + data.inspect)
24
25
  response = tipjoy_http_request(method, url, data)
25
26
 
26
27
  if !(200..299).include?(response.code.to_i)
28
+ Tipjoy.logger.info(" RequestError " + response.inspect)
27
29
  raise RequestError.new('ah!')
28
30
  end
29
31
 
@@ -31,9 +33,11 @@ module Tipjoy
31
33
  json = JSON.parse(response.body)
32
34
 
33
35
  if json['result'] != 'success'
36
+ Tipjoy.logger.info(" ResultError " + json.inspect)
34
37
  raise ::Tipjoy::ResultError.new(json.inspect)
35
38
  end
36
39
 
40
+ Tipjoy.logger.info(" response: " + json.inspect)
37
41
  json
38
42
  end
39
43
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  dir = File.expand_path(File.dirname(__FILE__))
2
2
  require "rubygems"
3
- require 'spec/autorun'
3
+ require 'spec'
4
+ #require 'spec/autorun'
4
5
  #require 'mash'
5
6
  require dir + '/../init'
6
7
  require dir + '/doubles/fake_oauth_client'
data/tipjoy.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tipjoy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Parker Thompson
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-05-28 00:00:00 -07:00
14
+ date: 2009-05-30 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies: []
17
17
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tipjoy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Parker Thompson
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-05-28 00:00:00 -07:00
14
+ date: 2009-05-30 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies: []
17
17