adify 0.2.0 → 0.3.0
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/.gitignore +2 -1
- data/Gemfile.lock +1 -1
- data/README.rdoc +5 -1
- data/lib/adify.rb +14 -8
- data/lib/adify/version.rb +1 -1
- data/spec/adify_spec.rb +28 -7
- data/spec/spec_helper.rb +5 -0
- metadata +47 -55
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -5,6 +5,10 @@ Adify is a simple to use (hopefully) rails gem that builds up ad tags for cashin
|
|
5
5
|
This is just the initial version and isn't really complete. I haven't worked with other ad servers so it might be a little tailored to double click. Also the generator is butchered right now.
|
6
6
|
|
7
7
|
== Releases
|
8
|
+
=== Version 0.3.0
|
9
|
+
* Bugfix: clone before merging. If key was missing from an action in a controller it would appear magically if there was a base controller
|
10
|
+
* added tests to prove bug
|
11
|
+
* use singletons to set the atribtutes
|
8
12
|
=== Version 0.2.0
|
9
13
|
* Refactored everything to use one module
|
10
14
|
* Tested with rails 2 & 3
|
@@ -17,7 +21,7 @@ This is just the initial version and isn't really complete. I haven't worked wi
|
|
17
21
|
* Do stuff
|
18
22
|
* Tests. Pull requests without tests will be flogged publically. Feel free to flog me for forgetting tests then add them.\
|
19
23
|
|
20
|
-
|
24
|
+
== Copyright
|
21
25
|
|
22
26
|
Copyright (c) 2011 Eric Harrison. See LICENSE.txt for
|
23
27
|
further details.
|
data/lib/adify.rb
CHANGED
@@ -9,20 +9,23 @@ module Adify
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def adify(args)
|
12
|
-
self.
|
12
|
+
if self.class == Class
|
13
13
|
include Adify::Methods
|
14
14
|
extend Adify::Methods
|
15
|
-
|
15
|
+
end
|
16
|
+
singleton = class << self; self; end
|
17
|
+
singleton.module_eval do
|
18
|
+
define_method(:adify_attributes=) do |hash|
|
19
|
+
@adify_attributes = hash
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
16
23
|
self.adify_attributes = args
|
17
24
|
end
|
18
25
|
|
19
26
|
module Methods
|
20
|
-
def adify_attributes=(hash)
|
21
|
-
@adify_attributes = hash
|
22
|
-
end
|
23
|
-
|
24
27
|
def adify_attributes
|
25
|
-
my_attributes =
|
28
|
+
my_attributes = get_adify_attributes
|
26
29
|
merge_with = self.respond_to?(:ancestors) ? self.ancestors.slice(1,self.ancestors.length).select{|c| c.respond_to?(:adify_attributes)}.first : self.class
|
27
30
|
merge_with.respond_to?(:adify_attributes) ? merge_with.adify_attributes.adify_merge(my_attributes) : my_attributes
|
28
31
|
end
|
@@ -30,10 +33,13 @@ module Adify
|
|
30
33
|
def adification(item = nil)
|
31
34
|
ad_attr = item.nil? ? self.adify_attributes : self.adify_attributes.adify_merge(item.adify_attributes)
|
32
35
|
item_for_adification = item.nil? ? self : item
|
33
|
-
ad_attr.update_values{|v| get_adify_value(item_for_adification,v)}.symbolize_keys_recursively
|
36
|
+
ad_attr.update_values{|v| get_adify_value(item_for_adification,v)}.symbolize_keys_recursively.clone
|
34
37
|
end
|
35
38
|
|
36
39
|
private
|
40
|
+
def get_adify_attributes
|
41
|
+
(@adify_attributes || {}).clone
|
42
|
+
end
|
37
43
|
def get_adify_value(item,value)
|
38
44
|
case value.class.to_s
|
39
45
|
when "Array" then value.each.collect{|v| get_adify_value(item,v)}
|
data/lib/adify/version.rb
CHANGED
data/spec/adify_spec.rb
CHANGED
@@ -8,7 +8,19 @@ class Item < ActiveRecord::Base
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def proc
|
11
|
-
"
|
11
|
+
"item return"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Thing < ActiveRecord::Base
|
16
|
+
adify :item_only => 'thing', :override_by_item => 'item'
|
17
|
+
|
18
|
+
def id
|
19
|
+
"item id via symbol"
|
20
|
+
end
|
21
|
+
|
22
|
+
def proc
|
23
|
+
"thing return"
|
12
24
|
end
|
13
25
|
end
|
14
26
|
|
@@ -21,17 +33,20 @@ class MyController < MyBaseController
|
|
21
33
|
|
22
34
|
def index
|
23
35
|
#maybe rename this
|
24
|
-
adify(:override_by_item => "Action", :override_by_action => 'Action', :
|
25
|
-
|
26
|
-
|
36
|
+
adify(:override_by_item => "Action", :override_by_action => 'Action', :index_only => Proc.new(){|item| item.proc})
|
37
|
+
@adtag = adification(Item.new)
|
38
|
+
end
|
39
|
+
|
40
|
+
def show
|
41
|
+
adify(:override_by_item => "Action", :override_by_action => 'Action', :show_only =>'foo')
|
42
|
+
[adification(Item.new), adification(Thing.new)]
|
27
43
|
end
|
28
44
|
end
|
29
45
|
|
30
46
|
describe Adify do
|
31
47
|
describe 'adification' do
|
32
48
|
it "should merge things properly" do
|
33
|
-
|
34
|
-
adify = app.index
|
49
|
+
adify = MyController.new.index
|
35
50
|
adify.should_not be_nil
|
36
51
|
adify.should == {
|
37
52
|
:override_by_item => "item",
|
@@ -39,9 +54,15 @@ describe Adify do
|
|
39
54
|
:override_by_controller => "controller",
|
40
55
|
:override_by_action => "Action",
|
41
56
|
:controller_only => :symbol_no_method,
|
42
|
-
:
|
57
|
+
:index_only => "item return",
|
43
58
|
:item_only => "item id via symbol"
|
44
59
|
}
|
45
60
|
end
|
61
|
+
|
62
|
+
it "should not share adify attributes between classes" do
|
63
|
+
adifications = MyController.new.show
|
64
|
+
adifications.first.should == {:override_by_item=>"item", :base_only=>["base_arry_only_1", {:item1=>"base array only 2"}], :override_by_controller=>"controller", :override_by_action=>"Action", :controller_only=>:symbol_no_method, :item_only => 'item id via symbol', :show_only => 'foo'}
|
65
|
+
adifications.last.should == {:override_by_item=>"item", :base_only=>["base_arry_only_1", {:item1=>"base array only 2"}], :override_by_controller=>"controller", :override_by_action=>"Action", :controller_only=>:symbol_no_method, :item_only=>"thing", :show_only => 'foo'}
|
66
|
+
end
|
46
67
|
end
|
47
68
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,61 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: adify
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
4
5
|
prerelease:
|
5
|
-
version: 0.2.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Eric Harrison
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-11-14 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
17
15
|
name: rspec
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2156095020 !ruby/object:Gem::Requirement
|
20
17
|
none: false
|
21
|
-
requirements:
|
22
|
-
- -
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
25
22
|
type: :development
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rails
|
29
23
|
prerelease: false
|
30
|
-
|
24
|
+
version_requirements: *2156095020
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rails
|
27
|
+
requirement: &2156089440 !ruby/object:Gem::Requirement
|
31
28
|
none: false
|
32
|
-
requirements:
|
33
|
-
- -
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version:
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
36
33
|
type: :development
|
37
|
-
version_requirements: *id002
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: sqlite3
|
40
34
|
prerelease: false
|
41
|
-
|
35
|
+
version_requirements: *2156089440
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: sqlite3
|
38
|
+
requirement: &2156089020 !ruby/object:Gem::Requirement
|
42
39
|
none: false
|
43
|
-
requirements:
|
44
|
-
- -
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version:
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
47
44
|
type: :development
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2156089020
|
47
|
+
description: Adify lets you create ad tags easily and quickly with a simple common
|
48
|
+
structure
|
49
|
+
email:
|
51
50
|
- eric@rubynooby.com
|
52
51
|
executables: []
|
53
|
-
|
54
52
|
extensions: []
|
55
|
-
|
56
53
|
extra_rdoc_files: []
|
57
|
-
|
58
|
-
files:
|
54
|
+
files:
|
59
55
|
- .document
|
60
56
|
- .gitignore
|
61
57
|
- .rspec
|
@@ -76,34 +72,30 @@ files:
|
|
76
72
|
- lib/generators/adify_generator.rb
|
77
73
|
- spec/adify_spec.rb
|
78
74
|
- spec/spec_helper.rb
|
79
|
-
has_rdoc: true
|
80
75
|
homepage: http://www.rubynooby.com
|
81
76
|
licenses: []
|
82
|
-
|
83
77
|
post_install_message:
|
84
78
|
rdoc_options: []
|
85
|
-
|
86
|
-
require_paths:
|
79
|
+
require_paths:
|
87
80
|
- lib
|
88
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
82
|
none: false
|
90
|
-
requirements:
|
91
|
-
- -
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version:
|
94
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
88
|
none: false
|
96
|
-
requirements:
|
97
|
-
- -
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
version:
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
100
93
|
requirements: []
|
101
|
-
|
102
94
|
rubyforge_project:
|
103
|
-
rubygems_version: 1.
|
95
|
+
rubygems_version: 1.8.10
|
104
96
|
signing_key:
|
105
97
|
specification_version: 3
|
106
98
|
summary: create ad tags for common ad servers easily.
|
107
|
-
test_files:
|
99
|
+
test_files:
|
108
100
|
- spec/adify_spec.rb
|
109
101
|
- spec/spec_helper.rb
|