item 0.0.2 → 0.0.3
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 +4 -4
- data/.gitignore +1 -1
- data/CHANGELOG.md +13 -0
- data/lib/item/version.rb +1 -1
- data/lib/item/view_helpers.rb +2 -6
- data/test/view_helpers_test.rb +14 -18
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6636b67af901b2fb8d53f9b5e07ee473847c986f
|
4
|
+
data.tar.gz: 1fb525437828700232569ffd3669dc6598c91b4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51c6516bc919592aa92f3788452d434f845da401967c1bc63ca13c330cdea911ea60a18b1d79f233350419d2e080fb282e43f933ce5e6993b4e4cca3be5c3774
|
7
|
+
data.tar.gz: 02de298d3b9174019921fe610f448221cad268333c81f09879cd0c635872f6423deea25bd9b270957adb1f4167efc14afdbb2846111e9d458440fde47ec32eb5
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
data/lib/item/version.rb
CHANGED
data/lib/item/view_helpers.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
module Item
|
2
2
|
module ViewHelpers
|
3
3
|
def scope(key, options = {}, &block)
|
4
|
-
|
5
|
-
concat content_tag(:div, content, itemscope: "itemscope", itemtype: Util.itemtype(key))
|
6
|
-
nil
|
4
|
+
content_tag(:div, itemscope: "itemscope", itemtype: Util.itemtype(key), &block)
|
7
5
|
end
|
8
6
|
|
9
7
|
def prop(key, value = nil, options = {}, &block)
|
@@ -16,10 +14,8 @@ module Item
|
|
16
14
|
itemprop = Util.itemprop(key)
|
17
15
|
|
18
16
|
if block
|
19
|
-
value = capture(&block)
|
20
17
|
itemtype = Util.itemtype(options[:type].presence || key)
|
21
|
-
|
22
|
-
nil
|
18
|
+
content_tag(:div, itemprop: itemprop, itemscope: "itemscope", itemtype: itemtype, &block)
|
23
19
|
else
|
24
20
|
content_tag(:span, value, itemprop: itemprop)
|
25
21
|
end
|
data/test/view_helpers_test.rb
CHANGED
@@ -4,63 +4,59 @@ class ViewHelpersTest < ActionView::TestCase
|
|
4
4
|
include Item::ViewHelpers
|
5
5
|
|
6
6
|
test "scope" do
|
7
|
-
|
7
|
+
content = scope :aggregate_rating do
|
8
8
|
"content"
|
9
9
|
end
|
10
10
|
|
11
|
-
assert_nil text
|
12
11
|
assert_equal %{<div itemscope="itemscope" itemtype="http://schema.org/AggregateRating">content</div>},
|
13
|
-
|
12
|
+
content
|
14
13
|
end
|
15
14
|
|
16
15
|
test "prop" do
|
17
|
-
|
16
|
+
content = prop(:aggregate_rating, "content")
|
18
17
|
|
19
18
|
assert_equal %{<span itemprop="aggregateRating">content</span>},
|
20
|
-
|
19
|
+
content
|
21
20
|
end
|
22
21
|
|
23
22
|
test "hidden prop" do
|
24
|
-
|
23
|
+
content = prop(aggregate_rating: "Rating content", title: "Title content")
|
25
24
|
|
26
25
|
assert_equal %{<meta content="Rating content" itemprop="aggregateRating" />\n<meta content="Title content" itemprop="title" />},
|
27
|
-
|
26
|
+
content
|
28
27
|
end
|
29
28
|
|
30
29
|
test "link prop" do
|
31
|
-
|
30
|
+
content = prop(:availability, :in_stock)
|
32
31
|
|
33
32
|
assert_equal %{<link href="http://schema.org/InStock" itemprop="availability" />},
|
34
|
-
|
33
|
+
content
|
35
34
|
end
|
36
35
|
|
37
36
|
test "prop block" do
|
38
|
-
|
37
|
+
content = prop :aggregate_rating do
|
39
38
|
"content"
|
40
39
|
end
|
41
40
|
|
42
|
-
assert_nil text
|
43
41
|
assert_equal %{<div itemprop="aggregateRating" itemscope="itemscope" itemtype="http://schema.org/AggregateRating">content</div>},
|
44
|
-
|
42
|
+
content
|
45
43
|
end
|
46
44
|
|
47
45
|
test "prop block with type" do
|
48
|
-
|
46
|
+
content = prop :aggregate_rating, type: :other_type do
|
49
47
|
"content"
|
50
48
|
end
|
51
49
|
|
52
|
-
assert_nil text
|
53
50
|
assert_equal %{<div itemprop="aggregateRating" itemscope="itemscope" itemtype="http://schema.org/OtherType">content</div>},
|
54
|
-
|
51
|
+
content
|
55
52
|
end
|
56
53
|
|
57
54
|
test "combined" do
|
58
|
-
|
55
|
+
content = scope :product do
|
59
56
|
concat prop(:title, "My Title")
|
60
57
|
end
|
61
58
|
|
62
|
-
assert_nil text
|
63
59
|
assert_equal %{<div itemscope="itemscope" itemtype="http://schema.org/Product"><span itemprop="title">My Title</span></div>},
|
64
|
-
|
60
|
+
content
|
65
61
|
end
|
66
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: item
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lasse Bunk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -75,6 +75,7 @@ extensions: []
|
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
77
|
- ".gitignore"
|
78
|
+
- CHANGELOG.md
|
78
79
|
- Gemfile
|
79
80
|
- LICENSE.txt
|
80
81
|
- README.html
|