adify 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +50 -0
- data/.rvmrc +1 -1
- data/Gemfile +2 -20
- data/Gemfile.lock +85 -88
- data/README.rdoc +6 -1
- data/Rakefile +1 -49
- data/adify.gemspec +17 -79
- data/lib/adify.rb +38 -60
- data/lib/adify/helper.rb +12 -10
- data/lib/adify/version.rb +3 -0
- data/lib/core_ext/array.rb +11 -0
- data/lib/core_ext/hash.rb +19 -0
- data/spec/adify_spec.rb +3 -3
- metadata +27 -157
- data/VERSION +0 -1
- data/lib/adify/controller.rb +0 -47
- data/lib/adify/model.rb +0 -41
data/.gitignore
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
|
4
|
+
# rdoc generated
|
5
|
+
rdoc
|
6
|
+
|
7
|
+
# yard generated
|
8
|
+
doc
|
9
|
+
.yardoc
|
10
|
+
|
11
|
+
# bundler
|
12
|
+
.bundle
|
13
|
+
|
14
|
+
# jeweler generated
|
15
|
+
pkg
|
16
|
+
|
17
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
18
|
+
#
|
19
|
+
# * Create a file at ~/.gitignore
|
20
|
+
# * Include files you want ignored
|
21
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
22
|
+
#
|
23
|
+
# After doing this, these files will be ignored in all your git projects,
|
24
|
+
# saving you from having to 'pollute' every project you touch with them
|
25
|
+
#
|
26
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
27
|
+
#
|
28
|
+
# For MacOS:
|
29
|
+
#
|
30
|
+
#.DS_Store
|
31
|
+
|
32
|
+
# For TextMate
|
33
|
+
#*.tmproj
|
34
|
+
#tmtags
|
35
|
+
|
36
|
+
# For emacs:
|
37
|
+
#*~
|
38
|
+
#\#*
|
39
|
+
#.\#*
|
40
|
+
|
41
|
+
# For vim:
|
42
|
+
#*.swp
|
43
|
+
|
44
|
+
# For redcar:
|
45
|
+
#.redcar
|
46
|
+
|
47
|
+
# For rubinius:
|
48
|
+
#*.rbc
|
49
|
+
|
50
|
+
.idea
|
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm --create ruby-1.
|
1
|
+
rvm --create ruby-1.9.2@adify
|
data/Gemfile
CHANGED
@@ -1,22 +1,4 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
gem "rails", ">= 2.3.5"
|
5
|
-
gem "activesupport", ">= 2.3.5"
|
6
|
-
gem "activerecord", ">= 2.3.5"
|
7
|
-
gem "actionpack", ">= 2.3.5"
|
8
2
|
|
9
|
-
#
|
10
|
-
|
11
|
-
group :development do
|
12
|
-
gem "rspec-rails", "~> 2.3.0"
|
13
|
-
gem "bundler", "~> 1.0.0"
|
14
|
-
gem "jeweler", "~> 1.6.0"
|
15
|
-
gem "rcov", ">= 0"
|
16
|
-
gem 'ruby-debug'
|
17
|
-
gem 'sqlite3'
|
18
|
-
end
|
19
|
-
|
20
|
-
group :test do
|
21
|
-
gem 'ruby-debug'
|
22
|
-
end
|
3
|
+
# Specify your gem's dependencies in adify.gemspec
|
4
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,108 +1,105 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
adify (0.2.0)
|
5
|
+
|
1
6
|
GEM
|
2
7
|
remote: http://rubygems.org/
|
3
8
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
rack (~> 1.
|
15
|
-
rack-mount (~> 0.
|
16
|
-
rack-test (~> 0.
|
17
|
-
|
18
|
-
activemodel (3.0
|
19
|
-
activesupport (= 3.0
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
git (>= 1.2.5)
|
42
|
-
rake
|
43
|
-
linecache (0.43)
|
44
|
-
mail (2.2.19)
|
45
|
-
activesupport (>= 2.3.6)
|
9
|
+
actionmailer (3.1.0)
|
10
|
+
actionpack (= 3.1.0)
|
11
|
+
mail (~> 2.3.0)
|
12
|
+
actionpack (3.1.0)
|
13
|
+
activemodel (= 3.1.0)
|
14
|
+
activesupport (= 3.1.0)
|
15
|
+
builder (~> 3.0.0)
|
16
|
+
erubis (~> 2.7.0)
|
17
|
+
i18n (~> 0.6)
|
18
|
+
rack (~> 1.3.2)
|
19
|
+
rack-cache (~> 1.0.3)
|
20
|
+
rack-mount (~> 0.8.2)
|
21
|
+
rack-test (~> 0.6.1)
|
22
|
+
sprockets (~> 2.0.0)
|
23
|
+
activemodel (3.1.0)
|
24
|
+
activesupport (= 3.1.0)
|
25
|
+
bcrypt-ruby (~> 3.0.0)
|
26
|
+
builder (~> 3.0.0)
|
27
|
+
i18n (~> 0.6)
|
28
|
+
activerecord (3.1.0)
|
29
|
+
activemodel (= 3.1.0)
|
30
|
+
activesupport (= 3.1.0)
|
31
|
+
arel (~> 2.2.1)
|
32
|
+
tzinfo (~> 0.3.29)
|
33
|
+
activeresource (3.1.0)
|
34
|
+
activemodel (= 3.1.0)
|
35
|
+
activesupport (= 3.1.0)
|
36
|
+
activesupport (3.1.0)
|
37
|
+
multi_json (~> 1.0)
|
38
|
+
arel (2.2.1)
|
39
|
+
bcrypt-ruby (3.0.0)
|
40
|
+
builder (3.0.0)
|
41
|
+
diff-lcs (1.1.3)
|
42
|
+
erubis (2.7.0)
|
43
|
+
hike (1.2.1)
|
44
|
+
i18n (0.6.0)
|
45
|
+
mail (2.3.0)
|
46
46
|
i18n (>= 0.4.0)
|
47
47
|
mime-types (~> 1.16)
|
48
48
|
treetop (~> 1.4.8)
|
49
49
|
mime-types (1.16)
|
50
|
-
|
51
|
-
|
52
|
-
rack
|
50
|
+
multi_json (1.0.3)
|
51
|
+
polyglot (0.3.2)
|
52
|
+
rack (1.3.2)
|
53
|
+
rack-cache (1.0.3)
|
54
|
+
rack (>= 0.4)
|
55
|
+
rack-mount (0.8.3)
|
53
56
|
rack (>= 1.0.0)
|
54
|
-
rack-
|
57
|
+
rack-ssl (1.3.2)
|
58
|
+
rack
|
59
|
+
rack-test (0.6.1)
|
55
60
|
rack (>= 1.0)
|
56
|
-
rails (3.0
|
57
|
-
actionmailer (= 3.0
|
58
|
-
actionpack (= 3.0
|
59
|
-
activerecord (= 3.0
|
60
|
-
activeresource (= 3.0
|
61
|
-
activesupport (= 3.0
|
61
|
+
rails (3.1.0)
|
62
|
+
actionmailer (= 3.1.0)
|
63
|
+
actionpack (= 3.1.0)
|
64
|
+
activerecord (= 3.1.0)
|
65
|
+
activeresource (= 3.1.0)
|
66
|
+
activesupport (= 3.1.0)
|
62
67
|
bundler (~> 1.0)
|
63
|
-
railties (= 3.0
|
64
|
-
railties (3.0
|
65
|
-
actionpack (= 3.0
|
66
|
-
activesupport (= 3.0
|
68
|
+
railties (= 3.1.0)
|
69
|
+
railties (3.1.0)
|
70
|
+
actionpack (= 3.1.0)
|
71
|
+
activesupport (= 3.1.0)
|
72
|
+
rack-ssl (~> 1.3.2)
|
67
73
|
rake (>= 0.8.7)
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
rspec-
|
74
|
-
rspec-
|
75
|
-
|
76
|
-
rspec-
|
74
|
+
rdoc (~> 3.4)
|
75
|
+
thor (~> 0.14.6)
|
76
|
+
rake (0.8.7)
|
77
|
+
rdoc (3.9.4)
|
78
|
+
rspec (2.6.0)
|
79
|
+
rspec-core (~> 2.6.0)
|
80
|
+
rspec-expectations (~> 2.6.0)
|
81
|
+
rspec-mocks (~> 2.6.0)
|
82
|
+
rspec-core (2.6.4)
|
83
|
+
rspec-expectations (2.6.0)
|
77
84
|
diff-lcs (~> 1.1.2)
|
78
|
-
rspec-mocks (2.
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
ruby-debug (0.10.4)
|
85
|
-
columnize (>= 0.1)
|
86
|
-
ruby-debug-base (~> 0.10.4.0)
|
87
|
-
ruby-debug-base (0.10.4)
|
88
|
-
linecache (>= 0.3)
|
89
|
-
sqlite3 (1.3.3)
|
85
|
+
rspec-mocks (2.6.0)
|
86
|
+
sprockets (2.0.0)
|
87
|
+
hike (~> 1.2)
|
88
|
+
rack (~> 1.0)
|
89
|
+
tilt (~> 1.1, != 1.3.0)
|
90
|
+
sqlite3 (1.3.4)
|
90
91
|
thor (0.14.6)
|
91
|
-
|
92
|
+
tilt (1.3.3)
|
93
|
+
treetop (1.4.10)
|
94
|
+
polyglot
|
92
95
|
polyglot (>= 0.3.1)
|
93
|
-
tzinfo (0.3.
|
96
|
+
tzinfo (0.3.29)
|
94
97
|
|
95
98
|
PLATFORMS
|
96
99
|
ruby
|
97
100
|
|
98
101
|
DEPENDENCIES
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
bundler (~> 1.0.0)
|
103
|
-
jeweler (~> 1.6.0)
|
104
|
-
rails (>= 2.3.5)
|
105
|
-
rcov
|
106
|
-
rspec-rails (~> 2.3.0)
|
107
|
-
ruby-debug
|
102
|
+
adify!
|
103
|
+
rails
|
104
|
+
rspec
|
108
105
|
sqlite3
|
data/README.rdoc
CHANGED
@@ -2,7 +2,12 @@
|
|
2
2
|
|
3
3
|
Adify is a simple to use (hopefully) rails gem that builds up ad tags for cashing in on your users. Adify is built to work with any ad server. The initial build will only include DFP (Google Ad Manager) as that is what I need this gem for.
|
4
4
|
|
5
|
-
This is just the initial version and isn't really complete. I haven't worked with other
|
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
|
+
|
7
|
+
== Releases
|
8
|
+
=== Version 0.2.0
|
9
|
+
* Refactored everything to use one module
|
10
|
+
* Tested with rails 2 & 3
|
6
11
|
|
7
12
|
== Contributing to adify
|
8
13
|
|
data/Rakefile
CHANGED
@@ -1,49 +1 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'bundler'
|
5
|
-
begin
|
6
|
-
Bundler.setup(:default, :development)
|
7
|
-
rescue Bundler::BundlerError => e
|
8
|
-
$stderr.puts e.message
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
-
exit e.status_code
|
11
|
-
end
|
12
|
-
require 'rake'
|
13
|
-
|
14
|
-
require 'jeweler'
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
-
gem.name = "adify"
|
18
|
-
gem.homepage = "http://github.com/fuelxc/adify"
|
19
|
-
gem.license = "MIT"
|
20
|
-
gem.summary = "create ad tags for common ad servers easily."
|
21
|
-
gem.description = "Adify lets you create ad tags easily and quickly with a simple common structure"
|
22
|
-
gem.email = "eharrison@classifiedadventures.com"
|
23
|
-
gem.authors = ["Eric Harrison"]
|
24
|
-
# dependencies defined in Gemfile
|
25
|
-
end
|
26
|
-
Jeweler::RubygemsDotOrgTasks.new
|
27
|
-
|
28
|
-
require 'rspec/core'
|
29
|
-
require 'rspec/core/rake_task'
|
30
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
-
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
-
end
|
33
|
-
|
34
|
-
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
-
spec.rcov = true
|
37
|
-
end
|
38
|
-
|
39
|
-
task :default => :spec
|
40
|
-
|
41
|
-
require 'rake/rdoctask'
|
42
|
-
Rake::RDocTask.new do |rdoc|
|
43
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
-
|
45
|
-
rdoc.rdoc_dir = 'rdoc'
|
46
|
-
rdoc.title = "adify #{version}"
|
47
|
-
rdoc.rdoc_files.include('README*')
|
48
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
-
end
|
1
|
+
require "bundler/gem_tasks"
|
data/adify.gemspec
CHANGED
@@ -1,85 +1,23 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "adify/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
9
|
-
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.date = %q{2011-07-05}
|
13
|
-
s.description = %q{Adify lets you create ad tags easily and quickly with a simple common structure}
|
14
|
-
s.email = %q{eharrison@classifiedadventures.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE.txt",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".rspec",
|
22
|
-
".rvmrc",
|
23
|
-
"Gemfile",
|
24
|
-
"Gemfile.lock",
|
25
|
-
"LICENSE.txt",
|
26
|
-
"README.rdoc",
|
27
|
-
"Rakefile",
|
28
|
-
"VERSION",
|
29
|
-
"adify.gemspec",
|
30
|
-
"lib/adify.rb",
|
31
|
-
"lib/adify/controller.rb",
|
32
|
-
"lib/adify/helper.rb",
|
33
|
-
"lib/adify/model.rb",
|
34
|
-
"lib/generators/adify/USAGE",
|
35
|
-
"lib/generators/adify/templates/_dfp.html.erb",
|
36
|
-
"lib/generators/adify_generator.rb",
|
37
|
-
"spec/adify_spec.rb",
|
38
|
-
"spec/spec_helper.rb"
|
39
|
-
]
|
40
|
-
s.homepage = %q{http://github.com/fuelxc/adify}
|
41
|
-
s.licenses = ["MIT"]
|
42
|
-
s.require_paths = ["lib"]
|
43
|
-
s.rubygems_version = %q{1.5.1}
|
6
|
+
s.name = "adify"
|
7
|
+
s.version = Adify::VERSION
|
8
|
+
s.authors = ["Eric Harrison"]
|
9
|
+
s.email = ["eric@rubynooby.com"]
|
10
|
+
s.homepage = "http://www.rubynooby.com"
|
44
11
|
s.summary = %q{create ad tags for common ad servers easily.}
|
12
|
+
s.description = %q{Adify lets you create ad tags easily and quickly with a simple common structure}
|
45
13
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
56
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
|
57
|
-
s.add_development_dependency(%q<rcov>, [">= 0"])
|
58
|
-
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
59
|
-
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
60
|
-
else
|
61
|
-
s.add_dependency(%q<rails>, [">= 2.3.5"])
|
62
|
-
s.add_dependency(%q<activesupport>, [">= 2.3.5"])
|
63
|
-
s.add_dependency(%q<activerecord>, [">= 2.3.5"])
|
64
|
-
s.add_dependency(%q<actionpack>, [">= 2.3.5"])
|
65
|
-
s.add_dependency(%q<rspec-rails>, ["~> 2.3.0"])
|
66
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
67
|
-
s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
|
68
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
69
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
70
|
-
s.add_dependency(%q<sqlite3>, [">= 0"])
|
71
|
-
end
|
72
|
-
else
|
73
|
-
s.add_dependency(%q<rails>, [">= 2.3.5"])
|
74
|
-
s.add_dependency(%q<activesupport>, [">= 2.3.5"])
|
75
|
-
s.add_dependency(%q<activerecord>, [">= 2.3.5"])
|
76
|
-
s.add_dependency(%q<actionpack>, [">= 2.3.5"])
|
77
|
-
s.add_dependency(%q<rspec-rails>, ["~> 2.3.0"])
|
78
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
79
|
-
s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
|
80
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
81
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
82
|
-
s.add_dependency(%q<sqlite3>, [">= 0"])
|
83
|
-
end
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
#s.add_development_dependency "ruby-debug19"
|
20
|
+
s.add_development_dependency "rspec"
|
21
|
+
s.add_development_dependency "rails"
|
22
|
+
s.add_development_dependency "sqlite3"
|
84
23
|
end
|
85
|
-
|
data/lib/adify.rb
CHANGED
@@ -1,74 +1,52 @@
|
|
1
|
-
require
|
2
|
-
require "active_record"
|
3
|
-
require "active_support"
|
4
|
-
|
5
|
-
require 'adify/controller'
|
6
|
-
require "adify/model"
|
1
|
+
require "adify/version"
|
7
2
|
require "adify/helper"
|
3
|
+
require "core_ext/hash"
|
4
|
+
require "core_ext/array"
|
8
5
|
|
9
|
-
#methods both controller and models call
|
10
6
|
module Adify
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
def self.included(base)
|
8
|
+
base.send :extend, Adify
|
9
|
+
end
|
10
|
+
|
11
|
+
def adify(args)
|
12
|
+
self.class_eval <<-EOM
|
13
|
+
include Adify::Methods
|
14
|
+
extend Adify::Methods
|
15
|
+
EOM
|
16
|
+
self.adify_attributes = args
|
17
|
+
end
|
18
|
+
|
19
|
+
module Methods
|
20
|
+
def adify_attributes=(hash)
|
21
|
+
@adify_attributes = hash
|
14
22
|
end
|
15
|
-
|
23
|
+
|
16
24
|
def adify_attributes
|
17
|
-
|
18
|
-
self.
|
25
|
+
my_attributes = @adify_attributes || {}
|
26
|
+
merge_with = self.respond_to?(:ancestors) ? self.ancestors.slice(1,self.ancestors.length).select{|c| c.respond_to?(:adify_attributes)}.first : self.class
|
27
|
+
merge_with.respond_to?(:adify_attributes) ? merge_with.adify_attributes.adify_merge(my_attributes) : my_attributes
|
19
28
|
end
|
20
|
-
|
29
|
+
|
21
30
|
def adification(item = nil)
|
22
31
|
ad_attr = item.nil? ? self.adify_attributes : self.adify_attributes.adify_merge(item.adify_attributes)
|
23
32
|
item_for_adification = item.nil? ? self : item
|
24
|
-
|
33
|
+
ad_attr.update_values{|v| get_adify_value(item_for_adification,v)}.symbolize_keys_recursively
|
25
34
|
end
|
26
|
-
|
35
|
+
|
27
36
|
private
|
28
|
-
|
29
|
-
|
30
|
-
|
37
|
+
def get_adify_value(item,value)
|
38
|
+
case value.class.to_s
|
39
|
+
when "Array" then value.each.collect{|v| get_adify_value(item,v)}
|
40
|
+
when "Proc" then (value.call item).to_s
|
41
|
+
when "Hash" then value.update(value){|k,v| get_adify_value(item,v)}
|
42
|
+
when "Symbol" then item.respond_to?(value) ? item.send(value) : value
|
43
|
+
else value
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
31
47
|
end
|
32
48
|
end
|
33
49
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
class ActionController::Base
|
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
|
60
|
-
end
|
61
|
-
|
62
|
-
class ActionView::Base
|
63
|
-
include AdifyHelper
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
|
-
class Hash
|
68
|
-
def update_values(&block)
|
69
|
-
self.update(self){|k,v| block.call v}
|
70
|
-
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 }
|
73
|
-
end
|
74
|
-
end
|
50
|
+
ActiveRecord::Base.send :include, Adify
|
51
|
+
ActionController::Base.send :include, Adify
|
52
|
+
ActionView::Base.send :include, Adify::Helper
|
data/lib/adify/helper.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
module Adify
|
2
|
+
module Helper
|
3
|
+
def adify_tag(args)
|
4
|
+
item = args.delete(:item) rescue nil
|
5
|
+
partial = args.delete(:partial) || 'adify/dfp'
|
6
|
+
tag_attributes = adification(item).merge(args)
|
7
|
+
#pass in the hash as a parameter too in case they need all the value but don't know the names
|
8
|
+
render :partial => partial, :locals => tag_attributes.merge(:tag_attributes => tag_attributes.clone)
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
def random(length)
|
12
|
+
Array.new(length){rand 9}.join
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Hash
|
2
|
+
def update_values(&block)
|
3
|
+
self.update(self){|k,v| block.call v}
|
4
|
+
end
|
5
|
+
def adify_merge(h)
|
6
|
+
self.merge!(h) {|key, _old, _new| _old.class == Hash ? _old.adify_merge(_new) : _new }
|
7
|
+
end
|
8
|
+
def symbolize_keys_recursively
|
9
|
+
self.symbolize_keys!
|
10
|
+
self.values.each do |v|
|
11
|
+
if v.is_a? Hash
|
12
|
+
v.symbolize_keys_recursively
|
13
|
+
elsif v.is_a? Array
|
14
|
+
v.symbolize_keys_recursively
|
15
|
+
end
|
16
|
+
end
|
17
|
+
self
|
18
|
+
end
|
19
|
+
end
|
data/spec/adify_spec.rb
CHANGED
@@ -34,12 +34,12 @@ describe Adify do
|
|
34
34
|
adify = app.index
|
35
35
|
adify.should_not be_nil
|
36
36
|
adify.should == {
|
37
|
-
:override_by_action => "Action",
|
38
37
|
:override_by_item => "item",
|
39
|
-
:controller_only => :symbol_no_method,
|
40
38
|
:base_only => ["base_arry_only_1", {:item1 => "base array only 2"}],
|
41
|
-
:action_only => "proc return",
|
42
39
|
:override_by_controller => "controller",
|
40
|
+
:override_by_action => "Action",
|
41
|
+
:controller_only => :symbol_no_method,
|
42
|
+
:action_only => "proc return",
|
43
43
|
:item_only => "item id via symbol"
|
44
44
|
}
|
45
45
|
end
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 23
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 6
|
10
|
-
version: 0.1.6
|
5
|
+
version: 0.2.0
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Eric Harrison
|
@@ -15,174 +10,54 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-
|
13
|
+
date: 2011-09-08 00:00:00 +10:00
|
19
14
|
default_executable:
|
20
15
|
dependencies:
|
21
16
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
17
|
+
name: rspec
|
18
|
+
prerelease: false
|
23
19
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
20
|
none: false
|
25
21
|
requirements:
|
26
22
|
- - ">="
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
|
30
|
-
- 2
|
31
|
-
- 3
|
32
|
-
- 5
|
33
|
-
version: 2.3.5
|
34
|
-
name: rails
|
24
|
+
version: "0"
|
25
|
+
type: :development
|
35
26
|
version_requirements: *id001
|
36
|
-
prerelease: false
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
type: :runtime
|
39
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
|
-
requirements:
|
42
|
-
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
hash: 9
|
45
|
-
segments:
|
46
|
-
- 2
|
47
|
-
- 3
|
48
|
-
- 5
|
49
|
-
version: 2.3.5
|
50
|
-
name: activesupport
|
51
|
-
version_requirements: *id002
|
52
|
-
prerelease: false
|
53
27
|
- !ruby/object:Gem::Dependency
|
54
|
-
|
55
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
-
none: false
|
57
|
-
requirements:
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
hash: 9
|
61
|
-
segments:
|
62
|
-
- 2
|
63
|
-
- 3
|
64
|
-
- 5
|
65
|
-
version: 2.3.5
|
66
|
-
name: activerecord
|
67
|
-
version_requirements: *id003
|
28
|
+
name: rails
|
68
29
|
prerelease: false
|
69
|
-
|
70
|
-
type: :runtime
|
71
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
72
31
|
none: false
|
73
32
|
requirements:
|
74
33
|
- - ">="
|
75
34
|
- !ruby/object:Gem::Version
|
76
|
-
|
77
|
-
segments:
|
78
|
-
- 2
|
79
|
-
- 3
|
80
|
-
- 5
|
81
|
-
version: 2.3.5
|
82
|
-
name: actionpack
|
83
|
-
version_requirements: *id004
|
84
|
-
prerelease: false
|
85
|
-
- !ruby/object:Gem::Dependency
|
86
|
-
type: :development
|
87
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
88
|
-
none: false
|
89
|
-
requirements:
|
90
|
-
- - ~>
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
hash: 3
|
93
|
-
segments:
|
94
|
-
- 2
|
95
|
-
- 3
|
96
|
-
- 0
|
97
|
-
version: 2.3.0
|
98
|
-
name: rspec-rails
|
99
|
-
version_requirements: *id005
|
100
|
-
prerelease: false
|
101
|
-
- !ruby/object:Gem::Dependency
|
102
|
-
type: :development
|
103
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
104
|
-
none: false
|
105
|
-
requirements:
|
106
|
-
- - ~>
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
hash: 23
|
109
|
-
segments:
|
110
|
-
- 1
|
111
|
-
- 0
|
112
|
-
- 0
|
113
|
-
version: 1.0.0
|
114
|
-
name: bundler
|
115
|
-
version_requirements: *id006
|
116
|
-
prerelease: false
|
117
|
-
- !ruby/object:Gem::Dependency
|
35
|
+
version: "0"
|
118
36
|
type: :development
|
119
|
-
|
120
|
-
none: false
|
121
|
-
requirements:
|
122
|
-
- - ~>
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
hash: 15
|
125
|
-
segments:
|
126
|
-
- 1
|
127
|
-
- 6
|
128
|
-
- 0
|
129
|
-
version: 1.6.0
|
130
|
-
name: jeweler
|
131
|
-
version_requirements: *id007
|
132
|
-
prerelease: false
|
37
|
+
version_requirements: *id002
|
133
38
|
- !ruby/object:Gem::Dependency
|
134
|
-
|
135
|
-
requirement: &id008 !ruby/object:Gem::Requirement
|
136
|
-
none: false
|
137
|
-
requirements:
|
138
|
-
- - ">="
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
hash: 3
|
141
|
-
segments:
|
142
|
-
- 0
|
143
|
-
version: "0"
|
144
|
-
name: rcov
|
145
|
-
version_requirements: *id008
|
39
|
+
name: sqlite3
|
146
40
|
prerelease: false
|
147
|
-
|
148
|
-
type: :development
|
149
|
-
requirement: &id009 !ruby/object:Gem::Requirement
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
150
42
|
none: false
|
151
43
|
requirements:
|
152
44
|
- - ">="
|
153
45
|
- !ruby/object:Gem::Version
|
154
|
-
hash: 3
|
155
|
-
segments:
|
156
|
-
- 0
|
157
46
|
version: "0"
|
158
|
-
name: ruby-debug
|
159
|
-
version_requirements: *id009
|
160
|
-
prerelease: false
|
161
|
-
- !ruby/object:Gem::Dependency
|
162
47
|
type: :development
|
163
|
-
|
164
|
-
none: false
|
165
|
-
requirements:
|
166
|
-
- - ">="
|
167
|
-
- !ruby/object:Gem::Version
|
168
|
-
hash: 3
|
169
|
-
segments:
|
170
|
-
- 0
|
171
|
-
version: "0"
|
172
|
-
name: sqlite3
|
173
|
-
version_requirements: *id010
|
174
|
-
prerelease: false
|
48
|
+
version_requirements: *id003
|
175
49
|
description: Adify lets you create ad tags easily and quickly with a simple common structure
|
176
|
-
email:
|
50
|
+
email:
|
51
|
+
- eric@rubynooby.com
|
177
52
|
executables: []
|
178
53
|
|
179
54
|
extensions: []
|
180
55
|
|
181
|
-
extra_rdoc_files:
|
182
|
-
|
183
|
-
- README.rdoc
|
56
|
+
extra_rdoc_files: []
|
57
|
+
|
184
58
|
files:
|
185
59
|
- .document
|
60
|
+
- .gitignore
|
186
61
|
- .rspec
|
187
62
|
- .rvmrc
|
188
63
|
- Gemfile
|
@@ -190,21 +65,21 @@ files:
|
|
190
65
|
- LICENSE.txt
|
191
66
|
- README.rdoc
|
192
67
|
- Rakefile
|
193
|
-
- VERSION
|
194
68
|
- adify.gemspec
|
195
69
|
- lib/adify.rb
|
196
|
-
- lib/adify/controller.rb
|
197
70
|
- lib/adify/helper.rb
|
198
|
-
- lib/adify/
|
71
|
+
- lib/adify/version.rb
|
72
|
+
- lib/core_ext/array.rb
|
73
|
+
- lib/core_ext/hash.rb
|
199
74
|
- lib/generators/adify/USAGE
|
200
75
|
- lib/generators/adify/templates/_dfp.html.erb
|
201
76
|
- lib/generators/adify_generator.rb
|
202
77
|
- spec/adify_spec.rb
|
203
78
|
- spec/spec_helper.rb
|
204
79
|
has_rdoc: true
|
205
|
-
homepage: http://
|
206
|
-
licenses:
|
207
|
-
|
80
|
+
homepage: http://www.rubynooby.com
|
81
|
+
licenses: []
|
82
|
+
|
208
83
|
post_install_message:
|
209
84
|
rdoc_options: []
|
210
85
|
|
@@ -215,18 +90,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
90
|
requirements:
|
216
91
|
- - ">="
|
217
92
|
- !ruby/object:Gem::Version
|
218
|
-
hash: 3
|
219
|
-
segments:
|
220
|
-
- 0
|
221
93
|
version: "0"
|
222
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
223
95
|
none: false
|
224
96
|
requirements:
|
225
97
|
- - ">="
|
226
98
|
- !ruby/object:Gem::Version
|
227
|
-
hash: 3
|
228
|
-
segments:
|
229
|
-
- 0
|
230
99
|
version: "0"
|
231
100
|
requirements: []
|
232
101
|
|
@@ -235,5 +104,6 @@ rubygems_version: 1.5.1
|
|
235
104
|
signing_key:
|
236
105
|
specification_version: 3
|
237
106
|
summary: create ad tags for common ad servers easily.
|
238
|
-
test_files:
|
239
|
-
|
107
|
+
test_files:
|
108
|
+
- spec/adify_spec.rb
|
109
|
+
- spec/spec_helper.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.6
|
data/lib/adify/controller.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
module Adify
|
2
|
-
module Controller
|
3
|
-
def self.included(base)
|
4
|
-
base.send :extend, ClassMethods
|
5
|
-
end
|
6
|
-
|
7
|
-
#TODO: refactor this up so both model and controller use same code. DRY
|
8
|
-
module ClassMethods
|
9
|
-
def adify(*args)
|
10
|
-
class_eval <<-EOV
|
11
|
-
cattr_accessor :adify_#{self.to_s.tableize.gsub(/\//,'_')}_attributes
|
12
|
-
cattr_accessor :adify_tag_number
|
13
|
-
|
14
|
-
def self.adify_attributes=(hash)
|
15
|
-
self.adify_#{self.to_s.tableize.gsub(/\//,'_')}_attributes = hash
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.adify_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
|
21
|
-
end
|
22
|
-
EOV
|
23
|
-
|
24
|
-
attr_accessor :adify_instance_attributes
|
25
|
-
helper_method :adification
|
26
|
-
send :include, ::Adify::InstanceMethods
|
27
|
-
|
28
|
-
def self.adification
|
29
|
-
@adification_of_item = self.adify_attributes.update_values{|v| get_adify_value(self,v)}
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
def get_adify_value(item,value)
|
34
|
-
case value.class.to_s
|
35
|
-
when 'Array' then value.each.collect{|v| get_adify_value(item,v)}
|
36
|
-
when 'Proc' then value.call item
|
37
|
-
when 'Hash' then value.update(value){|k,v| get_adify_value(item,v)}
|
38
|
-
when 'Symbol' then item.respond_to?(value) ? item.send(value) : value
|
39
|
-
else value
|
40
|
-
end
|
41
|
-
end
|
42
|
-
self.adify_attributes = *args
|
43
|
-
self.adify_tag_number = 0
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
data/lib/adify/model.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
module Adify
|
2
|
-
module Model
|
3
|
-
def self.included(base)
|
4
|
-
base.send :extend, ClassMethods
|
5
|
-
end
|
6
|
-
|
7
|
-
#TODO: refactor this up so both model and controller use same code. DRY
|
8
|
-
module ClassMethods
|
9
|
-
def adify(*args)
|
10
|
-
@@adify_class_attributes = HashWithIndifferentAccess.new()
|
11
|
-
attr_accessor :adify_instance_attributes
|
12
|
-
send :include, ::Adify::InstanceMethods
|
13
|
-
|
14
|
-
def self.adify_attributes=(hash)
|
15
|
-
@@adify_class_attributes = hash
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.adification
|
19
|
-
@adification_of_item = self.adify_attributes.update_values{|v| get_adify_value(self,v)}
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.adify_attributes
|
23
|
-
super.deep_merge(@@adify_class_attributes) rescue @@adify_class_attributes
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
def get_adify_value(item,value)
|
28
|
-
case value.class
|
29
|
-
when Array then value.each.collect{|v| self.get_adify_value(item,v)}
|
30
|
-
when Proc then (value.call item).to_s
|
31
|
-
when Hash then value.update(value){|k,v| self.get_adify_value(item,v)}
|
32
|
-
when Symbol then item.respond_to?(value) ? item.send(value) : value
|
33
|
-
else value
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
self.adify_attributes = *args
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|