arbo 1.2.0

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.
Files changed (70) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ci.yaml +21 -0
  3. data/.github/workflows/daily.yaml +23 -0
  4. data/.gitignore +11 -0
  5. data/CHANGELOG.md +95 -0
  6. data/CONTRIBUTING.md +3 -0
  7. data/Gemfile +17 -0
  8. data/LICENSE +20 -0
  9. data/README.md +29 -0
  10. data/Rakefile +18 -0
  11. data/arbo.gemspec +25 -0
  12. data/docs/Gemfile +2 -0
  13. data/docs/_config.yml +7 -0
  14. data/docs/_includes/footer.html +8 -0
  15. data/docs/_includes/google-analytics.html +16 -0
  16. data/docs/_includes/head.html +7 -0
  17. data/docs/_includes/toc.html +12 -0
  18. data/docs/_includes/top-menu.html +8 -0
  19. data/docs/_layouts/default.html +21 -0
  20. data/docs/index.md +106 -0
  21. data/docs/stylesheets/main.css +1152 -0
  22. data/lib/arbo/component.rb +22 -0
  23. data/lib/arbo/context.rb +118 -0
  24. data/lib/arbo/element/builder_methods.rb +83 -0
  25. data/lib/arbo/element/proxy.rb +28 -0
  26. data/lib/arbo/element.rb +225 -0
  27. data/lib/arbo/element_collection.rb +31 -0
  28. data/lib/arbo/html/attributes.rb +41 -0
  29. data/lib/arbo/html/class_list.rb +28 -0
  30. data/lib/arbo/html/document.rb +31 -0
  31. data/lib/arbo/html/html5_elements.rb +47 -0
  32. data/lib/arbo/html/tag.rb +220 -0
  33. data/lib/arbo/html/text_node.rb +43 -0
  34. data/lib/arbo/rails/forms.rb +101 -0
  35. data/lib/arbo/rails/rendering.rb +17 -0
  36. data/lib/arbo/rails/template_handler.rb +35 -0
  37. data/lib/arbo/rails.rb +5 -0
  38. data/lib/arbo/version.rb +3 -0
  39. data/lib/arbo.rb +21 -0
  40. data/spec/arbo/integration/html_spec.rb +307 -0
  41. data/spec/arbo/unit/component_spec.rb +54 -0
  42. data/spec/arbo/unit/context_spec.rb +35 -0
  43. data/spec/arbo/unit/element_finder_methods_spec.rb +116 -0
  44. data/spec/arbo/unit/element_spec.rb +272 -0
  45. data/spec/arbo/unit/html/class_list_spec.rb +16 -0
  46. data/spec/arbo/unit/html/tag_attributes_spec.rb +104 -0
  47. data/spec/arbo/unit/html/tag_spec.rb +124 -0
  48. data/spec/arbo/unit/html/text_node_spec.rb +5 -0
  49. data/spec/rails/integration/forms_spec.rb +117 -0
  50. data/spec/rails/integration/rendering_spec.rb +98 -0
  51. data/spec/rails/rails_spec_helper.rb +46 -0
  52. data/spec/rails/stub_app/config/database.yml +3 -0
  53. data/spec/rails/stub_app/config/routes.rb +3 -0
  54. data/spec/rails/stub_app/db/schema.rb +3 -0
  55. data/spec/rails/stub_app/log/.gitignore +1 -0
  56. data/spec/rails/stub_app/public/favicon.ico +0 -0
  57. data/spec/rails/support/mock_person.rb +15 -0
  58. data/spec/rails/templates/arbo/_partial.arb +1 -0
  59. data/spec/rails/templates/arbo/_partial_with_assignment.arb +1 -0
  60. data/spec/rails/templates/arbo/empty.arb +0 -0
  61. data/spec/rails/templates/arbo/page_with_arb_partial_and_assignment.arb +3 -0
  62. data/spec/rails/templates/arbo/page_with_assignment.arb +1 -0
  63. data/spec/rails/templates/arbo/page_with_erb_partial.arb +3 -0
  64. data/spec/rails/templates/arbo/page_with_helpers.arb +7 -0
  65. data/spec/rails/templates/arbo/page_with_partial.arb +3 -0
  66. data/spec/rails/templates/arbo/simple_page.arb +8 -0
  67. data/spec/rails/templates/erb/_partial.erb +1 -0
  68. data/spec/spec_helper.rb +7 -0
  69. data/spec/support/bundle.rb +4 -0
  70. metadata +169 -0
@@ -0,0 +1,98 @@
1
+ require 'rails/rails_spec_helper'
2
+
3
+ ARBO_VIEWS_PATH = File.expand_path("../../templates", __FILE__)
4
+
5
+ class TestController < ActionController::Base
6
+ append_view_path ARBO_VIEWS_PATH
7
+
8
+ def render_empty
9
+ render "arbo/empty"
10
+ end
11
+
12
+ def render_simple_page
13
+ render "arbo/simple_page"
14
+ end
15
+
16
+ def render_partial
17
+ render "arbo/page_with_partial"
18
+ end
19
+
20
+ def render_erb_partial
21
+ render "arbo/page_with_erb_partial"
22
+ end
23
+
24
+ def render_with_instance_variable
25
+ @my_instance_var = "From Instance Var"
26
+ render "arbo/page_with_assignment"
27
+ end
28
+
29
+ def render_partial_with_instance_variable
30
+ @my_instance_var = "From Instance Var"
31
+ render "arbo/page_with_arb_partial_and_assignment"
32
+ end
33
+
34
+ def render_page_with_helpers
35
+ render "arbo/page_with_helpers"
36
+ end
37
+ end
38
+
39
+
40
+ describe TestController, "Rendering with Arbo", type: :request do
41
+ let(:body){ response.body }
42
+
43
+ it "should render the empty template" do
44
+ get "/test/render_empty"
45
+ expect(response).to be_successful
46
+ end
47
+
48
+ it "should render a simple page" do
49
+ get "/test/render_simple_page"
50
+ expect(response).to be_successful
51
+ expect(body).to have_selector("h1", text: "Hello World")
52
+ expect(body).to have_selector("p", text: "Hello again!")
53
+ end
54
+
55
+ it "should render an arb partial" do
56
+ get "/test/render_partial"
57
+ expect(response).to be_successful
58
+ expect(body).to eq <<-EOS
59
+ <h1>Before Partial</h1>
60
+ <p>Hello from a partial</p>
61
+ <h2>After Partial</h2>
62
+ EOS
63
+ end
64
+
65
+ it "should render an erb (or other) partial" do
66
+ get "/test/render_erb_partial"
67
+ expect(response).to be_successful
68
+ expect(body).to eq <<-EOS
69
+ <h1>Before Partial</h1>
70
+ <p>Hello from an erb partial</p>
71
+ <h2>After Partial</h2>
72
+ EOS
73
+ end
74
+
75
+ it "should render with instance variables" do
76
+ get "/test/render_with_instance_variable"
77
+ expect(response).to be_successful
78
+ expect(body).to have_selector("h1", text: "From Instance Var")
79
+ end
80
+
81
+ it "should render an arbo partial with assignments" do
82
+ get "/test/render_partial_with_instance_variable"
83
+ expect(response).to be_successful
84
+ expect(body).to have_selector("p", text: "Partial: From Instance Var")
85
+ end
86
+
87
+ it "should render a page with helpers" do
88
+ get "/test/render_page_with_helpers"
89
+ expect(response).to be_successful
90
+ expect(body).to eq <<EOS
91
+ <span>before h1 link</span>
92
+ <h1><a href="/h1_link_path">h1 link text</a></h1>
93
+ <span>before link_to block</span>
94
+ <a href="/link_path"> <i class=\"link-class\">Link text</i>
95
+ </a><span>at end</span>
96
+ EOS
97
+ end
98
+ end
@@ -0,0 +1,46 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'combustion'
5
+
6
+ Combustion.path = 'spec/rails/stub_app'
7
+ Combustion.initialize! :action_controller,
8
+ :action_view
9
+
10
+ require 'rspec/rails'
11
+ require 'capybara/rspec'
12
+ require 'capybara/rails'
13
+
14
+ require 'spec_helper'
15
+
16
+ require 'rails/support/mock_person'
17
+
18
+ # Ensure that the rails plugin is installed
19
+ require 'arbo/rails'
20
+
21
+ Rails.application.routes.draw do
22
+ get 'test/:action', controller: "test"
23
+ end
24
+
25
+ module AdditionalHelpers
26
+
27
+ def protect_against_forgery?
28
+ true
29
+ end
30
+
31
+ def form_authenticity_token(form_options: {})
32
+ "AUTH_TOKEN"
33
+ end
34
+
35
+ end
36
+
37
+ def mock_action_view(assigns = {})
38
+ controller = ActionView::TestCase::TestController.new
39
+ ActionView::Base.send :include, ActionView::Helpers
40
+ ActionView::Base.send :include, AdditionalHelpers
41
+ ActionView::Base.new(ActionController::Base.view_paths, assigns, controller)
42
+ end
43
+
44
+ RSpec.configure do |config|
45
+ config.include Capybara::RSpecMatchers
46
+ end
@@ -0,0 +1,3 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/combustion_test.sqlite
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ #
3
+ end
@@ -0,0 +1,3 @@
1
+ # ActiveRecord::Schema.define do
2
+ # #
3
+ # end
@@ -0,0 +1 @@
1
+ *.log
File without changes
@@ -0,0 +1,15 @@
1
+ require 'active_model'
2
+
3
+ class MockPerson
4
+ extend ActiveModel::Naming
5
+
6
+ attr_accessor :name
7
+
8
+ def persisted?
9
+ false
10
+ end
11
+
12
+ def to_key
13
+ []
14
+ end
15
+ end
@@ -0,0 +1 @@
1
+ para "Hello from a partial"
@@ -0,0 +1 @@
1
+ para "Partial: #{my_instance_var}"
File without changes
@@ -0,0 +1,3 @@
1
+ h1 "Before Partial"
2
+ render "arbo/partial_with_assignment"
3
+ h2 "After Partial"
@@ -0,0 +1 @@
1
+ h1 my_instance_var
@@ -0,0 +1,3 @@
1
+ h1 "Before Partial"
2
+ render "erb/partial"
3
+ h2 "After Partial"
@@ -0,0 +1,7 @@
1
+ span { 'before h1 link' }
2
+ h1 { link_to('/h1_link_path') { 'h1 link text' } }
3
+
4
+ span { 'before link_to block' }
5
+ text_node link_to('/link_path') { i("Link text", class: 'link-class') }
6
+
7
+ span { 'at end' }
@@ -0,0 +1,3 @@
1
+ h1 "Before Partial"
2
+ render "arbo/partial"
3
+ h2 "After Partial"
@@ -0,0 +1,8 @@
1
+ html do
2
+ head do
3
+ end
4
+ body do
5
+ h1 "Hello World"
6
+ para "Hello again!"
7
+ end
8
+ end
@@ -0,0 +1 @@
1
+ <p>Hello from an erb partial</p>
@@ -0,0 +1,7 @@
1
+ require 'support/bundle'
2
+
3
+ require 'arbo'
4
+
5
+ def arbo(&block)
6
+ Arbo::Context.new assigns, helpers, &block
7
+ end
@@ -0,0 +1,4 @@
1
+ $LOAD_PATH.unshift(File.expand_path("../../", __FILE__))
2
+
3
+ require "bundler"
4
+ Bundler.setup
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: arbo
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Piers Chambers
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-07-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruby2_keywords
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.2
41
+ description: Forked from Greg Bell's 'Arbre', An Object Oriented DOM Tree in Ruby
42
+ email:
43
+ - piers@varyonic.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".github/workflows/ci.yaml"
49
+ - ".github/workflows/daily.yaml"
50
+ - ".gitignore"
51
+ - CHANGELOG.md
52
+ - CONTRIBUTING.md
53
+ - Gemfile
54
+ - LICENSE
55
+ - README.md
56
+ - Rakefile
57
+ - arbo.gemspec
58
+ - docs/Gemfile
59
+ - docs/_config.yml
60
+ - docs/_includes/footer.html
61
+ - docs/_includes/google-analytics.html
62
+ - docs/_includes/head.html
63
+ - docs/_includes/toc.html
64
+ - docs/_includes/top-menu.html
65
+ - docs/_layouts/default.html
66
+ - docs/index.md
67
+ - docs/stylesheets/main.css
68
+ - lib/arbo.rb
69
+ - lib/arbo/component.rb
70
+ - lib/arbo/context.rb
71
+ - lib/arbo/element.rb
72
+ - lib/arbo/element/builder_methods.rb
73
+ - lib/arbo/element/proxy.rb
74
+ - lib/arbo/element_collection.rb
75
+ - lib/arbo/html/attributes.rb
76
+ - lib/arbo/html/class_list.rb
77
+ - lib/arbo/html/document.rb
78
+ - lib/arbo/html/html5_elements.rb
79
+ - lib/arbo/html/tag.rb
80
+ - lib/arbo/html/text_node.rb
81
+ - lib/arbo/rails.rb
82
+ - lib/arbo/rails/forms.rb
83
+ - lib/arbo/rails/rendering.rb
84
+ - lib/arbo/rails/template_handler.rb
85
+ - lib/arbo/version.rb
86
+ - spec/arbo/integration/html_spec.rb
87
+ - spec/arbo/unit/component_spec.rb
88
+ - spec/arbo/unit/context_spec.rb
89
+ - spec/arbo/unit/element_finder_methods_spec.rb
90
+ - spec/arbo/unit/element_spec.rb
91
+ - spec/arbo/unit/html/class_list_spec.rb
92
+ - spec/arbo/unit/html/tag_attributes_spec.rb
93
+ - spec/arbo/unit/html/tag_spec.rb
94
+ - spec/arbo/unit/html/text_node_spec.rb
95
+ - spec/rails/integration/forms_spec.rb
96
+ - spec/rails/integration/rendering_spec.rb
97
+ - spec/rails/rails_spec_helper.rb
98
+ - spec/rails/stub_app/config/database.yml
99
+ - spec/rails/stub_app/config/routes.rb
100
+ - spec/rails/stub_app/db/schema.rb
101
+ - spec/rails/stub_app/log/.gitignore
102
+ - spec/rails/stub_app/public/favicon.ico
103
+ - spec/rails/support/mock_person.rb
104
+ - spec/rails/templates/arbo/_partial.arb
105
+ - spec/rails/templates/arbo/_partial_with_assignment.arb
106
+ - spec/rails/templates/arbo/empty.arb
107
+ - spec/rails/templates/arbo/page_with_arb_partial_and_assignment.arb
108
+ - spec/rails/templates/arbo/page_with_assignment.arb
109
+ - spec/rails/templates/arbo/page_with_erb_partial.arb
110
+ - spec/rails/templates/arbo/page_with_helpers.arb
111
+ - spec/rails/templates/arbo/page_with_partial.arb
112
+ - spec/rails/templates/arbo/simple_page.arb
113
+ - spec/rails/templates/erb/_partial.erb
114
+ - spec/spec_helper.rb
115
+ - spec/support/bundle.rb
116
+ homepage: ''
117
+ licenses:
118
+ - MIT
119
+ metadata: {}
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '2.5'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubygems_version: 3.3.7
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: Forked from Greg Bell's 'Arbre', An Object Oriented DOM Tree in Ruby
139
+ test_files:
140
+ - spec/arbo/integration/html_spec.rb
141
+ - spec/arbo/unit/component_spec.rb
142
+ - spec/arbo/unit/context_spec.rb
143
+ - spec/arbo/unit/element_finder_methods_spec.rb
144
+ - spec/arbo/unit/element_spec.rb
145
+ - spec/arbo/unit/html/class_list_spec.rb
146
+ - spec/arbo/unit/html/tag_attributes_spec.rb
147
+ - spec/arbo/unit/html/tag_spec.rb
148
+ - spec/arbo/unit/html/text_node_spec.rb
149
+ - spec/rails/integration/forms_spec.rb
150
+ - spec/rails/integration/rendering_spec.rb
151
+ - spec/rails/rails_spec_helper.rb
152
+ - spec/rails/stub_app/config/database.yml
153
+ - spec/rails/stub_app/config/routes.rb
154
+ - spec/rails/stub_app/db/schema.rb
155
+ - spec/rails/stub_app/log/.gitignore
156
+ - spec/rails/stub_app/public/favicon.ico
157
+ - spec/rails/support/mock_person.rb
158
+ - spec/rails/templates/arbo/_partial.arb
159
+ - spec/rails/templates/arbo/_partial_with_assignment.arb
160
+ - spec/rails/templates/arbo/empty.arb
161
+ - spec/rails/templates/arbo/page_with_arb_partial_and_assignment.arb
162
+ - spec/rails/templates/arbo/page_with_assignment.arb
163
+ - spec/rails/templates/arbo/page_with_erb_partial.arb
164
+ - spec/rails/templates/arbo/page_with_helpers.arb
165
+ - spec/rails/templates/arbo/page_with_partial.arb
166
+ - spec/rails/templates/arbo/simple_page.arb
167
+ - spec/rails/templates/erb/_partial.erb
168
+ - spec/spec_helper.rb
169
+ - spec/support/bundle.rb