eac_rails_utils 0.5.0 → 0.6.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 926390e40752868353a97b85802a2f3626ed5b9206c570ce88931c4fde036836
|
4
|
+
data.tar.gz: 56fa6a845cedfc2afda247787dd6c94a62013f883def7e2c7dcf06f2cb348260
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68dd63e8acea983a4716bd9b9e349d4320358349fe3845b9e4961c5b6005e505362c8c3f7b0c7c121fce3b8d6445687760230c790b4345c88c1ac8d1d33975fc
|
7
|
+
data.tar.gz: ccb1f573919f77aee1b7eb14eb8db72eea4e969b6ea465b6561fc632995af978b9bc1c3a46281a89da1e46bce3227ab396541b15170073d9287cb63222e1e488
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module EacRailsUtils
|
3
|
+
module OpenGraphProtocolHelper
|
4
|
+
OGP_META_DEFAULT_PREFIX = 'og'
|
5
|
+
|
6
|
+
def ogp_meta_prefix
|
7
|
+
OGP_META_DEFAULT_PREFIX
|
8
|
+
end
|
9
|
+
|
10
|
+
def ogp_prefix
|
11
|
+
"#{ogp_meta_prefix}: http://ogp.me/ns#"
|
12
|
+
end
|
13
|
+
|
14
|
+
def ogp_meta_tags
|
15
|
+
ogp_root.children_tags
|
16
|
+
end
|
17
|
+
|
18
|
+
def ogp_root
|
19
|
+
@ogp_root ||= RootEntry.new(self)
|
20
|
+
end
|
21
|
+
|
22
|
+
def ogp_set(data)
|
23
|
+
ogp_root.data = data
|
24
|
+
end
|
25
|
+
|
26
|
+
class AbstractEntry
|
27
|
+
attr_reader :view
|
28
|
+
|
29
|
+
def initialize(view)
|
30
|
+
@view = view
|
31
|
+
@children = ::ActiveSupport::HashWithIndifferentAccess.new
|
32
|
+
end
|
33
|
+
|
34
|
+
def child(child_suffix)
|
35
|
+
@children[child_suffix] ||= Entry.new(view, self, child_suffix)
|
36
|
+
end
|
37
|
+
|
38
|
+
def children_tags
|
39
|
+
view.capture do
|
40
|
+
view.concat tag
|
41
|
+
@children.values.each do |child|
|
42
|
+
view.concat(child.children_tags)
|
43
|
+
view.concat("\n")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def data=(a_data)
|
49
|
+
if a_data.is_a?(::Hash)
|
50
|
+
a_data.each { |k, v| child(k).data = v }
|
51
|
+
else
|
52
|
+
self.content = a_data
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class Entry < AbstractEntry
|
58
|
+
attr_reader :parent, :suffix
|
59
|
+
|
60
|
+
def initialize(view, parent, suffix)
|
61
|
+
super view
|
62
|
+
@parent = parent
|
63
|
+
@suffix = suffix
|
64
|
+
end
|
65
|
+
|
66
|
+
def components
|
67
|
+
(parent.present? ? parent.components : []) + [suffix]
|
68
|
+
end
|
69
|
+
|
70
|
+
def content
|
71
|
+
view.content_for content_for_key
|
72
|
+
end
|
73
|
+
|
74
|
+
def content=(a_content)
|
75
|
+
view.content_for content_for_key, a_content.to_s
|
76
|
+
end
|
77
|
+
|
78
|
+
def content?
|
79
|
+
view.content_for? content_for_key
|
80
|
+
end
|
81
|
+
|
82
|
+
def content_for_key
|
83
|
+
"ogp_#{components.join('_')}"
|
84
|
+
end
|
85
|
+
|
86
|
+
def property_value
|
87
|
+
"#{view.ogp_meta_prefix}:#{components.join(':')}"
|
88
|
+
end
|
89
|
+
|
90
|
+
def tag
|
91
|
+
return ::ActiveSupport::SafeBuffer.new unless content?
|
92
|
+
view.tag(:meta, prefix: view.ogp_prefix, property: property_value, content: content)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
class RootEntry < AbstractEntry
|
97
|
+
def components
|
98
|
+
[]
|
99
|
+
end
|
100
|
+
|
101
|
+
def content=(_a_content)
|
102
|
+
raise 'Root OGP entry cannot have content'
|
103
|
+
end
|
104
|
+
|
105
|
+
def tag
|
106
|
+
::ActiveSupport::SafeBuffer.new
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
data/lib/eac_rails_utils.rb
CHANGED
@@ -11,7 +11,7 @@ module EacRailsUtils
|
|
11
11
|
require 'eac_rails_utils/patches/action_controller_base'
|
12
12
|
require 'eac_rails_utils/patches/model_attribute_required'
|
13
13
|
require 'eac_rails_utils/patches/ofx_parser'
|
14
|
-
require 'eac_rails_utils/
|
14
|
+
require 'eac_rails_utils/engine'
|
15
15
|
require 'eac_rails_utils/tableless_model'
|
16
16
|
require 'eac/cpf_validator'
|
17
17
|
require 'eac/common_form_helper/form_builder/association_select_field'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eac_rails_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- E.A.C.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel-associations
|
@@ -135,6 +135,7 @@ extensions: []
|
|
135
135
|
extra_rdoc_files: []
|
136
136
|
files:
|
137
137
|
- Rakefile
|
138
|
+
- app/helpers/eac_rails_utils/open_graph_protocol_helper.rb
|
138
139
|
- lib/assets/javascripts/currency_field.js
|
139
140
|
- lib/assets/javascripts/eac_rails_utils.js
|
140
141
|
- lib/assets/javascripts/input_searchable.js
|
@@ -177,11 +178,11 @@ files:
|
|
177
178
|
- lib/eac/source_target_fixtures.rb
|
178
179
|
- lib/eac/test_utils.rb
|
179
180
|
- lib/eac_rails_utils.rb
|
181
|
+
- lib/eac_rails_utils/engine.rb
|
180
182
|
- lib/eac_rails_utils/helpers/formatter.rb
|
181
183
|
- lib/eac_rails_utils/patches/action_controller_base.rb
|
182
184
|
- lib/eac_rails_utils/patches/model_attribute_required.rb
|
183
185
|
- lib/eac_rails_utils/patches/ofx_parser.rb
|
184
|
-
- lib/eac_rails_utils/rails/engine.rb
|
185
186
|
- lib/eac_rails_utils/tableless_model.rb
|
186
187
|
- lib/eac_rails_utils/version.rb
|
187
188
|
- test/dummy/Rakefile
|