arbre 1.5.0 → 1.6.0

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
  SHA256:
3
- metadata.gz: 167ce642a1b64eb122a2d02ce8a1d738a0c480303769ad7a896df8afbfa2f197
4
- data.tar.gz: 0a4a5d4b7e788155b66eeca1dfdae4ed138403449cda43d915e76fd52bdbdb84
3
+ metadata.gz: a6bd316883dba940a6d63639b1fb6d5b76c416f43303d886f5293192cbe77e35
4
+ data.tar.gz: 7eb8b78f40571d050271cc2d703be3bd0439d1b991008117bff5e710be44dc11
5
5
  SHA512:
6
- metadata.gz: 31df82dc237aeb220e55fa3ae4bc1fb6d39cb7189cffe36ad2f4839a01ead4336cd1f556a7005ebfb608d258988407db479d9cef855c68016f0b646279e8a2a6
7
- data.tar.gz: 53b572e7001fccc30d284865292613b3f33a35e73f7c4f95a56db7c6c4e96b42721c73d87130b7fc1c402b04acdd2562106efec0c8d7b60ef1ee8bd7bd5034c5
6
+ metadata.gz: 41159412bec401e716eabe1213badd287f032d146feca7e4a1278b1ebe9c808c491d72a26f3451f08100c3ff3ef65c2d0341085ed5a1aca5b6e68d818a19048a
7
+ data.tar.gz: fc64a514c27f0a6fb010803e2316f1d3e279cd5ada6d20c7860533ef64ce1a36d39f5b9b9929c02ec3ff97a5c0a1206da69bc1e2cf44cfb4f44d442aba223a5f
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## Master (unreleased)
4
4
 
5
+ ## 1.6.0 [☰](https://github.com/activeadmin/arbre/compare/v1.5.0...v1.6.0)
6
+
7
+ * Drop support for Ruby 2.6. [#345][] by [@alejandroperea][]
8
+ * Add 'main' to HTML5 elements. [#270][] by [@mynnx][]
9
+ * Support nested attribute hashes rendered as hyphenated attributes. [#451][] [@Ikariusrb][]
10
+ * Lazy-load rails interactions. [#456][] [@ngan][]
11
+
5
12
  ## 1.5.0 [☰](https://github.com/activeadmin/arbre/compare/v1.4.0...v1.5.0)
6
13
 
7
14
  * Avoid mutating string literals. [#292][] by [@tomgilligan][]
@@ -36,7 +43,7 @@ _No changes_.
36
43
  ## 1.1.1 [☰](https://github.com/activeadmin/arbre/compare/v1.1.0...v1.1.1)
37
44
 
38
45
  * Use mime-types 2.x for Ruby 1.9 by [@timoschilling][]
39
- * Verify Ruby 2.3 support. [#59][] by [@dlackty][]
46
+ * Verify Ruby 2.3 support. [#59][] by [@dlackty][]
40
47
 
41
48
  ## 1.1.0 [☰](https://github.com/activeadmin/arbre/compare/v1.0.3...v1.1.0)
42
49
 
@@ -105,10 +112,14 @@ Initial release and extraction from Active Admin
105
112
  [#202]: https://github.com/activeadmin/arbre/pull/202
106
113
  [#205]: https://github.com/activeadmin/arbre/pull/205
107
114
  [#242]: https://github.com/activeadmin/arbre/pull/242
115
+ [#270]: https://github.com/activeadmin/arbre/pull/270
108
116
  [#292]: https://github.com/activeadmin/arbre/pull/292
109
117
  [#314]: https://github.com/activeadmin/arbre/pull/314
110
118
  [#315]: https://github.com/activeadmin/arbre/pull/315
111
119
  [#318]: https://github.com/activeadmin/arbre/pull/318
120
+ [#345]: https://github.com/activeadmin/arbre/pull/345
121
+ [#451]: https://github.com/activeadmin/arbre/pull/451
122
+ [#456]: https://github.com/activeadmin/arbre/pull/456
112
123
 
113
124
  [@aramvisser]: https://github.com/aramvisser
114
125
  [@LTe]: https://github.com/LTe
@@ -127,3 +138,6 @@ Initial release and extraction from Active Admin
127
138
  [@varyonic]: https://github.com/varyonic
128
139
  [@tagliala]: https://github.com/tagliala
129
140
  [@tomgilligan]: https://github.com/tomgilligan
141
+ [@mynnx]: https://github.com/mynnx
142
+ [@Ikariusrb]: https://github.com/Ikariusrb
143
+ [@ngan]: https://github.com/ngan
data/lib/arbre/context.rb CHANGED
@@ -30,7 +30,7 @@ module Arbre
30
30
  # Initialize a new Arbre::Context
31
31
  #
32
32
  # @param [Hash] assigns A hash of objecs that you would like to be
33
- # availble as local variables within the Context
33
+ # available as local variables within the Context
34
34
  #
35
35
  # @param [Object] helpers An object that has methods on it which will become
36
36
  # instance methods within the context.
@@ -100,7 +100,7 @@ module Arbre
100
100
 
101
101
 
102
102
  # Caches the rendered HTML so that we don't re-render just to
103
- # get the content lenght or to delegate a method to the HTML
103
+ # get the content length or to delegate a method to the HTML
104
104
  def cached_html
105
105
  if defined?(@cached_html)
106
106
  @cached_html
@@ -5,7 +5,7 @@ module Arbre
5
5
  class Attributes < Hash
6
6
 
7
7
  def to_s
8
- map do |name, value|
8
+ flatten_hash.map do |name, value|
9
9
  next if value_empty?(value)
10
10
  "#{html_escape(name)}=\"#{html_escape(value)}\""
11
11
  end.compact.join ' '
@@ -17,6 +17,18 @@ module Arbre
17
17
 
18
18
  protected
19
19
 
20
+ def flatten_hash(hash = self, old_path = [], accumulator = {})
21
+ hash.each do |key, value|
22
+ path = old_path + [key]
23
+ if value.is_a? Hash
24
+ flatten_hash(value, path, accumulator)
25
+ else
26
+ accumulator[path.join('-')] = value
27
+ end
28
+ end
29
+ accumulator
30
+ end
31
+
20
32
  def value_empty?(value)
21
33
  value.respond_to?(:empty?) ? value.empty? : !value
22
34
  end
@@ -6,9 +6,9 @@ module Arbre
6
6
  :bdo, :blockquote, :body, :br, :button, :canvas, :caption, :cite,
7
7
  :code, :col, :colgroup, :command, :datalist, :dd, :del, :details,
8
8
  :dfn, :div, :dl, :dt, :em, :embed, :fieldset, :figcaption, :figure,
9
- :footer, :form, :h1, :h2, :h3, :h4, :h5, :h6, :head, :header, :hgroup,
10
- :hr, :html, :i, :iframe, :img, :input, :ins, :keygen, :kbd, :label,
11
- :legend, :li, :link, :map, :mark, :menu, :menuitem, :meta, :meter, :nav, :noscript,
9
+ :footer, :form, :h1, :h2, :h3, :h4, :h5, :h6, :head, :header, :hgroup,
10
+ :hr, :html, :i, :iframe, :img, :input, :ins, :keygen, :kbd, :label,
11
+ :legend, :li, :link, :main, :map, :mark, :menu, :menuitem, :meta, :meter, :nav, :noscript,
12
12
  :object, :ol, :optgroup, :option, :output, :param, :pre, :progress, :q,
13
13
  :s, :samp, :script, :section, :select, :small, :source, :span,
14
14
  :strong, :style, :sub, :summary, :sup, :svg, :table, :tbody, :td,
@@ -92,5 +92,3 @@ module Arbre
92
92
  end
93
93
  end
94
94
  end
95
-
96
-
@@ -12,7 +12,6 @@ module Arbre
12
12
  text_node rendered
13
13
  end
14
14
  end
15
-
16
15
  end
17
16
  end
18
17
  end
@@ -14,5 +14,3 @@ module Arbre
14
14
  end
15
15
  end
16
16
  end
17
-
18
- ActionView::Template.register_template_handler :arb, Arbre::Rails::TemplateHandler.new
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ require 'arbre/rails/template_handler'
3
+ require 'arbre/rails/forms'
4
+ require 'arbre/rails/rendering'
5
+ require 'rails'
6
+
7
+ Arbre::Element.include(Arbre::Rails::Rendering)
8
+
9
+ module Arbre
10
+ class Railtie < ::Rails::Railtie
11
+ initializer "arbre" do
12
+ ActiveSupport.on_load(:action_view) do
13
+ ActionView::Template.register_template_handler :arb, Arbre::Rails::TemplateHandler.new
14
+ end
15
+ end
16
+ end
17
+ end
data/lib/arbre/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Arbre
3
- VERSION = "1.5.0"
3
+ VERSION = "1.6.0"
4
4
  end
data/lib/arbre.rb CHANGED
@@ -17,5 +17,5 @@ require 'arbre/html/html5_elements'
17
17
  require 'arbre/component'
18
18
 
19
19
  if defined?(Rails)
20
- require 'arbre/rails'
20
+ require 'arbre/railtie'
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arbre
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Bell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-08 00:00:00.000000000 Z
11
+ date: 2023-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -85,15 +85,16 @@ files:
85
85
  - lib/arbre/html/html5_elements.rb
86
86
  - lib/arbre/html/tag.rb
87
87
  - lib/arbre/html/text_node.rb
88
- - lib/arbre/rails.rb
89
88
  - lib/arbre/rails/forms.rb
90
89
  - lib/arbre/rails/rendering.rb
91
90
  - lib/arbre/rails/template_handler.rb
91
+ - lib/arbre/railtie.rb
92
92
  - lib/arbre/version.rb
93
93
  homepage: https://github.com/activeadmin/arbre
94
94
  licenses:
95
95
  - MIT
96
- metadata: {}
96
+ metadata:
97
+ rubygems_mfa_required: 'true'
97
98
  post_install_message:
98
99
  rdoc_options: []
99
100
  require_paths:
@@ -102,14 +103,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
103
  requirements:
103
104
  - - ">="
104
105
  - !ruby/object:Gem::Version
105
- version: '2.6'
106
+ version: '2.7'
106
107
  required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  requirements:
108
109
  - - ">="
109
110
  - !ruby/object:Gem::Version
110
111
  version: '0'
111
112
  requirements: []
112
- rubygems_version: 3.3.6
113
+ rubygems_version: 3.4.13
113
114
  signing_key:
114
115
  specification_version: 4
115
116
  summary: An Object Oriented DOM Tree in Ruby
data/lib/arbre/rails.rb DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'arbre/rails/template_handler'
3
- require 'arbre/rails/forms'
4
- require 'arbre/rails/rendering'
5
-
6
- Arbre::Element.send :include, Arbre::Rails::Rendering