birdel 0.2.13

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: a79f1b4f0c4b34626afad66b0c0eb5f184bce42289a9d03ab4200622c19331a0
4
+ data.tar.gz: c80b4d665dfba4a7b96f1defa2957df8b170f27ec513b53703a4c2d605736872
5
+ SHA512:
6
+ metadata.gz: 3037016fc600adc8be9546ed22229d39ad247eef75c6021ee11857e669b2e58205781f9f752a78d8901212d70b7d051cb16c66a897f831d9c85ef75120f789cf
7
+ data.tar.gz: dae31e049e6b28dfa714c3d50f1ea27ce3d5af86f3cdf20af16480cc9b4b4742b67d0311c93ad8889d97b41d9912d29192c2b540a327cc455b560399593a5cc5
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-3.2.1
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at serhii.jun@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in birdel.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,57 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ birdel (0.2.13)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ diff-lcs (1.5.0)
11
+ json (2.6.3)
12
+ parallel (1.22.1)
13
+ parser (3.2.1.1)
14
+ ast (~> 2.4.1)
15
+ rainbow (3.1.1)
16
+ rake (13.0.6)
17
+ regexp_parser (2.7.0)
18
+ rexml (3.2.5)
19
+ rspec (3.12.0)
20
+ rspec-core (~> 3.12.0)
21
+ rspec-expectations (~> 3.12.0)
22
+ rspec-mocks (~> 3.12.0)
23
+ rspec-core (3.12.1)
24
+ rspec-support (~> 3.12.0)
25
+ rspec-expectations (3.12.2)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.12.0)
28
+ rspec-mocks (3.12.4)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.12.0)
31
+ rspec-support (3.12.0)
32
+ rubocop (1.48.1)
33
+ json (~> 2.3)
34
+ parallel (~> 1.10)
35
+ parser (>= 3.2.0.0)
36
+ rainbow (>= 2.2.2, < 4.0)
37
+ regexp_parser (>= 1.8, < 3.0)
38
+ rexml (>= 3.2.5, < 4.0)
39
+ rubocop-ast (>= 1.26.0, < 2.0)
40
+ ruby-progressbar (~> 1.7)
41
+ unicode-display_width (>= 2.4.0, < 3.0)
42
+ rubocop-ast (1.27.0)
43
+ parser (>= 3.2.1.0)
44
+ ruby-progressbar (1.13.0)
45
+ unicode-display_width (2.4.2)
46
+
47
+ PLATFORMS
48
+ x86_64-darwin-22
49
+
50
+ DEPENDENCIES
51
+ birdel!
52
+ rake (~> 13.0)
53
+ rspec (~> 3.0)
54
+ rubocop (~> 1.21)
55
+
56
+ BUNDLED WITH
57
+ 2.4.6
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Serhii
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/README.md ADDED
@@ -0,0 +1,180 @@
1
+ # Birdel - make rails great again 🐦
2
+
3
+ Use actors as never before
4
+
5
+ ## 🛣️ Rona - resolve request/respond
6
+
7
+ Processing birdel.js actors requests based on request specifications. And response based on response specification
8
+
9
+ ## 🔄 Cif - Chain of Responsibility pattern
10
+
11
+ Each actor should be sure, that previews actor successfully finished his job.
12
+
13
+ ## 🧩 Components generator
14
+
15
+ Birdel can generate actors (or components same to ViewComponent generator)
16
+
17
+ ```
18
+ # Nested namespace example
19
+ $ birdel act Ui::AngryCatActor
20
+ ```
21
+
22
+ ```
23
+ app/
24
+ ├─ bactors/
25
+ ├─── ui/
26
+ ├───── angry_cat_actor/
27
+ ├─────── angry_cat_actor.rb
28
+ ├─────── angry_cat_actor_specification.rb
29
+ ```
30
+
31
+ ```
32
+ $ birdel com Ui::TopBarComponent
33
+ ```
34
+
35
+ ```
36
+ app/
37
+ ├─ components/
38
+ │ ├─ ui/
39
+ │ │ ├─ top_bar_component/
40
+ │ │ │ ├─ top_bar_component.rb
41
+ │ │ │ ├─ top_bar_component.js
42
+ │ │ │ ├─ top_bar_component.css
43
+ │ │ │ ├─ top_bar_component_controller.js
44
+ │ │ │ └─ top_bar_component_actor.js
45
+ ```
46
+
47
+ ## 📈 Synth - Building indexes
48
+
49
+ You should store your entries same to this:
50
+ ```
51
+ app/
52
+ ├─ assets/
53
+ │ ├─ stylesheets/
54
+ │ │ ├─ bentries/
55
+ │ │ │ ├─ home/
56
+ │ │ │ │ ├─ index.css
57
+ │ │ │ │ ├─ components.css
58
+ │ │ │ │ ├─ precomponents.json
59
+ │ │ │ │ └─ components.json
60
+ │ │ │ ├─ some_page/
61
+ │ │ │ │ ├─ index.css
62
+ │ │ │ │ ├─ components.css
63
+ │ │ │ │ ├─ precomponents.json
64
+ │ │ │ │ └─ components.json
65
+
66
+ # Feel free to put bentries/ folder inside some nested folder in stylesheets/
67
+ ```
68
+
69
+ ```
70
+ # Resynchoronize entries
71
+ $ birdel synth
72
+ ```
73
+
74
+ ```
75
+ # precomponents.json example
76
+
77
+ [
78
+ "ui/birdel/fantasy",
79
+ "ui/birdel/layout"
80
+ ]
81
+
82
+ # components.json example
83
+ [
84
+ "ui/bentries/home_component/home_component",
85
+ "ui/mix/mini_product_component/mini_product_component"
86
+ ]
87
+ ```
88
+
89
+ ## 📜 Request/Response specifications
90
+
91
+ ```ruby
92
+ #"actorDirect" and "actorThrough" - still an idea for some field
93
+ #Request
94
+ {
95
+ "actor": "angry_cat_actor",
96
+ "method": "process_order",
97
+ "required_component": "ui--bars--top-bar-component",
98
+ "inputs": {
99
+ "customer": "John Doe",
100
+ "items": [
101
+ { "name": "Milk", "price": 1.5 },
102
+ { "name": "Bread", "price": 2.5 }
103
+ ]
104
+ },
105
+ "callback": {
106
+ "actor": "angry_swallow_actor",
107
+ "method": "process_bla",
108
+ "inputs": {
109
+ "customer": "John Doe",
110
+ "items": [
111
+ { "name": "Milk", "price": 1.5 },
112
+ { "name": "Bread", "price": 2.5 }
113
+ ]
114
+ }
115
+ }
116
+ }
117
+
118
+ #Response
119
+ {
120
+ "ok": true,
121
+ "message": "Order processed successfully",
122
+ "data": {
123
+ "actor": "angry_cat_actor",
124
+ "method": "process_order",
125
+ "outputs": {
126
+ "order_id": 1234,
127
+ "total_amount": 4.0,
128
+ },
129
+ "html": "<div></div>",
130
+ }
131
+ }
132
+ ```
133
+
134
+ ## Actor
135
+
136
+ ```ruby
137
+ class AngryCatActor::AngryCatActor < Birdel::BaseActor
138
+ def initialize()
139
+ end
140
+ def process_order
141
+
142
+ end
143
+ end
144
+ ```
145
+
146
+ ## Actor Specification example
147
+
148
+ ```ruby
149
+ class AngryCatActor::AngryCatActorSpecification
150
+ def initialize(msg)
151
+ parsed_msg = JSON.parse(msg)
152
+ @msg = parsed_msg.transform_keys(&:to_sym)
153
+ end
154
+
155
+ def inputs
156
+ [
157
+ { name: "customer", type: "string" },
158
+ { name: "items", type: "array" }
159
+ ]
160
+ end
161
+
162
+ def outputs
163
+ [
164
+ { name: "order_id", type: "integer" },
165
+ { name: "total_amount", type: "float" }
166
+ ]
167
+ end
168
+
169
+ def methods
170
+ [
171
+ { name: "process_order", input: ["customer", "items"], output: ["order_id", "total_amount"] }
172
+ ]
173
+ end
174
+
175
+ def msg_valid?
176
+ @msg[:inputs]&.keys.to_set == inputs.map { |i| i[:name] }.to_set &&
177
+ inputs.all? { |i| @msg[:inputs][i[:name]].is_a?(i[:type].camelize.constantize) }
178
+ end
179
+ end
180
+ ```
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/esbuild.config.js ADDED
@@ -0,0 +1,55 @@
1
+ import path from 'path';
2
+ import * as esbuild from 'esbuild'
3
+
4
+ const cssEntrypoints = [
5
+ 'assets/stylesheets/ui/entries/home/index.css',
6
+ 'assets/stylesheets/ui/entries/swallow/index.css',
7
+ 'assets/stylesheets/ui/entries/lizard/index.css',
8
+ ]
9
+ const cssOutbase = 'assets/stylesheets'
10
+
11
+ const jsEntrypoints = [
12
+ 'javascript/ui/entries/home/index.js',
13
+ 'javascript/ui/entries/swallow/index.js',
14
+ 'javascript/ui/entries/lizard/index.js',
15
+ ]
16
+ const jsOutbase = 'javascript'
17
+
18
+ const opt = {
19
+ bundle: true,
20
+ sourcemap: true,
21
+ outdir: 'assets/builds',
22
+ logLevel: 'info',
23
+ absWorkingDir: path.join(process.cwd(), 'app'),
24
+ loader: {
25
+ '.css': 'css',
26
+ '.js': 'js',
27
+ },
28
+ }
29
+
30
+ let cssOpt = {
31
+ ...opt,
32
+ entryPoints: cssEntrypoints,
33
+ outbase: 'assets/stylesheets',
34
+ }
35
+ let jsOpt = {
36
+ ...opt,
37
+ entryPoints: jsEntrypoints,
38
+ outbase: 'javascript',
39
+ }
40
+ if (process.argv.includes('--watch')) {
41
+ esbuild.context(cssOpt)
42
+ .then(ctx => {
43
+ ctx.watch().then(() => console.log('watching css...'))
44
+ })
45
+ .catch(() => process.exit(1));
46
+
47
+ esbuild.context(jsOpt)
48
+ .then(ctx => {
49
+ ctx.watch().then(() => console.log('watching js...'))
50
+ })
51
+ .catch(() => process.exit(1));
52
+ } else {
53
+ esbuild.build(cssOpt).catch(() => process.exit(1));
54
+ esbuild.build(jsOpt).catch(() => process.exit(1));
55
+ }
@@ -0,0 +1,63 @@
1
+ require "pathname"
2
+ require 'active_support/inflector'
3
+ require 'colored'
4
+
5
+ class Birdel::Com
6
+ def initialize
7
+ end
8
+
9
+ def roll
10
+ app_path = Pathname.new("#{Dir.pwd}")
11
+ components_path = app_path.join("app", "components")
12
+ component_ns = ARGV[0]
13
+ component_ns_camelized = component_ns.split("::").map(&:camelize).join("::")
14
+ component_name = component_ns_camelized.split("::").last
15
+ component_path = component_ns.split("::").join("/")
16
+ full_component_path = components_path.join(component_path.underscore)
17
+
18
+ variable_name = "css_class"
19
+ css_class = component_ns_camelized.underscore.gsub('_', '-').gsub('/', '--')
20
+ actor_name = "#{component_name.gsub("Component", "")}Actor"
21
+ files = [
22
+ { name: "#{component_name.underscore}.rb", content: "class #{component_ns_camelized}::#{component_name} < ViewComponent::Base\nend" },
23
+ { name: "#{component_name.underscore}.css", content: ".#{css_class}{}" },
24
+ { name: "#{component_name.underscore}.js", content: "" },
25
+ { name: "#{component_name.underscore}_controller.js", content: "
26
+ import { Controller } from \"@hotwired/stimulus\";
27
+
28
+ export default class extends Controller {
29
+ connect() {
30
+ console.log(\"Hello, component!\");
31
+ }
32
+ }
33
+ " },
34
+ { name: "#{component_name.underscore}_actor.js", content: "
35
+ export class #{actor_name}{
36
+ constructor() {
37
+ console.log(\"Hi, #{actor_name}!\");
38
+ }
39
+ }
40
+ " },
41
+ { name: "#{component_name.underscore}.html.erb", content: "<div class=\"<%= #{variable_name} %>\" data-controller=\"<%= #{variable_name} %>\">\n</div>" },
42
+ ]
43
+
44
+ files.each do |file|
45
+ file_path = full_component_path.join(file[:name])
46
+ if file_path.exist?
47
+ puts "File already exists: #{file_path}".red
48
+ else
49
+ puts "Creating file: #{file_path}".yellow
50
+ #create new file and folders if needed
51
+ file_path.dirname.mkpath
52
+ File.open(file_path, "w") do |f|
53
+ f.puts file[:content]
54
+ end
55
+ if file_path.exist?
56
+ puts "Done!".bold.green
57
+ else
58
+ puts "Failed".red
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,121 @@
1
+ require "pathname"
2
+ require 'active_support/inflector'
3
+ require 'colored'
4
+
5
+ class Birdel::Map
6
+ def initialize
7
+ end
8
+
9
+ def roll
10
+ myapp_path = Pathname.new("#{Dir.pwd}")
11
+ stylesheets_path = myapp_path.join("app", "assets", "stylesheets")
12
+ javascript_path = myapp_path.join("app", "javascript")
13
+ layouts_path = myapp_path.join("app", "views", "layouts")
14
+ css_bentries_path = stylesheets_path.join("ui", "bentries")
15
+ js_bentries_path = javascript_path.join("ui", "bentries")
16
+ layouts_bentries_path = layouts_path.join("ui", "bentries")
17
+
18
+ entry_ns = ARGV[0]
19
+ entry_ns_camelized = entry_ns.split("::").map(&:camelize).join("::")
20
+ entry_name = entry_ns_camelized.split("::").last
21
+ entry_path = entry_ns.split("::").join("/")
22
+
23
+ full_css_entry_path = css_bentries_path.join(entry_path.underscore)
24
+ full_js_entry_path = js_bentries_path.join(entry_path.underscore)
25
+ full_layout_entry_path = layouts_bentries_path.join(entry_path.underscore)
26
+
27
+ if full_css_entry_path.exist?
28
+ puts "Entry #{full_css_entry_path.relative_path_from(myapp_path)} already exists".red.bold
29
+ else
30
+ full_css_entry_path.mkpath
31
+ css_entry_files = [
32
+ { name: "components.css", content: "" },
33
+ { name: "components.css.json", content: "[]" },
34
+ { name: "precomponents.css", content: "" },
35
+ { name: "precomponents.css.json", content: "[]" },
36
+ { name: "index.css", content: "@import url(\"./components.css\");" },
37
+ ]
38
+ css_entry_files.each do |file|
39
+ if full_css_entry_path.join(file[:name]).exist?
40
+ puts "File #{full_css_entry_path.join(file[:name]).relative_path_from(myapp_path)} already exists".red.bold
41
+ else
42
+ puts full_css_entry_path.join(file[:name]).to_s.green.bold
43
+ full_css_entry_path.join(file[:name]).open("w") do |f|
44
+ f.write(file[:content])
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ if full_js_entry_path.exist?
51
+ puts "Entry #{full_js_entry_path.relative_path_from(myapp_path)} already exists".red.bold
52
+ else
53
+ full_js_entry_path.mkpath
54
+ js_entry_files = [
55
+ { name: "components.js", content: "" },
56
+ { name: "components.js.json", content: "[]" },
57
+ { name: "precomponents.js", content: "" },
58
+ { name: "precomponents.js.json", content: "[]" },
59
+ { name: "index.js", content: "import \"./components\";"},
60
+ ]
61
+ js_entry_files.each do |file|
62
+ if full_js_entry_path.join(file[:name]).exist?
63
+ puts "File #{full_js_entry_path.join(file[:name]).relative_path_from(myapp_path)} already exists".red.bold
64
+ else
65
+ puts "+ #{full_js_entry_path.join(file[:name]).relative_path_from(myapp_path).to_s}".green.bold
66
+ full_js_entry_path.join(file[:name]).open("w") do |f|
67
+ f.write(file[:content])
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ css_index_path = full_css_entry_path.join("index.css").relative_path_from(stylesheets_path)
74
+ js_index_path = full_js_entry_path.join("index.js").relative_path_from(javascript_path)
75
+
76
+ js_index_directory_path = js_index_path.dirname.to_s
77
+ js_index_filename_without_extension = js_index_path.basename('.js').to_s
78
+ js_index_formatted_path = "#{js_index_directory_path}/#{js_index_filename_without_extension}"
79
+
80
+ css_index_directory_path = css_index_path.dirname.to_s
81
+ css_index_filename_without_extension = css_index_path.basename('.css').to_s
82
+ css_index_formatted_path = "#{css_index_directory_path}/#{css_index_filename_without_extension}"
83
+
84
+
85
+ if full_layout_entry_path.exist?
86
+ puts "Entry #{full_layout_entry_path.relative_path_from(myapp_path)} already exists".red.bold
87
+ else
88
+ full_layout_entry_path.mkpath
89
+ layout_entry_files = [
90
+ { name: "index.html.erb", content: "
91
+ <!DOCTYPE html>
92
+ <html>
93
+ <head>
94
+ <meta name=\"viewport\" content=\"width=device-width,initial-scale=1, maximum-scale=1.0, user-scalable=no\" >
95
+ <%= action_cable_meta_tag %>
96
+ <%= csrf_meta_tags %>
97
+ <%= csp_meta_tag %>
98
+ <%= display_meta_tags %>
99
+ <%= stylesheet_link_tag \"#{css_index_formatted_path}\", \"data-turbo-track\": \"reload\" %>
100
+ <%= javascript_include_tag \"#{js_index_formatted_path}\", \"data-turbo-track\": \"reload\", defer: true, type: \"module\" %>
101
+ </head>
102
+
103
+ <body>
104
+ <%= yield %>
105
+ </body>
106
+ </html>
107
+ " },
108
+ ]
109
+ layout_entry_files.each do |file|
110
+ if full_layout_entry_path.join(file[:name]).exist?
111
+ puts "File #{full_layout_entry_path.join(file[:name]).relative_path_from(myapp_path)} already exists".red.bold
112
+ else
113
+ puts "+ #{full_layout_entry_path.join(file[:name]).relative_path_from(myapp_path).to_s}".green.bold
114
+ full_layout_entry_path.join(file[:name]).open("w") do |f|
115
+ f.write(file[:content])
116
+ end
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,9 @@
1
+ # Routing Overlay Network Actor
2
+
3
+ class Birdel::Rona
4
+ class << self
5
+ def route(data)
6
+ puts "Birdel::Rona::Rona.route"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,114 @@
1
+ require "json"
2
+ require 'pathname'
3
+ require 'colored'
4
+
5
+ class Birdel::Synth::Synth
6
+ def initialize
7
+ end
8
+
9
+ def roll
10
+ root_dir_path = Pathname.new("#{Dir.pwd}")
11
+ app_folder_path = root_dir_path.join("app")
12
+ components_folder_path = app_folder_path.join("components")
13
+ js_folder_path = app_folder_path.join("javascript")
14
+ stylesheets_folder_path = app_folder_path.join("assets/stylesheets")
15
+ js_application_file_path = js_folder_path.join("ui/application.js")
16
+ css_bentries_path = stylesheets_folder_path.join("ui/bentries")
17
+ js_bentries_path = js_folder_path.join("ui/bentries")
18
+
19
+ css_entries_error = false
20
+ js_entries_error = false
21
+ css_bentries_path.each_child do |entry_folder_path|
22
+ # entry_folder_path = Pathname.new(entry_folder)
23
+ # entry_folder_index_path = Pathname.new("#{entry_folder}/components.css")
24
+ entry_folder_index_path = entry_folder_path.join("components.css")
25
+ puts "(css) Building #{entry_folder_index_path.relative_path_from(app_folder_path)}".yellow.bold
26
+ # entry_folder_components_path = Pathname.new("#{entry_folder}/components.json")
27
+ entry_folder_components_path = entry_folder_path.join("components.css.json")
28
+ entry_folder_precomponents_path = entry_folder_path.join("precomponents.css.json")
29
+ File.truncate(entry_folder_index_path, 0)
30
+ file = File.open(entry_folder_index_path, "w")
31
+
32
+ #precomponents
33
+ puts "-> Precomponents...".yellow
34
+ precomponents = JSON.parse(File.read(entry_folder_precomponents_path))
35
+ precomponents.each do |precomponent_path_string|
36
+ # # file_path = Pathname.new("#{stylesheets_folder_path.to_s}/#{precomponent_path_string}.css")
37
+ file_path = stylesheets_folder_path.join("#{precomponent_path_string}.css")
38
+ if file_path.exist?
39
+ puts "+ #{precomponent_path_string.split("/").last}.css".green
40
+ file.puts "@import url(\"#{file_path.relative_path_from(entry_folder_path).to_s}\");"
41
+ else
42
+ css_entries_error = true
43
+ puts "File not found: #{file_path}".red
44
+ end
45
+ end
46
+
47
+ file.puts ""
48
+
49
+ #components
50
+ puts "-> Components...".yellow
51
+ components = JSON.parse(File.read(entry_folder_components_path))
52
+ components.each do |component_path_string|
53
+ # full_component_path = Pathname.new("#{components_folder_path.to_s}/#{component_path_string}.css")
54
+ full_component_path = components_folder_path.join("#{component_path_string}.css")
55
+ if full_component_path.exist?
56
+ file_name = component_path_string.split("/").last
57
+ puts "+ #{file_name}.css".green
58
+ file.puts "@import url(\"#{full_component_path.relative_path_from(entry_folder_path).to_s}\");"
59
+ else
60
+ css_entries_error = true
61
+ puts "Component not found: #{component_path_string}".red
62
+ puts "Check => #{entry_folder_components_path.relative_path_from(root_dir_path)}".red.bold
63
+ end
64
+ end
65
+ end
66
+ if css_entries_error
67
+ puts "(css-error) Building failed.".red
68
+ exit
69
+ end
70
+ puts "(css-success) Building finished.".green
71
+ puts ""
72
+
73
+ js_bentries_path.each_child do |entry_folder_path|
74
+ # js_entries.each do |entry|
75
+ # index_path = Pathname.new("#{entry}/components.js")
76
+ index_path = entry_folder_path.join("components.js")
77
+ components_json_path = entry_folder_path.join("components.js.json")
78
+ # entry_folder_path = Pathname.new(entry)
79
+ puts "(js) Building #{index_path.relative_path_from(app_folder_path)}".green
80
+ puts "-> (js) Components...".yellow
81
+ File.truncate(index_path, 0)
82
+ component_controllers = JSON.parse(File.read(components_json_path))
83
+ file = File.open(index_path, "w")
84
+ js_application_file_name = js_application_file_path.basename.to_s.split(".").first
85
+ file.puts "import { #{js_application_file_name} } from \"#{js_application_file_path.relative_path_from(entry_folder_path).to_s.gsub(js_application_file_path.extname, "")}\";"
86
+ file.puts ""
87
+ component_controllers.each do |component_path|
88
+ path_parts = component_path.split("/")
89
+ component_name = path_parts.pop
90
+ controller_from_components = "#{component_path}/#{component_name}_controller"
91
+ # component_controller_path = Pathname.new("#{components_folder_path.to_s}/#{controller_from_components}.js")
92
+ component_controller_path = components_folder_path.join("#{controller_from_components}.js")
93
+ if component_controller_path.exist?
94
+ component_path_dashed = component_path.tr("_", "-").gsub("/", "--")
95
+ camelized_component_name = component_name.split("_").map(&:capitalize).join
96
+ controller_backpath = component_controller_path.relative_path_from(entry_folder_path)
97
+ controller_backpath_without_ext = controller_backpath.to_s.gsub(controller_backpath.extname, "")
98
+ file.puts "import #{camelized_component_name} from \"#{controller_backpath_without_ext}\";"
99
+ file.puts "application.register(\"#{component_path_dashed}\", #{camelized_component_name});"
100
+ file.puts ""
101
+ puts "+ #{component_path_dashed}"
102
+ else
103
+ js_entries_error = true
104
+ puts "Stimulus controller not found: #{component_path}".red
105
+ end
106
+ end
107
+ end
108
+ if js_entries_error
109
+ puts "(js-error) Building failed.".red
110
+ exit
111
+ end
112
+ puts "(js-success) Building finished.".green
113
+ end
114
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Birdel
4
+ VERSION = "0.2.13"
5
+ end
data/lib/birdel.rb ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "birdel/version"
4
+ require_relative "birdel/com/com"
5
+ require_relative "birdel/map/map"
6
+ require_relative "birdel/rona/rona"
7
+ require_relative "birdel/synth/synth"
8
+
9
+ module Birdel
10
+ class Error < StandardError; end
11
+ class << self
12
+ def test1
13
+ puts "Birdel is a gem for sending messages to your actors and getting view_components back!"
14
+ end
15
+ end
16
+ end
data/sig/birdel.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Birdel
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: birdel
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.13
5
+ platform: ruby
6
+ authors:
7
+ - Serhii
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-03-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Send json messages to your actors and get view_components back! Now you
14
+ can be sure that your actors are processed correctly.
15
+ email:
16
+ - serhii.jun@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".rspec"
22
+ - ".rubocop.yml"
23
+ - ".ruby-version"
24
+ - CODE_OF_CONDUCT.md
25
+ - Gemfile
26
+ - Gemfile.lock
27
+ - LICENSE.txt
28
+ - README.md
29
+ - Rakefile
30
+ - esbuild.config.js
31
+ - lib/birdel.rb
32
+ - lib/birdel/com/com.rb
33
+ - lib/birdel/map/map.rb
34
+ - lib/birdel/rona/rona.rb
35
+ - lib/birdel/synth/synth.rb
36
+ - lib/birdel/version.rb
37
+ - sig/birdel.rbs
38
+ homepage: https://github.com/serhiijun/birdel
39
+ licenses:
40
+ - MIT
41
+ metadata:
42
+ allowed_push_host: https://rubygems.org
43
+ homepage_uri: https://github.com/serhiijun/birdel
44
+ source_code_uri: https://github.com/serhiijun/birdel
45
+ changelog_uri: https://github.com/serhiijun/birdel
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.6.0
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubygems_version: 3.4.6
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: Make actors great again!
65
+ test_files: []