rails_view_component 0.0.2 → 0.0.3

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
  SHA1:
3
- metadata.gz: 809d813dc621a89b1e749b28f5715666f03c421d
4
- data.tar.gz: 1e4a24a3c781c60ddfdbb2982208fa7560967ec3
3
+ metadata.gz: fa29f991d3bacd5e0360e5d915e386db1eae7a71
4
+ data.tar.gz: a37ecdb501734e7e73353ef82f995a5b9e4b7d34
5
5
  SHA512:
6
- metadata.gz: e99531e3bcba4e2794965ebb201c089b1aa391c602d4900915e283f797725be7a8b58d16b4e04269378cc513d6113c1a212a5204b0147f16b01d9f279501307e
7
- data.tar.gz: 28a7a07dd203128bf9e48340d3399a7ad916f43e2b1ee5c6a562be4374ed48698bf0b2d280bf2dce036c78ae7c4f5c0d396e25ce2ef8447d649fa8771e12d427
6
+ metadata.gz: a9aeee402c1608b1d03b3a87e59e88a5445ef5b41cd436f4c35e05c00d0d32db70f2e23bd3e728b03233b4ed7c65521be916aa1886750bb06adcf7dd687f39ef
7
+ data.tar.gz: e7263fc15c1fb1e4bf178c871a4c64d2fd69cdb0c9bd91b791c845fa6f78b1a871cd4c93a998cc12b48d3212a029341563e6732cb30a063bd8664867d7481ef1
@@ -0,0 +1,19 @@
1
+ module RailsViewComponent
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ source_root File.expand_path('../templates', __FILE__)
6
+ def copy
7
+ %w( view_component/view_component_builder.rb
8
+ view_component/view_component_helper.rb
9
+ view_component/view_component_model.rb
10
+ view_component/haxe/ViewComponent.hx
11
+ ).each{|file|
12
+ copy_file file, "lib/#{file}"
13
+ }
14
+ copy_file "haxe_compile.hxml", "hax_compile.hxml"
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -1,43 +1,35 @@
1
- class RailsViewComponentGenerator < Rails::Generators::NamedBase
2
- source_root File.expand_path('../templates', __FILE__)
3
1
 
4
- desc "This generator creates RailsViewComponent files."
2
+ module RailsViewComponent
3
+ module Generators
4
+ class RailsViewComponentGenerator < Rails::Generators::NamedBase
5
+
6
+ source_root File.expand_path('../templates', __FILE__)
5
7
 
6
- def create_rails_view_component_file
7
- gname, cmd = name.split(":")
8
- if cmd == "install"
9
- %w( view_component/view_component_builder.rb
10
- view_component/view_component_helper.rb
11
- view_component/view_component_model.rb
12
- view_component/haxe/ViewComponent.hx
13
- ).each{|file|
14
- copy_file file, "lib/#{file}"
15
- }
16
- copy_file "haxe_compile.hxml", "hax_compile.hxml"
17
-
18
- else
19
- copy_and_compile = ->(from, to){
20
- root = File.expand_path("../", __FILE__)
21
- erb = ERB.new(open("#{root}/erb/#{from}").read)
22
- @class_name = class_name
23
- @file_name = file_name
24
- @args = args
25
- create_file "app/rails_view_components/#{file_name}/#{to}",
26
- erb.result(binding)
27
- }
8
+ desc "This generator creates RailsViewComponent files."
9
+
10
+ def create_rails_view_component_file
11
+ copy_and_compile = ->(from, to){
12
+ root = File.expand_path("../", __FILE__)
13
+ erb = ERB.new(open("#{root}/erb/#{from}").read)
14
+ @class_name = class_name
15
+ @file_name = file_name
16
+ @args = args
17
+ create_file "app/rails_view_components/#{file_name}/#{to}",
18
+ erb.result(binding)
19
+ }
28
20
 
29
- copy_and_compile.call("controller.rb.erb", "#{file_name}_controller.rb")
30
- copy_and_compile.call("model.rb.erb", "#{file_name}_model.rb")
31
- copy_and_compile.call("routes.rb.erb", "routes.rb")
32
- copy_and_compile.call("views/rails_view_component.html.erb.erb",
21
+ copy_and_compile.call("controller.rb.erb", "#{file_name}_controller.rb")
22
+ copy_and_compile.call("model.rb.erb", "#{file_name}_model.rb")
23
+ copy_and_compile.call("routes.rb.erb", "routes.rb")
24
+ copy_and_compile.call("views/rails_view_component.html.erb.erb",
33
25
  "views/#{file_name}_view_component.html.erb")
34
- copy_and_compile.call("haxe/RailsViewComponent.hx.erb",
26
+ copy_and_compile.call("haxe/RailsViewComponent.hx.erb",
35
27
  "haxe/#{class_name}ViewComponent.hx")
36
28
 
37
- route "#{class_name}::Routes.routings"
29
+ route "#{class_name}::Routes.routings"
38
30
 
39
- inject_into_file "haxe_compile.hxml",
40
- after: "## RailsViewComponent JavaScripts\n" do <<RUBY
31
+ inject_into_file "haxe_compile.hxml",
32
+ after: "## RailsViewComponent JavaScripts\n" do <<RUBY
41
33
  --next
42
34
  # #{@class_name}
43
35
  -lib JQueryExtern
@@ -47,7 +39,8 @@ class RailsViewComponentGenerator < Rails::Generators::NamedBase
47
39
  -js public/javascripts/#{@file_name}_view_component.js
48
40
 
49
41
  RUBY
50
- end
42
+ end
43
+ end
51
44
  end
52
- end
45
+ end
53
46
  end
@@ -1,3 +1,3 @@
1
1
  module RailsViewComponent
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_view_component
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takeshi Kojima
@@ -40,6 +40,7 @@ files:
40
40
  - lib/generators/rails_view_component/erb/model.rb.erb
41
41
  - lib/generators/rails_view_component/erb/routes.rb.erb
42
42
  - lib/generators/rails_view_component/erb/views/rails_view_component.html.erb.erb
43
+ - lib/generators/rails_view_component/install_generator.rb
43
44
  - lib/generators/rails_view_component/rails_view_component_generator.rb
44
45
  - lib/generators/rails_view_component/templates/haxe_compile.hxml
45
46
  - lib/generators/rails_view_component/templates/view_component/haxe/ViewComponent.hx