tuttle 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +22 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/javascripts/tuttle/application.js +12 -0
  6. data/app/assets/stylesheets/scaffold.css +56 -0
  7. data/app/assets/stylesheets/tuttle/application.css +71 -0
  8. data/app/controllers/tuttle/application_controller.rb +20 -0
  9. data/app/controllers/tuttle/cancancan_controller.rb +29 -0
  10. data/app/controllers/tuttle/devise_controller.rb +12 -0
  11. data/app/controllers/tuttle/home_controller.rb +14 -0
  12. data/app/controllers/tuttle/rails_controller.rb +52 -0
  13. data/app/controllers/tuttle/ruby_controller.rb +10 -0
  14. data/app/helpers/tuttle/application_helper.rb +4 -0
  15. data/app/views/layouts/tuttle/application.html.erb +68 -0
  16. data/app/views/tuttle/cancancan/_rule_table.html.erb +31 -0
  17. data/app/views/tuttle/cancancan/index.html.erb +45 -0
  18. data/app/views/tuttle/cancancan/rule_tester.html.erb +68 -0
  19. data/app/views/tuttle/devise/index.html.erb +84 -0
  20. data/app/views/tuttle/home/index.html.erb +74 -0
  21. data/app/views/tuttle/rails/assets.html.erb +44 -0
  22. data/app/views/tuttle/rails/controllers.html.erb +10 -0
  23. data/app/views/tuttle/rails/database.html.erb +46 -0
  24. data/app/views/tuttle/rails/helpers.html.erb +35 -0
  25. data/app/views/tuttle/rails/index.html.erb +235 -0
  26. data/app/views/tuttle/rails/instrumentation.html.erb +22 -0
  27. data/app/views/tuttle/rails/models.html.erb +61 -0
  28. data/app/views/tuttle/rails/routes.html.erb +37 -0
  29. data/app/views/tuttle/ruby/index.html.erb +83 -0
  30. data/config/routes.rb +21 -0
  31. data/lib/tasks/tuttle_tasks.rake +4 -0
  32. data/lib/tuttle.rb +4 -0
  33. data/lib/tuttle/engine.rb +39 -0
  34. data/lib/tuttle/version.rb +3 -0
  35. data/test/controllers/tuttle/cancancan_controller_test.rb +60 -0
  36. data/test/controllers/tuttle/devise_controller_test.rb +12 -0
  37. data/test/controllers/tuttle/home_controller_test.rb +13 -0
  38. data/test/controllers/tuttle/rails_controller_test.rb +56 -0
  39. data/test/controllers/tuttle/ruby_controller_test.rb +12 -0
  40. data/test/dummy/Gemfile.lock +142 -0
  41. data/test/dummy/README.rdoc +261 -0
  42. data/test/dummy/Rakefile +7 -0
  43. data/test/dummy/app/assets/javascripts/application.js +15 -0
  44. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  45. data/test/dummy/app/controllers/application_controller.rb +3 -0
  46. data/test/dummy/app/helpers/application_helper.rb +2 -0
  47. data/test/dummy/app/models/ability.rb +7 -0
  48. data/test/dummy/app/models/user.rb +6 -0
  49. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  50. data/test/dummy/config.ru +4 -0
  51. data/test/dummy/config/application.rb +52 -0
  52. data/test/dummy/config/boot.rb +11 -0
  53. data/test/dummy/config/database.yml +25 -0
  54. data/test/dummy/config/environment.rb +5 -0
  55. data/test/dummy/config/environments/development.rb +30 -0
  56. data/test/dummy/config/environments/test.rb +38 -0
  57. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  58. data/test/dummy/config/initializers/devise.rb +257 -0
  59. data/test/dummy/config/initializers/inflections.rb +15 -0
  60. data/test/dummy/config/initializers/mime_types.rb +5 -0
  61. data/test/dummy/config/initializers/secret_token.rb +7 -0
  62. data/test/dummy/config/initializers/session_store.rb +8 -0
  63. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  64. data/test/dummy/config/locales/en.yml +5 -0
  65. data/test/dummy/config/routes.rb +6 -0
  66. data/test/dummy/db/migrate/20141229204528_devise_create_users.rb +42 -0
  67. data/test/dummy/db/schema.rb +34 -0
  68. data/test/dummy/public/404.html +26 -0
  69. data/test/dummy/public/422.html +26 -0
  70. data/test/dummy/public/500.html +25 -0
  71. data/test/dummy/public/favicon.ico +0 -0
  72. data/test/dummy/script/rails +6 -0
  73. data/test/dummy/test/fixtures/users.yml +6 -0
  74. data/test/dummy/test/models/user_test.rb +7 -0
  75. data/test/dummy/tmp/cache/assets/test/sprockets/00091e0cb6df543a8e704290f4dec8db +0 -0
  76. data/test/dummy/tmp/cache/assets/test/sprockets/11599cd5b5d6a0a58a5e98c0902e1997 +0 -0
  77. data/test/dummy/tmp/cache/assets/test/sprockets/9b2e26c1e54d4ff5ae04270e8f03907f +0 -0
  78. data/test/dummy/tmp/cache/assets/test/sprockets/a65793481a75afa9f660d1032ee66ef5 +0 -0
  79. data/test/dummy/tmp/cache/assets/test/sprockets/d9450766086a9f3f994e8c4a2273bfaa +0 -0
  80. data/test/dummy/tmp/cache/assets/test/sprockets/e117b0425a7b9daef8a213c1a2203f00 +0 -0
  81. data/test/integration/navigation_test.rb +9 -0
  82. data/test/test_helper.rb +37 -0
  83. data/test/tuttle_test.rb +7 -0
  84. data/test/unit/tuttle/note_test.rb +9 -0
  85. metadata +219 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0963798b9bf628797d626ed70371409f23b4082c
4
+ data.tar.gz: b384585c3232cda44288aea143de10a5f27cc758
5
+ SHA512:
6
+ metadata.gz: 98002c7f9eed3ca3b860919cf51524cbbe9aba54956e0e202509eb5adb07228c20ed50f5b5f0dc1ea1bae44a7a3cb21072097a41417c4a5edf80792aebf7e390
7
+ data.tar.gz: 4215b17a7f740a9c1c155471355ea141b1340052abb5480d48d8bf3a84ce87eab2d09cc3402b8874067856cf1408d873eef3a92327138d29586649b427ff994a
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # Tuttle
2
+
3
+ [![Build Status](https://api.travis-ci.org/dgynn/tuttle.svg?branch=develop)](https://travis-ci.org/dgynn/tuttle)
4
+ [![Code Climate](https://codeclimate.com/github/dgynn/tuttle/badges/gpa.svg)](https://codeclimate.com/github/dgynn/tuttle)
5
+ [![Test Coverage](https://codeclimate.com/github/dgynn/tuttle/badges/coverage.svg)](https://codeclimate.com/github/dgynn/tuttle)
6
+ [![Dependency Status](https://gemnasium.com/dgynn/tuttle.svg)](https://gemnasium.com/dgynn/tuttle)
7
+
8
+ Tuttle is a tool for assisting Rails developers by exposing runtime configuration information for your application. It is similar to the `/rails/info/routes` and `/rails/info/properties` information pages or the `rake routes` and `rake middleware` tasks.
9
+
10
+ Tuttle is very much in alpha/proof-of-concept mode. The [tuttle-demo](github.com/dgynn/tuttle-demo) project shows it being used in a simple application.
11
+
12
+ ## To use...
13
+
14
+ Add tuttle to you Gemfile
15
+ ```ruby
16
+ gem 'tuttle', :github => 'dgynn/tuttle', :branch => 'develop'
17
+ ```
18
+ Add a route to the Tuttle engine
19
+ ```ruby
20
+ mount Tuttle::Engine, at: "tuttle"
21
+ ```
22
+ Browse to `/tuttle`
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'Tuttle'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.md')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
28
+ require 'rake/testtask'
29
+
30
+ Rake::TestTask.new(:test) do |t|
31
+ t.libs << 'lib'
32
+ t.libs << 'test'
33
+ t.pattern = 'test/**/*_test.rb'
34
+ t.verbose = false
35
+ end
36
+
37
+ task :default => :test
@@ -0,0 +1,12 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,71 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
14
+
15
+ html {
16
+ overflow: -moz-scrollbars-vertical;
17
+ overflow-y: scroll;
18
+ }
19
+ body { padding-top: 50px; }
20
+
21
+ /* Typeahead */
22
+ .typeahead,
23
+ .tt-query,
24
+ .tt-hint {
25
+ width: 396px;
26
+ height: 30px;
27
+ padding: 8px 12px;
28
+ outline: none;
29
+ }
30
+
31
+ .typeahead {
32
+ background-color: #fff;
33
+ }
34
+
35
+ .typeahead:focus {
36
+ border: 2px solid #0097cf;
37
+ }
38
+
39
+ .tt-query {
40
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
41
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
42
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
43
+ }
44
+
45
+ .tt-hint {
46
+ color: #999
47
+ }
48
+
49
+ .tt-dropdown-menu {
50
+ width: 422px;
51
+ margin-top: 12px;
52
+ padding: 8px 0;
53
+ background-color: #fff;
54
+ border: 1px solid #ccc;
55
+ border: 1px solid rgba(0, 0, 0, 0.2);
56
+ }
57
+
58
+ .tt-suggestion {
59
+ padding: 3px 20px;
60
+ font-size: 18px;
61
+ line-height: 24px;
62
+ }
63
+
64
+ .tt-suggestion.tt-cursor {
65
+ color: #fff;
66
+ background-color: #0097cf;
67
+ }
68
+
69
+ .tt-suggestion p {
70
+ margin: 0;
71
+ }
@@ -0,0 +1,20 @@
1
+ module Tuttle
2
+ class ApplicationController < ActionController::Base
3
+ abstract!
4
+
5
+ before_action :check_reload_status
6
+
7
+ def check_reload_status
8
+ return unless Tuttle::Engine.reload_needed && !Rails.configuration.eager_load
9
+ Rails.logger.warn('Tuttle: Eager-loading application')
10
+ # Rails::Application::Finisher defines an initializer that *would* execute
11
+ # these two lines if eager_load were enabled
12
+ # ActiveSupport.run_load_hooks(:before_eager_load, Rails.application)
13
+ ActiveSupport::Notifications.instrument 'tuttle.perform_eager_load' do
14
+ Rails.configuration.eager_load_namespaces.each(&:eager_load!)
15
+ Tuttle::Engine.reload_needed = false
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,29 @@
1
+ require_dependency 'tuttle/application_controller'
2
+
3
+ module Tuttle
4
+ class CancancanController < ApplicationController
5
+
6
+ def index
7
+ @cancan_user = current_user || User.new
8
+ @ability = Ability.new(@cancan_user)
9
+ end
10
+
11
+ def rule_tester
12
+ @action = params[:action_name] || 'read'
13
+ subject_class = params[:subject_class]
14
+ subject_id = params[:subject_id]
15
+ if subject_class
16
+ begin
17
+ subject_klass = subject_class.constantize
18
+ @subject = subject_klass.find(subject_id) unless subject_id.blank?
19
+ @subject ||= subject_klass.new
20
+ rescue
21
+ # Could not load subject
22
+ end
23
+ end
24
+ @cancan_user = current_user || User.new
25
+ @ability = Ability.new(@cancan_user)
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,12 @@
1
+ require_dependency 'tuttle/application_controller'
2
+ require 'devise/version' if defined? Devise
3
+
4
+ module Tuttle
5
+ class DeviseController < ApplicationController
6
+
7
+ def index
8
+ render(plain: "Devise not installed") and return unless defined? ::Devise
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ require_dependency 'tuttle/application_controller'
2
+
3
+ # NOTE: needed for ruby < 2.1.5 - should figure out why
4
+ require 'tuttle/version'
5
+
6
+ module Tuttle
7
+ class HomeController < ApplicationController
8
+
9
+ def index
10
+ @event_counts = Tuttle::Engine.event_counts
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,52 @@
1
+ require_dependency 'tuttle/application_controller'
2
+ require 'rails/generators'
3
+
4
+ module Tuttle
5
+ class RailsController < ApplicationController
6
+
7
+ def index
8
+ Rails::Generators.lookup! if Rails::Generators.subclasses.empty?
9
+ end
10
+
11
+ def controllers
12
+ # TODO: Both ObjectSpace and .descendants approaches have issues with class reloading during development
13
+ # It seems likely that .descendants will work best when Tuttle and Rails classes are not modified
14
+ # but both approaches also require eager_load to be true
15
+ # @controllers = ObjectSpace.each_object(::Class).select {|klass| klass < ActionController::Base }
16
+ @controllers = ActionController::Base.descendants
17
+ @controllers.reject! {|controller| controller <= Tuttle::ApplicationController || controller.abstract?}
18
+ @controllers.sort_by!(&:name)
19
+ end
20
+
21
+ def models
22
+ @models = ActiveRecord::Base.descendants
23
+ @models.sort_by!(&:name)
24
+ end
25
+
26
+ def database
27
+ @conn = ActiveRecord::Base.connection
28
+ end
29
+
30
+ def helpers
31
+ @helpers = ::ApplicationController.send(:modules_for_helpers,[:all])
32
+ end
33
+
34
+ def assets
35
+ @sprockets = Rails.application.assets
36
+ @engines = @sprockets.instance_variable_get(:@engines)
37
+ end
38
+
39
+ def routes
40
+ @routes = Rails.application.routes.routes.collect do |route|
41
+ ActionDispatch::Routing::RouteWrapper.new(route)
42
+ end
43
+ # TODO: include engine-mounted routes
44
+ end
45
+
46
+ def instrumentation
47
+ @events = Tuttle::Engine.events
48
+ @event_counts = Tuttle::Engine.event_counts
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,10 @@
1
+ require_dependency 'tuttle/application_controller'
2
+
3
+ module Tuttle
4
+ class RubyController < ApplicationController
5
+
6
+ def index
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ module Tuttle
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,68 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+ <title>Tuttle</title>
8
+ <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
9
+ <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
10
+ <%= stylesheet_link_tag "tuttle/application", :media => "all" %>
11
+ <%= csrf_meta_tags %>
12
+ </head>
13
+ <body>
14
+
15
+ <nav class="navbar-wrapper navbar-inverse navbar-fixed-top" role="navigation">
16
+ <div class="container">
17
+ <div class="navbar-header">
18
+ <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
19
+ <span class="sr-only">Toggle navigation</span>
20
+ <span class="icon-bar"></span>
21
+ <span class="icon-bar"></span>
22
+ <span class="icon-bar"></span>
23
+ </button>
24
+ <%= link_to('Tuttle', root_path, :class => 'navbar-brand') %>
25
+ <%= link_to('(back to app)', '/', :class => 'navbar-brand') %>
26
+ </div>
27
+ <div class="navbar-collapse collapse">
28
+ <ul class="nav navbar-nav navbar-right">
29
+ <li class="dropdown">
30
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">Rails <span class="caret"></span></a>
31
+ <ul class="dropdown-menu" role="menu">
32
+ <li><%= link_to 'Overview', rails_path %></li>
33
+ <li class="divider"></li>
34
+ <li><%= link_to 'Controllers', rails_controllers_path %></li>
35
+ <li><%= link_to 'Models', rails_models_path %></li>
36
+ <li><%= link_to 'Helpers', rails_helpers_path %></li>
37
+ <li><%= link_to 'Assets', rails_assets_path %></li>
38
+ <li><%= link_to 'Routes', rails_routes_path %></li>
39
+ <li><%= link_to 'Database', rails_database_path %></li>
40
+ <li><%= link_to 'Instrumentation', rails_instrumentation_path %></li>
41
+ </ul>
42
+ </li>
43
+ <li class="dropdown">
44
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">Gems <span class="caret"></span></a>
45
+ <ul class="dropdown-menu" role="menu">
46
+ <li><%= link_to 'Devise', devise_path if defined?(Devise) %></li>
47
+ <li><%= link_to 'CanCanCan', cancancan_path if defined?(CanCanCan) %></li>
48
+ </ul>
49
+ </li>
50
+ <li><%= link_to 'Ruby', ruby_path %></li>
51
+ </ul>
52
+ </div>
53
+ </div>
54
+ </nav>
55
+
56
+ <div class="container">
57
+ <div class="row">
58
+ <%= yield =%>
59
+ </div>
60
+ </div>
61
+
62
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
63
+ <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
64
+ <script src="//cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.10.4/typeahead.bundle.min.js"></script>
65
+ <%= javascript_include_tag "tuttle/application" =%>
66
+ <%= content_for(:javascripts) =%>
67
+ </body>
68
+ </html>