omniturize 0.0.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +17 -19
- data/lib/omniturize.rb +1 -4
- data/lib/omniturize/base.rb +5 -94
- data/lib/omniturize/printer.rb +25 -15
- data/lib/omniturize/version.rb +1 -1
- data/omniturize.gemspec +2 -0
- metadata +22 -11
- data/lib/class_level_inheritable_attributes.rb +0 -31
- data/lib/omniturize/meta_js.rb +0 -56
- data/lib/omniturize/meta_var.rb +0 -67
- data/lib/omniturize/var.rb +0 -22
data/README.markdown
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
# Omniturize
|
2
|
-
This gem integrates Omniture SiteCatalyst into your web app.
|
2
|
+
This gem integrates Omniture SiteCatalyst into your web app.
|
3
|
+
|
4
|
+
## Dependencies
|
5
|
+
This gem depends on [meta_vars](https://github.com/eLafo/meta_vars "eLafo's meta_vars") gem
|
3
6
|
|
4
7
|
## Installation
|
5
8
|
gem install omniturize
|
6
9
|
|
7
10
|
## Based on and unaware collaborators
|
8
|
-
This is gem is based on [activenetwork's OmnitureClient gem](https://github.com/activenetwork/omniture_client
|
11
|
+
This is gem is based on [activenetwork's OmnitureClient gem](https://github.com/activenetwork/omniture_client "activenetwork's OmnitureClient"), which was forked from [acatighera's](https://github.com/acatighera/omniture_client, "acatighera's OmnitureClient").
|
9
12
|
|
10
13
|
There is some borrowed code from unawared coders. So thank you to
|
11
14
|
|
12
|
-
* [acatighera](https://github.com/acatighera
|
13
|
-
* [activenetwork](https://github.com/activenetwork
|
14
|
-
* [John Nunemaker](http://railstips.org/about
|
15
|
+
* [acatighera](https://github.com/acatighera "acatighera github homepage")
|
16
|
+
* [activenetwork](https://github.com/activenetwork "activenetwork github homepage")
|
17
|
+
* [John Nunemaker](http://railstips.org/about "railstips") for his [ClassLevelInheritableAttributes solution](http://railstips.org/blog/archives/2006/11/18/class-and-instance-variables-in-ruby/ "Class and instance variables in ruby")
|
15
18
|
|
16
19
|
## Configuration
|
17
20
|
You must configure the Omniture namespace, suite(s), version that you wish to use.
|
@@ -65,33 +68,27 @@ You can define a var by giving it a name and defining a block
|
|
65
68
|
end
|
66
69
|
|
67
70
|
|
68
|
-
You can define a var to be present in
|
71
|
+
You can define a var to be present only in given actions.
|
69
72
|
|
70
73
|
#This var will be present only in index and new actions
|
71
|
-
var :my_var,
|
74
|
+
var :my_var, 'index', 'new' do
|
72
75
|
'value_for_my_var'
|
73
76
|
end
|
74
77
|
|
75
|
-
#this var will be excluded from index, new, create, update and destroy actions
|
76
|
-
|
77
|
-
var :my_var, :except => [:index, :new, :create, :update, :destroy] do
|
78
|
-
params[:id]
|
79
|
-
end
|
80
|
-
|
81
78
|
|
82
|
-
If no
|
79
|
+
If no namespaces are passed, the defined var will be available in every action.
|
83
80
|
|
84
81
|
###Events
|
85
|
-
You can define an event the same way you define a var
|
82
|
+
You can define an event the same way you define a var
|
86
83
|
|
87
|
-
event
|
84
|
+
event :my_event, 'search' do
|
88
85
|
'my_event'
|
89
86
|
end
|
90
87
|
|
91
88
|
###Custom javascript
|
92
89
|
You can define custom javascript code the same way you define an event
|
93
90
|
|
94
|
-
js_snippet
|
91
|
+
js_snippet :my_snippet 'search' do
|
95
92
|
's.server = window.location.host;'
|
96
93
|
end
|
97
94
|
|
@@ -133,7 +130,8 @@ Somewhere in your view -probably in one of your layouts- you should add the next
|
|
133
130
|
##More info
|
134
131
|
Since this gem has been created for a very specific use, it may be that this documentation is not enough for you. I have tried to keep the most code from the original sources, so you would want to take a look to the code itself or to the original sources where I took the code
|
135
132
|
|
136
|
-
* [OmnitureClient gem](https://github.com/acatighera/omniture_client
|
137
|
-
* [activenetwork's fork](https://github.com/activenetwork/omniture_client
|
133
|
+
* [OmnitureClient gem](https://github.com/acatighera/omniture_client "acathigera's OmnitureClient")
|
134
|
+
* [activenetwork's fork](https://github.com/activenetwork/omniture_client "activenetwork's OmnitureClient")
|
135
|
+
* [meta_vars gem](https://github.com/eLafo/meta_vars "eLafo's meta_vars")
|
138
136
|
|
139
137
|
##### Copyright (c) 2011 Javier Lafora, released under MIT license
|
data/lib/omniturize.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
|
+
require 'meta_vars'
|
1
2
|
require "omniturize/version"
|
2
|
-
require File.dirname(__FILE__) + '/class_level_inheritable_attributes'
|
3
3
|
require File.dirname(__FILE__) + '/omniturize/printer'
|
4
4
|
require File.dirname(__FILE__) + '/omniturize/base'
|
5
|
-
require File.dirname(__FILE__) + '/omniturize/var'
|
6
|
-
require File.dirname(__FILE__) + '/omniturize/meta_js'
|
7
|
-
require File.dirname(__FILE__) + '/omniturize/meta_var'
|
8
5
|
require 'cgi'
|
9
6
|
|
10
7
|
module Omniturize
|
data/lib/omniturize/base.rb
CHANGED
@@ -1,110 +1,21 @@
|
|
1
1
|
module Omniturize
|
2
2
|
class Base
|
3
3
|
|
4
|
-
include Omniturize::ClassLevelInheritableAttributes
|
5
4
|
include Omniturize::Printer
|
6
|
-
|
7
|
-
|
8
|
-
attr_reader :controller
|
5
|
+
include MetaVars
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
has_meta_var :var, :default_namespace => 'default', :inheritable => true
|
8
|
+
has_meta_var :event, :default_namespace => 'default', :inheritable => true
|
9
|
+
has_meta_var :js_snippet, :default_namespace => 'default', :inheritable => true
|
13
10
|
|
11
|
+
attr_reader :controller
|
14
12
|
|
15
13
|
class << self
|
16
|
-
attr_accessor :meta_vars, :meta_js_events, :meta_js_snippets
|
17
14
|
@@controller = nil
|
18
|
-
|
19
|
-
def var(name, options={}, &block)
|
20
|
-
meta_var = Omniturize::MetaVar.new(name.to_s, options)
|
21
|
-
meta_var.add_var(block)
|
22
|
-
meta_vars.insert(0, meta_var) unless meta_vars.include?(meta_var)
|
23
|
-
meta_var
|
24
|
-
end
|
25
|
-
|
26
|
-
def event(options = {}, &block)
|
27
|
-
meta_js(meta_js_events, block, options)
|
28
|
-
end
|
29
|
-
|
30
|
-
def js_snippet(options = {}, &block)
|
31
|
-
meta_js(meta_js_snippets, block, options)
|
32
|
-
end
|
33
|
-
|
34
|
-
def find_meta_vars(name, action = nil)
|
35
|
-
filter_collection_for_action(meta_vars.select{|x|x.matches_name?(name)}, action).uniq_by(:name)
|
36
|
-
end
|
37
|
-
|
38
|
-
def filter_collection_for_action(collection, action)
|
39
|
-
return collection if action.blank?
|
40
|
-
collection.select do |element|
|
41
|
-
element.passes_filter?(action)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
protected
|
46
|
-
|
47
|
-
def meta_js(collection, block, options = {})
|
48
|
-
meta_js = Omniture::MetaJs.new(options)
|
49
|
-
meta_js.add_js(block)
|
50
|
-
collection.insert(0, meta_js)
|
51
|
-
meta_js
|
52
|
-
end
|
53
|
-
|
54
15
|
end
|
55
16
|
|
56
17
|
def initialize(controller)
|
57
18
|
@controller = controller
|
58
19
|
end
|
59
|
-
|
60
|
-
def vars(options = {})
|
61
|
-
meta_collection_to_values(self.class.meta_vars, options[:action]).uniq_by(:name)
|
62
|
-
end
|
63
|
-
|
64
|
-
def js_events(options = {})
|
65
|
-
meta_collection_to_values(self.class.meta_js_events, options[:action]).uniq
|
66
|
-
end
|
67
|
-
|
68
|
-
def js_snippets(options = {})
|
69
|
-
meta_collection_to_values(self.class.meta_js_snippets, options[:action]).uniq
|
70
|
-
end
|
71
|
-
|
72
|
-
def add_var(name, value)
|
73
|
-
self.class.var(name) do
|
74
|
-
value
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def find_vars(name, options = {})
|
79
|
-
meta_vars_to_vars(self.class.find_meta_vars(name, options))
|
80
|
-
end
|
81
|
-
|
82
|
-
def find_var(name, options = {})
|
83
|
-
find_vars(name, options).first
|
84
|
-
end
|
85
|
-
|
86
|
-
def find_values(name, options = {})
|
87
|
-
find_vars(name, options).map(&:value)
|
88
|
-
end
|
89
|
-
|
90
|
-
def meta_vars_to_vars(meta_vars)
|
91
|
-
meta_vars.inject([]) do |vars, meta_var|
|
92
|
-
vars << (meta_var.value(controller) if meta_var) rescue nil
|
93
|
-
vars
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
protected
|
98
|
-
|
99
|
-
def build_js_collection(procs_collection)
|
100
|
-
procs_collection.inject([]) do |code, js|
|
101
|
-
code << controller.instance_eval(&js)
|
102
|
-
code
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def meta_collection_to_values(collection, action = nil)
|
107
|
-
action.present? ? meta_vars_to_vars(self.class.filter_collection_for_action(collection, action)): meta_vars_to_vars(collection)
|
108
|
-
end
|
109
20
|
end
|
110
21
|
end
|
data/lib/omniturize/printer.rb
CHANGED
@@ -13,28 +13,30 @@ module Omniturize
|
|
13
13
|
output = <<-JS
|
14
14
|
<script type="text/javascript" language="JavaScript" src="#{Omniturize::js_src}"></script>
|
15
15
|
<script type="text/javascript" language="JavaScript" #{html_options.join(' ')}>
|
16
|
-
#{js_vars(options)}
|
17
|
-
#{print_js_events(options)}
|
18
|
-
#{print_js_snippets(options)}
|
16
|
+
#{js_vars(options[:action])}
|
17
|
+
#{print_js_events(options[:action])}
|
18
|
+
#{print_js_snippets(options[:action])}
|
19
19
|
var s_code=s.t();if(s_code)document.write(s_code)
|
20
20
|
</script>
|
21
21
|
JS
|
22
22
|
end
|
23
23
|
|
24
24
|
def query(options = {})
|
25
|
-
vars(
|
25
|
+
vars(controller).inject([]) do |query, var|
|
26
26
|
query << var_to_query(var) if var.value && var.value != ""
|
27
27
|
query
|
28
28
|
end.join('&')
|
29
29
|
end
|
30
30
|
|
31
|
-
def js_vars(
|
32
|
-
|
33
|
-
query << var_to_js(var) if var.value
|
31
|
+
def js_vars(action)
|
32
|
+
output = (find_meta_vars(action) + find_meta_vars).uniq_by(&:name).map{|x| x.to_var(controller)}.inject([]) do |query, var|
|
33
|
+
query << var_to_js(var) if var.value.present?
|
34
34
|
query
|
35
|
-
end.join(";\n")
|
35
|
+
end.join(";\n")
|
36
|
+
|
37
|
+
output.blank? ? nil : output + ';'
|
36
38
|
end
|
37
|
-
|
39
|
+
|
38
40
|
def raw_vars(options = {})
|
39
41
|
vars(options).inject([]) do |query, var|
|
40
42
|
query << { var.name.to_sym => var.value } if var.value && var.value != ""
|
@@ -42,13 +44,17 @@ module Omniturize
|
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
45
|
-
def print_js_events(
|
46
|
-
|
47
|
-
|
47
|
+
def print_js_events(action)
|
48
|
+
events = (find_meta_events(action) + find_meta_events).uniq_by(&:name).map{|event| event.to_var(controller)}.inject([]) do |values, event|
|
49
|
+
(values << event.value) if event.value.present?
|
50
|
+
end.join(',')
|
51
|
+
events.blank? ? nil : "s.events=\"#{events}\";"
|
48
52
|
end
|
49
53
|
|
50
|
-
def print_js_snippets(
|
51
|
-
|
54
|
+
def print_js_snippets(action)
|
55
|
+
(find_meta_js_snippets(action) + find_meta_js_snippets).uniq_by(&:name).map{|snippet| snippet.to_var(controller)}.inject([]) do |snippets, snippet|
|
56
|
+
(snippets << snippet.value) if snippet.value.present?
|
57
|
+
end.join("\n")
|
52
58
|
end
|
53
59
|
|
54
60
|
private
|
@@ -58,7 +64,11 @@ module Omniturize
|
|
58
64
|
end
|
59
65
|
|
60
66
|
def var_to_js(var)
|
61
|
-
%Q{\t#{Omniturize::var_prefix + '.' if Omniturize::var_prefix}#{var
|
67
|
+
%Q{\t#{Omniturize::var_prefix + '.' if Omniturize::var_prefix}#{var_name(var)}="#{var.value}"} if var
|
68
|
+
end
|
69
|
+
|
70
|
+
def var_name(var)
|
71
|
+
Omniturize::aliases && Omniturize::aliases[var.name.to_s] ? Omniturize::aliases[var.name.to_s] : var.name
|
62
72
|
end
|
63
73
|
end
|
64
74
|
end
|
data/lib/omniturize/version.rb
CHANGED
data/omniturize.gemspec
CHANGED
@@ -17,4 +17,6 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
|
+
s.requirements << 'meta_vars 1.0.0'
|
21
|
+
s.add_dependency('meta_vars', '1.0.0')
|
20
22
|
end
|
metadata
CHANGED
@@ -4,10 +4,10 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
|
+
- 1
|
7
8
|
- 0
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.4
|
10
|
+
version: 1.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- eLafo
|
@@ -15,9 +15,24 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
dependencies:
|
20
|
-
|
18
|
+
date: 2011-10-21 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: meta_vars
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - "="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 23
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
- 0
|
33
|
+
version: 1.0.0
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
21
36
|
description: This gem integrates Omniture SiteCatalyst into your web app. You can specify vars, events and custom javascript for every action of a controller. This gem is proudly based on the omniture_client gem, from which it takes much code and ideas
|
22
37
|
email:
|
23
38
|
- javierlafora@gmail.com
|
@@ -33,13 +48,9 @@ files:
|
|
33
48
|
- MIT-LICENSE
|
34
49
|
- README.markdown
|
35
50
|
- Rakefile
|
36
|
-
- lib/class_level_inheritable_attributes.rb
|
37
51
|
- lib/omniturize.rb
|
38
52
|
- lib/omniturize/base.rb
|
39
|
-
- lib/omniturize/meta_js.rb
|
40
|
-
- lib/omniturize/meta_var.rb
|
41
53
|
- lib/omniturize/printer.rb
|
42
|
-
- lib/omniturize/var.rb
|
43
54
|
- lib/omniturize/version.rb
|
44
55
|
- lib/omniturize_rails.rb
|
45
56
|
- omniturize.gemspec
|
@@ -69,8 +80,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
80
|
segments:
|
70
81
|
- 0
|
71
82
|
version: "0"
|
72
|
-
requirements:
|
73
|
-
|
83
|
+
requirements:
|
84
|
+
- meta_vars 1.0.0
|
74
85
|
rubyforge_project: omniturize
|
75
86
|
rubygems_version: 1.8.10
|
76
87
|
signing_key:
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# This code was proudly and shamelessly copied from
|
2
|
-
# http://railstips.org/blog/archives/2006/11/18/class-and-instance-variables-in-ruby/
|
3
|
-
# so let's all thank John Nunemaker with a loud and strong applause: PLAS!!!!'
|
4
|
-
|
5
|
-
module Omniturize
|
6
|
-
module ClassLevelInheritableAttributes
|
7
|
-
def self.included(base)
|
8
|
-
base.extend(ClassMethods)
|
9
|
-
end
|
10
|
-
|
11
|
-
module ClassMethods
|
12
|
-
def inheritable_attributes(*args)
|
13
|
-
@omniture_inheritable_attributes ||= [:omniture_inheritable_attributes]
|
14
|
-
@omniture_inheritable_attributes += args
|
15
|
-
args.each do |arg|
|
16
|
-
class_eval %(
|
17
|
-
class << self; attr_accessor :#{arg} end
|
18
|
-
)
|
19
|
-
end
|
20
|
-
@omniture_inheritable_attributes
|
21
|
-
end
|
22
|
-
|
23
|
-
def inherited(subclass)
|
24
|
-
@omniture_inheritable_attributes.each do |inheritable_attribute|
|
25
|
-
instance_var = "@#{inheritable_attribute}"
|
26
|
-
subclass.instance_variable_set(instance_var, instance_variable_get(instance_var))
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/lib/omniturize/meta_js.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
module Omniture
|
2
|
-
class MetaJs
|
3
|
-
attr_reader :cache_key, :expires_in, :only, :except, :delimiter
|
4
|
-
attr_accessor :value_procs
|
5
|
-
|
6
|
-
DEFAULT_OPTIONS = { :unique => nil,
|
7
|
-
:expires_in => 0,
|
8
|
-
:only => [],
|
9
|
-
:except => [],
|
10
|
-
:delimiter => ','
|
11
|
-
}
|
12
|
-
|
13
|
-
def initialize(options = {})
|
14
|
-
options = DEFAULT_OPTIONS.merge(options)
|
15
|
-
|
16
|
-
@value_procs = []
|
17
|
-
@cache_key = "omniture/#{Time.now.to_i}/#{options[:unique]}"
|
18
|
-
@expires_in = options[:expires_in]
|
19
|
-
@only = options[:only]
|
20
|
-
@except = options[:except]
|
21
|
-
end
|
22
|
-
|
23
|
-
def add_js(value_proc)
|
24
|
-
value_procs << value_proc
|
25
|
-
end
|
26
|
-
|
27
|
-
def value(scope)
|
28
|
-
if @expires_in > 0
|
29
|
-
Rails.cache.fetch(@cache_key, :expires_in => @expires_in) do
|
30
|
-
return_var(scope)
|
31
|
-
end
|
32
|
-
else
|
33
|
-
return_var(scope)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def return_var(scope)
|
38
|
-
value_procs.map{ |p| scope.instance_eval(&p) }.flatten.uniq.join(delimiter)
|
39
|
-
end
|
40
|
-
|
41
|
-
def passes_filter?(filter)
|
42
|
-
passes_only_filter?(filter) && passes_except_filter?(filter)
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
def passes_only_filter?(filter)
|
48
|
-
only.blank? || only.detect{|x| x.is_a?(Regexp) ? filter.match(x) : filter.to_sym == x.to_sym}.present?
|
49
|
-
end
|
50
|
-
|
51
|
-
def passes_except_filter?(filter)
|
52
|
-
except.blank? || except.detect{|x| x.is_a?(Regexp) ? filter.match(x) : filter.to_sym == x.to_sym}.blank?
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
data/lib/omniturize/meta_var.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
module Omniturize
|
2
|
-
class MetaVar
|
3
|
-
|
4
|
-
DEFAULT_OPTIONS = { :delimiter => ',',
|
5
|
-
:unique => nil,
|
6
|
-
:expires_in => 0,
|
7
|
-
:only => [],
|
8
|
-
:except => []
|
9
|
-
}
|
10
|
-
|
11
|
-
attr_reader :name, :delimiter, :cache_key, :expires_in, :only, :except
|
12
|
-
attr_accessor :value_procs
|
13
|
-
|
14
|
-
def initialize(name, options = {})
|
15
|
-
options = DEFAULT_OPTIONS.merge(options)
|
16
|
-
@name = name
|
17
|
-
@value_procs = []
|
18
|
-
@delimiter = options[:delimiter]
|
19
|
-
@cache_key = "omniture/#{name}/#{options[:unique]}"
|
20
|
-
@expires_in = options[:expires_in]
|
21
|
-
@only = Array(options[:only])
|
22
|
-
@except = Array(options[:except])
|
23
|
-
end
|
24
|
-
|
25
|
-
def add_var(value_proc)
|
26
|
-
value_procs << value_proc
|
27
|
-
end
|
28
|
-
|
29
|
-
# wrap up the value in a Var object and cache if needed
|
30
|
-
def value(scope)
|
31
|
-
if @expires_in > 0
|
32
|
-
Rails.cache.fetch(@cache_key, :expires_in => @expires_in) do
|
33
|
-
return_var(scope)
|
34
|
-
end
|
35
|
-
else
|
36
|
-
return_var(scope)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def return_var(scope)
|
41
|
-
Var.new(name, value_procs.map{ |p| scope.instance_eval(&p) }.flatten.uniq.join(delimiter))
|
42
|
-
end
|
43
|
-
|
44
|
-
def matches_name?(name)
|
45
|
-
select_condition = case name
|
46
|
-
when Regexp then self.name.match(name)
|
47
|
-
when String then self.name == name
|
48
|
-
else raise ArgumentError.new('name must be a String or a Regexp')
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def passes_filter?(filter)
|
53
|
-
passes_only_filter?(filter) && passes_except_filter?(filter)
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def passes_only_filter?(filter)
|
59
|
-
only.blank? || only.detect{|x| x.is_a?(Regexp) ? filter.match(x) : filter.to_sym == x.to_sym}.present?
|
60
|
-
end
|
61
|
-
|
62
|
-
def passes_except_filter?(filter)
|
63
|
-
except.blank? || except.detect{|x| x.is_a?(Regexp) ? filter.match(x) : filter.to_sym == x.to_sym}.blank?
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
end
|
data/lib/omniturize/var.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module Omniturize
|
2
|
-
class Var
|
3
|
-
attr_reader :name, :value
|
4
|
-
def initialize(name, value)
|
5
|
-
if Omniturize::aliases && Omniturize::aliases[name.to_s]
|
6
|
-
@name = Omniturize::aliases[name.to_s]
|
7
|
-
else
|
8
|
-
@name = name.to_s
|
9
|
-
end
|
10
|
-
@value = value
|
11
|
-
end
|
12
|
-
|
13
|
-
def matches_name?(name)
|
14
|
-
select_condition = case name
|
15
|
-
when Regexp then self.name.match(name)
|
16
|
-
when String then self.name == name
|
17
|
-
else raise ArgumentError.new('name must be a String or a Regexp')
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|