rails_view_component 0.0.5 → 1.0.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 (91) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/rails_view_component/erb/controller.rb.erb +2 -2
  3. data/lib/generators/rails_view_component/erb/haxe/RailsViewComponent.hx.erb +18 -15
  4. data/lib/generators/rails_view_component/erb/model.rb.erb +2 -2
  5. data/lib/generators/rails_view_component/erb/routes.rb.erb +2 -2
  6. data/lib/generators/rails_view_component/install_generator.rb +17 -2
  7. data/lib/generators/rails_view_component/rails_view_component_generator.rb +25 -18
  8. data/lib/generators/rails_view_component/templates/RailsViewComponent.hx +60 -17
  9. data/lib/generators/rails_view_component/templates/rails_view_component_builder.rb +4 -2
  10. data/lib/generators/rails_view_component/templates/rails_view_component_helper.rb +2 -2
  11. data/lib/generators/rails_view_component/templates/rails_view_component_model.rb +8 -6
  12. data/lib/rails_view_component/version.rb +1 -1
  13. data/test/rails_view_component_test/Gemfile +47 -0
  14. data/test/rails_view_component_test/Gemfile.lock +171 -0
  15. data/test/{dummy → rails_view_component_test}/README.rdoc +0 -0
  16. data/test/{dummy → rails_view_component_test}/Rakefile +0 -0
  17. data/test/{dummy → rails_view_component_test}/app/assets/javascripts/application.js +3 -0
  18. data/test/rails_view_component_test/app/assets/javascripts/top.coffee +3 -0
  19. data/test/{dummy → rails_view_component_test}/app/assets/stylesheets/application.css +0 -0
  20. data/test/rails_view_component_test/app/assets/stylesheets/top.scss +3 -0
  21. data/test/{dummy → rails_view_component_test}/app/controllers/application_controller.rb +0 -0
  22. data/test/rails_view_component_test/app/controllers/top_controller.rb +4 -0
  23. data/test/{dummy → rails_view_component_test}/app/helpers/application_helper.rb +0 -0
  24. data/test/rails_view_component_test/app/helpers/top_helper.rb +2 -0
  25. data/test/{dummy → rails_view_component_test}/app/views/layouts/application.html.erb +1 -1
  26. data/test/rails_view_component_test/app/views/top/index.html.erb +8 -0
  27. data/test/{dummy → rails_view_component_test}/bin/bundle +0 -0
  28. data/test/{dummy → rails_view_component_test}/bin/rails +4 -0
  29. data/test/{dummy → rails_view_component_test}/bin/rake +4 -0
  30. data/test/{dummy → rails_view_component_test}/bin/setup +0 -0
  31. data/test/rails_view_component_test/bin/spring +18 -0
  32. data/test/{dummy → rails_view_component_test}/config/application.rb +5 -3
  33. data/test/rails_view_component_test/config/boot.rb +3 -0
  34. data/test/{dummy → rails_view_component_test}/config/database.yml +0 -0
  35. data/test/{dummy → rails_view_component_test}/config/environment.rb +0 -0
  36. data/test/{dummy → rails_view_component_test}/config/environments/development.rb +0 -0
  37. data/test/{dummy → rails_view_component_test}/config/environments/production.rb +0 -0
  38. data/test/{dummy → rails_view_component_test}/config/environments/test.rb +0 -0
  39. data/test/{dummy → rails_view_component_test}/config/initializers/assets.rb +0 -0
  40. data/test/{dummy → rails_view_component_test}/config/initializers/backtrace_silencers.rb +0 -0
  41. data/test/{dummy → rails_view_component_test}/config/initializers/cookies_serializer.rb +0 -0
  42. data/test/{dummy → rails_view_component_test}/config/initializers/filter_parameter_logging.rb +0 -0
  43. data/test/{dummy → rails_view_component_test}/config/initializers/inflections.rb +0 -0
  44. data/test/{dummy → rails_view_component_test}/config/initializers/mime_types.rb +0 -0
  45. data/test/rails_view_component_test/config/initializers/session_store.rb +3 -0
  46. data/test/{dummy → rails_view_component_test}/config/initializers/wrap_parameters.rb +0 -0
  47. data/test/{dummy → rails_view_component_test}/config/locales/en.yml +0 -0
  48. data/test/{dummy → rails_view_component_test}/config/routes.rb +2 -0
  49. data/test/{dummy → rails_view_component_test}/config/secrets.yml +2 -2
  50. data/test/{dummy → rails_view_component_test}/config.ru +0 -0
  51. data/test/{dummy/db/test.sqlite3 → rails_view_component_test/db/development.sqlite3} +0 -0
  52. data/test/rails_view_component_test/db/seeds.rb +7 -0
  53. data/test/rails_view_component_test/log/development.log +3858 -0
  54. data/test/{dummy → rails_view_component_test}/public/404.html +0 -0
  55. data/test/{dummy → rails_view_component_test}/public/422.html +0 -0
  56. data/test/{dummy → rails_view_component_test}/public/500.html +0 -0
  57. data/test/{dummy → rails_view_component_test}/public/favicon.ico +0 -0
  58. data/test/rails_view_component_test/public/robots.txt +5 -0
  59. data/test/rails_view_component_test/test/controllers/top_controller_test.rb +9 -0
  60. data/test/rails_view_component_test/test/test_helper.rb +10 -0
  61. data/test/rails_view_component_test/tmp/cache/assets/development/sass/67c9b54d35a5ee282bb7db2d8f62e5182a4981b4/top.scssc +0 -0
  62. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  63. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/144480218666373c17378e01c880a73e +0 -0
  64. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/18d2cbb0f2269d20680f775d08981e72 +0 -0
  65. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  66. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/34226a9205e8dd111f3fd667140e3557 +0 -0
  67. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  68. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/55775c8c8fb4940e0575e4087043324a +0 -0
  69. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/69a055f006179beba2a830d88e39fa88 +0 -0
  70. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/7c6e5314d519217e99ce56f93eacb7ca +0 -0
  71. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/82ac2910cee5ad83240253d81fd60ad8 +0 -0
  72. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/86d34baf8dfb1e16ed00123e1e2a2190 +0 -0
  73. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/9c1b6c9edc5c7d33d390964b955748a8 +0 -0
  74. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/a69a6a0e8b2413a18e01dcc9e07b7263 +0 -0
  75. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/ccf10475f5be0d54da1c2c223b3fca5d +0 -0
  76. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/cdf84c819e9ef95e6edb7a5d36549ca4 +0 -0
  77. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  78. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  79. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/f4779bd843bfdc90d8c4fe47fcfc5c02 +0 -0
  80. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  81. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/fe9f4bf7a4d033c8ec226c659ceba27e +0 -0
  82. data/test/rails_view_component_test/tmp/cache/assets/development/sprockets/ffa538b8e1d908ed228e70f373c3aa00 +0 -0
  83. data/test/rails_view_component_test/tmp/pids/server.pid +1 -0
  84. metadata +155 -89
  85. data/lib/rails_view_component/haxe/RailsViewComponent.hx +0 -26
  86. data/lib/rails_view_component/rails_view_component_builder.rb +0 -31
  87. data/lib/rails_view_component/rails_view_component_helper.rb +0 -14
  88. data/lib/rails_view_component/rails_view_component_model.rb +0 -30
  89. data/test/dummy/config/boot.rb +0 -5
  90. data/test/dummy/config/initializers/session_store.rb +0 -3
  91. data/test/dummy/log/test.log +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: abb27a87197e92c1ae57eeae4da0d052f1fd8131
4
- data.tar.gz: 32e3aa3a6ff56a5feaa32506d67e0c13e4701e96
3
+ metadata.gz: 2393b5e56e4851de5e4be5eefc3853f449971025
4
+ data.tar.gz: bd0494e571ee2ea7553e193563d8cffb36972379
5
5
  SHA512:
6
- metadata.gz: 1dd3fcb552e5ab1da54c3078135c5b1ea0b602576e9dbd6c7e62c5ee341bda1ad043869afd5a94f2e8557693d2cc3b36228689a4631529ad16b1b832f3b2de08
7
- data.tar.gz: ebc8610bfb432dabd11a5fdbb97cdf2ba26927414b525cae37d8f4939ea4a4cf2890cd19de996afffedb0161eb961801ee7c3dd18339e82ec8de20481bee0919
6
+ metadata.gz: 48023c68a7a9a51785f81928e58237969de5db51a43bddd9756436dc730d5a821c14ac7f4b845a009a003fa2febd27095ece387a78189e500626bc70f2654f02
7
+ data.tar.gz: af7e80820c8c2694329b641030f11df2d13da7bfcbbf444a51f976de8c00747525b4ff024d99dc308bbe6de1c81fd2a07528e4191f66f08baaba1f5b5fce0108
@@ -1,5 +1,5 @@
1
- class <%= @class_name %>::<%= @class_name%>Controller < ApplicationController
2
- <% @args.each do |name| %>
1
+ class <%= @class_name%>Controller < ApplicationController
2
+ <% @args.map{|arg|arg.split(':')}.each do |name,method| %>
3
3
  def <%= name %>
4
4
  render json: { result: "success",
5
5
  message: "returned from <%= @class_name %>.<%= name %>" }
@@ -1,23 +1,26 @@
1
1
  import jQuery.*;
2
2
 
3
- class <%= @class_name %>ViewComponent extends RailsViewComponent {
4
- public static function eachComponent(klass:String,
5
- f:RailsViewComponent->String->JQuery->Dynamic->Void){
6
- var dom = new JQuery("."+klass+"_view_component");
7
- dom.each(function(i,e){
8
- var d = new JQuery(e);
9
- var id = d.attr("id");
10
- var params = d.data();
11
- var com = new <%= @class_name %>ViewComponent(klass);
12
- f(com, id,d,params);
13
- });
3
+ class <%= @haxe_class_name %> extends RailsViewComponent {
4
+ public static function main(){
5
+ RailsViewComponent.start("<%= @file_path %>");
14
6
  }
15
7
 
16
- public static function main(){
17
- eachComponent("<%= @file_name %>", function(com, id, dom, params){
18
-
19
- /// TODO
8
+ public override function onLoad(){
20
9
 
10
+ <% @args.map{|arg|arg.split(":")}.each do |name,method| %>
11
+ // <%= route = "#{name}@#{method}" %>
12
+ addCallback("<%= route %>", function(data){
13
+ /// TODO
14
+ this.getDOM().html("<%= route%>:" + data.message);
21
15
  });
16
+ <% end %>
17
+
18
+
19
+ <% @args.map{|arg|arg.split(":")}.each.with_index do |(name,method), i| %>
20
+ <%= "// " if i > 0 %>sendAsync("<%= "#{name}@#{method}" %>", {} );
21
+ <% end %>
22
22
  }
23
23
  }
24
+
25
+
26
+
@@ -1,10 +1,10 @@
1
- class <%= @class_name %>::<%= @class_name %>Model < RailsViewComponent::RailsViewComponentModel
1
+ class <%= @class_name %>Model < RailsViewComponentModel
2
2
  def erb_script
3
3
  "<%= @file_name %>_view_component.html.erb"
4
4
  end
5
5
 
6
6
  def javascripts
7
- ["/javascripts/<%= @file_name %>_view_component.js"]
7
+ ["/javascripts/<%= @haxe_js_name %>"]
8
8
  end
9
9
  def stylesheets
10
10
  []
@@ -1,8 +1,8 @@
1
- class <%= @class_name %>::Routes
1
+ class <%= @class_name %>Routes
2
2
  def self.routings
3
3
 
4
4
  Rails.application.routes.draw do
5
- scope "rails_view_component/<%= @file_name %>", module: :<%= @file_name %> do
5
+ scope "rails_view_component/<%= @file_path %>", module: "<%= @file_path %>" do
6
6
  <% @args.map{|arg|arg.split(":")}.each do |name,method| %>
7
7
  <%= method || "post" %> "<%= name %>" => "<%= @file_name %>#<%= name %>"
8
8
  <% end %>
@@ -14,8 +14,23 @@ module RailsViewComponent
14
14
  }.each{|file,dir|
15
15
  copy_file file, "#{dir}/#{file}"
16
16
  }
17
- `mkdir public/javascripts`
18
- `mkdir public/stylesheets`
17
+
18
+ inject_into_file "app/helpers/application_helper.rb",
19
+ after: "module ApplicationHelper\n" do <<RUBY
20
+ include RailsViewComponentHelper
21
+ RUBY
22
+ end
23
+
24
+ inject_into_file "config/application.rb",
25
+ after: "class Application < Rails::Application\n" do <<RUBY
26
+ config.autoload_paths += [
27
+ "\#{config.root}/app/rails_view_components",
28
+ "\#{config.root}/lib/rails_view_component",
29
+ ]
30
+
31
+ RUBY
32
+ end
33
+
19
34
  end
20
35
 
21
36
  end
@@ -8,38 +8,45 @@ module RailsViewComponent
8
8
  desc "This generator creates RailsViewComponent files."
9
9
 
10
10
  def create_rails_view_component_file
11
+
12
+ puts @dir = "app/rails_view_components/#{file_path}"
13
+ puts @haxe_dir = "#{@dir}/haxe"
14
+ puts @haxe_class_name = "#{@file_name.camelize}ViewComponent"
15
+ puts @haxe_file_name = "#{@haxe_dir}/#{@haxe_class_name}.hx"
16
+ puts @haxe_js_name = "#{@file_path.gsub("/",".")}_view_component.js"
17
+ @file_path
18
+ @file_name = file_name
19
+ @class_name = "#{class_name}::#{class_name.split('::').last}"
20
+ @args = args
21
+
11
22
  copy_and_compile = ->(from, to){
12
23
  root = File.expand_path("../", __FILE__)
13
24
  erb = ERB.new(open("#{root}/erb/#{from}").read)
14
- @class_name = class_name.split("::").last
15
- @file_name = file_name
16
- @args = args
17
- create_file "app/rails_view_components/#{file_name}/#{to}",
18
- erb.result(binding)
25
+ create_file to, erb.result(binding)
19
26
  }
20
27
 
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")
28
+
29
+ copy_and_compile.call("controller.rb.erb", "#{@dir}/#{@file_name}_controller.rb")
30
+ copy_and_compile.call("model.rb.erb", "#{@dir}/#{@file_name}_model.rb")
31
+ copy_and_compile.call("routes.rb.erb", "#{@dir}/#{@file_name}_routes.rb")
24
32
  copy_and_compile.call("views/rails_view_component.html.erb.erb",
25
- "views/#{file_name}_view_component.html.erb")
26
- copy_and_compile.call("haxe/RailsViewComponent.hx.erb",
27
- "haxe/#{@class_name}ViewComponent.hx")
28
-
29
- route "#{@class_name}::Routes.routings"
33
+ "#{@dir}/views/#{@file_name}_view_component.html.erb")
34
+ copy_and_compile.call("haxe/RailsViewComponent.hx.erb", @haxe_file_name)
30
35
 
31
36
  inject_into_file "haxe_compile.hxml",
32
- after: "## RailsViewComponent JavaScripts\n" do <<RUBY
37
+ after: "## RailsViewComponent JavaScripts\n" do
38
+ <<RUBY
33
39
  --next
34
- # #{@class_name}
40
+ # #{@haxe_dir}/#{@haxe_class_name}
35
41
  -lib JQueryExtern
36
42
  -cp lib/rails_view_component/haxe
37
- -cp app/rails_view_components/#{@file_name}/haxe
38
- -main #{@class_name}ViewComponent
39
- -js public/javascripts/#{@file_name}_view_component.js
43
+ -cp #{@haxe_dir}
44
+ -main #{@haxe_class_name}
45
+ -js public/javascripts/#{@haxe_js_name}
40
46
 
41
47
  RUBY
42
48
  end
49
+ route "#{@class_name}Routes.routings"
43
50
  end
44
51
  end
45
52
  end
@@ -1,25 +1,68 @@
1
1
  import jQuery.*;
2
2
 
3
- class RailsViewComponent{
4
- public var callbacks = new Map<String, Dynamic->Dynamic->Dynamic->Void>();
5
- public function addCallback(method:String, fun:Dynamic->Dynamic->Dynamic->Void){
6
- this.callbacks.set(method, fun);
3
+ typedef AsyncCallback = Dynamic -> Void
4
+
5
+ class RailsViewComponent {
6
+ public static var com_name : String;
7
+
8
+ public static function start(name, ?pos:haxe.PosInfos){
9
+ com_name = name;
10
+ var klass = Type.resolveClass(pos.className);
11
+ var class_name = StringTools.replace(name, "/", "-");
12
+ var coms = new JQuery(".rails_view_component-"+class_name);
13
+ for(com in coms){
14
+ var id = new JQuery(com).attr("id");
15
+ var c = Type.createInstance(klass, [id]);
16
+ c.onLoad();
17
+ }
7
18
  }
8
- private var componentName : String;
9
- public function new(name:String){
10
- this.componentName = name;
19
+
20
+ public function onLoad(){}
21
+
22
+ private var id : String;
23
+ private var dom : JQuery;
24
+ private var callbacks = new Map<String, Array<AsyncCallback>>();
25
+
26
+ public function new(id : String){
27
+ this.id = id;
28
+ this.dom = new JQuery("#"+id);
11
29
  }
12
- public function sendRequest(method:String, params){
13
- JQueryStatic.post(
14
- "/rails_view_component/"+ this.componentName +"/"+ method,
15
- params,
16
- function(data, status, xhr){
17
- var func = this.callbacks.get(method);
18
- if(func != null){ func(data, status, xhr); }
19
- }).fail(function(e){
20
- trace("ERROR:"+e);
21
- });
30
+
31
+ public function getId(){ return this.id;}
32
+ public function getDOM(){ return this.dom; }
33
+
34
+ public function addCallback(route:String, func:AsyncCallback){
35
+ if(!this.callbacks.exists(route)){
36
+ this.callbacks.set(route, new Array<AsyncCallback>());
37
+ }
38
+ this.callbacks.get(route).push(func);
39
+ }
40
+ private function callCallback(route:String, data:Dynamic){
41
+ if(this.callbacks.exists(route)){
42
+ for(func in this.callbacks.get(route)){
43
+ func(data);
44
+ }
45
+ }
22
46
  }
47
+
48
+ public function sendAsync(route:String, params:Dynamic){
49
+ var xs = route.split("@");
50
+ var action = xs[0];
51
+ var method = xs[1];
52
+ var url = "/rails_view_component/"+ com_name +"/"+ action;
53
+ var callback = function(data,status,xhr){
54
+ callCallback(route, data);
55
+ }
56
+ var query = switch(method){
57
+ case "get":
58
+ JQueryStatic.get(url, params, callback);
59
+ case "post", _:
60
+ JQueryStatic.post(url, params, callback);
61
+ }
62
+ query.fail(function(e){
63
+ trace("ERROR:"+e);
64
+ });
65
+ }
23
66
  }
24
67
 
25
68
 
@@ -1,11 +1,13 @@
1
- class RailsViewComponent::RailsViewComponentBuilder
1
+ class RailsViewComponentBuilder
2
2
  def initialize
3
3
  @count = 0
4
4
  @components = []
5
5
  end
6
6
  def destribute name, erb_params={}, ajax_params = {}
7
+ namespace = name.to_s.camelize
8
+ name = namespace.split("::").last
7
9
  @count += 1
8
- klass = Module.const_get("#{name.to_s.camelize}::#{name.to_s.camelize}Model")
10
+ klass = Module.const_get("#{namespace}::#{name}Model")
9
11
  obj = klass.new @count
10
12
  @components.push obj
11
13
  obj.html(erb_params, ajax_params).html_safe
@@ -1,8 +1,8 @@
1
1
 
2
- module RailsViewComponent::RailsViewComponentHelper
2
+ module RailsViewComponentHelper
3
3
 
4
4
  def rails_view_components &block
5
- builder = RailsViewComponent::RailsViewComponentBuilder.new
5
+ builder = RailsViewComponentBuilder.new
6
6
  block.call builder
7
7
  footer = builder.refer_to_javascripts
8
8
  footer += builder.refer_to_stylesheets
@@ -1,9 +1,12 @@
1
- class RailsViewComponent::RalsViewComponentModel
1
+ class RailsViewComponentModel
2
2
  attr_reader :component_name, :html_identifier, :html_classes
3
3
  def initialize id
4
- @component_name = self.class.name.match(/^(?<name>[^:]+)::/)[:name].underscore
5
- @html_identifier = "#{@component_name}_#{id}"
6
- @html_classes = ["rails_view_component", "#{@component_name}_view_component"]
4
+ @prefix = "rails_view_component"
5
+ @components = self.class.name.underscore.split("/")[0..-2]
6
+ @dir = @components.join("/")
7
+ @html_class_name = @prefix + "-" + @components.join("-")
8
+ @html_identifier = "#{@html_class_name}-#{id}"
9
+ @html_classes = ["rails_view_component", @html_class_name]
7
10
  end
8
11
 
9
12
  def responsibility
@@ -18,8 +21,7 @@ class RailsViewComponent::RalsViewComponentModel
18
21
  end
19
22
 
20
23
  def html erb_params={}, ajax_params={}
21
- action_view = ActionView::Base.new
22
- "#{Rails.root}/app/rails_view_components/#{@component_name}/views"
24
+ action_view = ActionView::Base.new "#{Rails.root}/app/rails_view_components/#{@dir}/views"
23
25
  erb_params.each{|k,v| action_view.assign(k=>v) }
24
26
  data = ajax_params.map{|k,v| "data-#{k}='#{v}'" }.join(' ')
25
27
  return <<HTML
@@ -1,3 +1,3 @@
1
1
  module RailsViewComponent
2
- VERSION = "0.0.5"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -0,0 +1,47 @@
1
+ source 'https://rubygems.org'
2
+
3
+
4
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
5
+ gem 'rails', '4.2.0'
6
+ # Use sqlite3 as the database for Active Record
7
+ gem 'sqlite3'
8
+ # Use SCSS for stylesheets
9
+ gem 'sass-rails', '~> 5.0'
10
+ # Use Uglifier as compressor for JavaScript assets
11
+ gem 'uglifier', '>= 1.3.0'
12
+ # Use CoffeeScript for .coffee assets and views
13
+ gem 'coffee-rails', '~> 4.1.0'
14
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
15
+ # gem 'therubyracer', platforms: :ruby
16
+
17
+ # Use jquery as the JavaScript library
18
+ gem 'jquery-rails'
19
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
20
+ gem 'turbolinks'
21
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
22
+ gem 'jbuilder', '~> 2.0'
23
+ # bundle exec rake doc:rails generates the API under doc/api.
24
+ gem 'sdoc', '~> 0.4.0', group: :doc
25
+
26
+ # Use ActiveModel has_secure_password
27
+ # gem 'bcrypt', '~> 3.1.7'
28
+
29
+ # Use Unicorn as the app server
30
+ # gem 'unicorn'
31
+
32
+ # Use Capistrano for deployment
33
+ # gem 'capistrano-rails', group: :development
34
+
35
+ group :development, :test do
36
+ # Call 'byebug' anywhere in the code to stop execution and get a debugger console
37
+ gem 'byebug'
38
+
39
+ # Access an IRB console on exception pages or by using <%= console %> in views
40
+ gem 'web-console', '~> 2.0'
41
+
42
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
43
+ gem 'spring'
44
+ end
45
+
46
+
47
+ gem 'rails_view_component', path: "../../"
@@ -0,0 +1,171 @@
1
+ PATH
2
+ remote: ../../
3
+ specs:
4
+ rails_view_component (0.0.6)
5
+ rails (~> 4.2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (4.2.0)
11
+ actionpack (= 4.2.0)
12
+ actionview (= 4.2.0)
13
+ activejob (= 4.2.0)
14
+ mail (~> 2.5, >= 2.5.4)
15
+ rails-dom-testing (~> 1.0, >= 1.0.5)
16
+ actionpack (4.2.0)
17
+ actionview (= 4.2.0)
18
+ activesupport (= 4.2.0)
19
+ rack (~> 1.6.0)
20
+ rack-test (~> 0.6.2)
21
+ rails-dom-testing (~> 1.0, >= 1.0.5)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
23
+ actionview (4.2.0)
24
+ activesupport (= 4.2.0)
25
+ builder (~> 3.1)
26
+ erubis (~> 2.7.0)
27
+ rails-dom-testing (~> 1.0, >= 1.0.5)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
29
+ activejob (4.2.0)
30
+ activesupport (= 4.2.0)
31
+ globalid (>= 0.3.0)
32
+ activemodel (4.2.0)
33
+ activesupport (= 4.2.0)
34
+ builder (~> 3.1)
35
+ activerecord (4.2.0)
36
+ activemodel (= 4.2.0)
37
+ activesupport (= 4.2.0)
38
+ arel (~> 6.0)
39
+ activesupport (4.2.0)
40
+ i18n (~> 0.7)
41
+ json (~> 1.7, >= 1.7.7)
42
+ minitest (~> 5.1)
43
+ thread_safe (~> 0.3, >= 0.3.4)
44
+ tzinfo (~> 1.1)
45
+ arel (6.0.0)
46
+ binding_of_caller (0.7.2)
47
+ debug_inspector (>= 0.0.1)
48
+ builder (3.2.2)
49
+ byebug (3.5.1)
50
+ columnize (~> 0.8)
51
+ debugger-linecache (~> 1.2)
52
+ slop (~> 3.6)
53
+ coffee-rails (4.1.0)
54
+ coffee-script (>= 2.2.0)
55
+ railties (>= 4.0.0, < 5.0)
56
+ coffee-script (2.3.0)
57
+ coffee-script-source
58
+ execjs
59
+ coffee-script-source (1.9.0)
60
+ columnize (0.9.0)
61
+ debug_inspector (0.0.2)
62
+ debugger-linecache (1.2.0)
63
+ erubis (2.7.0)
64
+ execjs (2.3.0)
65
+ globalid (0.3.0)
66
+ activesupport (>= 4.1.0)
67
+ hike (1.2.3)
68
+ i18n (0.7.0)
69
+ jbuilder (2.2.6)
70
+ activesupport (>= 3.0.0, < 5)
71
+ multi_json (~> 1.2)
72
+ jquery-rails (4.0.3)
73
+ rails-dom-testing (~> 1.0)
74
+ railties (>= 4.2.0)
75
+ thor (>= 0.14, < 2.0)
76
+ json (1.8.2)
77
+ loofah (2.0.1)
78
+ nokogiri (>= 1.5.9)
79
+ mail (2.6.3)
80
+ mime-types (>= 1.16, < 3)
81
+ mime-types (2.4.3)
82
+ mini_portile (0.6.2)
83
+ minitest (5.5.1)
84
+ multi_json (1.10.1)
85
+ nokogiri (1.6.6.2)
86
+ mini_portile (~> 0.6.0)
87
+ rack (1.6.0)
88
+ rack-test (0.6.3)
89
+ rack (>= 1.0)
90
+ rails (4.2.0)
91
+ actionmailer (= 4.2.0)
92
+ actionpack (= 4.2.0)
93
+ actionview (= 4.2.0)
94
+ activejob (= 4.2.0)
95
+ activemodel (= 4.2.0)
96
+ activerecord (= 4.2.0)
97
+ activesupport (= 4.2.0)
98
+ bundler (>= 1.3.0, < 2.0)
99
+ railties (= 4.2.0)
100
+ sprockets-rails
101
+ rails-deprecated_sanitizer (1.0.3)
102
+ activesupport (>= 4.2.0.alpha)
103
+ rails-dom-testing (1.0.5)
104
+ activesupport (>= 4.2.0.beta, < 5.0)
105
+ nokogiri (~> 1.6.0)
106
+ rails-deprecated_sanitizer (>= 1.0.1)
107
+ rails-html-sanitizer (1.0.1)
108
+ loofah (~> 2.0)
109
+ railties (4.2.0)
110
+ actionpack (= 4.2.0)
111
+ activesupport (= 4.2.0)
112
+ rake (>= 0.8.7)
113
+ thor (>= 0.18.1, < 2.0)
114
+ rake (10.4.2)
115
+ rdoc (4.2.0)
116
+ json (~> 1.4)
117
+ sass (3.4.11)
118
+ sass-rails (5.0.1)
119
+ railties (>= 4.0.0, < 5.0)
120
+ sass (~> 3.1)
121
+ sprockets (>= 2.8, < 4.0)
122
+ sprockets-rails (>= 2.0, < 4.0)
123
+ tilt (~> 1.1)
124
+ sdoc (0.4.1)
125
+ json (~> 1.7, >= 1.7.7)
126
+ rdoc (~> 4.0)
127
+ slop (3.6.0)
128
+ spring (1.2.0)
129
+ sprockets (2.12.3)
130
+ hike (~> 1.2)
131
+ multi_json (~> 1.0)
132
+ rack (~> 1.0)
133
+ tilt (~> 1.1, != 1.3.0)
134
+ sprockets-rails (2.2.4)
135
+ actionpack (>= 3.0)
136
+ activesupport (>= 3.0)
137
+ sprockets (>= 2.8, < 4.0)
138
+ sqlite3 (1.3.10)
139
+ thor (0.19.1)
140
+ thread_safe (0.3.4)
141
+ tilt (1.4.1)
142
+ turbolinks (2.5.3)
143
+ coffee-rails
144
+ tzinfo (1.2.2)
145
+ thread_safe (~> 0.1)
146
+ uglifier (2.7.0)
147
+ execjs (>= 0.3.0)
148
+ json (>= 1.8.0)
149
+ web-console (2.0.0)
150
+ activemodel (~> 4.0)
151
+ binding_of_caller (>= 0.7.2)
152
+ railties (~> 4.0)
153
+ sprockets-rails (>= 2.0, < 4.0)
154
+
155
+ PLATFORMS
156
+ ruby
157
+
158
+ DEPENDENCIES
159
+ byebug
160
+ coffee-rails (~> 4.1.0)
161
+ jbuilder (~> 2.0)
162
+ jquery-rails
163
+ rails (= 4.2.0)
164
+ rails_view_component!
165
+ sass-rails (~> 5.0)
166
+ sdoc (~> 0.4.0)
167
+ spring
168
+ sqlite3
169
+ turbolinks
170
+ uglifier (>= 1.3.0)
171
+ web-console (~> 2.0)
File without changes
@@ -10,4 +10,7 @@
10
10
  // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
11
  // about supported directives.
12
12
  //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require turbolinks
13
16
  //= require_tree .
@@ -0,0 +1,3 @@
1
+ # Place all the behaviors and hooks related to the matching controller here.
2
+ # All this logic will automatically be available in application.js.
3
+ # You can use CoffeeScript in this file: http://coffeescript.org/
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the top controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,4 @@
1
+ class TopController < ApplicationController
2
+ def index
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ module TopHelper
2
+ end
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>Dummy</title>
4
+ <title>RailsViewComponentTest</title>
5
5
  <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
6
  <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
7
  <%= csrf_meta_tags %>
@@ -0,0 +1,8 @@
1
+ <h1>Top#index</h1>
2
+ <p>Find me in app/views/top/index.html.erb</p>
3
+
4
+ <%= rails_view_components do |b| %>
5
+
6
+ <%= b.destribute "misc/todo", {},{} %>
7
+
8
+ <% end %>
@@ -1,4 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path("../spring", __FILE__)
4
+ rescue LoadError
5
+ end
2
6
  APP_PATH = File.expand_path('../../config/application', __FILE__)
3
7
  require_relative '../config/boot'
4
8
  require 'rails/commands'
@@ -1,4 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path("../spring", __FILE__)
4
+ rescue LoadError
5
+ end
2
6
  require_relative '../config/boot'
3
7
  require 'rake'
4
8
  Rake.application.run
File without changes
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file loads spring without using Bundler, in order to be fast
4
+ # It gets overwritten when you run the `spring binstub` command
5
+
6
+ unless defined?(Spring)
7
+ require "rubygems"
8
+ require "bundler"
9
+
10
+ if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)
11
+ ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
12
+ ENV["GEM_HOME"] = ""
13
+ Gem.paths = ENV
14
+
15
+ gem "spring", match[1]
16
+ require "spring/binstub"
17
+ end
18
+ end