adify 0.1.2 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -5,7 +5,6 @@ gem "rails", ">= 2.3.5"
5
5
  gem "activesupport", ">= 2.3.5"
6
6
  gem "activerecord", ">= 2.3.5"
7
7
  gem "actionpack", ">= 2.3.5"
8
- gem 'deep_merge'
9
8
 
10
9
  # Add dependencies to develop your gem here.
11
10
  # Include everything needed to run rake, tests, features, etc.
data/Gemfile.lock CHANGED
@@ -31,7 +31,6 @@ GEM
31
31
  arel (2.0.10)
32
32
  builder (2.1.2)
33
33
  columnize (0.3.2)
34
- deep_merge (0.1.0)
35
34
  diff-lcs (1.1.2)
36
35
  erubis (2.6.6)
37
36
  abstract (>= 1.0.0)
@@ -101,7 +100,6 @@ DEPENDENCIES
101
100
  activerecord (>= 2.3.5)
102
101
  activesupport (>= 2.3.5)
103
102
  bundler (~> 1.0.0)
104
- deep_merge
105
103
  jeweler (~> 1.6.0)
106
104
  rails (>= 2.3.5)
107
105
  rcov
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.6
data/adify.gemspec CHANGED
@@ -51,7 +51,6 @@ Gem::Specification.new do |s|
51
51
  s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
52
52
  s.add_runtime_dependency(%q<activerecord>, [">= 2.3.5"])
53
53
  s.add_runtime_dependency(%q<actionpack>, [">= 2.3.5"])
54
- s.add_runtime_dependency(%q<deep_merge>, [">= 0"])
55
54
  s.add_development_dependency(%q<rspec-rails>, ["~> 2.3.0"])
56
55
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
57
56
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
@@ -63,7 +62,6 @@ Gem::Specification.new do |s|
63
62
  s.add_dependency(%q<activesupport>, [">= 2.3.5"])
64
63
  s.add_dependency(%q<activerecord>, [">= 2.3.5"])
65
64
  s.add_dependency(%q<actionpack>, [">= 2.3.5"])
66
- s.add_dependency(%q<deep_merge>, [">= 0"])
67
65
  s.add_dependency(%q<rspec-rails>, ["~> 2.3.0"])
68
66
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
69
67
  s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
@@ -76,7 +74,6 @@ Gem::Specification.new do |s|
76
74
  s.add_dependency(%q<activesupport>, [">= 2.3.5"])
77
75
  s.add_dependency(%q<activerecord>, [">= 2.3.5"])
78
76
  s.add_dependency(%q<actionpack>, [">= 2.3.5"])
79
- s.add_dependency(%q<deep_merge>, [">= 0"])
80
77
  s.add_dependency(%q<rspec-rails>, ["~> 2.3.0"])
81
78
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
82
79
  s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
data/lib/adify.rb CHANGED
@@ -15,11 +15,11 @@ module Adify
15
15
 
16
16
  def adify_attributes
17
17
  ad_attr = self.adify_instance_attributes || {}
18
- self.class.adify_attributes.deep_merge(ad_attr) rescue ad_attr
18
+ self.class.adify_attributes.adify_merge(ad_attr) rescue ad_attr
19
19
  end
20
20
 
21
21
  def adification(item = nil)
22
- ad_attr = item.nil? ? self.adify_attributes : self.adify_attributes.deep_merge(item.adify_attributes)
22
+ ad_attr = item.nil? ? self.adify_attributes : self.adify_attributes.adify_merge(item.adify_attributes)
23
23
  item_for_adification = item.nil? ? self : item
24
24
  @adification_of_item = ad_attr.update_values{|v| get_adify_value(item_for_adification,v)}
25
25
  end
@@ -37,6 +37,26 @@ end
37
37
 
38
38
  class ActionController::Base
39
39
  include Adify::Controller
40
+ helper_method :adification, :registered_ad_spots, :register_ad_spot, :tag_number
41
+
42
+ @registered_ad_spots
43
+
44
+ def tag_number
45
+ adify_tag_number += 1
46
+ end
47
+
48
+ def registered_ad_spots
49
+ @registered_ad_spots || []
50
+ end
51
+
52
+ def register_ad_spot(val)
53
+ @registered_ad_spots ||= []
54
+ @registered_ad_spots << val
55
+ end
56
+
57
+ def self.adification
58
+ @adification_of_item = self.adify_attributes.update_values{|v| get_adify_value(self,v)}
59
+ end
40
60
  end
41
61
 
42
62
  class ActionView::Base
@@ -48,7 +68,7 @@ class Hash
48
68
  def update_values(&block)
49
69
  self.update(self){|k,v| block.call v}
50
70
  end
51
- def deep_merge(h)
52
- self.merge!(h) {|key, _old, _new| if _old.class == Hash then _old.deep_merge(_new) else _new end }
71
+ def adify_merge(h)
72
+ self.merge!(h) {|key, _old, _new| if _old.class == Hash then _old.adify_merge(_new) else _new end }
53
73
  end
54
74
  end
@@ -12,11 +12,12 @@ module Adify
12
12
  cattr_accessor :adify_tag_number
13
13
 
14
14
  def self.adify_attributes=(hash)
15
- self.adify_#{self.to_s.tableize}_attributes = hash
15
+ self.adify_#{self.to_s.tableize.gsub(/\//,'_')}_attributes = hash
16
16
  end
17
17
 
18
18
  def self.adify_attributes
19
- self.ancestors[1].adify_attributes.deep_merge(self.adify_#{self.to_s.tableize.gsub(/\//,'_')}_attributes) rescue self.adify_#{self.to_s.tableize.gsub(/\//,'_')}_attributes
19
+ ancestor = self.ancestors.slice(1,self.ancestors.length).select{|c| c.respond_to?(:adify_attributes)}.first
20
+ ancestor.adify_attributes.deep_merge(self.adify_#{self.to_s.tableize.gsub(/\//,'_')}_attributes) rescue self.adify_#{self.to_s.tableize.gsub(/\//,'_')}_attributes
20
21
  end
21
22
  EOV
22
23
 
data/lib/adify/helper.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  module AdifyHelper
2
-
3
2
  def adify_tag(args)
4
3
  item = args.delete(:item) rescue nil
5
4
  partial = args.delete(:partial) || 'adify/dfp'
@@ -11,8 +10,4 @@ module AdifyHelper
11
10
  def random(length)
12
11
  Array.new(length){rand 9}.join
13
12
  end
14
-
15
- def tag_number
16
- @controller.class.adify_tag_number += 1
17
- end
18
13
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adify
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 6
10
+ version: 0.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eric Harrison
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-05 00:00:00 +10:00
18
+ date: 2011-07-06 00:00:00 +10:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -82,23 +82,9 @@ dependencies:
82
82
  name: actionpack
83
83
  version_requirements: *id004
84
84
  prerelease: false
85
- - !ruby/object:Gem::Dependency
86
- type: :runtime
87
- requirement: &id005 !ruby/object:Gem::Requirement
88
- none: false
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- hash: 3
93
- segments:
94
- - 0
95
- version: "0"
96
- name: deep_merge
97
- version_requirements: *id005
98
- prerelease: false
99
85
  - !ruby/object:Gem::Dependency
100
86
  type: :development
101
- requirement: &id006 !ruby/object:Gem::Requirement
87
+ requirement: &id005 !ruby/object:Gem::Requirement
102
88
  none: false
103
89
  requirements:
104
90
  - - ~>
@@ -110,11 +96,11 @@ dependencies:
110
96
  - 0
111
97
  version: 2.3.0
112
98
  name: rspec-rails
113
- version_requirements: *id006
99
+ version_requirements: *id005
114
100
  prerelease: false
115
101
  - !ruby/object:Gem::Dependency
116
102
  type: :development
117
- requirement: &id007 !ruby/object:Gem::Requirement
103
+ requirement: &id006 !ruby/object:Gem::Requirement
118
104
  none: false
119
105
  requirements:
120
106
  - - ~>
@@ -126,11 +112,11 @@ dependencies:
126
112
  - 0
127
113
  version: 1.0.0
128
114
  name: bundler
129
- version_requirements: *id007
115
+ version_requirements: *id006
130
116
  prerelease: false
131
117
  - !ruby/object:Gem::Dependency
132
118
  type: :development
133
- requirement: &id008 !ruby/object:Gem::Requirement
119
+ requirement: &id007 !ruby/object:Gem::Requirement
134
120
  none: false
135
121
  requirements:
136
122
  - - ~>
@@ -142,11 +128,11 @@ dependencies:
142
128
  - 0
143
129
  version: 1.6.0
144
130
  name: jeweler
145
- version_requirements: *id008
131
+ version_requirements: *id007
146
132
  prerelease: false
147
133
  - !ruby/object:Gem::Dependency
148
134
  type: :development
149
- requirement: &id009 !ruby/object:Gem::Requirement
135
+ requirement: &id008 !ruby/object:Gem::Requirement
150
136
  none: false
151
137
  requirements:
152
138
  - - ">="
@@ -156,11 +142,11 @@ dependencies:
156
142
  - 0
157
143
  version: "0"
158
144
  name: rcov
159
- version_requirements: *id009
145
+ version_requirements: *id008
160
146
  prerelease: false
161
147
  - !ruby/object:Gem::Dependency
162
148
  type: :development
163
- requirement: &id010 !ruby/object:Gem::Requirement
149
+ requirement: &id009 !ruby/object:Gem::Requirement
164
150
  none: false
165
151
  requirements:
166
152
  - - ">="
@@ -170,11 +156,11 @@ dependencies:
170
156
  - 0
171
157
  version: "0"
172
158
  name: ruby-debug
173
- version_requirements: *id010
159
+ version_requirements: *id009
174
160
  prerelease: false
175
161
  - !ruby/object:Gem::Dependency
176
162
  type: :development
177
- requirement: &id011 !ruby/object:Gem::Requirement
163
+ requirement: &id010 !ruby/object:Gem::Requirement
178
164
  none: false
179
165
  requirements:
180
166
  - - ">="
@@ -184,7 +170,7 @@ dependencies:
184
170
  - 0
185
171
  version: "0"
186
172
  name: sqlite3
187
- version_requirements: *id011
173
+ version_requirements: *id010
188
174
  prerelease: false
189
175
  description: Adify lets you create ad tags easily and quickly with a simple common structure
190
176
  email: eharrison@classifiedadventures.com