arbre 1.0.0 → 1.0.1

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.
@@ -1,3 +1,10 @@
1
+ ## 1.0.1
2
+
3
+ * Template handler converts to string to satisfy Rack::Lint (@jpmckinney, #6)
4
+ * Fix to `Tag#add_class` when passing a string of classes to Tag build method
5
+ (@gregbell, #7)
6
+ * Not longer uses the default separator (@LTe, #4)
7
+
1
8
  ## 1.0.0
2
9
 
3
10
  * Added support for the use of `:for` with non Active Model objects
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ gemspec
4
4
 
5
5
  group :test do
6
6
  gem "rspec"
7
+ gem "rack"
7
8
  end
8
9
 
9
10
  group :rails do
@@ -106,7 +106,7 @@ module Arbre
106
106
  def get_elements_by_class_name(class_name)
107
107
  elements = ElementCollection.new
108
108
  children.each do |child|
109
- elements << child if child.class_list =~ /#{class_name}/
109
+ elements << child if child.class_list.include?(class_name)
110
110
  elements.concat(child.get_elements_by_tag_name(tag_name))
111
111
  end
112
112
  elements
@@ -18,7 +18,7 @@ module Arbre
18
18
  def to_s
19
19
  self.collect do |element|
20
20
  element.to_s
21
- end.join.html_safe
21
+ end.join('').html_safe
22
22
  end
23
23
  end
24
24
 
@@ -6,6 +6,13 @@ module Arbre
6
6
  # Holds a set of classes
7
7
  class ClassList < Set
8
8
 
9
+ def self.build_from_string(class_names)
10
+ list = new
11
+ list.add(class_names)
12
+
13
+ list
14
+ end
15
+
9
16
  def add(class_names)
10
17
  class_names.to_s.split(" ").each do |class_name|
11
18
  super(class_name)
@@ -77,7 +77,16 @@ module Arbre
77
77
  end
78
78
 
79
79
  def class_list
80
- get_attribute(:class) || set_attribute(:class, ClassList.new)
80
+ list = get_attribute(:class)
81
+
82
+ case list
83
+ when ClassList
84
+ list
85
+ when String
86
+ set_attribute(:class, ClassList.build_from_string(list))
87
+ else
88
+ set_attribute(:class, ClassList.new)
89
+ end
81
90
  end
82
91
 
83
92
  def to_s
@@ -4,7 +4,7 @@ module Arbre
4
4
  class TemplateHandler
5
5
 
6
6
  def call(template)
7
- "Arbre::Context.new(assigns, self){ #{template.source} }"
7
+ "Arbre::Context.new(assigns, self){ #{template.source} }.to_s"
8
8
  end
9
9
 
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module Arbre
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -164,11 +164,24 @@ describe Arbre::Element do
164
164
 
165
165
  describe "rendering to html" do
166
166
 
167
+ before { @separator = $, }
168
+ after { $, = @separator }
169
+ let(:collection){ element + "hello world" }
170
+
167
171
  it "should render the children collection" do
168
172
  element.children.should_receive(:to_s).and_return("content")
169
173
  element.to_s.should == "content"
170
174
  end
171
175
 
176
+ it "should render collection when is set the default separator" do
177
+ $, = "_"
178
+ collection.to_s.should == "hello world"
179
+ end
180
+
181
+ it "should render collection when is not set the default separator" do
182
+ collection.to_s.should == "hello world"
183
+ end
184
+
172
185
  end
173
186
 
174
187
  describe "adding elements together" do
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Arbre::HTML::ClassList do
4
+
5
+ describe ".build_from_string" do
6
+
7
+ it "should build a new list from a string of classes" do
8
+ list = Arbre::HTML::ClassList.build_from_string("first second")
9
+ list.size.should == 2
10
+
11
+ list.to_a.sort.should == %w{first second}
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -91,6 +91,13 @@ describe Arbre::HTML::Tag do
91
91
  tag.class_list.size.should == 2
92
92
  end
93
93
 
94
+ it "should create a class list from a string" do
95
+ tag = Arbre::HTML::Tag.new
96
+ tag.build(:class => "first-class")
97
+ tag.add_class "second-class"
98
+ tag.class_list.size.should == 2
99
+ end
100
+
94
101
  end
95
102
 
96
103
  end
@@ -4,6 +4,12 @@ require 'capybara/rspec'
4
4
 
5
5
  # Combustion
6
6
  require 'combustion'
7
+
8
+ # Arbre's Rails integration should satisfy Rack::Lint.
9
+ class Combustion::Application
10
+ config.middleware.use 'Rack::Lint'
11
+ end
12
+
7
13
  Combustion.path = 'spec/rails/stub_app'
8
14
  Combustion.initialize! :action_controller,
9
15
  :action_view,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arbre
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-30 00:00:00.000000000 Z
12
+ date: 2012-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &70180007616740 !ruby/object:Gem::Requirement
16
+ requirement: &70297377112220 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70180007616740
24
+ version_requirements: *70297377112220
25
25
  description: An Object Oriented DOM Tree in Ruby
26
26
  email:
27
27
  - gregdbell@gmail.com
@@ -58,6 +58,7 @@ files:
58
58
  - spec/arbre/unit/context_spec.rb
59
59
  - spec/arbre/unit/element_finder_methods_spec.rb
60
60
  - spec/arbre/unit/element_spec.rb
61
+ - spec/arbre/unit/html/class_list_spec.rb
61
62
  - spec/arbre/unit/html/tag_attributes_spec.rb
62
63
  - spec/arbre/unit/html/tag_spec.rb
63
64
  - spec/arbre/unit/html/text_node_spec.rb
@@ -109,6 +110,7 @@ test_files:
109
110
  - spec/arbre/unit/context_spec.rb
110
111
  - spec/arbre/unit/element_finder_methods_spec.rb
111
112
  - spec/arbre/unit/element_spec.rb
113
+ - spec/arbre/unit/html/class_list_spec.rb
112
114
  - spec/arbre/unit/html/tag_attributes_spec.rb
113
115
  - spec/arbre/unit/html/tag_spec.rb
114
116
  - spec/arbre/unit/html/text_node_spec.rb