masstaden 0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e0defe8ad455494664cc0c1b68492f189f07e5639f15c4128d132c35a763d6da
4
+ data.tar.gz: 5e9fa295e1ee07c5e14501c78bdd55abc29c4acbc4d721f2cf0bc4d95faa852b
5
+ SHA512:
6
+ metadata.gz: 3503cf888b3afa84655d27d0bd80b4960104fa362ab934a53612392ab36dc4c2304417935ebef65bdacb77e2d6b16bafff95929ffe1c56fc5d5c2b9a0aa36396
7
+ data.tar.gz: 9018341cbb2b348536e6de68e01326206cc57b734a8c8cc27d0d9949c09ef045cd35d530b885905f7f367795c53a6c744689813d0f014a427a4139549d7f16c6
data/.editorconfig ADDED
@@ -0,0 +1,17 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = tab
5
+ indent_size = 4
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [*.yml]
12
+ indent_style = space
13
+ indent_size = 2
14
+
15
+ [*.conf]
16
+ indent_style = space
17
+ indent_size = 2
@@ -0,0 +1,147 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="AutoImportSettings">
4
+ <option name="autoReloadType" value="SELECTIVE" />
5
+ </component>
6
+ <component name="ChangeListManager">
7
+ <list default="true" id="e004c60b-e53b-4f77-8657-f9a95e58de0a" name="Changes" comment="dsl" />
8
+ <option name="SHOW_DIALOG" value="false" />
9
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
10
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
11
+ <option name="LAST_RESOLUTION" value="IGNORE" />
12
+ </component>
13
+ <component name="FileTemplateManagerImpl">
14
+ <option name="RECENT_TEMPLATES">
15
+ <list>
16
+ <option value="RBS Class" />
17
+ </list>
18
+ </option>
19
+ </component>
20
+ <component name="MarkdownSettingsMigration">
21
+ <option name="stateVersion" value="1" />
22
+ </component>
23
+ <component name="ProjectColorInfo">{
24
+ &quot;associatedIndex&quot;: 3
25
+ }</component>
26
+ <component name="ProjectId" id="2aSw2V7px9YuDnlDfjlVHc7zkYX" />
27
+ <component name="ProjectViewState">
28
+ <option name="hideEmptyMiddlePackages" value="true" />
29
+ <option name="showExcludedFiles" value="false" />
30
+ <option name="showLibraryContents" value="true" />
31
+ </component>
32
+ <component name="PropertiesComponent">{
33
+ &quot;keyToString&quot;: {
34
+ &quot;Rake.Test.executor&quot;: &quot;Run&quot;,
35
+ &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
36
+ &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
37
+ &quot;Test::Unit/Shoulda/Minitest.Test.executor&quot;: &quot;Run&quot;,
38
+ &quot;Test::Unit/Shoulda/Minitest.TestDSL.executor&quot;: &quot;Run&quot;,
39
+ &quot;Test::Unit/Shoulda/Minitest.TestMasstaden.executor&quot;: &quot;Run&quot;,
40
+ &quot;Test::Unit/Shoulda/Minitest.test_dynamic_header (1).executor&quot;: &quot;Run&quot;,
41
+ &quot;Test::Unit/Shoulda/Minitest.test_dynamic_header.executor&quot;: &quot;Run&quot;,
42
+ &quot;Test::Unit/Shoulda/Minitest.test_html_tag_rendering.executor&quot;: &quot;Run&quot;,
43
+ &quot;Test::Unit/Shoulda/Minitest.test_that_generic_tag_renders (1).executor&quot;: &quot;Run&quot;,
44
+ &quot;Test::Unit/Shoulda/Minitest.test_that_generic_tag_renders.executor&quot;: &quot;Debug&quot;,
45
+ &quot;Test::Unit/Shoulda/Minitest.test_the_construction_of_a_tag.executor&quot;: &quot;Run&quot;,
46
+ &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
47
+ &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
48
+ &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
49
+ &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
50
+ &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
51
+ &quot;ruby.structure.view.model.defaults.configured&quot;: &quot;true&quot;,
52
+ &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
53
+ }
54
+ }</component>
55
+ <component name="RecentsManager">
56
+ <key name="MoveFile.RECENT_KEYS">
57
+ <recent name="$PROJECT_DIR$/test/fixtures/pages" />
58
+ </key>
59
+ </component>
60
+ <component name="RunManager" selected="Shell Script.Build">
61
+ <configuration name="Test" type="RakeRunConfigurationType" factoryName="Rake">
62
+ <module name="masstaden" />
63
+ <predefined_log_file enabled="true" id="RUBY_RAKE" />
64
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="" />
65
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
66
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
67
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
68
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
69
+ <EXTENSION ID="BundlerRunConfigurationExtension" BUNDLE_MODE="AUTO" bundleExecEnabled="true" />
70
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" track_test_folders="true" runner="rcov" ENABLE_BRANCH_COVERAGE="true" ENABLE_FORKED_COVERAGE="true">
71
+ <COVERAGE_PATTERN ENABLED="true">
72
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
73
+ </COVERAGE_PATTERN>
74
+ </EXTENSION>
75
+ <EXTENSION ID="org.jetbrains.plugins.ruby.rails.run.RailsRunConfigurationExtension" SCRATCH_USE_RAILS_RUNNER="false" />
76
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_NAME" VALUE="test" />
77
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_ARGS" VALUE="" />
78
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_ATTACHED_TEST_FRAMEWORKS" VALUE=":test_unit " />
79
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_TRACE" VALUE="false" />
80
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_DRYRUN" VALUE="false" />
81
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_PREREQS" VALUE="false" />
82
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_TESTOPTS" VALUE="" />
83
+ <method v="2" />
84
+ </configuration>
85
+ <configuration name="Build" type="ShConfigurationType">
86
+ <option name="SCRIPT_TEXT" value="gem build masstaden.gemspec" />
87
+ <option name="INDEPENDENT_SCRIPT_PATH" value="true" />
88
+ <option name="SCRIPT_PATH" value="" />
89
+ <option name="SCRIPT_OPTIONS" value="" />
90
+ <option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
91
+ <option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
92
+ <option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
93
+ <option name="INTERPRETER_PATH" value="/usr/local/bin/fish" />
94
+ <option name="INTERPRETER_OPTIONS" value="" />
95
+ <option name="EXECUTE_IN_TERMINAL" value="true" />
96
+ <option name="EXECUTE_SCRIPT_FILE" value="false" />
97
+ <envs />
98
+ <method v="2" />
99
+ </configuration>
100
+ <list>
101
+ <item itemvalue="Rake.Test" />
102
+ <item itemvalue="Shell Script.Build" />
103
+ </list>
104
+ </component>
105
+ <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
106
+ <component name="SpringUtil" SPRING_PRE_LOADER_OPTION="true" RAKE_SPRING_PRE_LOADER_OPTION="true" RAILS_SPRING_PRE_LOADER_OPTION="true" />
107
+ <component name="TaskManager">
108
+ <task active="true" id="Default" summary="Default task">
109
+ <changelist id="e004c60b-e53b-4f77-8657-f9a95e58de0a" name="Changes" comment="" />
110
+ <created>1704325081171</created>
111
+ <option name="number" value="Default" />
112
+ <option name="presentableId" value="Default" />
113
+ <updated>1704325081171</updated>
114
+ <workItem from="1704325082438" duration="20975000" />
115
+ <workItem from="1704390744844" duration="27000" />
116
+ <workItem from="1704390780218" duration="771000" />
117
+ </task>
118
+ <task id="LOCAL-00001" summary="dsl">
119
+ <option name="closed" value="true" />
120
+ <created>1704391351499</created>
121
+ <option name="number" value="00001" />
122
+ <option name="presentableId" value="LOCAL-00001" />
123
+ <option name="project" value="LOCAL" />
124
+ <updated>1704391351499</updated>
125
+ </task>
126
+ <option name="localTasksCounter" value="2" />
127
+ <servers />
128
+ </component>
129
+ <component name="TypeScriptGeneratedFilesManager">
130
+ <option name="version" value="3" />
131
+ </component>
132
+ <component name="VcsManagerConfiguration">
133
+ <MESSAGE value="dsl" />
134
+ <option name="LAST_COMMIT_MESSAGE" value="dsl" />
135
+ </component>
136
+ <component name="com.intellij.coverage.CoverageDataManagerImpl">
137
+ <SUITE FILE_PATH="coverage/masstaden@Test.rcov" NAME="Test Coverage Results" MODIFIED="1704385637009" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="masstaden" />
138
+ <SUITE FILE_PATH="coverage/masstaden@TestDSL.rcov" NAME="TestDSL Coverage Results" MODIFIED="1704390959627" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="masstaden" />
139
+ <SUITE FILE_PATH="coverage/masstaden@test_dynamic_header__1_.rcov" NAME="test_dynamic_header (1) Coverage Results" MODIFIED="1704340690485" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="masstaden" />
140
+ <SUITE FILE_PATH="coverage/masstaden@test_that_generic_tag_renders.rcov" NAME="test_that_generic_tag_renders Coverage Results" MODIFIED="1704334153136" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="masstaden" />
141
+ <SUITE FILE_PATH="coverage/masstaden@test_that_generic_tag_renders__1_.rcov" NAME="test_that_generic_tag_renders (1) Coverage Results" MODIFIED="1704346781980" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="masstaden" />
142
+ <SUITE FILE_PATH="coverage/masstaden@TestMasstaden.rcov" NAME="TestMasstaden Coverage Results" MODIFIED="1704330261319" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="masstaden" />
143
+ <SUITE FILE_PATH="coverage/masstaden@test_the_construction_of_a_tag.rcov" NAME="test_the_construction_of_a_tag Coverage Results" MODIFIED="1704334430434" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="masstaden" />
144
+ <SUITE FILE_PATH="coverage/masstaden@test_html_tag_rendering.rcov" NAME="test_html_tag_rendering Coverage Results" MODIFIED="1704385758799" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="masstaden" />
145
+ <SUITE FILE_PATH="coverage/masstaden@test_dynamic_header.rcov" NAME="test_dynamic_header Coverage Results" MODIFIED="1704340277488" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="masstaden" />
146
+ </component>
147
+ </project>
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in masstaden.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+ gem "minitest", "~> 5.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 hstaab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/test_*.rb"]
10
+ end
11
+
12
+ task default: :test
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'tags'
4
+
5
+ module Masstaden::HTM
6
+ module DSL
7
+
8
+ # create methods for each tag in default_tags
9
+ Tags.default_tags.each do |tag|
10
+ if tag[:self_closing]
11
+ define_method(tag[:name]) do |*args|
12
+ Tag.new(tag[:name], *args).render
13
+ end
14
+ else
15
+ define_method(tag[:name]) do |*args, &block|
16
+ Tag.new(tag[:name], *args, &block).render
17
+ end
18
+ end
19
+ end
20
+
21
+ # def html(*args, &block)
22
+ # Tag.new(:html, *args, &block).render
23
+ # end
24
+ #
25
+ # def head(*args, &block)
26
+ # Tag.new(:head, *args, &block).render
27
+ # end
28
+ #
29
+ # def title(*args, &block)
30
+ # Tag.new(:title, *args, &block).render
31
+ # end
32
+ #
33
+ # def meta(*args)
34
+ # Tag.new(:meta, *args).render
35
+ # end
36
+ #
37
+ # def body(*args, &block)
38
+ # Tag.new(:body, *args, &block).render
39
+ # end
40
+ #
41
+ # def h1(*args, &block)
42
+ # Tag.new(:h1, *args, &block).render
43
+ # end
44
+
45
+
46
+ end
47
+ end
@@ -0,0 +1,124 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Masstaden::HTM
4
+
5
+ class Tags
6
+ def self.default_tags
7
+ [
8
+ # Document tags
9
+ { name: :html, self_closing: false },
10
+
11
+ # Metadata tags
12
+ { name: :title, self_closing: false },
13
+ { name: :meta, self_closing: true },
14
+
15
+ # Scripting tags
16
+ { name: :script, self_closing: false },
17
+ { name: :noscript, self_closing: false },
18
+
19
+ # Sectioning tags
20
+ { name: :header, self_closing: false },
21
+ { name: :footer, self_closing: false },
22
+ { name: :section, self_closing: false },
23
+ { name: :article, self_closing: false },
24
+ { name: :nav, self_closing: false },
25
+
26
+ # Text content tags
27
+ { name: :p, self_closing: false },
28
+ { name: :h1, self_closing: false },
29
+ { name: :h2, self_closing: false },
30
+ { name: :h3, self_closing: false },
31
+ { name: :h4, self_closing: false },
32
+ { name: :h5, self_closing: false },
33
+ { name: :h6, self_closing: false },
34
+ { name: :ul, self_closing: false },
35
+ { name: :ol, self_closing: false },
36
+ { name: :li, self_closing: false },
37
+ { name: :dl, self_closing: false },
38
+ { name: :dt, self_closing: false },
39
+ { name: :dd, self_closing: false },
40
+ { name: :pre, self_closing: false },
41
+ { name: :blockquote, self_closing: false },
42
+
43
+ # Inline text semantics tags
44
+ { name: :a, self_closing: false },
45
+ { name: :em, self_closing: false },
46
+ { name: :strong, self_closing: false },
47
+ { name: :small, self_closing: false },
48
+ { name: :s, self_closing: false },
49
+ { name: :cite, self_closing: false },
50
+ { name: :q, self_closing: false },
51
+ { name: :dfn, self_closing: false },
52
+ { name: :abbr, self_closing: false },
53
+ { name: :data, self_closing: false },
54
+ { name: :time, self_closing: false },
55
+ { name: :code, self_closing: false },
56
+ { name: :var, self_closing: false },
57
+ { name: :samp, self_closing: false },
58
+ { name: :kbd, self_closing: false },
59
+ { name: :sub, self_closing: false },
60
+ { name: :sup, self_closing: false },
61
+ { name: :i, self_closing: false },
62
+ { name: :b, self_closing: false },
63
+ { name: :u, self_closing: false },
64
+ { name: :mark, self_closing: false },
65
+ { name: :ruby, self_closing: false },
66
+ { name: :rt, self_closing: false },
67
+ { name: :rp, self_closing: false },
68
+ { name: :bdi, self_closing: false },
69
+ { name: :bdo, self_closing: false },
70
+ { name: :span, self_closing: false },
71
+
72
+ # Image and multimedia tags
73
+ { name: :img, self_closing: true },
74
+ { name: :audio, self_closing: false },
75
+ { name: :video, self_closing: false },
76
+ { name: :source, self_closing: true },
77
+ { name: :track, self_closing: true },
78
+
79
+ # Embedded content tags
80
+ { name: :iframe, self_closing: false },
81
+ { name: :embed, self_closing: true },
82
+ { name: :object, self_closing: false },
83
+ { name: :param, self_closing: true },
84
+
85
+ # Script-supporting tags
86
+ { name: :canvas, self_closing: false },
87
+ { name: :map, self_closing: false },
88
+ { name: :area, self_closing: true },
89
+
90
+ # Table tags
91
+ { name: :table, self_closing: false },
92
+ { name: :caption, self_closing: false },
93
+ { name: :thead, self_closing: false },
94
+ { name: :tbody, self_closing: false },
95
+ { name: :tfoot, self_closing: false },
96
+ { name: :tr, self_closing: false },
97
+ { name: :th, self_closing: false },
98
+ { name: :td, self_closing: false },
99
+
100
+ # Forms and input tags
101
+ { name: :form, self_closing: false },
102
+ { name: :input, self_closing: true },
103
+ { name: :textarea, self_closing: false },
104
+ { name: :button, self_closing: false },
105
+ { name: :select, self_closing: false },
106
+ { name: :optgroup, self_closing: false },
107
+ { name: :option, self_closing: false },
108
+ { name: :label, self_closing: false },
109
+ { name: :fieldset, self_closing: false },
110
+ { name: :legend, self_closing: false },
111
+ { name: :datalist, self_closing: false },
112
+ { name: :output, self_closing: false },
113
+
114
+ # Interactive elements
115
+ { name: :details, self_closing: false },
116
+ { name: :summary, self_closing: false },
117
+ { name: :dialog, self_closing: false }
118
+ ]
119
+
120
+ end
121
+ end
122
+ end
123
+
124
+
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ require_relative 'htm/dsl'
4
+
5
+
6
+
7
+ module Masstaden::HTM
8
+ class Tag
9
+ attr_accessor :name, :content, :attributes
10
+
11
+ def initialize(*args, &block)
12
+ @name = args.shift
13
+ @attributes = {}
14
+ @content = nil
15
+ @block = block
16
+
17
+ args.each do |arg|
18
+ if arg.is_a?(Hash)
19
+ @attributes = arg
20
+ elsif arg.is_a?(String)
21
+ @content = arg
22
+ end
23
+ end
24
+ end
25
+
26
+ def render
27
+ if @block
28
+ r_open + @block.call + r_close
29
+ elsif @content.is_a?(String)
30
+ r_open + @content + r_close
31
+ else
32
+ r_open + r_close
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def r_open
39
+ "<#{[@name, r_attr].compact.join(" ")}>"
40
+ end
41
+
42
+ def r_close
43
+ "</#{@name}>"
44
+ end
45
+
46
+ def r_attr
47
+ attrs = @attributes.map do |key, value|
48
+ key = key.to_s.gsub('_', '-')
49
+ "#{key}=\"#{value}\""
50
+ end
51
+
52
+ attrs.empty? ? nil : attrs.join(" ")
53
+ end
54
+ end
55
+
56
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Masstaden
4
+ VERSION = "0.0.1"
5
+ end
data/lib/masstaden.rb ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "masstaden/version"
4
+ require_relative "masstaden/htm"
5
+
6
+ module Masstaden
7
+ class Error < StandardError; end
8
+
9
+ # Your code goes here...
10
+ end
data/masstaden.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/masstaden/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "masstaden"
7
+ spec.version = Masstaden::VERSION
8
+ spec.authors = ["hstaab"]
9
+ spec.email = ["hstaab@sunbather.xyz"]
10
+
11
+ spec.summary = "Data types library for the web"
12
+ spec.description = "A library of data types and tools for constructing web applications in Ruby."
13
+ spec.homepage = "https://git.sunbather.xyz/lib/masstaden"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://git.sunbather.xyz/lib/masstaden"
19
+ # spec.metadata["changelog_uri"] = ""
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
26
+ end
27
+ end
28
+ spec.bindir = "bin"
29
+ spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ # Uncomment to register a new dependency of your gem
33
+ # spec.add_dependency "example-gem", "~> 1.0"
34
+
35
+ # For more information and examples about making a new gem, check out our
36
+ # guide at: https://bundler.io/guides/creating_gem.html
37
+ end
@@ -0,0 +1,7 @@
1
+ module Masstaden
2
+ module HTM
3
+ class Tag
4
+ def render: -> String
5
+ end
6
+ end
7
+ end
data/sig/masstaden.rbs ADDED
@@ -0,0 +1,5 @@
1
+ module Masstaden
2
+ VERSION: String
3
+
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: masstaden
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - hstaab
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-01-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A library of data types and tools for constructing web applications in
14
+ Ruby.
15
+ email:
16
+ - hstaab@sunbather.xyz
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".editorconfig"
22
+ - ".idea/workspace.xml"
23
+ - Gemfile
24
+ - LICENSE.txt
25
+ - Rakefile
26
+ - lib/masstaden.rb
27
+ - lib/masstaden/htm.rb
28
+ - lib/masstaden/htm/dsl.rb
29
+ - lib/masstaden/htm/tags.rb
30
+ - lib/masstaden/version.rb
31
+ - masstaden.gemspec
32
+ - sig/masstaden.rbs
33
+ - sig/masstaden/html/tag.rbs
34
+ homepage: https://git.sunbather.xyz/lib/masstaden
35
+ licenses:
36
+ - MIT
37
+ metadata:
38
+ homepage_uri: https://git.sunbather.xyz/lib/masstaden
39
+ source_code_uri: https://git.sunbather.xyz/lib/masstaden
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 2.6.0
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubygems_version: 3.4.8
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: Data types library for the web
59
+ test_files: []