birdel 0.3.3 → 1.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21efe23c6887077f40706fef43acca2ec2f963b5ca4d7e7b891c200f0b6962b7
4
- data.tar.gz: 689f618982ec571ff2122a547c02f4eac43a1d61bcd6f6e168e908c2316d3007
3
+ metadata.gz: '02798ff80cb63bbbf42789d1f49e2f46cb17b9008970963d715b3ff49ed20558'
4
+ data.tar.gz: a2285f9e9826ca7ff1fba64208ad294be447710ce8d54c2d2bed7f640a6c2df0
5
5
  SHA512:
6
- metadata.gz: b6258f33135d6ecaabb03786a0b2957967466555406eccb72019028ceabcc87afdde7a577c5b5f43f25eaee0f359b166008eb33610f967d67af0f32f75a3aefd
7
- data.tar.gz: 47e43042afb020d52cb00843da62bb9f91cdd41b8f150f99a22f41cb780fd26d66b6a275cda7e1a94d2ee8ced22cea4b1858181f3a69ce6230cc75a83852e2ed
6
+ metadata.gz: bdbc51c7fbd2a9eeaa2a8c273a5e0ce65222f0685b1c118a937984ee569dfecd242e189f15fc6bce6d6562890d0e06bb6ed530b84d3e62a8196f262c8e5e5155
7
+ data.tar.gz: 7610cac4dd92487e97a64f0e97f85a4306c711b23c1ebd9beb83e8dfe44839a7048cd82f58e0f6955c2b59ae92c5b48d6cb2695f70d3b868abf4b2893cef4df2
data/Gemfile CHANGED
@@ -13,4 +13,6 @@ gem "rubocop", "~> 1.21"
13
13
 
14
14
  gem 'activesupport', '~> 7.0', '>= 7.0.4.3'
15
15
 
16
- gem 'colored', '~> 1.2'
16
+ gem 'colored', '~> 1.2'
17
+
18
+ gem 'thor', '~> 1.2', '>= 1.2.1'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- birdel (0.2.16)
4
+ birdel (0.3.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -52,6 +52,7 @@ GEM
52
52
  rubocop-ast (1.27.0)
53
53
  parser (>= 3.2.1.0)
54
54
  ruby-progressbar (1.13.0)
55
+ thor (1.2.1)
55
56
  tzinfo (2.0.6)
56
57
  concurrent-ruby (~> 1.0)
57
58
  unicode-display_width (2.4.2)
@@ -66,6 +67,7 @@ DEPENDENCIES
66
67
  rake (~> 13.0)
67
68
  rspec (~> 3.0)
68
69
  rubocop (~> 1.21)
70
+ thor (~> 1.2, >= 1.2.1)
69
71
 
70
72
  BUNDLED WITH
71
73
  2.4.6
data/bin/birdel ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'birdel/cli'
3
+
4
+ Birdel::CLI.start(ARGV)
data/lib/birdel/cli.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'thor'
2
+
3
+ module Birdel
4
+ class CLI < Thor
5
+ desc "gcom NAME", "Generate a new component"
6
+ def gcom(name)
7
+ Birdel::Com.roll(name)
8
+ end
9
+
10
+ desc "synth", "Syncronize components assets"
11
+ def synth
12
+ Birdel::Synth.roll(name)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,68 @@
1
+ module Birdel
2
+ module Com
3
+ def roll
4
+ app_path = Pathname.new("#{Dir.pwd}")
5
+ components_path = app_path.join("app", "components")
6
+ component_ns = ARGV[0]
7
+ component_ns_camelized = component_ns.split("::").map(&:camelize).join("::")
8
+ component_name = component_ns_camelized.split("::").last
9
+ component_path = component_ns.split("::").join("/")
10
+ full_component_path = components_path.join(component_path.underscore)
11
+
12
+ variable_name = "css_class"
13
+ css_class = component_ns_camelized.underscore.gsub('_', '-').gsub('/', '--')
14
+ actor_name = "#{component_name}Actor"
15
+ files = [
16
+ {
17
+ name: "#{component_name.underscore}.rb",
18
+ content: "
19
+ class #{component_ns_camelized}::#{component_name} < ViewComponent::Base
20
+ include Birdel::Component
21
+ end
22
+ "
23
+ },
24
+ { name: "#{component_name.underscore}.css", content: ".#{css_class}{}" },
25
+ { name: "#{component_name.underscore}.js", content: "" },
26
+ {
27
+ name: "#{component_name.underscore}_controller.js",
28
+ content: "
29
+ import { #{actor_name} } from \"./#{component_name.underscore}_actor\";
30
+ import { Controller } from \"@hotwired/stimulus\";
31
+ export default class extends Controller {
32
+ connect() {}
33
+ }
34
+ " },
35
+ {
36
+ name: "#{component_name.underscore}_actor.js",
37
+ content: "
38
+ import { ActorBase } from \"birdeljs\"
39
+ export class #{actor_name} extends ActorBase {
40
+ constructor() {
41
+ console.log(\"#{actor_name}!\");
42
+ }
43
+ }
44
+ "},
45
+ { name: "#{component_name.underscore}.html.erb", content: "<div class=\"<%= #{variable_name} %>\" data-controller=\"<%= #{variable_name} %>\">\n</div>" },
46
+ ]
47
+
48
+ files.each do |file|
49
+ file_path = full_component_path.join(file[:name])
50
+ if file_path.exist?
51
+ puts "File already exists: #{file_path}".red
52
+ else
53
+ puts "Creating file: #{file_path}".yellow
54
+ #create new file and folders if needed
55
+ file_path.dirname.mkpath
56
+ File.open(file_path, "w") do |f|
57
+ f.puts file[:content]
58
+ end
59
+ if file_path.exist?
60
+ puts "Done!".bold.green
61
+ else
62
+ puts "Failed".red
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,7 @@
1
+ module Birdel
2
+ module Component
3
+ def css_class
4
+ self.class.name.underscore.gsub('_', '-').gsub('/', '--').split('--')[0..-2].join('--')
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,116 @@
1
+
2
+ module Birdel
3
+ module Map
4
+ def roll(entry_ns)
5
+ myapp_path = Pathname.new("#{Dir.pwd}")
6
+ stylesheets_path = myapp_path.join("app", "assets", "stylesheets")
7
+ javascript_path = myapp_path.join("app", "javascript")
8
+ layouts_path = myapp_path.join("app", "views", "layouts")
9
+ css_bentries_path = stylesheets_path.join("ui", "bentries")
10
+ js_bentries_path = javascript_path.join("ui", "bentries")
11
+ layouts_bentries_path = layouts_path.join("ui", "bentries")
12
+
13
+ entry_ns_camelized = entry_ns.split("::").map(&:camelize).join("::")
14
+ entry_name = entry_ns_camelized.split("::").last
15
+ entry_path = entry_ns.split("::").join("/")
16
+
17
+ full_css_entry_path = css_bentries_path.join(entry_path.underscore)
18
+ full_js_entry_path = js_bentries_path.join(entry_path.underscore)
19
+ full_layout_entry_path = layouts_bentries_path.join(entry_path.underscore)
20
+
21
+ if full_css_entry_path.exist?
22
+ puts "Entry #{full_css_entry_path.relative_path_from(myapp_path)} already exists".red.bold
23
+ else
24
+ full_css_entry_path.mkpath
25
+ css_entry_files = [
26
+ { name: "components.css", content: "" },
27
+ { name: "components.css.json", content: "[]" },
28
+ { name: "precomponents.css", content: "" },
29
+ { name: "precomponents.css.json", content: "[]" },
30
+ { name: "index.css", content: "@import url(\"./components.css\");" },
31
+ ]
32
+ css_entry_files.each do |file|
33
+ if full_css_entry_path.join(file[:name]).exist?
34
+ puts "File #{full_css_entry_path.join(file[:name]).relative_path_from(myapp_path)} already exists".red.bold
35
+ else
36
+ puts full_css_entry_path.join(file[:name]).to_s.green.bold
37
+ full_css_entry_path.join(file[:name]).open("w") do |f|
38
+ f.write(file[:content])
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ if full_js_entry_path.exist?
45
+ puts "Entry #{full_js_entry_path.relative_path_from(myapp_path)} already exists".red.bold
46
+ else
47
+ full_js_entry_path.mkpath
48
+ js_entry_files = [
49
+ { name: "components.js", content: "" },
50
+ { name: "components.js.json", content: "[]" },
51
+ { name: "precomponents.js", content: "" },
52
+ { name: "precomponents.js.json", content: "[]" },
53
+ { name: "index.js", content: "import \"./components\";"},
54
+ ]
55
+ js_entry_files.each do |file|
56
+ if full_js_entry_path.join(file[:name]).exist?
57
+ puts "File #{full_js_entry_path.join(file[:name]).relative_path_from(myapp_path)} already exists".red.bold
58
+ else
59
+ puts "+ #{full_js_entry_path.join(file[:name]).relative_path_from(myapp_path).to_s}".green.bold
60
+ full_js_entry_path.join(file[:name]).open("w") do |f|
61
+ f.write(file[:content])
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ css_index_path = full_css_entry_path.join("index.css").relative_path_from(stylesheets_path)
68
+ js_index_path = full_js_entry_path.join("index.js").relative_path_from(javascript_path)
69
+
70
+ js_index_directory_path = js_index_path.dirname.to_s
71
+ js_index_filename_without_extension = js_index_path.basename('.js').to_s
72
+ js_index_formatted_path = "#{js_index_directory_path}/#{js_index_filename_without_extension}"
73
+
74
+ css_index_directory_path = css_index_path.dirname.to_s
75
+ css_index_filename_without_extension = css_index_path.basename('.css').to_s
76
+ css_index_formatted_path = "#{css_index_directory_path}/#{css_index_filename_without_extension}"
77
+
78
+
79
+ if full_layout_entry_path.exist?
80
+ puts "Entry #{full_layout_entry_path.relative_path_from(myapp_path)} already exists".red.bold
81
+ else
82
+ full_layout_entry_path.mkpath
83
+ layout_entry_files = [
84
+ { name: "index.html.erb", content: "
85
+ <!DOCTYPE html>
86
+ <html>
87
+ <head>
88
+ <meta name=\"viewport\" content=\"width=device-width,initial-scale=1, maximum-scale=1.0, user-scalable=no\" >
89
+ <%= action_cable_meta_tag %>
90
+ <%= csrf_meta_tags %>
91
+ <%= csp_meta_tag %>
92
+ <%= display_meta_tags %>
93
+ <%= stylesheet_link_tag \"#{css_index_formatted_path}\", \"data-turbo-track\": \"reload\" %>
94
+ <%= javascript_include_tag \"#{js_index_formatted_path}\", \"data-turbo-track\": \"reload\", defer: true, type: \"module\" %>
95
+ </head>
96
+
97
+ <body>
98
+ <%= yield %>
99
+ </body>
100
+ </html>
101
+ " },
102
+ ]
103
+ layout_entry_files.each do |file|
104
+ if full_layout_entry_path.join(file[:name]).exist?
105
+ puts "File #{full_layout_entry_path.join(file[:name]).relative_path_from(myapp_path)} already exists".red.bold
106
+ else
107
+ puts "+ #{full_layout_entry_path.join(file[:name]).relative_path_from(myapp_path).to_s}".green.bold
108
+ full_layout_entry_path.join(file[:name]).open("w") do |f|
109
+ f.write(file[:content])
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
@@ -48,7 +48,7 @@ module Birdel
48
48
  }
49
49
  }
50
50
  res[:callback] = callback
51
- res[:callback][:resourceId] = method_res[:resource_id] if method_res[:resource_id]
51
+ res[:callback][:resourceId] = callback[:resource_id]
52
52
  ActionCable.server.broadcast(self.first_stream, res)
53
53
  end
54
54
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Birdel
4
- VERSION = "0.3.3"
4
+ VERSION = "1.1.0"
5
5
  end
data/lib/birdel.rb CHANGED
@@ -5,16 +5,13 @@ require 'colored'
5
5
  require 'active_support/inflector'
6
6
 
7
7
  require_relative "birdel/version"
8
- # require_relative "birdel/com/com"
9
- # require_relative "birdel/map/map"
10
8
  require_relative "birdel/rona/rona_actor"
11
9
  require_relative "birdel/synth/synth_actor"
12
-
10
+ require_relative "birdel/com/com_actor"
11
+ require_relative "birdel/map/map_actor"
12
+ require_relative "birdel/component/component_actor"
13
13
  module Birdel
14
14
  class Error < StandardError; end
15
15
  class << self
16
- def test1
17
- puts "Birdel is a gem for sending messages to your actors and getting view_components back!"
18
- end
19
16
  end
20
17
  end
metadata CHANGED
@@ -1,20 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: birdel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serhii
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-03 00:00:00.000000000 Z
11
+ date: 2023-05-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Send json messages to your actors and get view_components back! Now you
14
14
  can be sure that your actors are processed correctly.
15
15
  email:
16
16
  - serhii.jun@gmail.com
17
- executables: []
17
+ executables:
18
+ - birdel
18
19
  extensions: []
19
20
  extra_rdoc_files: []
20
21
  files:
@@ -27,10 +28,13 @@ files:
27
28
  - LICENSE.txt
28
29
  - README.md
29
30
  - Rakefile
31
+ - bin/birdel
30
32
  - esbuild.config.js
31
33
  - lib/birdel.rb
32
- - lib/birdel/com/com.rb
33
- - lib/birdel/map/map.rb
34
+ - lib/birdel/cli.rb
35
+ - lib/birdel/com/com_actor.rb
36
+ - lib/birdel/component/component_actor.rb
37
+ - lib/birdel/map/map_actor.rb
34
38
  - lib/birdel/rona/rona_actor.rb
35
39
  - lib/birdel/synth/synth_actor.rb
36
40
  - lib/birdel/version.rb
@@ -1,63 +0,0 @@
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
@@ -1,118 +0,0 @@
1
-
2
- class Birdel::Map
3
- def initialize
4
- end
5
-
6
- def roll
7
- myapp_path = Pathname.new("#{Dir.pwd}")
8
- stylesheets_path = myapp_path.join("app", "assets", "stylesheets")
9
- javascript_path = myapp_path.join("app", "javascript")
10
- layouts_path = myapp_path.join("app", "views", "layouts")
11
- css_bentries_path = stylesheets_path.join("ui", "bentries")
12
- js_bentries_path = javascript_path.join("ui", "bentries")
13
- layouts_bentries_path = layouts_path.join("ui", "bentries")
14
-
15
- entry_ns = ARGV[0]
16
- entry_ns_camelized = entry_ns.split("::").map(&:camelize).join("::")
17
- entry_name = entry_ns_camelized.split("::").last
18
- entry_path = entry_ns.split("::").join("/")
19
-
20
- full_css_entry_path = css_bentries_path.join(entry_path.underscore)
21
- full_js_entry_path = js_bentries_path.join(entry_path.underscore)
22
- full_layout_entry_path = layouts_bentries_path.join(entry_path.underscore)
23
-
24
- if full_css_entry_path.exist?
25
- puts "Entry #{full_css_entry_path.relative_path_from(myapp_path)} already exists".red.bold
26
- else
27
- full_css_entry_path.mkpath
28
- css_entry_files = [
29
- { name: "components.css", content: "" },
30
- { name: "components.css.json", content: "[]" },
31
- { name: "precomponents.css", content: "" },
32
- { name: "precomponents.css.json", content: "[]" },
33
- { name: "index.css", content: "@import url(\"./components.css\");" },
34
- ]
35
- css_entry_files.each do |file|
36
- if full_css_entry_path.join(file[:name]).exist?
37
- puts "File #{full_css_entry_path.join(file[:name]).relative_path_from(myapp_path)} already exists".red.bold
38
- else
39
- puts full_css_entry_path.join(file[:name]).to_s.green.bold
40
- full_css_entry_path.join(file[:name]).open("w") do |f|
41
- f.write(file[:content])
42
- end
43
- end
44
- end
45
- end
46
-
47
- if full_js_entry_path.exist?
48
- puts "Entry #{full_js_entry_path.relative_path_from(myapp_path)} already exists".red.bold
49
- else
50
- full_js_entry_path.mkpath
51
- js_entry_files = [
52
- { name: "components.js", content: "" },
53
- { name: "components.js.json", content: "[]" },
54
- { name: "precomponents.js", content: "" },
55
- { name: "precomponents.js.json", content: "[]" },
56
- { name: "index.js", content: "import \"./components\";"},
57
- ]
58
- js_entry_files.each do |file|
59
- if full_js_entry_path.join(file[:name]).exist?
60
- puts "File #{full_js_entry_path.join(file[:name]).relative_path_from(myapp_path)} already exists".red.bold
61
- else
62
- puts "+ #{full_js_entry_path.join(file[:name]).relative_path_from(myapp_path).to_s}".green.bold
63
- full_js_entry_path.join(file[:name]).open("w") do |f|
64
- f.write(file[:content])
65
- end
66
- end
67
- end
68
- end
69
-
70
- css_index_path = full_css_entry_path.join("index.css").relative_path_from(stylesheets_path)
71
- js_index_path = full_js_entry_path.join("index.js").relative_path_from(javascript_path)
72
-
73
- js_index_directory_path = js_index_path.dirname.to_s
74
- js_index_filename_without_extension = js_index_path.basename('.js').to_s
75
- js_index_formatted_path = "#{js_index_directory_path}/#{js_index_filename_without_extension}"
76
-
77
- css_index_directory_path = css_index_path.dirname.to_s
78
- css_index_filename_without_extension = css_index_path.basename('.css').to_s
79
- css_index_formatted_path = "#{css_index_directory_path}/#{css_index_filename_without_extension}"
80
-
81
-
82
- if full_layout_entry_path.exist?
83
- puts "Entry #{full_layout_entry_path.relative_path_from(myapp_path)} already exists".red.bold
84
- else
85
- full_layout_entry_path.mkpath
86
- layout_entry_files = [
87
- { name: "index.html.erb", content: "
88
- <!DOCTYPE html>
89
- <html>
90
- <head>
91
- <meta name=\"viewport\" content=\"width=device-width,initial-scale=1, maximum-scale=1.0, user-scalable=no\" >
92
- <%= action_cable_meta_tag %>
93
- <%= csrf_meta_tags %>
94
- <%= csp_meta_tag %>
95
- <%= display_meta_tags %>
96
- <%= stylesheet_link_tag \"#{css_index_formatted_path}\", \"data-turbo-track\": \"reload\" %>
97
- <%= javascript_include_tag \"#{js_index_formatted_path}\", \"data-turbo-track\": \"reload\", defer: true, type: \"module\" %>
98
- </head>
99
-
100
- <body>
101
- <%= yield %>
102
- </body>
103
- </html>
104
- " },
105
- ]
106
- layout_entry_files.each do |file|
107
- if full_layout_entry_path.join(file[:name]).exist?
108
- puts "File #{full_layout_entry_path.join(file[:name]).relative_path_from(myapp_path)} already exists".red.bold
109
- else
110
- puts "+ #{full_layout_entry_path.join(file[:name]).relative_path_from(myapp_path).to_s}".green.bold
111
- full_layout_entry_path.join(file[:name]).open("w") do |f|
112
- f.write(file[:content])
113
- end
114
- end
115
- end
116
- end
117
- end
118
- end