rails_info 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +4 -2
- data/Rakefile +7 -13
- data/app/controllers/rails_info/routes_controller.rb +1 -0
- data/app/presenters/rails_info/logs/test/rspec/file_presenter.rb +2 -0
- data/app/presenters/rails_info/logs/test/rspec_presenter.rb +4 -1
- data/app/presenters/rails_info/routes/namespace_presenter.rb +0 -0
- data/app/presenters/rails_info/routes_presenter.rb +41 -0
- data/app/views/rails_info/routes/_table.html.erb +18 -0
- data/app/views/rails_info/routes/index.html.erb +1 -18
- data/lib/rails_info/logs/test/rspec.rb +11 -4
- data/lib/rails_info/version.rb +1 -1
- data/spec/dummy/log/development.log +3 -0
- data/spec/lib/rails_info/logs/server_spec.rb +50 -0
- data/spec/lib/rails_info/logs/test/rspec_spec.rb +38 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/spec_helper_without_rails.rb +25 -0
- data/spec/support/deferred_garbage_collection.rb +46 -0
- metadata +57 -22
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= RailsInfo
|
1
|
+
= RailsInfo {<img src="https://secure.travis-ci.org/Applicat/rails_info.png" />}[http://travis-ci.org/Applicat/rails_info] {<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/Applicat/rails_info]
|
2
2
|
|
3
3
|
Wiki[https://github.com/applicat/rails_info/wiki]
|
4
4
|
|
@@ -11,7 +11,7 @@ There will be a configuration option for deactivating syntax highlighting soon f
|
|
11
11
|
|
12
12
|
Tested on MacOS with: Rails 3.1 & Ruby 1.9.2, Rails 3.2.6 & Ruby 1.9.3.
|
13
13
|
|
14
|
-
|
14
|
+
http://img207.imageshack.us/img207/8505/railsinfonavigation001.png
|
15
15
|
|
16
16
|
== Installation
|
17
17
|
|
@@ -33,6 +33,8 @@ Just follow the screencast of Ryan Bates on railscasts.com:
|
|
33
33
|
|
34
34
|
http://railscasts.com/episodes/300-contributing-to-open-source
|
35
35
|
|
36
|
+
Add a description about your changes to CHANGELOG.md under section rails_info (unreleased).
|
37
|
+
|
36
38
|
== License
|
37
39
|
|
38
40
|
This project uses MIT-LICENSE.
|
data/Rakefile
CHANGED
@@ -4,6 +4,11 @@ begin
|
|
4
4
|
rescue LoadError
|
5
5
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
6
|
end
|
7
|
+
|
8
|
+
require "rspec/core/rake_task"
|
9
|
+
|
10
|
+
RSpec::Core::RakeTask.new("spec")
|
11
|
+
|
7
12
|
begin
|
8
13
|
require 'rdoc/task'
|
9
14
|
rescue LoadError
|
@@ -23,18 +28,7 @@ end
|
|
23
28
|
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
24
29
|
load 'rails/tasks/engine.rake'
|
25
30
|
|
26
|
-
|
27
|
-
|
28
31
|
Bundler::GemHelper.install_tasks
|
29
32
|
|
30
|
-
|
31
|
-
|
32
|
-
Rake::TestTask.new(:test) do |t|
|
33
|
-
t.libs << 'lib'
|
34
|
-
t.libs << 'test'
|
35
|
-
t.pattern = 'test/**/*_test.rb'
|
36
|
-
t.verbose = false
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
task :default => :test
|
33
|
+
task :default => :spec
|
34
|
+
task :test => :spec
|
@@ -60,6 +60,8 @@ class RailsInfo::Logs::Test::Rspec::FilePresenter < ::RailsInfo::Presenter
|
|
60
60
|
attributes = []
|
61
61
|
|
62
62
|
[:failure_code, :exception_class].each do |attribute|
|
63
|
+
next if @content[attribute].strip.blank?
|
64
|
+
|
63
65
|
attributes << (content_tag(:strong, "#{attribute.to_s.humanize}: ") + h(@content[attribute]))
|
64
66
|
end
|
65
67
|
|
@@ -8,7 +8,10 @@ class RailsInfo::Logs::Test::RspecPresenter < ::RailsInfo::Presenter
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def summary
|
11
|
-
|
11
|
+
text = ["#{@rails_info_log.hash.keys.length} files"]
|
12
|
+
text << @rails_info_log.summary unless @rails_info_log.summary.blank?
|
13
|
+
|
14
|
+
content_tag :p, text.join(', ')
|
12
15
|
end
|
13
16
|
|
14
17
|
def accordion
|
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class RailsInfo::RoutesPresenter < ::RailsInfo::Presenter
|
2
|
+
def accordion
|
3
|
+
routes = request.env['action_dispatch.routes'].routes.map do |route|
|
4
|
+
{
|
5
|
+
source: (route.verb.respond_to?(:source) ? route.verb.source : route.verb).gsub(/[$^]/, ''),
|
6
|
+
spec: route.path.respond_to?(:spec) ? route.path.spec.to_s : route.path,
|
7
|
+
name: route.name,
|
8
|
+
requirements: route.requirements.inspect
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
namespaced_routes = {}
|
13
|
+
|
14
|
+
routes.each do |route|
|
15
|
+
namespace = '/'
|
16
|
+
|
17
|
+
unless route[:spec] == namespace
|
18
|
+
spec = route[:spec].split('/')
|
19
|
+
spec.shift
|
20
|
+
namespace = spec.shift
|
21
|
+
end
|
22
|
+
|
23
|
+
namespaced_routes[namespace] ||= []
|
24
|
+
namespaced_routes[namespace] << route
|
25
|
+
end
|
26
|
+
|
27
|
+
content_tag :div, class: 'accordions' do
|
28
|
+
html = ''
|
29
|
+
|
30
|
+
namespaced_routes.each do |namespace, routes|
|
31
|
+
html += content_tag(
|
32
|
+
:h3, raw(" #{namespace}")
|
33
|
+
)
|
34
|
+
table = render partial: 'rails_info/routes/table', locals: { routes: routes }
|
35
|
+
html += content_tag :div, raw(table), style: "max-height:300px; overflow: auto"
|
36
|
+
end
|
37
|
+
|
38
|
+
raw html
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<table class="table table-striped">
|
2
|
+
<thead>
|
3
|
+
<th>Verb</th>
|
4
|
+
<th>Path</th>
|
5
|
+
<th>Name</th>
|
6
|
+
<th>Requirements</th>
|
7
|
+
</thead>
|
8
|
+
<tbody>
|
9
|
+
<% routes.each do |route| %>
|
10
|
+
<tr>
|
11
|
+
<td><%= route[:source] %></td>
|
12
|
+
<td><%= route[:spec] %></td>
|
13
|
+
<td><%= route[:name] %></td>
|
14
|
+
<td><%= route[:requirements] %></td>
|
15
|
+
</tr>
|
16
|
+
<% end %>
|
17
|
+
</tbody>
|
18
|
+
</table>
|
@@ -1,18 +1 @@
|
|
1
|
-
|
2
|
-
<thead>
|
3
|
-
<th>Verb</th>
|
4
|
-
<th>Path</th>
|
5
|
-
<th>Name</th>
|
6
|
-
<th>Requirements</th>
|
7
|
-
</thead>
|
8
|
-
<tbody>
|
9
|
-
<% request.env['action_dispatch.routes'].routes.each do |route| %>
|
10
|
-
<tr>
|
11
|
-
<td><%= (route.verb.respond_to?(:source) ? route.verb.source : route.verb).gsub(/[$^]/, '') %></td>
|
12
|
-
<td><%= route.path.respond_to?(:source) ? route.path.spec.to_s : route.path %></td>
|
13
|
-
<td><%= route.name %></td>
|
14
|
-
<td><%= route.requirements.inspect %></td>
|
15
|
-
</tr>
|
16
|
-
<% end %>
|
17
|
-
</tbody>
|
18
|
-
</table>
|
1
|
+
<%= @rails_info_routes.accordion %>
|
@@ -49,7 +49,7 @@ class RailsInfo::Logs::Test::Rspec
|
|
49
49
|
failures_found = true
|
50
50
|
|
51
51
|
next
|
52
|
-
elsif line.match(/Finished in/) && @body[line_index + 1].match(/
|
52
|
+
elsif line.match(/Finished in/) && @body[line_index + 1].match(/example|failure|pending/)
|
53
53
|
add_entry(example, failure_code, exception_class, exception_message, stack_trace, after_stack_trace_entry)
|
54
54
|
|
55
55
|
@summary = @body[line_index + 1]
|
@@ -73,14 +73,21 @@ class RailsInfo::Logs::Test::Rspec
|
|
73
73
|
#oMethodError:
|
74
74
|
exception_class = @body[line_index + 2].split(':').first.strip
|
75
75
|
|
76
|
-
if exception_class
|
76
|
+
if exception_class.match(/^expected/) || @body[line_index + 3].split(':').first.strip.match(/^expected/)
|
77
77
|
#Reaction it should behave like objects that are 'hidable'#text_or_reason_for_hiding should return a notice if the entry has been hidden
|
78
78
|
#Failure/Error: subject.content_or_reason_for_hiding.should == "Dieser Beitrag wurde am 2000-01-01 21:15:01 +0100 von Johann Wolfgang von Goethe gelöscht. Der Grund war: This entry sucks!"
|
79
79
|
#expected: "Dieser Beitrag wurde am 2000-01-01 21:15:01 +0100 von Johann Wolfgang von Goethe gelöscht. Der Grund war: This entry sucks!"
|
80
80
|
#got: "Dieser Beitrag wurde am 2000-01-01 20:15:01 +0000 von Johann Wolfgang von Goethe gelöscht. Der Grund war: This entry sucks!" (using ==)
|
81
81
|
#Shared Example Group: "objects that are 'hidable'" called from ./spec/models/shared/hidable_trait_spec.rb:113
|
82
82
|
## ./spec/models/shared/hidable_trait_spec.rb:102:in `block (3 levels) in <top (required)>'
|
83
|
-
|
83
|
+
span = if @body[line_index + 3].match(/^got:/) || @body[line_index + 3].split(':').first.strip.match(/^expected/)
|
84
|
+
# TODO: write a spec for this case @body[line_index + 3].split(':').first.strip.match(/^expected/)
|
85
|
+
2..4
|
86
|
+
else
|
87
|
+
2..2
|
88
|
+
end
|
89
|
+
|
90
|
+
exception_class, exception_message, after_stack_trace_entry = alternative_exception_message(line_index, span)
|
84
91
|
else
|
85
92
|
#undefined method `moderators' for nil:NilClass
|
86
93
|
exception_message = @body[line_index + 3]
|
@@ -136,7 +143,7 @@ class RailsInfo::Logs::Test::Rspec
|
|
136
143
|
end
|
137
144
|
|
138
145
|
def alternative_exception_message(line_index, span)
|
139
|
-
exception_class = '',
|
146
|
+
exception_class, after_stack_trace_entry = '', nil
|
140
147
|
|
141
148
|
exception_message = span.to_a.map {|i| @body[line_index + i] }
|
142
149
|
|
data/lib/rails_info/version.rb
CHANGED
@@ -4874,3 +4874,6 @@ RuntimeError (ok):
|
|
4874
4874
|
Rendered /Users/mgawlista/.rvm/gems/ruby-1.9.3-p125@rails_info_dummy/gems/actionpack-3.2.6/lib/action_dispatch/middleware/templates/rescues/_trace.erb (3.2ms)
|
4875
4875
|
Rendered /Users/mgawlista/.rvm/gems/ruby-1.9.3-p125@rails_info_dummy/gems/actionpack-3.2.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.9ms)
|
4876
4876
|
Rendered /Users/mgawlista/.rvm/gems/ruby-1.9.3-p125@rails_info_dummy/gems/actionpack-3.2.6/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (9.6ms)
|
4877
|
+
Connecting to database specified by database.yml
|
4878
|
+
Connecting to database specified by database.yml
|
4879
|
+
Connecting to database specified by database.yml
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper_without_rails'
|
2
|
+
|
3
|
+
require 'active_support/core_ext/object/blank'
|
4
|
+
#require 'active_support/core_ext/array/access'
|
5
|
+
|
6
|
+
require 'rails_info/logs'
|
7
|
+
require 'rails_info/logs/server'
|
8
|
+
|
9
|
+
describe RailsInfo::Logs::Server do
|
10
|
+
before do
|
11
|
+
body = "Started POST \"/users/bronze\" for 127.0.0.1 at 2012-07-05 19:33:44 +0200
|
12
|
+
Creating scope :visible. Overwriting existing method Reaction.visible.
|
13
|
+
Processing by DeviseCustomized::RegistrationsController#create as HTML
|
14
|
+
Parameters: {\"utf8\"=>'', \"authenticity_token\"=>\"k4xMIcuqMThMsdlbsVJ7GFgzNDw/HgGGp1ldElFULoY=\", \"user\"=>{\"screen_name\"=>\"mgawlista\", \"email\"=>\"gawlista@googlemail.com\", \"password\"=>\"[FILTERED]\", \"password_confirmation\"=>\"[FILTERED]\"}, \"community_id\"=>\"bronze\"}
|
15
|
+
[1m[35mCACHE (0.0ms)[0m SELECT `communities`.* FROM `communities` WHERE `communities`.`deleted` = 0 AND `communities`.`slug` = 'bronze' LIMIT 1
|
16
|
+
[1m[35mSQL (276.4ms)[0m INSERT INTO `users` (`city`, `city_permissions`, `confirmation_sent_at`, `confirmation_token`, `confirmed_at`, `created_at`, `current_sign_in_at`, `current_sign_in_ip`, `delete_token`, `deleted`, `developer`, `email`, `encrypted_password`, `facebook`, `facebook_id`, `facebook_permissions`, `failed_attempts`, `forename`, `google_id`, `initial_community_id`, `last_sign_in_at`, `last_sign_in_ip`, `linkedin`, `linkedin_permissions`, `locked_at`, `master`, `name_permissions`, `notification_email`, `password_salt`, `phone`, `phone_permissions`, `photo_content_type`, `photo_file_name`, `photo_file_size`, `photo_updated_at`, `remember_created_at`, `reset_password_sent_at`, `reset_password_token`, `screen_name`, `screen_name_permissions`, `sign_in_count`, `slug`, `street`, `street_permissions`, `surname`, `tagline`, `tagline_permissions`, `twitter`, `twitter_permissions`, `unconfirmed_email`, `unlock_token`, `updated_at`, `url`, `website`, `website_permissions`, `xing`, `xing_permissions`, `zipcode`, `zipcode_permissions`) VALUES (NULL, 0, '2012-07-05 17:33:50', 'xVQj9z8xGm1bzqqJBjUn', NULL, '2012-07-05 17:33:50', NULL, NULL, NULL, 0, NULL, 'gawlista@googlemail.com', '$2a$10$KnrBV6m64g0zqKwUnQRR/exiUN9HtzJCGLSUse.jPTxLp0WQtNec2', NULL, NULL, 0, 0, NULL, NULL, 2, NULL, NULL, NULL, 0, NULL, 0, 0, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'mgawlista', 0, 0, 'mgawlista', NULL, 0, NULL, NULL, 0, NULL, 0, NULL, NULL, '2012-07-05 17:33:50', NULL, NULL, 0, NULL, 0, NULL, 0)
|
17
|
+
Rendered devise/shared/_header.html.erb (70.4ms)
|
18
|
+
[paperclip] Saving attachments.
|
19
|
+
[1m[35m (148.3ms)[0m COMMIT
|
20
|
+
[1m[36mCommunity Load (0.5ms)[0m [1mSELECT `communities`.* FROM `communities` WHERE `communities`.`id` = 2 LIMIT 1[0m
|
21
|
+
Redirected to http://localhost:3000/bronze
|
22
|
+
[1m[32mSOLR Request (45541.1ms)[0m [ path=#<RSolr::Client:0x007fbf26dc8b28> parameters={data: [1m[1m<?xml version=\"1.0\" encoding=\"UTF-8\"?><commit/>[0m, headers: [1m[1m{\"Content-Type\"=>\"text/xml\"}[0m, method: [1m[1mpost[0m, params: [1m[1m{:wt=>:ruby}[0m, query: [1m[1mwt=ruby[0m, path: [1m[1mupdate[0m, uri: [1m[1mhttp://localhost:8982/solr/update?wt=ruby[0m} ]
|
23
|
+
Completed 302 Found in 125493ms"
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#process' do
|
27
|
+
context 'just read' do
|
28
|
+
it 'principally works' do
|
29
|
+
body = "Started POST \"/users/bronze\" for 127.0.0.1 at 2012-07-05 19:33:44 +0200
|
30
|
+
Processing by DeviseCustomized::RegistrationsController#create as HTML
|
31
|
+
[1m[35mCACHE (0.0ms)[0m SELECT `communities`.* FROM `communities` WHERE `communities`.`deleted` = 0 AND `communities`.`slug` = 'bronze' LIMIT 1
|
32
|
+
"
|
33
|
+
@rails_info_log = ::RailsInfo::Logs::Server.new(log: { body: body })
|
34
|
+
|
35
|
+
raise @rails_info_log.hash.inspect
|
36
|
+
|
37
|
+
@rails_info_log.hash.should == {
|
38
|
+
'DeviseCustomized::RegistrationsController#create #1' => {
|
39
|
+
'READ' => [
|
40
|
+
"SELECT `communities`.* FROM `communities` WHERE `communities`.`deleted` = 0 AND `communities`.`slug` = 'bronze' LIMIT 1'",
|
41
|
+
],
|
42
|
+
'misc' => [
|
43
|
+
'Processing by DeviseCustomized::RegistrationsController#create as HTML'
|
44
|
+
]
|
45
|
+
}
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper_without_rails'
|
2
|
+
|
3
|
+
require 'active_support/core_ext/object/blank'
|
4
|
+
require 'active_support/core_ext/array/access'
|
5
|
+
|
6
|
+
require 'rails_info/logs'
|
7
|
+
require 'rails_info/logs/test'
|
8
|
+
require 'rails_info/logs/test/rspec'
|
9
|
+
|
10
|
+
describe RailsInfo::Logs::Test::Rspec do
|
11
|
+
describe '#process' do
|
12
|
+
context 'failing method expactations' do
|
13
|
+
it 'principally works' do
|
14
|
+
body = "
|
15
|
+
Failures:
|
16
|
+
1) NotificationRules user stream should notify subscribers about reactions
|
17
|
+
Failure/Error: expect { Reaction.make! }.to notify(:feedback => :subscribers).about(Reaction, :created).via(:user_stream)
|
18
|
+
expected #<Proc:0x007ff75134a6c0@/Users/mgawlista/workspace/reqorder2_copy/spec/notifications/notification_spec.rb:72> to notify feedback subscribers about Reaction created via user_stream, but it didn't:{:class=>Reaction(id: integer, content: text, feedback_id: integer, user_id: integer, created_at: datetime, updated_at: datetime, deleted: boolean, hidden_by_id: integer, hidden_at: datetime, reason_for_hiding: string, likes_count: integer, official: boolean, mood_content: string, mood_type: integer, photo_file_name: string, photo_content_type: string, photo_file_size: integer, photo_updated_at: datetime, editable: boolean, official_by: integer, slug: string, editor_id: integer, reason_for_editing: text, edited_at: datetime, internal_state: string, trigger_object_created_or_internal_state_changed_at: datetime), :role=>[:feedback, :subscribers], :event_method=>:created, :options=>{:via=>:user_stream}} not found in []
|
19
|
+
# ./spec/notifications/notification_spec.rb:72:in `block (3 levels) in <top (required)>'
|
20
|
+
Finished in 1.00 second
|
21
|
+
1 example, 1 failure, 0 pending
|
22
|
+
"
|
23
|
+
@rails_info_log = ::RailsInfo::Logs::Test::Rspec.new(log: { body: body })
|
24
|
+
@rails_info_log.hash.should == {
|
25
|
+
'./spec/notifications/notification_spec.rb' => {
|
26
|
+
'NotificationRules user stream should notify subscribers about reactions' =>
|
27
|
+
{
|
28
|
+
failure_code: 'Failure/Error: expect { Reaction.make! }.to notify(:feedback => :subscribers).about(Reaction, :created).via(:user_stream)',
|
29
|
+
exception_class: '',
|
30
|
+
exception_message: "expected #<Proc:0x007ff75134a6c0@/Users/mgawlista/workspace/reqorder2_copy/spec/notifications/notification_spec.rb:72> to notify feedback subscribers about Reaction created via user_stream, but it didn't:{:class=>Reaction(id: integer, content: text, feedback_id: integer, user_id: integer, created_at: datetime, updated_at: datetime, deleted: boolean, hidden_by_id: integer, hidden_at: datetime, reason_for_hiding: string, likes_count: integer, official: boolean, mood_content: string, mood_type: integer, photo_file_name: string, photo_content_type: string, photo_file_size: integer, photo_updated_at: datetime, editable: boolean, official_by: integer, slug: string, editor_id: integer, reason_for_editing: text, edited_at: datetime, internal_state: string, trigger_object_created_or_internal_state_changed_at: datetime), :role=>[:feedback, :subscribers], :event_method=>:created, :options=>{:via=>:user_stream}} not found in []",
|
31
|
+
stack_trace: "# ./spec/notifications/notification_spec.rb:72:in `block (3 levels) in <top (required)>'"
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
unless defined? Rails
|
2
|
+
class Rails
|
3
|
+
def self.root
|
4
|
+
File.expand_path('dummy', __FILE__)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
ENV["RAILS_ENV"] ||= 'test'
|
10
|
+
|
11
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f }
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.mock_with :rspec
|
15
|
+
end
|
16
|
+
|
17
|
+
# https://makandracards.com/makandra/950-speed-up-rspec-by-deferring-garbage-collection
|
18
|
+
RSpec.configure do |config|
|
19
|
+
config.before(:all) do
|
20
|
+
DeferredGarbageCollection.start
|
21
|
+
end
|
22
|
+
config.after(:all) do
|
23
|
+
DeferredGarbageCollection.reconsider
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
# https://makandracards.com/makandra/950-speed-up-rspec-by-deferring-garbage-collection
|
3
|
+
class DeferredGarbageCollection
|
4
|
+
|
5
|
+
DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 10.0).to_f #used to be 10.0
|
6
|
+
|
7
|
+
@@last_gc_run = Time.now
|
8
|
+
|
9
|
+
def self.start
|
10
|
+
return if unsupported_enviroment
|
11
|
+
GC.disable if DEFERRED_GC_THRESHOLD > 0
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.memory_threshold
|
15
|
+
@mem = %x(free 2>/dev/null).to_s.split(" ")
|
16
|
+
return nil if @mem.empty?
|
17
|
+
@mem[15].to_i / (@mem[7].to_i/100)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.reconsider
|
21
|
+
return if unsupported_enviroment
|
22
|
+
|
23
|
+
if (percent_used = self.memory_threshold)
|
24
|
+
running_out_of_memory = percent_used > 90
|
25
|
+
|
26
|
+
# just for info, as soon as we got some numbers remove it
|
27
|
+
swap_percent_used = @mem[19].to_i / (@mem[18].to_i/100) rescue 0
|
28
|
+
puts "percent memory used #{percent_used} (#{@mem[8]} of #{@mem[7]})"
|
29
|
+
puts "percent swap used #{swap_percent_used} (#{@mem[19]} of #{@mem[18]})"
|
30
|
+
else
|
31
|
+
running_out_of_memory = false
|
32
|
+
end
|
33
|
+
|
34
|
+
if( (DEFERRED_GC_THRESHOLD > 0 && Time.now - @@last_gc_run >= DEFERRED_GC_THRESHOLD) || running_out_of_memory )
|
35
|
+
GC.enable
|
36
|
+
GC.start
|
37
|
+
GC.disable
|
38
|
+
@@last_gc_run = Time.now
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.unsupported_enviroment
|
43
|
+
ENV['TRAVIS'] # TODO: enable for ruby 1.9.3 or more RAM
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_info
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &70253477230800 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70253477230800
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: coffee-script
|
27
|
-
requirement: &
|
27
|
+
requirement: &70253477230000 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70253477230000
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: uglifier
|
38
|
-
requirement: &
|
38
|
+
requirement: &70253477228920 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70253477228920
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jquery-rails
|
49
|
-
requirement: &
|
49
|
+
requirement: &70253477228160 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70253477228160
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: jquery-ui-rails
|
60
|
-
requirement: &
|
60
|
+
requirement: &70253477227440 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70253477227440
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pygments.rb
|
71
|
-
requirement: &
|
71
|
+
requirement: &70253477226720 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70253477226720
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: twitter-bootstrap-rails
|
82
|
-
requirement: &
|
82
|
+
requirement: &70253477226040 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70253477226040
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: simple-navigation-bootstrap
|
93
|
-
requirement: &
|
93
|
+
requirement: &70253477225320 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,32 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70253477225320
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: awesome_print
|
104
|
+
requirement: &70253477224820 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *70253477224820
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: rspec-rails
|
115
|
+
requirement: &70253477224320 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
type: :development
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: *70253477224320
|
102
124
|
- !ruby/object:Gem::Dependency
|
103
125
|
name: mysql2
|
104
|
-
requirement: &
|
126
|
+
requirement: &70253477223880 !ruby/object:Gem::Requirement
|
105
127
|
none: false
|
106
128
|
requirements:
|
107
129
|
- - ! '>='
|
@@ -109,7 +131,7 @@ dependencies:
|
|
109
131
|
version: '0'
|
110
132
|
type: :development
|
111
133
|
prerelease: false
|
112
|
-
version_requirements: *
|
134
|
+
version_requirements: *70253477223880
|
113
135
|
description: Engine for a rails application which extends /rails/info about some information
|
114
136
|
resources in development environment.
|
115
137
|
email:
|
@@ -147,6 +169,8 @@ files:
|
|
147
169
|
- app/presenters/rails_info/logs/test/rspec_presenter.rb
|
148
170
|
- app/presenters/rails_info/model_presenter.rb
|
149
171
|
- app/presenters/rails_info/presenter.rb
|
172
|
+
- app/presenters/rails_info/routes/namespace_presenter.rb
|
173
|
+
- app/presenters/rails_info/routes_presenter.rb
|
150
174
|
- app/presenters/rails_info/stack_trace_presenter.rb
|
151
175
|
- app/views/layouts/_layout.html.erb
|
152
176
|
- app/views/layouts/rails_info/exception.html.erb
|
@@ -158,6 +182,7 @@ files:
|
|
158
182
|
- app/views/rails_info/logs/test/rspec/new.html.erb
|
159
183
|
- app/views/rails_info/model/index.html.erb
|
160
184
|
- app/views/rails_info/properties/index.html.erb
|
185
|
+
- app/views/rails_info/routes/_table.html.erb
|
161
186
|
- app/views/rails_info/routes/index.html.erb
|
162
187
|
- app/views/rails_info/stack_traces/_accordion.html.erb
|
163
188
|
- app/views/rails_info/stack_traces/_form.html.erb
|
@@ -212,6 +237,11 @@ files:
|
|
212
237
|
- spec/dummy/Rakefile
|
213
238
|
- spec/dummy/README.rdoc
|
214
239
|
- spec/dummy/script/rails
|
240
|
+
- spec/lib/rails_info/logs/server_spec.rb
|
241
|
+
- spec/lib/rails_info/logs/test/rspec_spec.rb
|
242
|
+
- spec/spec_helper.rb
|
243
|
+
- spec/spec_helper_without_rails.rb
|
244
|
+
- spec/support/deferred_garbage_collection.rb
|
215
245
|
homepage: http://applicat.github.com/rails_info
|
216
246
|
licenses: []
|
217
247
|
post_install_message:
|
@@ -226,7 +256,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
226
256
|
version: '0'
|
227
257
|
segments:
|
228
258
|
- 0
|
229
|
-
hash:
|
259
|
+
hash: 206197979266972554
|
230
260
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
231
261
|
none: false
|
232
262
|
requirements:
|
@@ -235,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
235
265
|
version: '0'
|
236
266
|
segments:
|
237
267
|
- 0
|
238
|
-
hash:
|
268
|
+
hash: 206197979266972554
|
239
269
|
requirements: []
|
240
270
|
rubyforge_project:
|
241
271
|
rubygems_version: 1.8.17
|
@@ -274,3 +304,8 @@ test_files:
|
|
274
304
|
- spec/dummy/Rakefile
|
275
305
|
- spec/dummy/README.rdoc
|
276
306
|
- spec/dummy/script/rails
|
307
|
+
- spec/lib/rails_info/logs/server_spec.rb
|
308
|
+
- spec/lib/rails_info/logs/test/rspec_spec.rb
|
309
|
+
- spec/spec_helper.rb
|
310
|
+
- spec/spec_helper_without_rails.rb
|
311
|
+
- spec/support/deferred_garbage_collection.rb
|