item 0.0.2 → 0.0.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: 56ba445d6443100a1fedeeed36b40af7f525cddd
4
- data.tar.gz: 7bddb796ba035f8fe3a0db15f71b91d5cd75013f
3
+ metadata.gz: 6636b67af901b2fb8d53f9b5e07ee473847c986f
4
+ data.tar.gz: 1fb525437828700232569ffd3669dc6598c91b4e
5
5
  SHA512:
6
- metadata.gz: c90429c61712c3e2236ff13b7ef2fc6b67058d2496bfde65f95d80efba7523a88a03abe5e7bf05fccacd649dce9d122e4ea265739e592aa0e18f940a50ff3fa6
7
- data.tar.gz: af169929858e6362b27093836eafd4c7fb0f864d198ec86851e8b04d5ad6851aa3ec61ec6ded8ecfb3ff7c7ab8327ec2535784b083f4aa672f55e25c5181dfc0
6
+ metadata.gz: 51c6516bc919592aa92f3788452d434f845da401967c1bc63ca13c330cdea911ea60a18b1d79f233350419d2e080fb282e43f933ce5e6993b4e4cca3be5c3774
7
+ data.tar.gz: 02de298d3b9174019921fe610f448221cad268333c81f09879cd0c635872f6423deea25bd9b270957adb1f4167efc14afdbb2846111e9d458440fde47ec32eb5
data/.gitignore CHANGED
@@ -19,4 +19,4 @@ tmp
19
19
  *.so
20
20
  *.o
21
21
  *.a
22
- mkmf.log
22
+ *.log
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ ### 0.0.3
4
+
5
+ * Don't use `capture` in view helpers
6
+
7
+ ### 0.0.2
8
+
9
+ * Require Rails >= 3.2.0 instead of 4.1
10
+
11
+ ### 0.0.1
12
+
13
+ * Initial release
@@ -1,3 +1,3 @@
1
1
  module Item
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,9 +1,7 @@
1
1
  module Item
2
2
  module ViewHelpers
3
3
  def scope(key, options = {}, &block)
4
- content = capture(&block)
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
- concat content_tag(:div, value, itemprop: itemprop, itemscope: "itemscope", itemtype: itemtype)
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
@@ -4,63 +4,59 @@ class ViewHelpersTest < ActionView::TestCase
4
4
  include Item::ViewHelpers
5
5
 
6
6
  test "scope" do
7
- text = scope :aggregate_rating do
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
- output_buffer
12
+ content
14
13
  end
15
14
 
16
15
  test "prop" do
17
- concat prop(:aggregate_rating, "content")
16
+ content = prop(:aggregate_rating, "content")
18
17
 
19
18
  assert_equal %{<span itemprop="aggregateRating">content</span>},
20
- output_buffer
19
+ content
21
20
  end
22
21
 
23
22
  test "hidden prop" do
24
- concat prop(aggregate_rating: "Rating content", title: "Title content")
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
- output_buffer
26
+ content
28
27
  end
29
28
 
30
29
  test "link prop" do
31
- concat prop(:availability, :in_stock)
30
+ content = prop(:availability, :in_stock)
32
31
 
33
32
  assert_equal %{<link href="http://schema.org/InStock" itemprop="availability" />},
34
- output_buffer
33
+ content
35
34
  end
36
35
 
37
36
  test "prop block" do
38
- text = prop :aggregate_rating do
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
- output_buffer
42
+ content
45
43
  end
46
44
 
47
45
  test "prop block with type" do
48
- text = prop :aggregate_rating, type: :other_type do
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
- output_buffer
51
+ content
55
52
  end
56
53
 
57
54
  test "combined" do
58
- text = scope :product do
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
- output_buffer
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.2
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-26 00:00:00.000000000 Z
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