README.rdoc in timecop-console-0.1.0 vs README.rdoc in timecop-console-0.2.0
- old
+ new
@@ -9,45 +9,48 @@
you can now easily make this available to your dev and QA team through a debug console.
I have plans to build out rails-caddy, a debug console that will pull in timecop-console (and a few others that I'm thinking about) to
truly give you a powerful QA tool.
-== Install
- sudo gem install timecop-console (latest stable release)
- sudo gem install jtrupiano-timecop-console (head of repository)
-
-== Requirements
- * Timecop ~> 0.2.1
-
== How to Use
-You'll want to hook in the functionality in the specific environments that you want this to load in (probably only development, staging, and qa). In the specific environment file (e.g. config/environments/staging.rb), include the following snippet:
+Add to your `Gemfile`:
- config.after_initialize do
- require 'timecop_console'
- end
+ gem 'timecop-console', :github => 'jtrupiano/timecop-console', :require => 'timecop_console'
-By requiring this file, you will open up ActionController::Base and inject an around_filter that will manage Time.now and friends for you. Additionally, it will add lib/timecop-console/controllers/timecop_controller.rb to the load path along with its routes. The two routes are:
+By requiring this dependency, it will open up ActionController::Base and inject an around_filter that will manage Time.now and friends for you.
- map.update_time '/timecop/update', :controller => 'timecop', :action => 'update'
- map.reset_time '/timecop/reset', :controller => 'timecop', :action => 'reset'
+You'll want to hook in the mountable engine for handling time changes in the specific environments that you want this to load in (probably only development, staging). Modify your `config/routes.rb`, adding:
+
+ if Rails.env.development? || Rails.env.staging?
+ mount TimecopConsole::Engine => '/timecop_console'
+ end
+
+
Then, to take advantage of this, you'll want to add a snippet of code to the bottom of your application's layout file, e.g.:
- <% if ["development", "staging", "qa"].include?(RAILS_ENV) -%>
- <div id="debug_console">
- The time is <%= Time.now.to_s(:db) %> |
- <% form_remote_tag :url => update_time_path do -%>
- <%= submit_tag "Time Travel" %>
- <% %w(year month day hour min sec).each do |field| -%>
- <%= text_field_tag field, Time.now.send(field), :size => 4 %>
- <% end -%>
- <% end -%>
- <%= link_to_remote "Reset", :url => reset_time_path %>
+ <% if Rails.env.development? || Rails.env.staging? %>
+
+ <div id="debug-console">
+ <p>
+ The time is <%= Time.now.to_s(:db) %> |
+ </p>
+ <%= form_tag timecop_console.update_path do %>
+ <p>
+ <%= datetime_select("timecop", "current_time") %>
+ </p>
+
+ <p>
+ <%= submit_tag "Time Travel", :class => 'btn' %>
+ </p>
+ <% end %>
+ <%= link_to "Reset", timecop_console.reset_path %>
</div>
- <% end -%>
+ <% end %>
+
This snippet exposes textfields to allow you to alter each component of time (year, month, day, hour, minute, second). It's raw, and there is no validation whatsoever. A default (and customizable) snippet like this will be added to this library shortly. In the meantime, you can hand-write it.
-
+
== Copyright
Copyright (c) 2009 John Trupiano. See LICENSE for details.