arbre2 2.2.0 → 2.2.1

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: 16f9018c606a0942060a2686db4afa15f967a9b7
4
- data.tar.gz: 94f228418b55716964de0b3c26474c208da97c32
3
+ metadata.gz: 66fd31e6deecb33fd6421abc61f4ac53513b0964
4
+ data.tar.gz: c2a175e9c2b22df524ba2704c95254b0fae99f71
5
5
  SHA512:
6
- metadata.gz: 10600d97b0f6f2a9284a56f14ac879cf924556a363e8a378378c9cdc5c09eaf950fab1bd492fbbba66c7758f4a91d6cc5ce5c0f3ad7ca2a4b00d18aec14084c7
7
- data.tar.gz: 0b6b82cc4256f35910a2a237db1720c77b14dc611d509b6e5d070d65a121a7a2a1ded3d6a6c7ab7d8d5f1b55bcd5bc660ee64ec3b1aa174d9435c9b7133bce6e
6
+ metadata.gz: 8a640b9624f022b05324e720306b1fa6875b2061e686a5f6b37ba50c7745e62a3ab8b6f498ac0c2e85b232c5fcb7bd8a9b7d24ce2bd1a5a8db87bf479057623b
7
+ data.tar.gz: cae1590fd832a6287d548c61b6c149539facf9f80fee23d71d6474ba2be93e5ac3ed96dde47e7e87501c3d773b2db4539850021b13f9e4f34a4c74f7eee95316
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- arbre2 (2.2.0)
4
+ arbre2 (2.2.1)
5
5
  activesupport
6
6
 
7
7
  GEM
@@ -61,7 +61,16 @@ module Arbre
61
61
  element = find(element).first if element.is_a?(String)
62
62
  arbre_context.with_current element: element, flow: :append, &block
63
63
  end
64
+
65
+ # Same as #{append_within}, except this doesn't do anything if the given element
66
+ # is +nil+ or not found.
67
+ def append_within?(element, &block)
68
+ element = find(element).first if element.is_a?(String)
69
+ arbre_context.with_current element: element, flow: :append, &block if element
70
+ end
71
+
64
72
  alias_method :within, :append_within
73
+ alias_method :within?, :append_within?
65
74
 
66
75
  # Executes a block within the context of the given element, or DOM query. All elements
67
76
  # are prepended.
@@ -70,6 +79,13 @@ module Arbre
70
79
  arbre_context.with_current element: element, flow: :prepend, &block
71
80
  end
72
81
 
82
+ # Same as #{prepend_within}, except this doesn't do anything if the given element
83
+ # is +nil+ or not found.
84
+ def prepend_within?(element, &block)
85
+ element = find(element).first if element.is_a?(String)
86
+ arbre_context.with_current element: element, flow: :prepend, &block if element
87
+ end
88
+
73
89
  %w(append prepend).each do |flow|
74
90
  class_eval <<-RUBY, __FILE__, __LINE__+1
75
91
  def #{flow}(klass = nil, *args, &block)
data/lib/arbre/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Arbre
2
- VERSION = "2.2.0"
2
+ VERSION = "2.2.1"
3
3
  end
@@ -78,6 +78,29 @@ describe Element::Building do
78
78
  end
79
79
  end
80
80
 
81
+ describe '#append_within?' do
82
+ it "should call within_element on to arbre_context" do
83
+ block = proc{}
84
+ element = Element.new
85
+ expect(arbre).to receive(:with_current).with(element: element, flow: :append) do |&blk|
86
+ expect(blk).to be(block)
87
+ end
88
+
89
+ Element.new(arbre).instance_exec do
90
+ append_within? element, &block
91
+ end
92
+ end
93
+
94
+ it "should do nothing if the given element is nil" do
95
+ block = proc{}
96
+ expect(arbre).not_to receive(:with_current)
97
+
98
+ Element.new(arbre).instance_exec do
99
+ append_within? nil, &block
100
+ end
101
+ end
102
+ end
103
+
81
104
  describe '#prepend_within' do
82
105
  it "should call within and with_flow(:prepend) on the context" do
83
106
  block = proc {}
@@ -104,6 +127,29 @@ describe Element::Building do
104
127
  end
105
128
  end
106
129
 
130
+ describe '#append_within?' do
131
+ it "should call within_element on to arbre_context" do
132
+ block = proc{}
133
+ element = Element.new
134
+ expect(arbre).to receive(:with_current).with(element: element, flow: :prepend) do |&blk|
135
+ expect(blk).to be(block)
136
+ end
137
+
138
+ Element.new(arbre).instance_exec do
139
+ prepend_within? element, &block
140
+ end
141
+ end
142
+
143
+ it "should do nothing if the given element is nil" do
144
+ block = proc{}
145
+ expect(arbre).not_to receive(:with_current)
146
+
147
+ Element.new(arbre).instance_exec do
148
+ prepend_within? nil, &block
149
+ end
150
+ end
151
+ end
152
+
107
153
  ######
108
154
  # Append / prepend
109
155
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arbre2
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Bell
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-10 00:00:00.000000000 Z
12
+ date: 2014-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -252,3 +252,4 @@ test_files:
252
252
  - spec/rails_spec_helper.rb
253
253
  - spec/spec_helper.rb
254
254
  - spec/support/arbre_example_group.rb
255
+ has_rdoc: