meta_manager 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3cd80ac98c0b65cd37250690a486909c3cead26
4
- data.tar.gz: 9cd0e104e998f9d87e17e4107ed4cac00e8cf5af
3
+ metadata.gz: 419562a536239133d474b71e3aafa19d50a9073d
4
+ data.tar.gz: 412be83ee94a87915a82e3e6216b4f48482e24ae
5
5
  SHA512:
6
- metadata.gz: f1b62e285426949d49d148edbcd5c136982ee00b702ef4077c77a75e26db5402c6b07a853e0e172f0eae2d780bfa63f8a014cce350e845628d66a82a900ceacd
7
- data.tar.gz: 7eb3d92a81c6570e2cc21d375e4aa410e4ffa71382c5ed9dfb50295ffb6c030ca17bd10a76ae8073dc1b0268432d89babe6f367bd77a59ab6e448d5b2e60d178
6
+ metadata.gz: 0f8c7998821a4764e20e1f83d3c0892d4f288832f7ea800f6c1dde5f398e22f3a494c2543694cd326a7f30740f2191c3507ff5c436ec204f2063d0e47b538df3
7
+ data.tar.gz: 30ba5960694e4c7e9316fd09686076085220da16a73e2957542ad9a9f9397e654b17e49227410b72307b86e98402f45620011ccabd95935fac12ddea8d4140bc
@@ -1,17 +1,20 @@
1
1
  module MetaManager
2
2
  module Taggable
3
3
  extend ::ActiveSupport::Concern
4
-
5
- included do
4
+
5
+ included do
6
6
  has_many :meta_tags, :as => :taggable, :dependent => :destroy, :autosave => true
7
-
7
+
8
8
  accepts_nested_attributes_for :meta_tags, :reject_if => proc { |tag| tag['content'].blank? }, :allow_destroy => true
9
+
10
+ alias_method_chain :respond_to?, :tags
11
+ alias_method_chain :method_missing, :tags
9
12
  end
10
-
13
+
11
14
  # Save meta tags records into one hash
12
15
  def meta_tag(attr_name, options={})
13
16
  key = normalize_meta_tag_name(attr_name)
14
-
17
+
15
18
  cached_meta_tags[key] ||= self.meta_tags.detect {|t| t.name == key}
16
19
  cached_meta_tags[key] ||= self.meta_tags.build(:name => key) if options[:build]
17
20
  cached_meta_tags[key]
@@ -20,38 +23,35 @@ module MetaManager
20
23
  def cached_meta_tags
21
24
  @cached_meta_tags ||= {}
22
25
  end
23
-
24
- def respond_to?(method_sym, include_private = false)
25
- if method_sym.to_s =~ meta_match_case
26
- true
27
- else
28
- super
29
- end
26
+
27
+ def respond_to_with_tags?(method_sym, include_all = false)
28
+ return true if method_sym.to_s =~ meta_match_case
29
+ respond_to_without_tags?(method_sym, include_all)
30
30
  end
31
-
31
+
32
32
  protected
33
-
34
- def normalize_meta_tag_name(value)
35
- value.to_s.downcase.strip.gsub("_before_type_cast", '').gsub(/=$/, '')
36
- end
37
-
38
- def method_missing(method, *args, &block)
39
- key = method.to_s
40
-
33
+
34
+ def method_missing_with_tags(method_name, *args)
35
+ key = method_name.to_s
36
+
41
37
  if key =~ meta_match_case
42
38
  attr_name = key.gsub(meta_match_case, '')
43
-
39
+
44
40
  if key =~ /=$/ && !args.first.blank?
45
41
  record = meta_tag(attr_name, :build => true)
46
42
  record.content = args.first
47
- else
43
+ else
48
44
  meta_tag(attr_name).try(:content)
49
45
  end
50
46
  else
51
- super
47
+ return method_missing_without_tags(method_name, *args)
52
48
  end
53
49
  end
54
-
50
+
51
+ def normalize_meta_tag_name(value)
52
+ value.to_s.downcase.strip.gsub("_before_type_cast", '').gsub(/=$/, '')
53
+ end
54
+
55
55
  def meta_match_case
56
56
  /^tag_/
57
57
  end
@@ -1,3 +1,3 @@
1
1
  module MetaManager
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meta_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Galeta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-01 00:00:00.000000000 Z
11
+ date: 2016-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: orm_adapter
@@ -87,7 +87,11 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - MIT-LICENSE
91
+ - README.rdoc
92
+ - Rakefile
90
93
  - db/migrate/20120105114018_create_meta_tags.rb
94
+ - lib/meta_manager.rb
91
95
  - lib/meta_manager/engine.rb
92
96
  - lib/meta_manager/helper.rb
93
97
  - lib/meta_manager/model.rb
@@ -97,13 +101,10 @@ files:
97
101
  - lib/meta_manager/orm/mongoid.rb
98
102
  - lib/meta_manager/taggable.rb
99
103
  - lib/meta_manager/version.rb
100
- - lib/meta_manager.rb
101
104
  - lib/tasks/meta_manager_tasks.rake
102
- - MIT-LICENSE
103
- - Rakefile
104
- - README.rdoc
105
105
  - test/controllers/posts_controller_test.rb
106
106
  - test/controllers/welcome_controller_test.rb
107
+ - test/dummy/Rakefile
107
108
  - test/dummy/app/assets/javascripts/application.js
108
109
  - test/dummy/app/assets/stylesheets/application.css
109
110
  - test/dummy/app/controllers/application_controller.rb
@@ -116,6 +117,7 @@ files:
116
117
  - test/dummy/app/views/posts/index.html.erb
117
118
  - test/dummy/app/views/posts/show.html.erb
118
119
  - test/dummy/app/views/welcome/index.html.erb
120
+ - test/dummy/config.ru
119
121
  - test/dummy/config/application.rb
120
122
  - test/dummy/config/boot.rb
121
123
  - test/dummy/config/database.yml
@@ -132,7 +134,6 @@ files:
132
134
  - test/dummy/config/initializers/wrap_parameters.rb
133
135
  - test/dummy/config/locales/en.yml
134
136
  - test/dummy/config/routes.rb
135
- - test/dummy/config.ru
136
137
  - test/dummy/db/migrate/20111226131910_create_categories.rb
137
138
  - test/dummy/db/migrate/20111226131911_create_posts.rb
138
139
  - test/dummy/db/test.sqlite3
@@ -141,7 +142,6 @@ files:
141
142
  - test/dummy/public/422.html
142
143
  - test/dummy/public/500.html
143
144
  - test/dummy/public/favicon.ico
144
- - test/dummy/Rakefile
145
145
  - test/dummy/script/rails
146
146
  - test/meta_manager_test.rb
147
147
  - test/models/category_test.rb
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  version: '0'
167
167
  requirements: []
168
168
  rubyforge_project:
169
- rubygems_version: 2.0.3
169
+ rubygems_version: 2.4.5
170
170
  signing_key:
171
171
  specification_version: 4
172
172
  summary: Head meta tags manager for models.
@@ -216,3 +216,4 @@ test_files:
216
216
  - test/models/category_test.rb
217
217
  - test/models/meta_tag_test.rb
218
218
  - test/test_helper.rb
219
+ has_rdoc: