tuttle 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/app/controllers/tuttle/active_model_serializers_controller.rb +26 -0
  4. data/app/controllers/tuttle/active_support_controller.rb +26 -0
  5. data/app/controllers/tuttle/cancancan_controller.rb +1 -0
  6. data/app/controllers/tuttle/gems_controller.rb +4 -0
  7. data/app/controllers/tuttle/home_controller.rb +1 -3
  8. data/app/controllers/tuttle/performance_tuning_controller.rb +14 -0
  9. data/app/controllers/tuttle/rails_controller.rb +20 -18
  10. data/app/controllers/tuttle/request_controller.rb +16 -0
  11. data/app/controllers/tuttle/ruby_controller.rb +2 -0
  12. data/app/helpers/tuttle/application_helper.rb +8 -0
  13. data/app/views/layouts/tuttle/application.html.erb +22 -7
  14. data/app/views/tuttle/active_model_serializers/index.html.erb +86 -0
  15. data/app/views/tuttle/active_model_serializers/index9.html.erb +68 -0
  16. data/app/views/tuttle/active_support/dependencies.html.erb +72 -0
  17. data/app/views/tuttle/active_support/index.html.erb +69 -0
  18. data/app/views/tuttle/{rails → active_support}/inflectors.html.erb +0 -0
  19. data/app/views/tuttle/active_support/time_zones.html.erb +24 -0
  20. data/app/views/tuttle/cancancan/rule_tester.html.erb +1 -20
  21. data/app/views/tuttle/devise/index.html.erb +62 -9
  22. data/app/views/tuttle/gems/get_process_mem.html.erb +92 -0
  23. data/app/views/tuttle/gems/other.html.erb +102 -0
  24. data/app/views/tuttle/home/index.html.erb +1 -1
  25. data/app/views/tuttle/performance_tuning/index.html.erb +79 -0
  26. data/app/views/tuttle/rails/assets.html.erb +38 -43
  27. data/app/views/tuttle/rails/database.html.erb +2 -2
  28. data/app/views/tuttle/rails/engines.html.erb +40 -0
  29. data/app/views/tuttle/rails/generators.html.erb +74 -0
  30. data/app/views/tuttle/rails/index.html.erb +62 -86
  31. data/app/views/tuttle/rails/models.html.erb +16 -1
  32. data/app/views/tuttle/rails/schema_cache.html.erb +3 -1
  33. data/app/views/tuttle/request/index.html.erb +37 -0
  34. data/app/views/tuttle/ruby/index.html.erb +65 -0
  35. data/config/routes.rb +19 -3
  36. data/lib/tuttle.rb +6 -1
  37. data/lib/tuttle/engine.rb +23 -61
  38. data/lib/tuttle/instrumenter.rb +38 -0
  39. data/lib/tuttle/middleware/request_profiler.rb +80 -0
  40. data/lib/tuttle/ruby_prof/fast_call_stack_printer.rb +164 -0
  41. data/lib/tuttle/version.rb +1 -1
  42. metadata +21 -21
  43. data/app/assets/images/tuttle/favicon.ico +0 -0
  44. data/app/assets/javascripts/tuttle/application.js +0 -12
  45. data/app/assets/stylesheets/tuttle/application.css +0 -71
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb3803eeb651c971a088c8f9f8b3b3d49c6ffd18
4
- data.tar.gz: 64d2b0b4252df7445c67207967e0c41eaec30c16
3
+ metadata.gz: 11308ee417997ed89c1e29539cc8cb0fecf125bc
4
+ data.tar.gz: 624f021eb368b6bd329771ce1a2af67970622cab
5
5
  SHA512:
6
- metadata.gz: 4bbd9338d565fc7d45aac1162480df1564d86ad0bfa5b8205d16438f8b1c1c36181a51c6789d09e5a14f20716df3d52f10423a0e6e131b52c8f9e3297173585a
7
- data.tar.gz: 75d0f95727f69ade04dde73568cc500b2b76af0a7d0132a3075e4ff0cc8551793bbe3be027e7dd9b9719a25a8ee320fdc592c1a2243f16d784c86ae50f93684a
6
+ metadata.gz: 5b59ac504e78b6e910f5e32808dfda8b9c5908b70fcfc8057a7e488d33604634a67256ea9b514ad421c5c2b833f8e3bfb182bf3963c829eb015a8530139523c4
7
+ data.tar.gz: 37577b68008df08c28a0355fc2425c4ccbf5b149e7fb126c141eb0750007b8b3d968fb60bb588a8517c7bfcbaa7d6b4b870fce0f6cdbe03457fb6f4a10ecde25
@@ -1,3 +1,12 @@
1
+ ### 0.0.5
2
+
3
+ * Features
4
+ * Request profiling middleware for ruby-prof and memory_profiler
5
+ * ActiveSupport inspection including Dependencies, TimeZones, and Deprecation
6
+ * Load path inspection (Ruby and Active Support autoloading)
7
+ * No longer requires asset pipeline
8
+ * Experimental inspector for Rack MiniProfiler and ActiveModelSerializers
9
+
1
10
  ### 0.0.4
2
11
 
3
12
  * Features
@@ -0,0 +1,26 @@
1
+ require_dependency 'tuttle/application_controller'
2
+
3
+ module Tuttle
4
+ class ActiveModelSerializersController < ApplicationController
5
+
6
+ def index
7
+ @models = ActiveRecord::Base.descendants
8
+ @models.sort_by!(&:name)
9
+
10
+ @serializers = ::ActiveModel::Serializer.descendants
11
+ @serializers.sort_by!(&:name)
12
+
13
+ @adapter_map = if ActiveModel::Serializer::Adapter.const_defined?(:ADAPTER_MAP)
14
+ ActiveModel::Serializer::Adapter.const_get(:ADAPTER_MAP)
15
+ else
16
+ ActiveModelSerializers::Adapter.const_get(:ADAPTER_MAP)
17
+ end
18
+
19
+ unless defined?(ActiveModelSerializers)
20
+ render 'index9'
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require_dependency 'tuttle/application_controller'
2
+
3
+ module Tuttle
4
+ class ActiveSupportController < ApplicationController
5
+
6
+ def index
7
+ end
8
+
9
+ def dependencies
10
+ end
11
+
12
+ def inflectors
13
+ @test_word = params[:test_word] || ''
14
+
15
+ @plurals = ActiveSupport::Inflector.inflections.plurals
16
+ @singulars = ActiveSupport::Inflector.inflections.singulars
17
+ @uncountables = ActiveSupport::Inflector.inflections.uncountables
18
+ @humans = ActiveSupport::Inflector.inflections.humans
19
+ @acronyms = ActiveSupport::Inflector.inflections.acronyms
20
+ end
21
+
22
+ def time_zones
23
+ end
24
+
25
+ end
26
+ end
@@ -11,6 +11,7 @@ module Tuttle
11
11
  def rule_tester
12
12
  @models = ActiveRecord::Base.descendants
13
13
  @action = params[:action_name] || 'read'
14
+ @subject = nil
14
15
 
15
16
  subject_class = params[:subject_class]
16
17
  subject_id = params[:subject_id]
@@ -15,6 +15,10 @@ module Tuttle
15
15
 
16
16
  end
17
17
 
18
+ def get_process_mem
19
+ require 'get_process_mem/version'
20
+ end
21
+
18
22
  def other
19
23
 
20
24
  end
@@ -1,13 +1,11 @@
1
1
  require_dependency 'tuttle/application_controller'
2
-
3
- # NOTE: needed for ruby < 2.1.5 - should figure out why
4
2
  require 'tuttle/version'
5
3
 
6
4
  module Tuttle
7
5
  class HomeController < ApplicationController
8
6
 
9
7
  def index
10
- @event_counts = Tuttle::Engine.event_counts
8
+ @event_counts = Tuttle::Instrumenter.event_counts
11
9
  end
12
10
 
13
11
  end
@@ -0,0 +1,14 @@
1
+ require_dependency 'tuttle/application_controller'
2
+
3
+ module Tuttle
4
+ class PerformanceTuningController < ApplicationController
5
+
6
+ def index
7
+ if defined?(::Rack::MiniProfiler)
8
+ @mp_config = ::Rack::MiniProfiler.config
9
+ @mp_client_settings = ::Rack::MiniProfiler::ClientSettings.new(request.env)
10
+ end
11
+ end
12
+
13
+ end
14
+ end
@@ -1,12 +1,11 @@
1
- require_dependency 'tuttle/application_controller'
2
1
  require 'rails/generators'
3
- require 'tuttle/presenters/action_dispatch/routing/route_wrapper'
2
+ require_dependency 'tuttle/application_controller'
3
+ require_dependency 'tuttle/presenters/action_dispatch/routing/route_wrapper'
4
4
 
5
5
  module Tuttle
6
6
  class RailsController < ApplicationController
7
7
 
8
8
  def index
9
- Rails::Generators.lookup! if Rails::Generators.subclasses.empty?
10
9
  end
11
10
 
12
11
  def controllers
@@ -19,6 +18,15 @@ module Tuttle
19
18
  @controllers.sort_by!(&:name)
20
19
  end
21
20
 
21
+ def engines
22
+ @engines = Rails::Engine.subclasses.map(&:instance)
23
+ end
24
+
25
+ def generators
26
+ Rails::Generators.lookup! if 'true' == params[:load_all_generators]
27
+ @generators = Rails::Generators.subclasses.group_by(&:base_name)
28
+ end
29
+
22
30
  def models
23
31
  @models = ActiveRecord::Base.descendants
24
32
  @models.sort_by!(&:name)
@@ -47,12 +55,16 @@ module Tuttle
47
55
  end
48
56
 
49
57
  def helpers
58
+ # TODO: Rails.application.helpers.instance_methods
59
+ # helper_symbol = Rails.application.helpers.instance_methods.first
60
+ # Rails.application.helpers.instance_method(helper_symbol).owner
61
+ # Rails.application.helpers.instance_method(helper_symbol).parameters
50
62
  @helpers = ::ApplicationController.send(:modules_for_helpers,[:all])
51
63
  end
52
64
 
53
65
  def assets
54
66
  @sprockets = Rails.application.assets
55
- @engines = Sprockets::VERSION >= '3' ? @sprockets.instance_variable_get(:@config)[:engines] : @sprockets.instance_variable_get(:@engines)
67
+ # TODO: revisit detection of "engines" which are classified as processors, transformers, etc.
56
68
  end
57
69
 
58
70
  def routes
@@ -63,18 +75,8 @@ module Tuttle
63
75
  end
64
76
 
65
77
  def instrumentation
66
- @events = Tuttle::Engine.events
67
- @event_counts = Tuttle::Engine.event_counts
68
- end
69
-
70
- def inflectors
71
- @test_word = params[:test_word] || ''
72
-
73
- @plurals = ActiveSupport::Inflector.inflections.plurals
74
- @singulars = ActiveSupport::Inflector.inflections.singulars
75
- @uncountables = ActiveSupport::Inflector.inflections.uncountables
76
- @humans = ActiveSupport::Inflector.inflections.humans
77
- @acronyms = ActiveSupport::Inflector.inflections.acronyms
78
+ @events = Tuttle::Instrumenter.events
79
+ @event_counts = Tuttle::Instrumenter.event_counts
78
80
  end
79
81
 
80
82
  def cache
@@ -84,8 +86,8 @@ module Tuttle
84
86
  ActiveSupport::Cache::Store.instrument=true
85
87
  end
86
88
  @cache = Rails.cache
87
- @cache_events = Tuttle::Engine.events.select {|e| /cache_(read|write)\.active_support/ =~ e.name }
88
- @tuttle_cache_events = Tuttle::Engine.cache_events
89
+ @cache_events = Tuttle::Instrumenter.events.select {|e| /cache_(read|write)\.active_support/ =~ e.name }
90
+ @tuttle_cache_events = Tuttle::Instrumenter.cache_events
89
91
  end
90
92
 
91
93
  end
@@ -0,0 +1,16 @@
1
+ require_dependency 'tuttle/application_controller'
2
+
3
+ module Tuttle
4
+ class RequestController < ApplicationController
5
+
6
+ def index
7
+ @session_hash = session.to_hash
8
+ @cookies_hash = request.cookie_jar.to_h
9
+ end
10
+
11
+ end
12
+ end
13
+
14
+
15
+
16
+
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require_dependency 'tuttle/application_controller'
2
4
 
3
5
  module Tuttle
@@ -11,6 +11,14 @@ module Tuttle
11
11
  end
12
12
  end
13
13
 
14
+ def main_app_root_path
15
+ main_app.respond_to?(:root_path) ? main_app.root_path : "/"
16
+ end
17
+
18
+ def main_app_root_url
19
+ main_app.respond_to?(:root_url) ? main_app.root_url : "/"
20
+ end
21
+
14
22
  private
15
23
 
16
24
  def redact_by_key(key, value)
@@ -7,9 +7,12 @@
7
7
  <title>Tuttle</title>
8
8
  <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">
9
9
  <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap-theme.min.css">
10
- <link rel="icon" href="<%= image_path 'tuttle/favicon.ico' %>">
11
-
12
- <%= stylesheet_link_tag "tuttle/application", :media => "all" %>
10
+ <link rel="icon" href="//s3.amazonaws.com/tuttle-assets/images/favicon.ico">
11
+ <style>
12
+ html { overflow: -moz-scrollbars-vertical; overflow-y: scroll; }
13
+ body { padding-top: 50px; }
14
+ table.not-wide { width: auto; }
15
+ </style>
13
16
  <%= csrf_meta_tags %>
14
17
  </head>
15
18
  <body>
@@ -24,7 +27,7 @@
24
27
  <span class="icon-bar"></span>
25
28
  </button>
26
29
  <%= link_to('Tuttle', root_path, :class => 'navbar-brand') %>
27
- <%= link_to('(back to app)', '/', :class => 'navbar-brand') %>
30
+ <%= link_to('(back to app)', main_app_root_path, :class => 'navbar-brand') %>
28
31
  </div>
29
32
  <div class="navbar-collapse collapse">
30
33
  <ul class="nav navbar-nav navbar-right">
@@ -38,13 +41,24 @@
38
41
  <li><%= link_to 'Helpers', rails_helpers_path %></li>
39
42
  <li><%= link_to 'Assets', rails_assets_path %></li>
40
43
  <li><%= link_to 'Routes', rails_routes_path %></li>
44
+ <li><%= link_to 'Generators', rails_generators_path %></li>
45
+ <li><%= link_to 'Engines', rails_engines_path %></li>
41
46
  <li><%= link_to 'Database', rails_database_path %></li>
42
47
  <li><%= link_to 'Schema Cache', rails_schema_cache_path %></li>
43
48
  <li><%= link_to 'Instrumentation', rails_instrumentation_path %></li>
44
- <li><%= link_to 'Inflectors', rails_inflectors_path %></li>
45
49
  <li><%= link_to 'Caching', rails_cache_path %></li>
46
50
  </ul>
47
51
  </li>
52
+ <li class="dropdown">
53
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">Active Support <span class="caret"></span></a>
54
+ <ul class="dropdown-menu" role="menu">
55
+ <li><%= link_to 'Overview', active_support_path %></li>
56
+ <li class="divider"></li>
57
+ <li><%= link_to 'Dependencies', active_support_dependencies_path %></li>
58
+ <li><%= link_to 'Inflectors', active_support_inflectors_path %></li>
59
+ <li><%= link_to 'Time Zones', active_support_time_zones_path %></li>
60
+ </ul>
61
+ </li>
48
62
  <li class="dropdown">
49
63
  <a href="#" class="dropdown-toggle" data-toggle="dropdown">Gems <span class="caret"></span></a>
50
64
  <ul class="dropdown-menu" role="menu">
@@ -59,6 +73,9 @@
59
73
  <%- if defined?(::Paperclip) %>
60
74
  <li><%= link_to 'Paperclip', paperclip_path %></li>
61
75
  <%- end %>
76
+ <%- if defined?(::GetProcessMem) %>
77
+ <li><%= link_to 'GetProcessMem', gems_get_process_mem_path %></li>
78
+ <%- end %>
62
79
  <li><%= link_to 'HTTP Clients', gems_http_clients_path %></li>
63
80
  <li><%= link_to 'JSON', gems_json_path %></li>
64
81
  <li><%= link_to 'Other', gems_other_path %></li>
@@ -86,8 +103,6 @@
86
103
 
87
104
  <script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
88
105
  <script src="//maxcdn.bootstrapcdn.com/bootstrap/latest/js/bootstrap.min.js"></script>
89
- <script src="//cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.10.4/typeahead.bundle.min.js"></script>
90
- <%= javascript_include_tag "tuttle/application" =%>
91
106
  <script type="application/javascript">
92
107
  $(function () {
93
108
  $('[data-toggle="tooltip"]').tooltip();
@@ -0,0 +1,86 @@
1
+ <h1>ActiveModelSerializers Configuration</h1>
2
+
3
+ <dl class="dl-horizontal">
4
+ <dt>AMS Version</dt><dd><%= ActiveModel::Serializer::VERSION %></dd>
5
+ </dl>
6
+
7
+ <h3>Config Settings</h3>
8
+ <table class="table table-condensed not-wide">
9
+ <tr>
10
+ <th>Setting</th>
11
+ <th>Value</th>
12
+ </tr>
13
+ <tr>
14
+ <td>ActiveModelSerializers.config.perform_caching</td>
15
+ <td><%= truth_label(ActiveModelSerializers.config.perform_caching) %></td>
16
+ </tr>
17
+ <tr>
18
+ <td>ActiveModelSerializers.config.cache_store</td>
19
+ <td><code><%= ActiveModelSerializers.config.cache_store.inspect %></code></td>
20
+ </tr>
21
+ <% [:collection_serializer, :serializer_lookup_enabled, :adapter, :schema_path,
22
+ :jsonapi_version, :jsonapi_resource_type, :jsonapi_toplevel_meta, :jsonapi_include_toplevel_object].each do |config_method| %>
23
+ <tr>
24
+ <td><%= config_method %></td>
25
+ <td><code><%= ActiveModel::Serializer.config.send(config_method).inspect %></code></td>
26
+ </tr>
27
+ <% end %>
28
+ </table>
29
+
30
+ <h3>Serializers</h3>
31
+ <table class="table table-condensed">
32
+ <tr>
33
+ <th>Serializer</th>
34
+ <th>Configuration</th>
35
+ </tr>
36
+ <% @serializers.each do |serializer_class| %>
37
+ <tr>
38
+ <td><%= serializer_class %></td>
39
+ <td>
40
+ Attributes: <code><%= serializer_class._attributes_data.keys.inspect %></code><br/>
41
+ Links: <code><%= serializer_class._links.keys.inspect %></code><br/>
42
+ Reflections: <code><%= serializer_class._reflections.collect(&:name).inspect %></code><br/>
43
+ Type: <code><%= serializer_class._type.inspect %></code><br/>
44
+ Cached?: <%= truth_label(serializer_class._cache.present?) %><br/>
45
+ <% if serializer_class._cache.present? %>
46
+ Cache Key: <code><%= serializer_class._cache_key.inspect %></code><br/>
47
+ Cache Only: <code><%= serializer_class._cache_only.inspect %></code><br/>
48
+ Cache Except: <code><%= serializer_class._cache_except.inspect %></code><br/>
49
+ Cache Options: <code><%= serializer_class._cache_options.inspect %></code><br/>
50
+ <% end %>
51
+ Instance Methods: <code><%= serializer_class.instance_methods(false).inspect %></code><br/>
52
+ </td>
53
+ </tr>
54
+ <% end %>
55
+ </table>
56
+
57
+ <h3>Adapters</h3>
58
+ <table class="table table-condensed not-wide">
59
+ <tr>
60
+ <th>Name</th>
61
+ <th>Adapter</th>
62
+ </tr>
63
+ <% @adapter_map.each do |k, v| %>
64
+ <tr>
65
+ <td><%= k %></td>
66
+ <td><%= v.inspect %></td>
67
+ </tr>
68
+ <% end %>
69
+ </table>
70
+
71
+ <h3>Active Record Models</h3>
72
+ <table class="table table-condensed not-wide">
73
+ <tr>
74
+ <th>Name</th>
75
+ <th>Adapter</th>
76
+ </tr>
77
+ <%
78
+ @models.each do |ar_model|
79
+ model_serializer = ActiveModel::Serializer.get_serializer_for(ar_model)
80
+ %>
81
+ <tr>
82
+ <td><%= ar_model %></td>
83
+ <td><%= model_serializer.inspect %></td>
84
+ </tr>
85
+ <% end %>
86
+ </table>
@@ -0,0 +1,68 @@
1
+ <h1>ActiveModelSerializers Configuration</h1>
2
+
3
+ <dl class="dl-horizontal">
4
+ <dt>AMS Version</dt><dd><%= ActiveModel::Serializer::VERSION %></dd>
5
+ </dl>
6
+
7
+ <h3>Config Settings</h3>
8
+ <table class="table table-condensed">
9
+ <tr>
10
+ <th>Setting</th>
11
+ <th>Value</th>
12
+ <th>Description</th>
13
+ </tr>
14
+ <% ActiveModel::Serializer::CONFIG.each do |k, v| %>
15
+ <tr>
16
+ <td><%= k %></td>
17
+ <td><code><%= v.inspect %></code></td>
18
+ <td></td>
19
+ </tr>
20
+ <% end %>
21
+ </table>
22
+
23
+ <h3>Serializers</h3>
24
+ <table class="table table-condensed">
25
+ <tr>
26
+ <th>Serializer</th>
27
+ <th>Configuration</th>
28
+ </tr>
29
+ <% @serializers.each do |serializer_class| %>
30
+ <tr>
31
+ <td><%= serializer_class %></td>
32
+ <td>
33
+ Root: <code><%= serializer_class._root.inspect %></code><br/>
34
+ Attributes: <code><%= serializer_class._attributes.inspect %></code><br/>
35
+ Associations: <code><%= serializer_class._associations.keys.inspect %></code><br/>
36
+ </td>
37
+ </tr>
38
+ <% end %>
39
+ </table>
40
+
41
+ <h3>Active Record Models with Serializers</h3>
42
+ <p>Note: Models do not need to have an assoicated Serializer to be rendered with a serializer.</p>
43
+ <table class="table table-condensed not-wide">
44
+ <tr>
45
+ <th>Model</th>
46
+ <th>Serializer</th>
47
+ </tr>
48
+ <%
49
+ @models.each do |ar_model|
50
+ begin
51
+ next if ar_model.abstract_class?
52
+ ar_instance = ar_model.new rescue nil
53
+ next unless ar_instance
54
+ model_serializer = ActiveModel::Serializer.serializer_for(ar_instance)
55
+ next unless model_serializer
56
+ %>
57
+ <tr>
58
+ <td><%= ar_model %></td>
59
+ <td><%= model_serializer.inspect %></td>
60
+ </tr>
61
+
62
+ <%
63
+ rescue
64
+ # ignore models that cause exceptions
65
+ end
66
+ end
67
+ %>
68
+ </table>