rack-olark 0.0.1 → 0.0.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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/rack/olark.rb +5 -3
  3. data/lib/rack-olark.rb +1 -0
  4. metadata +3 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/lib/rack/olark.rb CHANGED
@@ -1,14 +1,16 @@
1
1
  require 'rack'
2
+ require 'rack/request'
2
3
  require 'haml'
3
4
 
4
5
  module Rack
5
6
  class Olark
6
- Defaults = {:format => :html5}
7
+ Defaults = {:format => :html5, :paths => []}
7
8
 
8
9
  def initialize(app, options = {})
9
10
  raise ArgumentError, "Need a valid Olark ID!" unless options[:id] and options[:id].length.eql? 16
10
11
  @app, @options = app, Defaults.merge(options)
11
- @id, @format = [@options.delete(:id), @options.delete(:format)]
12
+ @id, @format, @paths = [@options.delete(:id), @options.delete(:format), @options.delete(:paths)]
13
+ @paths = [] unless @paths.class.eql? Array
12
14
  @option_js = "olark.identify('#{@id}');"
13
15
  @options.each do |key, val|
14
16
  @option_js << "olark.configure('#{key.to_s}', #{[String, Symbol].include? val.class ? "'#{val.to_s}'" : val.to_s});"
@@ -21,7 +23,7 @@ module Rack
21
23
 
22
24
  def _call(env)
23
25
  @status, @headers, @response = @app.call(env)
24
- return [@status, @headers, @response] unless html?
26
+ return [@status, @headers, @response] unless html? and (@paths.empty? or @paths.include? Rack::Request.new(env).path_info)
25
27
  response = Rack::Response.new [], @status, @headers
26
28
  @response.each {|fragment| response.write inject(fragment)}
27
29
  response.finish
data/lib/rack-olark.rb ADDED
@@ -0,0 +1 @@
1
+ require 'rack/olark'
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rack-olark
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dan Poggi
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-04 00:00:00 Z
13
+ date: 2011-05-05 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -51,6 +51,7 @@ files:
51
51
  - README.md
52
52
  - Rakefile
53
53
  - VERSION
54
+ - lib/rack-olark.rb
54
55
  - lib/rack/olark.rb
55
56
  - lib/rack/templates/olark.haml
56
57
  - rack-olark.gemspec