saas_pulse-ruby 0.1.1 → 0.1.2

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 CHANGED
@@ -15,6 +15,12 @@ First, build your client with your API id:
15
15
 
16
16
  SaasPulse.srv_id "YOUR_ID_GOES_HERE"
17
17
 
18
+ You must turn the tracker on - otherwise the url will be printed to stdout and no call will be performed.
19
+
20
+ SaasPulse.on!
21
+
22
+ You will probably only want to do this in production mode.
23
+
18
24
  You can then interact with `SaasPulse.client` to do your bidding:
19
25
 
20
26
  SaasPulse.client.track({
data/lib/saas_pulse.rb CHANGED
@@ -4,6 +4,7 @@ $:.unshift(lib) unless $:.include?(lib)
4
4
  require 'open-uri'
5
5
  require 'cgi'
6
6
 
7
+ require 'saas_pulse/config'
7
8
  require 'saas_pulse/client'
8
9
  require 'saas_pulse/arg_parser'
9
10
  require 'saas_pulse/tracker'
@@ -16,11 +16,11 @@ module SaasPulse
16
16
  end
17
17
 
18
18
  def on?
19
- !!@on
19
+ Config[:on]
20
20
  end
21
21
 
22
22
  def on!
23
- @on = true
23
+ Config[:on] = true
24
24
  end
25
25
  end
26
26
 
@@ -33,9 +33,17 @@ module SaasPulse
33
33
  url = build_url(data)
34
34
 
35
35
  if SaasPulse.on?
36
- Thread.new {open(url)}
36
+ Thread.new do
37
+ begin
38
+ open(url)
39
+ rescue => e
40
+ STDERR.puts "[SaasPulse] ERROR making call to SaaSPulse: #{e.class} ~> #{e.message}"
41
+ end
42
+ end
37
43
  else
38
- puts "[SaasPulse] Fake call to #{url}. To make a real call, run SaasPulse.on!"
44
+ unless Config[:suppress_output]
45
+ puts "[SaasPulse] Fake call to #{url}. To make a real call, run SaasPulse.on!"
46
+ end
39
47
  end
40
48
  end
41
49
 
@@ -0,0 +1,25 @@
1
+ module SaasPulse
2
+ class Config
3
+ class <<self
4
+ def defaults
5
+ @defaults ||= {
6
+ :on => false,
7
+ :suppress_output => false
8
+ }
9
+ end
10
+
11
+ def [](setting)
12
+ defaults[setting]
13
+ end
14
+
15
+ def []=(setting, value)
16
+ defaults[setting] = value
17
+ end
18
+
19
+ def use
20
+ yield defaults
21
+ end
22
+ end
23
+ end
24
+ end
25
+
@@ -1,3 +1,3 @@
1
1
  module SaasPulse
2
- VERSION = "0.1.1" unless defined?(::SaasPulse::VERSION)
2
+ VERSION = "0.1.2" unless defined?(::SaasPulse::VERSION)
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - jonah honeyman
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-23 00:00:00 +02:00
17
+ date: 2010-12-13 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -50,6 +50,7 @@ files:
50
50
  - lib/saas_pulse/adapters/merb.rb
51
51
  - lib/saas_pulse/adapter.rb
52
52
  - lib/saas_pulse/tracker.rb
53
+ - lib/saas_pulse/config.rb
53
54
  - LICENSE
54
55
  - README.md
55
56
  has_rdoc: true