arbre 1.4.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: c3372e73956d615bd5690efe4c862f4e9bb312aaa8e12117caada56cbc0a1f69
4
- data.tar.gz: f6649676ae291d3d745ad53b4eb7fd932b921560af92d4a1065c1178ad8ff1c6
3
+ metadata.gz: a6bd316883dba940a6d63639b1fb6d5b76c416f43303d886f5293192cbe77e35
4
+ data.tar.gz: 7eb8b78f40571d050271cc2d703be3bd0439d1b991008117bff5e710be44dc11
5
5
  SHA512:
6
- metadata.gz: 5a510c2925f63a88a75f20c0de6d9adac67da0f8c615cbe25c1debd8b5c7f48830de8a89d947780c76f1f762a91e37c63bf118f2db1a52c218f9a2a174f91021
7
- data.tar.gz: 01347d69439526f887b81f35bf1c241d873790fe9220cd55839954df551134abfb065afea2b4c952b89447930b175e23e426329dde7ad2fc010ecec9c77c8257
6
+ metadata.gz: 41159412bec401e716eabe1213badd287f032d146feca7e4a1278b1ebe9c808c491d72a26f3451f08100c3ff3ef65c2d0341085ed5a1aca5b6e68d818a19048a
7
+ data.tar.gz: fc64a514c27f0a6fb010803e2316f1d3e279cd5ada6d20c7860533ef64ce1a36d39f5b9b9929c02ec3ff97a5c0a1206da69bc1e2cf44cfb4f44d442aba223a5f
data/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
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
+
12
+ ## 1.5.0 [☰](https://github.com/activeadmin/arbre/compare/v1.4.0...v1.5.0)
13
+
14
+ * Avoid mutating string literals. [#292][] by [@tomgilligan][]
15
+ * Allow activesupport 7.0. [#314][] by [@tagliala][]
16
+ * Drop ruby 2.5 support. [#315][] by [@alejandroperea][]
17
+ * Fix keyword delegation in form component. [#318][] by [@deivid-rodriguez][]
18
+
5
19
  ## 1.4.0 [☰](https://github.com/activeadmin/arbre/compare/v1.3.0...v1.4.0)
6
20
 
7
21
  * Allow activesupport 6.1 prereleases. [#242][] by [@deivid-rodriguez][]
@@ -29,7 +43,7 @@ _No changes_.
29
43
  ## 1.1.1 [☰](https://github.com/activeadmin/arbre/compare/v1.1.0...v1.1.1)
30
44
 
31
45
  * Use mime-types 2.x for Ruby 1.9 by [@timoschilling][]
32
- * Verify Ruby 2.3 support. [#59][] by [@dlackty][]
46
+ * Verify Ruby 2.3 support. [#59][] by [@dlackty][]
33
47
 
34
48
  ## 1.1.0 [☰](https://github.com/activeadmin/arbre/compare/v1.0.3...v1.1.0)
35
49
 
@@ -98,10 +112,19 @@ Initial release and extraction from Active Admin
98
112
  [#202]: https://github.com/activeadmin/arbre/pull/202
99
113
  [#205]: https://github.com/activeadmin/arbre/pull/205
100
114
  [#242]: https://github.com/activeadmin/arbre/pull/242
115
+ [#270]: https://github.com/activeadmin/arbre/pull/270
116
+ [#292]: https://github.com/activeadmin/arbre/pull/292
117
+ [#314]: https://github.com/activeadmin/arbre/pull/314
118
+ [#315]: https://github.com/activeadmin/arbre/pull/315
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
101
123
 
102
124
  [@aramvisser]: https://github.com/aramvisser
103
125
  [@LTe]: https://github.com/LTe
104
126
  [@OscarBarrett]: https://github.com/OscarBarrett
127
+ [@alejandroperea]: https://github.com/alejandroperea
105
128
  [@alexesDev]: https://github.com/alexesDev
106
129
  [@deivid-rodriguez]: https://github.com/deivid-rodriguez
107
130
  [@dlackty]: https://github.com/dlackty
@@ -113,3 +136,8 @@ Initial release and extraction from Active Admin
113
136
  [@seanlinsley]: https://github.com/seanlinsley
114
137
  [@timoschilling]: https://github.com/timoschilling
115
138
  [@varyonic]: https://github.com/varyonic
139
+ [@tagliala]: https://github.com/tagliala
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/docs/Gemfile CHANGED
@@ -1,2 +1,3 @@
1
+ # frozen_string_literal: true
1
2
  gem 'github-pages'
2
3
  gem 'jekyll-redirect-from'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arbre
2
3
  class Component < Arbre::HTML::Div
3
4
 
data/lib/arbre/context.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'arbre/element'
2
3
  require 'ruby2_keywords'
3
4
 
@@ -29,7 +30,7 @@ module Arbre
29
30
  # Initialize a new Arbre::Context
30
31
  #
31
32
  # @param [Hash] assigns A hash of objecs that you would like to be
32
- # availble as local variables within the Context
33
+ # available as local variables within the Context
33
34
  #
34
35
  # @param [Object] helpers An object that has methods on it which will become
35
36
  # instance methods within the context.
@@ -99,7 +100,7 @@ module Arbre
99
100
 
100
101
 
101
102
  # Caches the rendered HTML so that we don't re-render just to
102
- # 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
103
104
  def cached_html
104
105
  if defined?(@cached_html)
105
106
  @cached_html
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arbre
2
3
  class Element
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arbre
2
3
  class Element
3
4
  class Proxy < BasicObject
data/lib/arbre/element.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'arbre/element/builder_methods'
2
3
  require 'arbre/element/proxy'
3
4
  require 'arbre/element_collection'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arbre
2
3
 
3
4
  # Stores a collection of Element objects
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  module Arbre
2
3
  module HTML
3
4
 
4
5
  class Attributes < Hash
5
6
 
6
7
  def to_s
7
- map do |name, value|
8
+ flatten_hash.map do |name, value|
8
9
  next if value_empty?(value)
9
10
  "#{html_escape(name)}=\"#{html_escape(value)}\""
10
11
  end.compact.join ' '
@@ -16,6 +17,18 @@ module Arbre
16
17
 
17
18
  protected
18
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
+
19
32
  def value_empty?(value)
20
33
  value.respond_to?(:empty?) ? value.empty? : !value
21
34
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'set'
2
3
 
3
4
  module Arbre
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arbre
2
3
  module HTML
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arbre
2
3
  module HTML
3
4
 
@@ -5,9 +6,9 @@ module Arbre
5
6
  :bdo, :blockquote, :body, :br, :button, :canvas, :caption, :cite,
6
7
  :code, :col, :colgroup, :command, :datalist, :dd, :del, :details,
7
8
  :dfn, :div, :dl, :dt, :em, :embed, :fieldset, :figcaption, :figure,
8
- :footer, :form, :h1, :h2, :h3, :h4, :h5, :h6, :head, :header, :hgroup,
9
- :hr, :html, :i, :iframe, :img, :input, :ins, :keygen, :kbd, :label,
10
- :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,
11
12
  :object, :ol, :optgroup, :option, :output, :param, :pre, :progress, :q,
12
13
  :s, :samp, :script, :section, :select, :small, :source, :span,
13
14
  :strong, :style, :sub, :summary, :sup, :svg, :table, :tbody, :td,
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'erb'
2
3
 
3
4
  module Arbre
@@ -119,19 +120,19 @@ module Arbre
119
120
 
120
121
  if no_child? || child_is_text?
121
122
  if self_closing_tag?
122
- html << spaces << open_tag.sub( />$/, '/>' )
123
+ html += spaces + open_tag.sub( />$/, '/>' )
123
124
  else
124
125
  # one line
125
- html << spaces << open_tag << child_content << close_tag
126
+ html += spaces + open_tag + child_content + close_tag
126
127
  end
127
128
  else
128
129
  # multiple lines
129
- html << spaces << open_tag << "\n"
130
- html << child_content # the child takes care of its own spaces
131
- html << spaces << close_tag
130
+ html += spaces + open_tag + "\n"
131
+ html += child_content # the child takes care of its own spaces
132
+ html += spaces + close_tag
132
133
  end
133
134
 
134
- html << "\n"
135
+ html += "\n"
135
136
 
136
137
  html
137
138
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'erb'
2
3
 
3
4
  module Arbre
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arbre
2
3
  module Rails
3
4
  module Forms
@@ -30,7 +31,7 @@ module Arbre
30
31
  text_node form_builder.send(method, *args, &block)
31
32
  end
32
33
 
33
- def method_missing(method, *args, &block)
34
+ ruby2_keywords def method_missing(method, *args, &block)
34
35
  if form_builder && form_builder.respond_to?(method)
35
36
  proxy_call_to_form(method, *args, &block)
36
37
  else
@@ -91,5 +92,3 @@ module Arbre
91
92
  end
92
93
  end
93
94
  end
94
-
95
-
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arbre
2
3
  module Rails
3
4
  module Rendering
@@ -11,7 +12,6 @@ module Arbre
11
12
  text_node rendered
12
13
  end
13
14
  end
14
-
15
15
  end
16
16
  end
17
17
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arbre
2
3
  module Rails
3
4
  class TemplateHandler
@@ -13,5 +14,3 @@ module Arbre
13
14
  end
14
15
  end
15
16
  end
16
-
17
- 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,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arbre
2
- VERSION = "1.4.0"
3
+ VERSION = "1.6.0"
3
4
  end
data/lib/arbre.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'active_support/core_ext/string/output_safety'
2
3
  require 'active_support/hash_with_indifferent_access'
3
4
  require 'active_support/inflector'
@@ -16,5 +17,5 @@ require 'arbre/html/html5_elements'
16
17
  require 'arbre/component'
17
18
 
18
19
  if defined?(Rails)
19
- require 'arbre/rails'
20
+ require 'arbre/railtie'
20
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.4.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Bell
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-11 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
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 3.0.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6.2'
22
+ version: '7.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 3.0.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6.2'
32
+ version: '7.1'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: ruby2_keywords
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -85,16 +85,17 @@ 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: {}
97
- post_install_message:
96
+ metadata:
97
+ rubygems_mfa_required: 'true'
98
+ post_install_message:
98
99
  rdoc_options: []
99
100
  require_paths:
100
101
  - lib
@@ -102,15 +103,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
103
  requirements:
103
104
  - - ">="
104
105
  - !ruby/object:Gem::Version
105
- version: '2.5'
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.2.0
113
- signing_key:
113
+ rubygems_version: 3.4.13
114
+ signing_key:
114
115
  specification_version: 4
115
116
  summary: An Object Oriented DOM Tree in Ruby
116
117
  test_files: []
data/lib/arbre/rails.rb DELETED
@@ -1,5 +0,0 @@
1
- require 'arbre/rails/template_handler'
2
- require 'arbre/rails/forms'
3
- require 'arbre/rails/rendering'
4
-
5
- Arbre::Element.send :include, Arbre::Rails::Rendering